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
- Create snmp_ip_addresses table with migration
- Add IpAddress schema with ip_type validation (ipv4/ipv6)
- Add prefix_length validation based on ip_type
- Implement discover_ip_addresses/1 in Base profile
- Extract IP addresses from IP-MIB ipAdEntTable
- Support multiple IPs per interface with subnet masks
- Add 12 schema tests and 4 discovery tests
- Test start_link/1 and Horde Registry registration
- Test initial check on monitoring enabled/disabled
- Test trigger_check/1 for running and stopped monitors
- Test successful and failed ping handling
- Test status change detection (up->down, down->up)
- Test alert creation and resolution
- Test PubSub broadcasts for status changes and alerts
- Test alert message formatting for ICMP vs SNMP
- Test check scheduling based on check_interval_seconds
- Coverage improved from 43.93% to 96.67%
Total tests: 1066 -> 1089 (23 new tests)
Total coverage: 48.72% -> 49.65%
- Add Mox stub setup in supervisor_test.exs to handle DeviceMonitor ping calls
- Change alert_notifier_test.exs to async: true to prevent mailbox contamination
- All 1066 tests now passing with 0 failures
Changes:
- Updated MonitorWorker to use configured ping_module adapter instead of System.cmd
- Removed direct ping command execution and regex parsing
- Simplified ping_device/1 to use adapter.ping/2 (mockable in tests)
- Added PingMock expectations to all MonitorWorker tests
- Removed @tag :integration from unreachable host test (now mocked)
- All ping calls now use mocked responses in tests
Benefits:
- MonitorWorker tests now run in 0.2s instead of 5+ seconds
- No real ICMP network traffic during test runs
- Tests are deterministic and don't depend on network conditions
- Follows same adapter pattern as SNMP (testable, configurable)
All 1041 tests passing with no real network operations.
- Add 'error' to valid sensor reading status values
- SensorReading changeset was rejecting 'error' status
- PollWorker creates error readings when SNMP fails
- Fixed validation to include: ok, warning, critical, error
- Replace log capture tests with functional assertions
- ExUnit.CaptureLog not reliably capturing worker logs
- Changed to verify actual behavior instead of log messages
- Tests now check created records and state changes
- Add debug assertions to sensor error test
- Verify SNMP device exists and has sensors
- Better error messages for test failures
All 1045 tests now passing (0 failures, 2 skipped)
- Fix Monitoring context API calls (list_devices_checks vs list_checks_for_device)
- Fix Snmp context API calls (get_interface_stats, get_sensor_readings)
- Fix Devices context API calls (update_device vs update_device!)
- Fix Discovery worker to expect 7 GET calls (test_connection + system_info)
- Fix Poll worker to use stub instead of expect for variable call counts
- Fix sensor setup to use correct types (sensor_index: string, sensor_divisor: integer)
- Fix neighbor schema to include required fields (protocol, last_discovered_at)
- Simplify walk mocks to use stub for complex neighbor discovery
18 of 23 tests now passing. Remaining issues:
- 1 sensor error reading test (may need investigation)
- 4 log capture tests (ExUnit.CaptureLog not capturing logs from workers)
Tests cover:
- Valid and invalid changesets
- All required field validations
- Foreign key constraints
- Status enum values
- Schema field types and associations
- Binary ID usage for primary/foreign keys
All 16 tests passing with good coverage of schema validation logic.
- DiscoveryWorker: Tests for SNMP device discovery
- MonitorWorker: Tests for ICMP ping monitoring checks
- PollWorker: Tests for SNMP polling of sensors, interfaces, and neighbors
These tests use fixtures and Mox for SNMP mocking to achieve good coverage
of the worker modules without requiring real SNMP devices.
Note: Some function names need correction based on actual Monitoring/Snmp context APIs.
Fixes crashes in Exq.Node.Server when Redis connections fail by adding
health checks before startup and wrapping Exq in a custom supervisor
with better resilience.
Problem:
- Valkey pod restarting frequently (24 times in 28h) due to K8s Flannel CNI issues
- When Redis disconnects, Exq.Node.Server crashes trying to process_signals/2
- Gets nil from Redis instead of expected list, crashes on Enum.each/2
- Rapid crash/restart cycles reduce application stability
Changes:
1. RedisHealthCheck module (lib/towerops/redis_health_check.ex)
- Waits for Redis availability with exponential backoff before starting Exq
- Prevents Exq from starting when Redis is unavailable
- Handles connection errors gracefully without crashing caller processes
- Supports configurable retry attempts, timeouts, and backoff intervals
2. ExqSupervisor module (lib/towerops/exq_supervisor.ex)
- Custom supervisor that wraps Exq with health checks
- Uses one_for_one strategy with limited restarts (3 per 60s)
- Prevents rapid crash loops when Redis is unstable
- Increased Exq retry/backoff settings for better Redis recovery
- Allows application to continue functioning without background jobs if Redis unavailable
3. Updated Application.ex
- Replaced direct Exq start with ExqSupervisor
- Removed inline exq_config/0 function (moved to supervisor)
4. Tests
- Comprehensive tests for RedisHealthCheck (health checks, retries, timeouts)
- Tests for ExqSupervisor (configuration, restart strategy)
- All 1006 tests passing
Benefits:
- Prevents Exq crashes from propagating when Redis fails
- Application continues running even when Redis is temporarily unavailable
- Better logging of Redis connection issues
- More graceful degradation during infrastructure problems
Infrastructure Issue (to be addressed separately):
- K8s Flannel CNI plugin failing: /run/flannel/subnet.env not found
- Causing Valkey pod network issues and restarts
- Needs investigation of Flannel daemonset and node configuration
🤖 Generated with Claude Code
- Created 23 tests covering all public functions and edge cases
- Tests for IPv4 and IPv6 address validation
- Tests for timeout behavior and error handling
- Tests for PingBehaviour implementation
- All tests passing (23 tests, 0 failures)
- Module now has improved test coverage
Improves test coverage toward 90% target by adding tests for:
- Organizations context (bulk SNMP/agent operations)
- Sites context (hierarchical structure and bulk operations)
- Profiles context and schemas (device/sensor OID management)
- EctoTypes.JsonAny custom type
- Snmp.Neighbor schema (LLDP/CDP topology)
All new tests validate changeset validations, business logic,
and database constraints to ensure data integrity.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
User deletion bug:
- Store client IP in socket assigns during mount
- Access stored IP during delete event instead of connect_info
- Fixes RuntimeError when attempting to delete users
Timezone support:
- Add timezone offset maps for common timezones (no external deps)
- Implement shift_timezone/2 helper using DateTime.add/3
- Add timezone-aware format_datetime/2, format_date/2, format_iso8601/2
- Keep backwards-compatible 1-arity versions defaulting to UTC
- Add comprehensive test coverage for timezone conversions
- All tests passing (23 tests, 0 failures)
Note: Timezone offsets are standard time only (no DST handling)
Common timezones supported: America/New_York, America/Los_Angeles,
Europe/London, Europe/Paris, Asia/Tokyo, Asia/Shanghai, Australia/Sydney