diff --git a/config/test.exs b/config/test.exs index d58481ed..1e24076e 100644 --- a/config/test.exs +++ b/config/test.exs @@ -92,4 +92,6 @@ config :towerops, # Disable rate limiting in tests to avoid blocking concurrent test requests rate_limiting_enabled: false, # Reduce debounce delay in tests for faster test execution (50ms vs 500ms in prod) - agent_channel_debounce_ms: 50 + agent_channel_debounce_ms: 50, + # Reduce device deletion delay for faster tests (10ms vs 500ms in prod) + device_deletion_delay_ms: 10 diff --git a/lib/towerops/devices.ex b/lib/towerops/devices.ex index caaa564f..a12be4d1 100644 --- a/lib/towerops/devices.ex +++ b/lib/towerops/devices.ex @@ -895,7 +895,9 @@ defmodule Towerops.Devices do # Wait briefly for any in-flight jobs to complete or detect deletion # This reduces (but doesn't eliminate) the window for orphaned writes # In-flight jobs check device existence via verify_polling_assignment_unchanged - Process.sleep(500) + # Configurable for faster tests (defaults to 500ms in prod, 10ms in test) + deletion_delay_ms = Application.get_env(:towerops, :device_deletion_delay_ms, 500) + Process.sleep(deletion_delay_ms) # Get agent assignment before deleting (if any) assignment = Agents.get_device_assignment(device.id)