This directory contains a testing framework for simulating student exercises across all containerlab labs.
parallel-testing/
├── lib/ # Shared library functions
│ ├── common.sh # Common utility functions
│ └── result-collector.sh # JSON result collection
├── student-tests/ # Student exercise simulations
│ ├── ospf-basics-exercises.sh
│ ├── bgp-ebgp-exercises.sh (planned)
│ ├── linux-namespaces-exercises.sh
│ ├── vyos-firewall-exercises.sh
│ ├── enterprise-vpn-exercises.sh
│ └── zero-trust-exercises.sh
└── results/ # JSON output files
└── *.json
log_info()- Blue info messageslog_success()- Green success messageslog_warning()- Yellow warning messageslog_error()- Red error messagesexec_vtysh()- Execute vtysh command in containerexec_bash()- Execute bash command in containercheck_container()- Verify container is runningcount_pattern()- Count pattern matches in outputhas_pattern()- Check if pattern exists in output
add_result()- Add exercise result to collectionoutput_results()- Generate JSON outputsave_results()- Save results to file
# Make sure lab is deployed first
cd ospf-basics
sudo containerlab deploy -t topology.clab.yml
# Run student exercises
cd ../parallel-testing
./student-tests/ospf-basics-exercises.sh{
"lab": "ospf-basics",
"timestamp": "2025-12-15T14:30:00Z",
"summary": {
"total": 5,
"passed": 5,
"failed": 0
},
"exercises": [
{
"exercise": 1,
"name": "Verify OSPF Neighbors",
"status": "passed",
"expected": "2 neighbors in Full state",
"actual": "Found 2 neighbors in Full state",
"details": "r1 has correct OSPF adjacencies"
}
]
}- Source the library files:
source "$LIB_DIR/common.sh"
source "$LIB_DIR/result-collector.sh"- Define exercise functions:
exercise_1() {
log_info "Exercise 1: Description"
# Run commands
output=$(exec_vtysh "$container" "show command")
# Validate results
if [ condition ]; then
add_result 1 "Exercise Name" "passed" "$expected" "$actual" "$details"
log_success "PASSED"
else
add_result 1 "Exercise Name" "failed" "$expected" "$actual" "$details"
log_error "FAILED"
fi
}- Output results:
output_results "$LAB_NAME"
save_results "$LAB_NAME" "$OUTPUT_FILE"Each student exercise script follows this pattern:
- Pre-flight checks - Verify containers are running
- Exercise execution - Run commands via docker exec
- Validation - Check expected vs actual results
- Result collection - Add to JSON results array
- Summary output - Display and save JSON results
- Parallel testing - Can run multiple lab exercises simultaneously
- Consistent format - Standardized JSON output
- Student simulation - Tests exercises exactly as students would run them
- CI/CD ready - Easy integration into GitHub Actions
- Detailed reporting - JSON output for analysis and tracking