#!/bin/bash # Volt Network Benchmark - Full Suite Runner # Runs all benchmarks and generates comprehensive report set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Parse arguments SERVER_IP="${1:?Usage: $0 [backend-name] [duration]}" BACKEND="${2:-unknown}" DURATION="${3:-30}" # Create shared timestamp for this run export BENCHMARK_TIMESTAMP=$(date +%Y-%m-%d_%H%M%S) RESULTS_DIR="${SCRIPT_DIR}/results/${BACKEND}/${BENCHMARK_TIMESTAMP}" mkdir -p "$RESULTS_DIR" echo "╔══════════════════════════════════════════════════════════════╗" echo "║ Volt Network Benchmark Suite ║" echo "╚══════════════════════════════════════════════════════════════╝" echo "" echo "Configuration:" echo " Server: $SERVER_IP" echo " Backend: $BACKEND" echo " Duration: ${DURATION}s per test" echo " Results: $RESULTS_DIR" echo " Started: $(date)" echo "" # Record system information echo "=== Recording System Info ===" { echo "Volt Network Benchmark" echo "===========================" echo "Date: $(date)" echo "Backend: $BACKEND" echo "Server: $SERVER_IP" echo "" echo "--- Client System ---" echo "Hostname: $(hostname)" echo "Kernel: $(uname -r)" echo "CPU: $(grep 'model name' /proc/cpuinfo | head -1 | cut -d: -f2 | xargs)" echo "Cores: $(nproc)" echo "" echo "--- Network Interfaces ---" ip addr show 2>/dev/null || ifconfig echo "" echo "--- Network Stats Before ---" cat /proc/net/dev 2>/dev/null | head -10 } > "${RESULTS_DIR}/system-info.txt" # Pre-flight checks echo "=== Pre-flight Checks ===" echo "" check_server() { local port=$1 local name=$2 if timeout 3 bash -c "echo > /dev/tcp/$SERVER_IP/$port" 2>/dev/null; then echo " ✓ $name ($SERVER_IP:$port)" return 0 else echo " ✗ $name ($SERVER_IP:$port) - not responding" return 1 fi } IPERF_OK=0 SOCKPERF_OK=0 NETPERF_OK=0 check_server 5201 "iperf3" && IPERF_OK=1 check_server 11111 "sockperf" && SOCKPERF_OK=1 check_server 12865 "netperf" && NETPERF_OK=1 echo "" if [ $IPERF_OK -eq 0 ]; then echo "ERROR: iperf3 server required but not running" echo "Start with: iperf3 -s" exit 1 fi # Run benchmarks echo "╔══════════════════════════════════════════════════════════════╗" echo "║ Running Benchmarks ║" echo "╚══════════════════════════════════════════════════════════════╝" echo "" # Throughput tests echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "PHASE 1: Throughput Tests" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "${SCRIPT_DIR}/throughput.sh" "$SERVER_IP" "$BACKEND" "$DURATION" 2>&1 | tee "${RESULTS_DIR}/throughput-log.txt" echo "" sleep 5 # Latency tests echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "PHASE 2: Latency Tests" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "${SCRIPT_DIR}/latency.sh" "$SERVER_IP" "$BACKEND" 1000 "$DURATION" 2>&1 | tee "${RESULTS_DIR}/latency-log.txt" echo "" sleep 5 # PPS tests echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "PHASE 3: Packets Per Second Tests" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "${SCRIPT_DIR}/pps.sh" "$SERVER_IP" "$BACKEND" "$DURATION" 2>&1 | tee "${RESULTS_DIR}/pps-log.txt" # Collect all results into unified directory echo "" echo "=== Consolidating Results ===" # Find and move nested results for subdir in throughput latency pps; do nested_dir="${SCRIPT_DIR}/results/${BACKEND}" if [ -d "$nested_dir" ]; then # Find most recent subdirectory from this run latest=$(ls -td "${nested_dir}"/*/ 2>/dev/null | head -1) if [ -n "$latest" ] && [ "$latest" != "$RESULTS_DIR/" ]; then cp -r "$latest"/* "$RESULTS_DIR/" 2>/dev/null || true fi fi done # Generate final report echo "" echo "╔══════════════════════════════════════════════════════════════╗" echo "║ Final Report ║" echo "╚══════════════════════════════════════════════════════════════╝" REPORT_FILE="${RESULTS_DIR}/REPORT.md" { echo "# Volt Network Benchmark Report" echo "" echo "## Configuration" echo "" echo "| Parameter | Value |" echo "|-----------|-------|" echo "| Backend | $BACKEND |" echo "| Server | $SERVER_IP |" echo "| Duration | ${DURATION}s per test |" echo "| Date | $(date) |" echo "| Hostname | $(hostname) |" echo "" echo "## Results Summary" echo "" # Throughput echo "### Throughput" echo "" echo "| Test | Result |" echo "|------|--------|" for json_file in "${RESULTS_DIR}"/tcp-*.json "${RESULTS_DIR}"/udp-*.json; do if [ -f "$json_file" ] && command -v jq &> /dev/null; then test_name=$(basename "$json_file" .json) if [[ "$test_name" == udp-* ]]; then bps=$(jq -r '.end.sum.bits_per_second // 0' "$json_file" 2>/dev/null) else bps=$(jq -r '.end.sum_sent.bits_per_second // 0' "$json_file" 2>/dev/null) fi gbps=$(echo "scale=2; $bps / 1000000000" | bc 2>/dev/null || echo "N/A") echo "| $test_name | ${gbps} Gbps |" fi done 2>/dev/null echo "" # Latency echo "### Latency" echo "" if [ -f "${RESULTS_DIR}/ping-summary.env" ]; then source "${RESULTS_DIR}/ping-summary.env" echo "| Metric | ICMP (µs) |" echo "|--------|-----------|" echo "| P50 | $ICMP_P50_US |" echo "| P95 | $ICMP_P95_US |" echo "| P99 | $ICMP_P99_US |" fi echo "" # PPS echo "### Packets Per Second" echo "" echo "| Packet Size | PPS |" echo "|-------------|-----|" for pkt_size in 64 128 256 512; do json_file="${RESULTS_DIR}/udp-${pkt_size}byte.json" if [ -f "$json_file" ] && command -v jq &> /dev/null; then packets=$(jq -r '.end.sum.packets // 0' "$json_file" 2>/dev/null) pps=$(echo "scale=0; $packets / $DURATION" | bc 2>/dev/null || echo "N/A") echo "| ${pkt_size} bytes | $pps |" fi done 2>/dev/null echo "" echo "## Files" echo "" echo '```' ls -la "$RESULTS_DIR" echo '```' } > "$REPORT_FILE" cat "$REPORT_FILE" echo "" echo "╔══════════════════════════════════════════════════════════════╗" echo "║ Benchmark Complete ║" echo "╚══════════════════════════════════════════════════════════════╝" echo "" echo "Results saved to: $RESULTS_DIR" echo "Report: ${REPORT_FILE}" echo "Completed: $(date)"