#! /bin/bash
set -o xtrace

# run this script on main ai
# this is testing the links to vision

# check pre errors
ssh vision1 "ethtool -S eth0 | grep _errors"
ssh vision1 "ethtool -S eth1 | grep _errors"
ssh vision1 "ethtool -S eth2 | grep _errors"
ssh vision1 "ethtool -S eth3 | grep _errors"
set +o xtrace
./run_switch_cmd.exp corner-switch-q1 "port show statistics 2"
./run_switch_cmd.exp corner-switch-q2 "port show statistics 2"
./run_switch_cmd.exp corner-switch-q3 "port show statistics 2"
./run_switch_cmd.exp corner-switch-q4 "port show statistics 2"
set -o xtrace

# run traffic
ssh -q vision1 "iperf3 -s -D -i 60"
iperf3 -i 60 -n 6250000000 -c 192.168.8.3
iperf3 -i 60 -n 6250000000 -c 192.168.8.3 -R
iperf3 -i 60 -n 6250000000 -c 192.168.9.3
iperf3 -i 60 -n 6250000000 -c 192.168.9.3 -R
iperf3 -i 60 -n 6250000000 -c 192.168.8.4
iperf3 -i 60 -n 6250000000 -c 192.168.8.4 -R
iperf3 -i 60 -n 6250000000 -c 192.168.9.4
iperf3 -i 60 -n 6250000000 -c 192.168.9.4 -R
ssh -q vision1 "pkill -TERM iperf3"

# check post errors
ssh vision1 "ethtool -S eth0 | grep _errors"
ssh vision1 "ethtool -S eth1 | grep _errors"
ssh vision1 "ethtool -S eth2 | grep _errors"
ssh vision1 "ethtool -S eth3 | grep _errors"
set +o xtrace
./run_switch_cmd.exp corner-switch-q1 "port show statistics 2"
./run_switch_cmd.exp corner-switch-q2 "port show statistics 2"
./run_switch_cmd.exp corner-switch-q3 "port show statistics 2"
./run_switch_cmd.exp corner-switch-q4 "port show statistics 2"
set -o xtrace
