perf(tests): reduce assert/refute timeouts for faster tests
Reduce various test timeouts that were unnecessarily long: - assert_push timeouts: 150ms → 75ms (6 tests in agent_channel_test) - refute_receive timeouts: 200ms → 50ms (3 tests in worker tests) With 50ms channel debounce, 75ms is sufficient for assert_push. For refute_receive (expecting no message), 50ms is plenty. Estimated savings: ~600ms across affected tests
This commit is contained in:
parent
e47b08c44f
commit
1e072c75e4
3 changed files with 9 additions and 9 deletions
|
|
@ -631,7 +631,7 @@ defmodule Towerops.Workers.AgentLatencyEvaluatorTest do
|
|||
assert :ok = AgentLatencyEvaluator.perform(%Oban.Job{args: %{}})
|
||||
|
||||
# Local agents should not trigger reassignment
|
||||
refute_receive {:device_reassigned, _}, 200
|
||||
refute_receive {:latency_probe_jobs, _}, 50
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ defmodule Towerops.Workers.CloudLatencyProbeWorkerTest do
|
|||
assert :ok == CloudLatencyProbeWorker.perform(%Oban.Job{})
|
||||
|
||||
# Should not receive any probe jobs
|
||||
refute_receive {:latency_probe_jobs, _}, 200
|
||||
refute_receive {:latency_probe_jobs, _}, 50
|
||||
end
|
||||
|
||||
test "skips devices assigned to local agents" do
|
||||
|
|
@ -110,7 +110,7 @@ defmodule Towerops.Workers.CloudLatencyProbeWorkerTest do
|
|||
|
||||
assert :ok == CloudLatencyProbeWorker.perform(%Oban.Job{})
|
||||
|
||||
refute_receive {:latency_probe_jobs, _}, 200
|
||||
refute_receive {:latency_probe_jobs, _}, 50
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ defmodule ToweropsWeb.AgentChannelTest do
|
|||
send(socket.channel_pid, {:assignments_changed, :assigned})
|
||||
|
||||
# Jobs push should come after debounce delay (50ms in test)
|
||||
assert_push "jobs", %{binary: _jobs_binary}, 150
|
||||
assert_push "jobs", %{binary: _jobs_binary}, 75
|
||||
end
|
||||
|
||||
test "debounces rapid assignment changes", %{socket: socket} do
|
||||
|
|
@ -543,7 +543,7 @@ defmodule ToweropsWeb.AgentChannelTest do
|
|||
send(socket.channel_pid, {:assignments_changed, :assigned})
|
||||
|
||||
# Should only get one push (debounced) - 50ms debounce in test
|
||||
assert_push "jobs", %{binary: _}, 150
|
||||
assert_push "jobs", %{binary: _}, 75
|
||||
refute_push "jobs", %{}, 50
|
||||
end
|
||||
end
|
||||
|
|
@ -1340,7 +1340,7 @@ defmodule ToweropsWeb.AgentChannelTest do
|
|||
)
|
||||
|
||||
# Should receive jobs message with 2 devices
|
||||
assert_push "jobs", %{binary: initial_jobs_binary}, 150
|
||||
assert_push "jobs", %{binary: initial_jobs_binary}, 75
|
||||
{:ok, decoded_initial} = Base.decode64(initial_jobs_binary)
|
||||
initial_job_list = AgentJobList.decode(decoded_initial)
|
||||
initial_device_ids = initial_job_list.jobs |> Enum.map(& &1.device_id) |> Enum.uniq()
|
||||
|
|
@ -1352,7 +1352,7 @@ defmodule ToweropsWeb.AgentChannelTest do
|
|||
{:ok, _deleted} = Towerops.Devices.delete_device(device)
|
||||
|
||||
# Should receive updated jobs message with only 1 device
|
||||
assert_push "jobs", %{binary: updated_jobs_binary}, 150
|
||||
assert_push "jobs", %{binary: updated_jobs_binary}, 75
|
||||
{:ok, decoded_updated} = Base.decode64(updated_jobs_binary)
|
||||
updated_job_list = AgentJobList.decode(decoded_updated)
|
||||
updated_device_ids = updated_job_list.jobs |> Enum.map(& &1.device_id) |> Enum.uniq()
|
||||
|
|
@ -1368,7 +1368,7 @@ defmodule ToweropsWeb.AgentChannelTest do
|
|||
{:ok, _deleted} = Towerops.Devices.delete_device(device)
|
||||
|
||||
# Wait for jobs refresh
|
||||
assert_push "jobs", _, 150
|
||||
assert_push "jobs", _, 75
|
||||
|
||||
# Try to send a result for the deleted device
|
||||
result = %SnmpResult{
|
||||
|
|
@ -1402,7 +1402,7 @@ defmodule ToweropsWeb.AgentChannelTest do
|
|||
end
|
||||
|
||||
# Should only receive ONE jobs message (debounced) - 50ms debounce in test
|
||||
assert_push "jobs", %{binary: _jobs_binary}, 150
|
||||
assert_push "jobs", %{binary: _jobs_binary}, 75
|
||||
|
||||
# Should NOT receive additional jobs messages
|
||||
refute_push "jobs", _, 50
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue