2.8 KiB
2.8 KiB
Testing Guide
Test Environment
The testing environment uses podman-compose to create a network topology with routers and an ICMP target:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Route-Switcher │ │ Primary Router│ │ ICMP Target │
│ │ │ │ │ │
│ eth0 ────────────┼────►│ eth0 ──────────┼────►│ 192.168.202.100│
│ eth1 ────────────┼────►│ eth1 ──────────┼────►│ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Container Setup
- route-switcher: Dual interfaces (eth0→primary-net, eth1→secondary-net)
- primary-router: Connects primary-net ↔ target-net (192.168.200.11 ↔ 192.168.202.11)
- secondary-router: Connects secondary-net ↔ target-net (192.168.201.11 ↔ 192.168.202.12)
- icmp-target: Single IP on target-net (192.168.202.100)
Test Scenarios
1. Basic Connectivity Test
podman-compose up -d
podman-compose exec route-switcher ping -c 3 -I eth0 192.168.202.100
podman-compose exec route-switcher ping -c 3 -I eth1 192.168.202.100
2. Failover Test
# Monitor logs
podman-compose logs -f route-switcher &
# Simulate primary router failure
podman-compose exec primary-router ip link set eth0 down
# Verify failover occurs and connectivity works
podman-compose exec route-switcher ping -c 3 192.168.202.100
# Restore primary router
podman-compose exec primary-router ip link set eth0 up
# Verify failback after 60 seconds
3. Dual Failure Test
# Fail both routers - system should NOT switch
podman-compose exec primary-router ip link set eth0 down
podman-compose exec secondary-router ip link set eth0 down
# Verify no routing changes occur
Automated Testing
Run the comprehensive test script:
./scripts/test-failover.sh
This script:
- Starts the test environment
- Verifies initial connectivity
- Simulates primary router failure
- Monitors failover
- Restores primary router
- Verifies failback
Unit Tests
# Run all tests
cargo test
# Run specific module
cargo test pinger
cargo test routing
cargo test state_machine
Debug Commands
# Check container interfaces
podman-compose exec route-switcher ip addr show
# Check routing table
podman-compose exec route-switcher ip route show
# Monitor network traffic
podman-compose exec route-switcher tcpdump -i any icmp