#!/bin/bash
function bail () { echo -e "Error: ${1:-Unknown Error}\n"; exit ${2:-1}; }
instance=${1:-Unset}
[[ $instance == "Unset" ]] && bail "Specify instance as parameter"
[[ ! -d /p4/$instance/logs ]] && bail "Instance $instance not found: /p4/$instance/logs"
P4BENCH_SCRIPT=${2:-Unset}
[[ $P4BENCH_SCRIPT == "Unset" ]] && bail "Specify P4BENCH_SCRIPT as second parameter"
[[ ! -f locust_files/p4_$P4BENCH_SCRIPT.py ]] && bail "Benchmark script $P4BENCH_SCRIPT not found: locust_files/p4_$P4BENCH_SCRIPT.py"
export P4BENCH_HOST=`hostname`
export P4BENCH_SCRIPT
# Calculate env vars to be picked up by run_master.sh
export P4BENCH_NUM_SLAVES_PER_HOST=$(grep "num_slaves" hosts | awk '{print $2}')
hosts=$(grep -A 99999 bench_clients: hosts | grep -E "^\s+\S+:$" | wc -l)
export P4BENCH_NUM_HOSTS=$(($hosts - 2))
echo "Running p4_${P4BENCH_SCRIPT} on instance ${instance}"
echo "Removing bruno clients"
./del_clients.sh $instance
# Remove existing logs to make sure they don't clutter up the measurements
[[ -f /p4/$instance/logs/log ]] && sudo rm /p4/$instance/logs/log
# Remove shared logs on other servers if appropriate
#sudo rm /remote/p4/rep/h02_$instance/logs/log
#sudo rm /remote/p4/rep/h03_$instance/logs/log
#sudo rm /remote/p4/rep/h04_$instance/logs/log
config_file="config_p4_${P4BENCH_SCRIPT}.yml"
sed -e "s/:1666/:${instance}666/" < locust_files/$config_file > $config_file
rm logs/*slave*.out
echo "Removing remote logs..."
ansible-playbook -i hosts ansible/rm_logs.yml > /dev/null
ansible-playbook -i hosts ansible/post_bench.yml
ansible-playbook -i hosts ansible/pre_bench.yml
# Flush filesystem caches
sudo sync
sudo bash -c 'echo 3 > /proc/sys/vm/drop_caches'
./run_master.sh
ansible-playbook -i hosts ansible/bench.yml
# ansible-playbook -i hosts ansible/replicas.yml
echo "Running monitor jobs in background"
nohup ./run_monitor.sh &
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #6 | 25669 | Robert Cowham | Refactored - move scripts to utils dir | ||
| #5 | 25520 | Robert Cowham |
Tidied up. Created 2 client workspaces |
||
| #4 | 25354 | Robert Cowham | Working with multiple edges | ||
| #3 | 25353 | Robert Cowham | Monitor network at beginning and end of benchmark | ||
| #2 | 25351 | Robert Cowham | Working with new structure /home/p4/ws as root and calculating num hosts | ||
| #1 | 25346 | Robert Cowham | Populate //stream/pure. |