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

  1. #!/bin/bash
  2. # start-virl-topology-benchmark.sh
  3. # HS-Fulda - sebastian.rieger@informatik.hs-fulda.de
  4. #
  5. # changelog:
  6. # V1.0 initial version
  7. # V2.0 changed benchmark to support clusters and VIRL Version >=1.0.0
  8. # usage
  9. if [ ! $# -gt 4 ] ; then
  10. echo -e "usage: $0 <my-topology.virl> <number of concurrent simulations> <username> <password> <timeout> [debug level], e.g.,\n"
  11. echo "$0 /home/virl/git-virl-hs-fulda/GIT-VIRL-HS-Fulda/advcompnet-lab2-dcn-fabricpath.virl 6 guest password 0.5"
  12. exit -1
  13. fi
  14. TOPOLOGY=$1
  15. RUNCOUNT=$2
  16. USERNAME=$3
  17. PASSWORD=$4
  18. TIMEOUT=$5
  19. if [ $6 ]; then
  20. DEBUG=$6
  21. else
  22. DEBUG=0
  23. fi
  24. TOPOLOGYFILENAME=$(basename $TOPOLOGY)
  25. TIMESTAMP=$(date +%H%M%S)
  26. FILENAME="VIRLBENCH-$TIMESTAMP@$TOPOLOGYFILENAME"
  27. SCRIPTSTART_DATE=$(date)
  28. SCRIPTSTART_TIMESTAMP=$(date "+%s")
  29. echo "Script started at $SCRIPTSTART_DATE"
  30. # start the simulations
  31. RUN=0
  32. while [ $RUN -lt $RUNCOUNT ]
  33. do
  34. # use simengine-launch to start the simulation
  35. if [ $DEBUG -lt 2 ]; then
  36. virl_std_client --username $USERNAME --password $PASSWORD simengine-launch \
  37. --virl-file $TOPOLOGY --file-name $FILENAME >/dev/null 2>&1
  38. else
  39. virl_std_client --username $USERNAME --password $PASSWORD simengine-launch \
  40. --virl-file $TOPOLOGY --file-name $FILENAME
  41. fi
  42. RUN=$(expr $RUN + 1)
  43. done
  44. START_DATE=$(date)
  45. START_TIMESTAMP=$(date "+%s")
  46. echo "Started at $START_DATE"
  47. RUNNING=true
  48. # wait for simulations to start
  49. sleep 5
  50. # get all running benchmark simulations
  51. SIMS=$(virl_std_client --username $USERNAME --password $PASSWORD --quiet --json simengine-list 2>&1 | egrep -o -e "VIRLBENCH-$TIMESTAMP@(.*)-[_a-zA-Z0-9]{6}")
  52. if [ $DEBUG -gt 1 ]; then
  53. echo "Running simulations:"
  54. for SIM in $SIMS; do
  55. echo $SIM
  56. done
  57. echo
  58. fi
  59. # count nodes in the running benchmark simulations
  60. NODE_COUNT=0
  61. for SIM in $SIMS; do
  62. SIM_NODE_COUNT=$(virl_std_client --username $USERNAME --password $PASSWORD simengine-nodes --session-id $SIM 2>&1 | grep -c state)
  63. if [ $DEBUG -gt 1 ]; then
  64. echo "$SIM has $SIM_NODE_COUNT nodes"
  65. fi
  66. NODE_COUNT=$(expr $NODE_COUNT + $SIM_NODE_COUNT)
  67. done
  68. if [ $DEBUG -gt 0 ] ; then echo "$NODE_COUNT nodes"; fi
  69. # continuously count all ACTIVE nodes in running benchmark simulations until all nodes are ACTIVE
  70. ACTIVE_COUNT=0
  71. while [ $ACTIVE_COUNT -lt $NODE_COUNT ]
  72. do
  73. ACTIVE_COUNT=0
  74. for SIM in $SIMS; do
  75. SIM_NODE_ACTIVE_COUNT=$(virl_std_client --username $USERNAME --password $PASSWORD simengine-nodes --session-id $SIM 2>&1 | grep -c ACTIVE)
  76. if [ $DEBUG -gt 1 ]; then
  77. echo "$SIM has $SIM_NODE_ACTIVE_COUNT active nodes"
  78. fi
  79. ACTIVE_COUNT=$(expr $ACTIVE_COUNT + $SIM_NODE_ACTIVE_COUNT)
  80. done
  81. if [ $DEBUG -gt 0 ] ; then echo "$ACTIVE_COUNT of $NODE_COUNT are ACTIVE"; fi
  82. sleep 1
  83. done
  84. ACTIVE_DATE=$(date)
  85. ACTIVE_TIMESTAMP=$(date "+%s")
  86. echo "Active at $ACTIVE_DATE"
  87. # Check if the nodes are ready-for-use using websocket consoles
  88. ./check-usability-of-sims $USERNAME $PASSWORD $TIMEOUT "VIRLBENCH-$TIMESTAMP@(.*)-[_a-zA-Z0-9]{6}" $DEBUG
  89. USABLE_DATE=$(date)
  90. USABLE_TIMESTAMP=$(date "+%s")
  91. echo "Usable at $USABLE_DATE"
  92. START_TIME=$(( $START_TIMESTAMP - $SCRIPTSTART_TIMESTAMP ))
  93. ACTIVE_TIME=$(( $ACTIVE_TIMESTAMP - $SCRIPTSTART_TIMESTAMP ))
  94. USABLE_TIME=$(( $USABLE_TIMESTAMP - $SCRIPTSTART_TIMESTAMP ))
  95. echo
  96. echo
  97. echo "CSV Result:"
  98. echo "==========="
  99. echo "Topology;ConcurrentSims;Nodes;Script-Start;Started;Active;Usable;Finished;Start Time (sec);Active Time (sec);Usable Time (sec)"
  100. echo "$TOPOLOGYFILENAME;$RUNCOUNT;$NODE_COUNT;$SCRIPTSTART_DATE;$STARTDATE;$ACTIVE_DATE;$USABLE_DATE;$START_TIME;$ACTIVE_TIME;$USABLE_TIME"
  101. echo
  102. echo