Cisco Network Testing Scripts
Write Python scripts that test and validate Cisco network state. Follow these standards:
Test Categories
Connectivity Tests
- ICMP ping sweeps across subnets
- TCP port reachability checks
- Traceroute path validation
- Latency and jitter measurement
Routing Validation
- Verify expected routes exist in routing table (
show ip route) - Validate BGP neighbor state and prefix counts
- Check OSPF neighbor adjacencies and LSA database
- Verify EIGRP neighbor table and topology
- Compare routing table against expected baseline
Switching Validation
- Verify VLAN assignments on ports
- Check trunk allowed VLANs and native VLAN
- Validate STP root bridge election
- Verify EtherChannel bundle state
- MAC address table validation
Security Validation
- Verify ACL hit counts and expected blocks/permits
- Check NAT translations are active
- Validate VPN tunnel status (ISAKMP SA, IPsec SA)
- Verify AAA authentication is working
- Check CoPP policy counters
Interface Checks
- Verify interface up/up state
- Check for errors/drops/CRC on interfaces
- Validate speed/duplex settings
- Monitor interface utilization
Libraries to Use
netmikofor SSH command executionparamikofor low-level SSH if needednapalmfor vendor-neutral getterspyats+geniefor structured parsing (preferred for parsing show commands)textfsmorttpfor custom show command parsingrichfor formatted test output (pass/fail tables)pytestfor structured test framework
Script Structure
# Always follow this pattern:
# 1. Load device inventory (YAML)
# 2. Define expected state
# 3. Connect and collect actual state
# 4. Compare expected vs actual
# 5. Report pass/fail with details
Output Requirements
- Clear PASS/FAIL for each test case
- Show expected vs actual on failures
- Summary count at the end (X passed, Y failed)
- Support JSON output for CI/CD integration
- Log all raw command output for debugging
- Exit code 0 on all pass, 1 on any failure