Skip to content

Commit fa019cf

Browse files
committed
test(s032): two flakes met on run 35603385277 closed at their source
The fake provider's failures and objects no longer outlive the test that set them (llm_test and SessionCase clear on exit), and the test helper waits for the boot receipt's Task before the sandbox goes manual, so the boot-receipt tests no longer depend on a runner's speed. Signed-off-by: Ayla Croft <aylacroft@proton.me>
1 parent 372e05d commit fa019cf

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎test/support/session_case.ex‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ defmodule Trinity.SessionCase do
1818
setup do
1919
Trinity.LLM.Providers.Fake.clear()
2020
on_exit(fn -> Trinity.SessionCase.stop_all_sessions() end)
21+
# Slice 032: scripts and objects set here do not outlive the test either.
22+
on_exit(fn -> Trinity.LLM.Providers.Fake.clear() end)
2123
:ok
2224
end
2325
end

‎test/test_helper.exs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@ ExUnit.start(
1919
if(fips_leg?, do: [], else: [:fips]) ++ if(local_model?, do: [], else: [:local_model])
2020
)
2121

22+
# Slice 024's boot receipt is written by a transient Task after the tree starts; once the
23+
# receipts pool is in manual mode that write can no longer check a connection out, and the
24+
# boot-receipt tests fail with an OwnershipError (postgres job, run 35603385277, at slice
25+
# 032). Wait for the Task to finish, either way, before the mode flips: bounded, and a Task
26+
# that is gone has either written or logged its reason.
27+
boot_task = fn ->
28+
Trinity.Supervisor
29+
|> Supervisor.which_children()
30+
|> Enum.find_value(fn
31+
{Trinity.Effects.Boot, pid, _, _} when is_pid(pid) -> pid
32+
_ -> nil
33+
end)
34+
end
35+
36+
Enum.find(1..200, fn _ ->
37+
case boot_task.() do
38+
nil -> true
39+
_pid -> Process.sleep(50) && false
40+
end
41+
end)
42+
2243
Ecto.Adapters.SQL.Sandbox.mode(Trinity.Repo, :manual)
2344
Ecto.Adapters.SQL.Sandbox.mode(Trinity.Repo.Receipts, :manual)
2445

‎test/trinity/llm/llm_test.exs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ defmodule Trinity.LLMTest do
1010

1111
setup :verify_on_exit!
1212

13+
# Cleared on the way out too: `Fake.fail(10, …)` below leaves failures behind for the next
14+
# test that does not clear first (seen at slice 032 on run 35603385277, seed 568667: the
15+
# memory page's consolidation test got `{:exhausted, 3, :down}` from this file's leftovers).
1316
setup do
1417
Fake.clear()
18+
on_exit(fn -> Fake.clear() end)
1519
:ok
1620
end
1721

0 commit comments

Comments
 (0)