Skip to content
elixir application to simulate and test distributed erlang/elixir applications
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
src
test
.gitignore
README.md
mix.exs
run_test

README.md

flock

flock is an elixir application to simulate and test distributed erlang/elixir applications. It can start nodes (erlang VMs), configure them and let them start applications. In addition it can simulate failure scenarios like nodes going down, network splits and network re-joins. flock is based on the "slave" module in Erlang.

Usage

To use flock in the tests of your mix project add it as an dependency and run your tests with ./deps/flock/run_test. This is needed since we need a special node setup.

Example

  • start two nodes in separate clusters with Mix running
  • try to ping one from the other and fail
  • join the nodes
  • ping again and succeed

iex --hidden --sname flock@localhost -S mix

Application.ensure_all_started(:flock)
---> {:ok, []}
Flock.Server.start_nodes([[:one], [:two]], %{rpcs: Flock.Server.mix_rpcs})
---> [:one@localhost, :two@localhost]
Flock.Server.rpc(:one, :net_adm, :ping, [:"two@localhost"])
---> :pang
=ERROR REPORT==== 20-Apr-2018::17:49:42 ===
** Connection attempt from disallowed node one@localhost **
Flock.Server.group([[:one, :two]])
---> :ok
Flock.Server.rpc(:one, :net_adm, :ping, [:"two@localhost"])
---> :pong

For the full range of features useful in tests see test/floc_server_test.ex.

Tests

mix compile && ./run_test

You can’t perform that action at this time.