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.
Add 8 new vendor modules for wireless sensor discovery:
- PMP: Cambium PMP 450/430/100 and PTP series
- Mimosa: B5/B5c PTP and A5/A5c PTMP radios
- Siklu: EtherHaul mmWave radios
- Radwin: WinLink and JET series
- UniFi: Ubiquiti UniFi Access Points
- LigoOS: LigoWave and Deliberant devices
- cnPilot: Cambium cnPilot E and R series
- SAF: SAF Tehnika Integra/Lumina/CFIP series
Each module implements the Vendor behaviour with:
- profile_names/0: OS profile identifiers
- detect_hardware/1: device model detection
- wireless_oid_defs/0: sensor OID definitions
- discover_wireless_sensors/1: sensor discovery
Includes comprehensive tests for all modules (104 tests).
- Add discover_vlans/1 to Cisco profile for VTP MIB discovery
- VTP OIDs: vtpVlanName, vtpVlanState, vtpVlanType
- Falls back to Q-BRIDGE-MIB when VTP not available
- Maps VTP states (operational, suspended, mtuTooBig)
- Maps VTP types (ethernet, fddi, tokenRing, etc.)
- Validates VLAN ID range (1-4094)
- Rewrote Ping module to use system ping binary instead of raw ICMP
sockets which required CAP_NET_RAW privileges
- Added iputils-ping package to Docker images for production
- Added proper IP address validation before executing ping command
- Updated tests to account for 1 second minimum timeout of system ping
- System ping binary is setuid root and works without elevated privileges
- Create snmp_physical_entities table with migration
- Add PhysicalEntity schema with entity_class validation
- Support parent/child hierarchy via parent_entity_id
- Implement discover_physical_entities/1 in Base profile
- Discover chassis, modules, PSUs, fans from ENTITY-MIB
- Map entity class integers to string names
- Add 10 schema tests and 4 discovery tests
- Fix flaky AlertNotifier test with unique names and mailbox clearing