From e36c1c2ec38c0b829b65bede89225de528782485 Mon Sep 17 00:00:00 2001 From: Steve Rowley Date: Wed, 29 Apr 2026 20:05:22 -0500 Subject: [PATCH 1/2] fix: trap Testcontainer process exit --- test/test_helper.exs | 53 ++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/test/test_helper.exs b/test/test_helper.exs index 723c32e..42f5442 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,25 +1,44 @@ # Start distribution for :peer-based distributed tests. # :peer needs the parent node to be alive for dist-connected peers. -unless Node.alive?() do - sname = :"dux_test_#{:erlang.unique_integer([:positive])}" +distributed_exclusion = + if Node.alive?() do + [] + else + sname = :"dux_test_#{:erlang.unique_integer([:positive])}" - case Node.start(sname, :shortnames) do + case Node.start(sname, :shortnames) do + {:ok, _} -> + [] + + {:error, reason} -> + IO.puts( + "⚠ Distribution not available (#{inspect(reason)}) — excluding :distributed tests" + ) + + :distributed + end + end + +# Start testcontainers for integration tests (requires Docker) +old = Process.flag(:trap_exit, true) + +container_exclusion = + case Testcontainers.start_link() do {:ok, _} -> - :ok + [] {:error, reason} -> - IO.puts("⚠ Distribution not available (#{inspect(reason)}) — excluding :distributed tests") + IO.puts("⚠ Test container not available (#{inspect(reason)}) — excluding :container tests") + :container end -end -# Start testcontainers for integration tests (requires Docker) -case Testcontainers.start_link() do - {:ok, _} -> :ok - {:error, _} -> IO.puts("⚠ Docker not available — excluding :container tests") -end - -if Node.alive?() do - ExUnit.start() -else - ExUnit.start(exclude: [:distributed]) -end +Process.flag(:trap_exit, old) + + + case List.flatten([distributed_exclusion, container_exclusion]) do + [] -> + ExUnit.start() + + exclusions -> + ExUnit.start(exclude: exclusions) + end From dd6fc72a64fecc90429cc8ad72ad3611a089b158 Mon Sep 17 00:00:00 2001 From: Steve Rowley Date: Sun, 3 May 2026 09:20:11 -0500 Subject: [PATCH 2/2] fix: set memory limit to avoid out-of-memory errors --- test/test_helper.exs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/test_helper.exs b/test/test_helper.exs index 42f5442..8702480 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -34,11 +34,12 @@ container_exclusion = Process.flag(:trap_exit, old) +Dux.exec("SET memory_limit = '8GB';") - case List.flatten([distributed_exclusion, container_exclusion]) do - [] -> - ExUnit.start() +case List.flatten([distributed_exclusion, container_exclusion]) do + [] -> + ExUnit.start() - exclusions -> - ExUnit.start(exclude: exclusions) - end + exclusions -> + ExUnit.start(exclude: exclusions) +end