leorodriguesrj
In Erlang, using “Common Test” framework, each test execution has a unique node name allowing a higher degree of resources isolation. Is it possible to achieve the same in elixir with ExUnit?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
ExUnit tests may run async to each other, so afaik there is no built in support for something like that. Though I guess nothing would prevent you from creating a case template, which restarts distribution each time and assigns a unique name to the node.
leorodriguesrj
Hmmm. I’m not sure how I could restart the distribution, but I’ll look into it! Thank you!
lud
So that would be with
:net_kernel.start/1and:net_kernel.stop/0right?LostKobrakai
Or
Node.start/3andNode.stop/0leorodriguesrj
Neat! Now I just have to find a way to start
epmdwhen I run mix test, because apparently it is not being started by default.LostKobrakai
Let me know if you do find a way. I‘ve resorted to raising an error in the tests I use distribution at the moment.
lud
I didn’t know those even existed
@leorodriguesrj To start epmd add
{_, 0} = System.cmd("epmd", ["-daemon"])beforeExUnit.start()intest_helper.exsleorodriguesrj
I came up with this
work in progress!
For some reason, I was unable to make correct use of
Port.close/1, so I used the kill command to stopepmd. Obviously, this implementation will fail in windows.ityonemo
I wouldn’t use clustering as a strategy for resource segregation. Certainly “actually testing clustering” using test-time clusters (for example using the :slave module) is a thing. But for resource segregation I think “recommended way” to do this is to do it in one node, and take advantage of something like Mox to mock out the contended resource, and in your mock, stub out calls to a process started using ExUnit.start_supervised – this process can be stateful and will automatically have a lifetime that matches the lifetime of your test. Mox is already “a resource that is sharded based on tests” so that could make what you are trying to do WAY easier.
You could also dig deeper and use the Process dictionary, :$caller and :$ancestor keys to manually build resource-shardable subsystems, and make it so that each test has its own checkout of your resource. I built a library around this concept but I don’t currently recommend it.
leorodriguesrj
Well I think I can consider this issue solved. But to further elucidate on the matter to @ityonemo, I’m currently building an application on top of
Mnesiaand whenever I ran the tests the database was being scrambled becauseMnesiawas always running on the same node.I had some code built in
erlangbefore usingCommon Test Framework. Inct, every time you run the tests, you run on a different node and the database is automatically isolated. I was trying to achieve a similar behavior inElixirwithExUnit.