Starting multiple named nodes locally for ExUnit tests

My app is distributed using @bitwalker’s libcluster and swarm libraries. I’m currently trying to write tests for specific parts of my app that hook into these libraries and am unable to due to the fact that I need to have multiple named nodes spun up locally in order to even function. I’ve tried using the test code in distillery/libcluster/swarm as examples in order to pull this off but have been unsuccessful. Furthermore I’m not entirely sure if the node’s creation should be in the test_helper.ex or in the setup_all. I’ve tried putting Node.start()'s and :slave.start_link's to no avail. Additionally since my app uses Phoenix, I think I will need to have multiple endpoint configs for test? Any and all help, tips, examples is appreciated. Thank you.


You can see an example in

It has tests with another node. Maybe you can adapt it to your needs.

1 Like

I’ve tried my hand at this using the clusters strategy that swarm and firenest employ, but to no avail:

1 Like

…and then I found this: Let’s see if I can get it to work.

You could look at what Phoenix itself does when testing PubSub:


I’ve updated the gist again with the work @bitwalker and I have put into it:
Still not working, but progress is being made.

Hey @beardedeagle, you should look into

It might give you some hints how to do setup the tests.
Good luck!

1 Like

Thanks for everyone’s help and suggestions. @bitwalker and I were able to get this running using the following cluster_case code: