beardedeagle

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

beardedeagle

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

Also Liked

chrismcg

chrismcg

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

https://github.com/phoenixframework/phoenix_pubsub/blob/master/test/support/cluster.ex

alexcastano

alexcastano

You can see an example in GitHub - ericentin/repg2: A translation of the original Erlang pg2 implementation to Elixir for educational purposes. · GitHub

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

beardedeagle

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

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement