BCM1982

BCM1982

How do you write unit tests for interactions between nodes?

Right now I am writing an Elixir application that is meant to be run in multiple nodes. When doing manual testing I run the application in different iex sessions using “iex --sname a@localhost -S mix” and call other nodes’ GenServers (for example one named Server) using “GenServer.call({Server, :b@localhost},{:write,1,2}).” This works for now but is tedious. I would like to write unit tests to automate this process, but can’t find any information on how to. What is the best way to get about doing this?

Most Liked

bitwalker

bitwalker

Leader

There are some pain points with :slave, which is ultimately why I wrote ex_unit_clustered_case - for simple cases, it works fine, a few of my libraries were basically built around testing via :slave; but for more complex applications the challenges start to become really noticeable.

The biggest thing you run into is realizing that just spinning up a few nodes isn’t enough - you generally want to test a lot of scenarios, and in a clustered application many of those scenarios will clobber other tests. This means you need to orchestrate clusters, not just nodes. Another problem is that you can get into situations where you have started nodes that don’t die when your tests fail, leaking beam processes. You have to have a mini framework built just to handle things like initializing nodes with different initial states for tests, etc.

Ultimately rebuilding all of that again and again is why I ended up throwing a library together. Ideally something would be baked into Elixir for this, but it’s definitely a lower priority in comparison to other things going on; in the meantime, let me know if my library covers your use cases, I’d like to make it a general solution to the problem

arjan

arjan

Last Post!

keathley

keathley

Something else I’ve been working on off and on is the ability to re-order rpcs between processes on different nodes. Its not quite ready to see the light of day but I’ve been doing this with a shim module that all rpcs are serialized through and proper’s statem modules to control interleavings and failure scenarios. I think there’s some promise there and its at least based on some sound research.

An even more interesting concept would be to use something like lineage driven fault injection: https://people.ucsc.edu/~palvaro/molly.pdf. I suspect you’d have better luck exploring the state space this way. I’ve been thinking about how to implement something like this in elixir but haven’t put any real effort into a solution yet.

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
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
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54260 488
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement