96 lines
2.8 KiB
Markdown
96 lines
2.8 KiB
Markdown
# 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
|
|
```bash
|
|
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
|
|
```bash
|
|
# 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
|
|
```bash
|
|
# 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:
|
|
```bash
|
|
./scripts/test-failover.sh
|
|
```
|
|
|
|
This script:
|
|
1. Starts the test environment
|
|
2. Verifies initial connectivity
|
|
3. Simulates primary router failure
|
|
4. Monitors failover
|
|
5. Restores primary router
|
|
6. Verifies failback
|
|
|
|
## Unit Tests
|
|
|
|
```bash
|
|
# Run all tests
|
|
cargo test
|
|
|
|
# Run specific module
|
|
cargo test pinger
|
|
cargo test routing
|
|
cargo test state_machine
|
|
```
|
|
|
|
## Debug Commands
|
|
|
|
```bash
|
|
# 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
|
|
```
|