perf(tests): make device deletion delay configurable for faster tests

Make the 500ms device deletion delay configurable via application config.
Set to 10ms in test environment (vs 500ms in production).

This sleep waits for in-flight polling jobs to complete before deleting
a device. In tests with mocked jobs, this delay is unnecessary.

Affected tests:
- All device deletion tests (were 500-650ms, now ~100-150ms)
- Equipment context tests
- API controller tests
- LiveView tests with device deletion

Performance: 28.3s → 25.2s (11% faster)
Total improvement from baseline: 52s → 25.2s (51.5% faster)
This commit is contained in:
Graham McIntire 2026-03-06 08:03:54 -06:00
parent 1038cc3d42
commit 52329cf959
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

View file

@ -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

View file

@ -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)