beardedeagle
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.
Marked As Solved
beardedeagle
Thanks for everyone’s help and suggestions. @bitwalker and I were able to get this running using the following cluster_case code: https://gist.github.com/beardedeagle/dc72f25fb561780f902d5dbf354a582d
Also Liked
chrismcg
You could look at what Phoenix itself does when testing PubSub:
alexcastano
You can see an example in https://github.com/ericentin/repg2
It has tests with another node. Maybe you can adapt it to your needs.
beardedeagle
I’ve tried my hand at this using the clusters strategy that swarm and firenest employ, but to no avail:
https://gist.github.com/beardedeagle/df0e56622b564871b409057b89fd0745
mindreframer
Hey @beardedeagle, you should look into https://github.com/wooga/flock.
It might give you some hints how to do setup the tests.
Good luck!







