You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.5 KiB

#!/bin/bash
# start-virl-topology-benchmark.sh
# HS-Fulda - sebastian.rieger@informatik.hs-fulda.de
#
# changelog:
# V1.0 initial version
# V2.0 changed benchmark to support clusters and VIRL Version >=1.0.0
# usage
if [ ! $# -gt 4 ] ; then
echo -e "usage: $0 <my-topology.virl> <number of concurrent simulations> <username> <password> <timeout> [debug level], e.g.,\n"
echo "$0 /home/virl/git-virl-hs-fulda/GIT-VIRL-HS-Fulda/advcompnet-lab2-dcn-fabricpath.virl 6 guest password 0.5"
exit -1
fi
TOPOLOGY=$1
RUNCOUNT=$2
USERNAME=$3
PASSWORD=$4
TIMEOUT=$5
if [ $6 ]; then
DEBUG=$6
else
DEBUG=0
fi
TOPOLOGYFILENAME=$(basename $TOPOLOGY)
TIMESTAMP=$(date +%H%M%S)
FILENAME="VIRLBENCH-$TIMESTAMP@$TOPOLOGYFILENAME"
SCRIPTSTART_DATE=$(date)
SCRIPTSTART_TIMESTAMP=$(date "+%s")
echo "Script started at $SCRIPTSTART_DATE"
# start the simulations
RUN=0
while [ $RUN -lt $RUNCOUNT ]
do
# use simengine-launch to start the simulation
if [ $DEBUG -lt 2 ]; then
virl_std_client --username $USERNAME --password $PASSWORD simengine-launch \
--virl-file $TOPOLOGY --file-name $FILENAME >/dev/null 2>&1
else
virl_std_client --username $USERNAME --password $PASSWORD simengine-launch \
--virl-file $TOPOLOGY --file-name $FILENAME
fi
RUN=$(expr $RUN + 1)
done
START_DATE=$(date)
START_TIMESTAMP=$(date "+%s")
echo "Started at $START_DATE"
RUNNING=true
# wait for simulations to start
sleep 5
# get all running benchmark simulations
SIMS=$(virl_std_client --username $USERNAME --password $PASSWORD --quiet --json simengine-list 2>&1 | egrep -o -e "VIRLBENCH-$TIMESTAMP@(.*)-[_a-zA-Z0-9]{6}")
if [ $DEBUG -gt 1 ]; then
echo "Running simulations:"
for SIM in $SIMS; do
echo $SIM
done
echo
fi
# count nodes in the running benchmark simulations
NODE_COUNT=0
for SIM in $SIMS; do
SIM_NODE_COUNT=$(virl_std_client --username $USERNAME --password $PASSWORD simengine-nodes --session-id $SIM 2>&1 | grep -c state)
if [ $DEBUG -gt 1 ]; then
echo "$SIM has $SIM_NODE_COUNT nodes"
fi
NODE_COUNT=$(expr $NODE_COUNT + $SIM_NODE_COUNT)
done
if [ $DEBUG -gt 0 ] ; then echo "$NODE_COUNT nodes"; fi
# continuously count all ACTIVE nodes in running benchmark simulations until all nodes are ACTIVE
ACTIVE_COUNT=0
while [ $ACTIVE_COUNT -lt $NODE_COUNT ]
do
ACTIVE_COUNT=0
for SIM in $SIMS; do
SIM_NODE_ACTIVE_COUNT=$(virl_std_client --username $USERNAME --password $PASSWORD simengine-nodes --session-id $SIM 2>&1 | grep -c ACTIVE)
if [ $DEBUG -gt 1 ]; then
echo "$SIM has $SIM_NODE_ACTIVE_COUNT active nodes"
fi
ACTIVE_COUNT=$(expr $ACTIVE_COUNT + $SIM_NODE_ACTIVE_COUNT)
done
if [ $DEBUG -gt 0 ] ; then echo "$ACTIVE_COUNT of $NODE_COUNT are ACTIVE"; fi
sleep 1
done
ACTIVE_DATE=$(date)
ACTIVE_TIMESTAMP=$(date "+%s")
echo "Active at $ACTIVE_DATE"
# Check if the nodes are ready-for-use using websocket consoles
./check-usability-of-sims $USERNAME $PASSWORD $TIMEOUT "VIRLBENCH-$TIMESTAMP@(.*)-[_a-zA-Z0-9]{6}" $DEBUG
USABLE_DATE=$(date)
USABLE_TIMESTAMP=$(date "+%s")
echo "Usable at $USABLE_DATE"
START_TIME=$(( $START_TIMESTAMP - $SCRIPTSTART_TIMESTAMP ))
ACTIVE_TIME=$(( $ACTIVE_TIMESTAMP - $SCRIPTSTART_TIMESTAMP ))
USABLE_TIME=$(( $USABLE_TIMESTAMP - $SCRIPTSTART_TIMESTAMP ))
echo
echo
echo "CSV Result:"
echo "==========="
echo "Topology;ConcurrentSims;Nodes;Script-Start;Started;Active;Usable;Finished;Start Time (sec);Active Time (sec);Usable Time (sec)"
echo "$TOPOLOGYFILENAME;$RUNCOUNT;$NODE_COUNT;$SCRIPTSTART_DATE;$STARTDATE;$ACTIVE_DATE;$USABLE_DATE;$START_TIME;$ACTIVE_TIME;$USABLE_TIME"
echo
echo