Add lightweight integration tests to verify:
- C NIF module loads properly in web application
- MIB library initializes successfully
- Standard MIB name resolution works
- MibTranslator wrapper functions correctly
- Error handling for invalid MIB names
- SNMP profiles can be loaded (uses MIB translation)
These tests verify the C NIF works end-to-end without checking
full page content, focusing on functional verification only.
Adds test case for the real-world scenario where MikroTik devices
report incorrect mtxrGaugeUnit values (e.g., reporting unit type 1
for celsius/temperature when the sensor is actually a voltage sensor).
This test verifies that the name-based override logic in
maybe_override_sensor_type/2 correctly handles this case:
- Sensor name: "psu1-voltage" or "psu2-voltage"
- Reported unit type: 1 (celsius/temperature)
- Expected result: voltage sensor with divisor 10
The override code was added in commit f402dcb (Jan 22, 2026) and
works correctly for new discoveries. Existing sensors created before
this date need the migration from commit 68a4ebf to fix their values.
Related: 20260125182836_fix_misclassified_mikrotik_voltage_sensors.exs
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed discover_all/1 to enqueue individual Oban jobs instead of using
Task.async_stream for better error visibility and resilience.
Benefits:
- Errors are visible in Oban dashboard with full stack traces
- Automatic retries on failure via Oban
- Jobs persist across pod restarts
- No more silent failures from Task crashes
- Better concurrency control via Oban queue configuration
Changes:
- discover_all/1 now enqueues DiscoveryWorker jobs and returns immediately
- Return type changed from %{success, failed, errors} to %{enqueued, failed, errors}
- Updated tests to match new async behavior
- Added DiscoveryWorker alias to Discovery module
All tests passing (3,625 tests, 0 failures).
Replaced GenServer-based periodic workers with Oban Cron jobs to improve
pod rollover resilience and simplify architecture.
Worker Changes:
- NeighborCleanupWorker: GenServer → Oban Cron (hourly)
- Cleans stale neighbors, ARP entries, and MAC addresses
- Runs every hour via Oban.Plugins.Cron
- StaleAgentWorker: GenServer → Oban Cron (every minute)
- Detects agents that haven't checked in for 10+ minutes
- Refactored to reduce nesting (extracted helper functions)
- Removed stateful tracking (now stateless, re-evaluates each run)
- AgentLatencyEvaluator: GenServer → Oban Cron (every 5 minutes)
- Latency-based agent reassignment with 20% threshold
- Removed trigger_evaluation/0 (no longer needed)
- JobHealthCheckWorker: NEW Oban Cron worker (every 10 minutes)
- Safety net to recover missing monitor/poller jobs
- Auto-creates jobs for devices with monitoring/SNMP enabled
Infrastructure Changes:
- Removed Monitoring.Supervisor (no longer needed)
- Updated application.ex to remove GenServer workers from supervision tree
- Added Oban.Plugins.Cron to dev.exs and runtime.exs
- All workers now run cluster-wide via PostgreSQL-backed coordination
Test Updates:
- Updated all worker tests to call perform(%Oban.Job{args: %{}})
- Removed GenServer lifecycle tests (start_link, send messages, etc.)
- Removed async sleep calls (no longer needed)
Benefits:
- Better pod rollover resilience (Cron jobs run cluster-wide)
- Simpler architecture (no GenServers for periodic tasks)
- Better observability (all jobs visible in Oban dashboard)
- Safety net for missing jobs (JobHealthCheckWorker)
- Stateless workers (easier to reason about and test)
Documentation:
- Updated CLAUDE.md with Background Job Architecture section
- Documented job types, queues, and resilience features
All tests passing (3,686 tests, 0 failures).
Optimized the 10 slowest tests from 4.7s to ~2.5s (47% reduction):
Property-based tests:
- Reduced max_runs from 50/100 to 10 iterations (still provides good coverage)
- ApiTokensTest: 3 property tests now run 10 iterations instead of 50-100
- EquipmentTest: 3 property tests now run 10 iterations instead of 50-100
Network timeout tests:
- Manager IPv6 tests: reduced timeout from 100ms to 25ms (75% faster)
- Tests already expect failures, so shorter timeouts don't affect validity
Database optimization:
- MemoryPoolTest: converted individual insert to bulk insert_all
- Added proper updated_at timestamp for MemoryPool (required by schema)
Async processing:
- AgentLatencyEvaluatorTest: reduced Process.sleep from 500ms to 100ms
- Worker processes reliably within 100ms threshold
All 3,686 tests pass with no failures.
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Optimized the slowest tests to improve test suite performance:
1. Property-based IP validation test (6s → ~2.4s)
- Reduced max_runs from 50 to 20 iterations
- Still provides good coverage while being much faster
2. Database-heavy tests (~1s each)
- Replaced individual create_check calls with bulk Repo.insert_all
- Reduced check counts from 15 to 10 where adequate for testing
- Fixed timestamp handling (truncate to :second for Ecto)
- Fixed response_time_ms to use floats (schema requirement)
- Removed updated_at (disabled in Check schema)
- Tests affected:
* get_device_latency_by_agent/2
* get_uptime_percentage/1
* get_latency_data/2 respects limit
* AgentLatencyEvaluator tests
Expected speedup: ~40% reduction in top 10 slowest tests (12.8s → ~7.7s)
These optimizations maintain test coverage while significantly reducing
database transaction overhead.