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.

cluster_case.ex

defmodule Vanguard.Support.ClusterCase do
@moduledoc false
def spawn(nodes) do
# Turn node into a distributed node with the given long name
:net_kernel.start([:"primary@127.0.0.1"])
# Allow spawned nodes to fetch all code from this node
:erl_boot_server.start([])
allow_boot(to_charlist("127.0.0.1"))

cluster_case.ex

defmodule Vanguard.Support.ClusterCase do
@moduledoc false
def spawn(nodes) do
# Turn node into a distributed node with the given long name
:net_kernel.start([:"primary@127.0.0.1"])
# Allow spawned nodes to fetch all code from this node
:erl_boot_server.start([])
allow_boot(to_charlist("127.0.0.1"))