bitwalker/libcluster

tests fail

bryanhuntesl opened this issue · 9 comments

I perform a fresh checkout of master - run the tests and get the following failures:

  1) test connect_nodes/4 handles connect ignore (Cluster.StrategyTest)
     test/strategy_test.exs:45
     ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!
     code: assert capture_log(fn ->
     stacktrace:
       (libcluster) lib/strategy/strategy.ex:117: Cluster.Strategy.ensure_exported!/3
       (libcluster) lib/strategy/strategy.ex:39: Cluster.Strategy.connect_nodes/4
       test/strategy_test.exs:51: anonymous fn/2 in Cluster.StrategyTest."test connect_nodes/4 handles connect ignore"/1
       (ex_unit) lib/ex_unit/capture_log.ex:78: ExUnit.CaptureLog.capture_log/2
       test/strategy_test.exs:49: (test)



  2) test connect_nodes/4 does not connect existing nodes again (Cluster.StrategyTest)
     test/strategy_test.exs:12
     ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!
     code: assert :ok = Strategy.connect_nodes(__MODULE__, connect, list_nodes, [Node.self()])
     stacktrace:
       (libcluster) lib/strategy/strategy.ex:117: Cluster.Strategy.ensure_exported!/3
       (libcluster) lib/strategy/strategy.ex:39: Cluster.Strategy.connect_nodes/4
       test/strategy_test.exs:16: (test)



  3) test disconnect_nodes/4 does not disconnect missing noded (Cluster.StrategyTest)
     test/strategy_test.exs:59
     ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!
     code: assert :ok = Strategy.disconnect_nodes(__MODULE__, disconnect, list_nodes, [Node.self()])
     stacktrace:
       (libcluster) lib/strategy/strategy.ex:117: Cluster.Strategy.ensure_exported!/3
       (libcluster) lib/strategy/strategy.ex:80: Cluster.Strategy.disconnect_nodes/4
       test/strategy_test.exs:63: (test)



  4) test disconnect_nodes/4 does disconnect new nodes (Cluster.StrategyTest)
     test/strategy_test.exs:68
     ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!
     code: assert capture_log(fn ->
     stacktrace:
       (libcluster) lib/strategy/strategy.ex:117: Cluster.Strategy.ensure_exported!/3
       (libcluster) lib/strategy/strategy.ex:80: Cluster.Strategy.disconnect_nodes/4
       test/strategy_test.exs:74: anonymous fn/1 in Cluster.StrategyTest."test disconnect_nodes/4 does disconnect new nodes"/1
       (ex_unit) lib/ex_unit/capture_log.ex:78: ExUnit.CaptureLog.capture_log/2
       test/strategy_test.exs:72: (test)



  5) test connect_nodes/4 handles connect failure (Cluster.StrategyTest)
     test/strategy_test.exs:33
     ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!
     code: assert capture_log(fn ->
     stacktrace:
       (libcluster) lib/strategy/strategy.ex:117: Cluster.Strategy.ensure_exported!/3
       (libcluster) lib/strategy/strategy.ex:39: Cluster.Strategy.connect_nodes/4
       test/strategy_test.exs:39: anonymous fn/2 in Cluster.StrategyTest."test connect_nodes/4 handles connect failure"/1
       (ex_unit) lib/ex_unit/capture_log.ex:78: ExUnit.CaptureLog.capture_log/2
       test/strategy_test.exs:37: (test)



  6) test disconnect_nodes/4 handles connect failure (Cluster.StrategyTest)
     test/strategy_test.exs:82
     ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!
     code: assert capture_log(fn ->
     stacktrace:
       (libcluster) lib/strategy/strategy.ex:117: Cluster.Strategy.ensure_exported!/3
       (libcluster) lib/strategy/strategy.ex:80: Cluster.Strategy.disconnect_nodes/4
       test/strategy_test.exs:88: anonymous fn/1 in Cluster.StrategyTest."test disconnect_nodes/4 handles connect failure"/1
       (ex_unit) lib/ex_unit/capture_log.ex:78: ExUnit.CaptureLog.capture_log/2
       test/strategy_test.exs:86: (test)



  7) test disconnect_nodes/4 handles disconnect ignore (Cluster.StrategyTest)
     test/strategy_test.exs:97
     ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!
     code: assert capture_log(fn ->
     stacktrace:
       (libcluster) lib/strategy/strategy.ex:117: Cluster.Strategy.ensure_exported!/3
       (libcluster) lib/strategy/strategy.ex:80: Cluster.Strategy.disconnect_nodes/4
       test/strategy_test.exs:103: anonymous fn/1 in Cluster.StrategyTest."test disconnect_nodes/4 handles disconnect ignore"/1
       (ex_unit) lib/ex_unit/capture_log.ex:78: ExUnit.CaptureLog.capture_log/2
       test/strategy_test.exs:101: (test)



  8) test connect_nodes/4 does connect new nodes (Cluster.StrategyTest)
     test/strategy_test.exs:21
     ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!
     code: assert capture_log(fn ->
     stacktrace:
       (libcluster) lib/strategy/strategy.ex:117: Cluster.Strategy.ensure_exported!/3
       (libcluster) lib/strategy/strategy.ex:39: Cluster.Strategy.connect_nodes/4
       test/strategy_test.exs:27: anonymous fn/2 in Cluster.StrategyTest."test connect_nodes/4 does connect new nodes"/1
       (ex_unit) lib/ex_unit/capture_log.ex:78: ExUnit.CaptureLog.capture_log/2
       test/strategy_test.exs:25: (test)

.

  9) test start_link/1 calls right functions (Cluster.Strategy.KubernetesTest)
     test/kubernetes_test.exs:28
     ** (RuntimeError) failed to start child with the spec {Cluster.Strategy.Kubernetes, [topology: :name, config: [kubernetes_node_basename: nil, kubernetes_selector: "app=", kubernetes_master: "cluster.localhost", kubernetes_service_account_path: "/common/libcluster/test/fixtures/kubernetes/service_account"], connect: {Cluster.Nodes, :connect, [#PID<0.226.0>]}, disconnect: {Cluster.Nodes, :disconnect, [#PID<0.226.0>]}, list_nodes: {Cluster.Nodes, :list_nodes, [[]]}, block_startup: true]}.
     Reason: an exception was raised:
         ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!
             (libcluster) lib/strategy/strategy.ex:117: Cluster.Strategy.ensure_exported!/3
             (libcluster) lib/strategy/strategy.ex:80: Cluster.Strategy.disconnect_nodes/4
             (libcluster) lib/strategy/kubernetes.ex:97: Cluster.Strategy.Kubernetes.load/1
             (libcluster) lib/strategy/kubernetes.ex:79: Cluster.Strategy.Kubernetes.init/1
             (stdlib) gen_server.erl:365: :gen_server.init_it/2
             (stdlib) gen_server.erl:333: :gen_server.init_it/6
             (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
     code: capture_log(fn ->
     stacktrace:
       (ex_unit) lib/ex_unit/callbacks.ex:311: ExUnit.Callbacks.start_supervised!/2
       test/kubernetes_test.exs:31: anonymous fn/0 in Cluster.Strategy.KubernetesTest."test start_link/1 calls right functions"/1
       (ex_unit) lib/ex_unit/capture_log.ex:78: ExUnit.CaptureLog.capture_log/2
       test/kubernetes_test.exs:30: (test)

....

 10) test start_link/1 calls right functions (Cluster.Strategy.EpmdTest)
     test/epmd_test.exs:12
     No message matching {:connect, :foo@bar} after 100ms.
     The process mailbox is empty.
     code: capture_log(fn ->
     stacktrace:
       test/epmd_test.exs:24: anonymous fn/0 in Cluster.Strategy.EpmdTest."test start_link/1 calls right functions"/1
       (ex_unit) lib/ex_unit/capture_log.ex:78: ExUnit.CaptureLog.capture_log/2
       test/epmd_test.exs:13: (test)

Finished in 0.4 seconds
15 tests, 10 failures

Randomized with seed 131338

Should I be performing some setup prior to testing ?

For me, the test suite doesn't even compile:

❯ mix test

== Compilation error in file test/app_test.exs ==
** (TokenMissingError) test/app_test.exs:58: missing terminator: end (for "do" starting at line 1)
    (elixir) lib/code.ex:677: Code.require_file/2
    (elixir) lib/kernel/parallel_compiler.ex:201: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

Yep - I got that too - actually I checked out a version one back from HEAD and executed against that - I then tried some bisection to try and find a version on which tests passed - I failed in that quest. It would be nice to get some more information -

  • Was anyone ever running the tests?
  • Do they require something else to be running?
  • Do they require a specific version of Elixir/Erlang?

There must be somthing wrong with the elixirrc path. The module Cluster.Nodes exists in the tests/support directory.

Could you both try to delete your _build dir just to be sure that there is no error with mix?

Nope. Still fails to compile. If we can get this building and tests running, I'd be happy to help with getting Travis CI working.

⚛︎□▷ git remote show origin
* remote origin
  Fetch URL: git@github.com:bitwalker/libcluster.git
  Push  URL: git@github.com:bitwalker/libcluster.git
  HEAD branch: master
  Remote branches:
    master   tracked
    refactor tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

/common/libcluster master
⚛︎□▷ git pull
Already up-to-date.

/common/libcluster master
⚛︎□▷ git checkout HEAD
Your branch is up-to-date with 'origin/master'.

/common/libcluster master
⚛︎□▷ rm -rf _build

/common/libcluster master
⚛︎□▷ mix deps.get && mix test
Resolving Hex dependencies...
Dependency resolution completed:
  dialyxir 0.5.1
  earmark 1.2.4
  ex_doc 0.18.2
  exactor 2.2.4
  exjsx 4.0.0
  exvcr 0.10.0
  jsx 2.8.3
  meck 0.8.9
  poison 3.1.0
All dependencies up to date
==> exactor
Compiling 10 files (.ex)
Generated exactor app
===> Compiling meck
warning: String.strip/1 is deprecated, use String.trim/1
  /common/libcluster/deps/poison/mix.exs:4

==> poison
Compiling 4 files (.ex)
warning: Integer.to_char_list/2 is deprecated, use Integer.to_charlist/2
  lib/poison/encoder.ex:173

Generated poison app
==> jsx
Compiling 9 files (.erl)
Generated jsx app
==> exjsx
Compiling 1 file (.ex)
Generated exjsx app
==> exvcr
Compiling 29 files (.ex)
warning: function :hackney_request.encode_form/1 is undefined (module :hackney_request is not available)
  lib/exvcr/adapter/hackney/converter.ex:78

Generated exvcr app
==> libcluster
Compiling 11 files (.ex)
warning: redefining module ExVCR.Adapter.Httpc.Converter (current version loaded from _build/test/lib/exvcr/ebin/Elixir.ExVCR.Adapter.Httpc.Converter.beam)
  test/support/exvcr.ex:1

Generated libcluster app

== Compilation error in file test/app_test.exs ==
** (TokenMissingError) test/app_test.exs:58: missing terminator: end (for "do" starting at line 1)
    (elixir) lib/code.ex:677: Code.require_file/2
    (elixir) lib/kernel/parallel_compiler.ex:201: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

/common/libcluster master 17s

@bryanhuntesl I have no idea why you got this error: ** (RuntimeError) Elixir.Cluster.Nodes.list_nodes/1 is undefined!

The compile error was because the changes from my PR were not merged correctly. I fixed them in #45

I think adding Travis CI would be a great addition, but you'll have to look at that with @bitwalker

I don't recall who submitted the PR with the test suite, but yeah, it's hard to imagine they even ran them, which is my bad for not checking. In any case, I've fixed the tests on another branch, I'll be merging those changes in today.

@bitwalker I submitted the test suite. Before you merged it by hand, the tests were passing.

@maennchen Ah, if it was my mistake then, I apologize - I should've had Travis setup to make sure each commit was getting tested, but didn't. Sorry for blaming you!