Thomas Vachuska | 9efd6b3 | 2016-07-13 15:44:32 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | #------------------------------------------------------------------------------- |
| 3 | # Loops the System Test Coordinator invocations while success/until failure. |
| 4 | #------------------------------------------------------------------------------- |
| 5 | |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 6 | count=0 |
| 7 | unset doSetup doTeardown |
| 8 | |
| 9 | # Scan arguments for user/password or other options... |
| 10 | while getopts c:st o; do |
| 11 | case "$o" in |
| 12 | c) count=$OPTARG;; |
| 13 | s) doSetup=true;; |
| 14 | t) toTeardown=true;; |
| 15 | esac |
| 16 | done |
| 17 | let OPC=$OPTIND-1 |
| 18 | shift $OPC |
| 19 | |
| 20 | if [ -n "$doSetup" ]; then |
| 21 | printf "Setting up...\n" |
| 22 | stc setup || exit 1 |
| 23 | fi |
| 24 | |
Thomas Vachuska | 978902a | 2016-08-31 11:05:17 -0700 | [diff] [blame] | 25 | # Iterate the specified number of times, or indefinitely if count not given |
Thomas Vachuska | 9efd6b3 | 2016-07-13 15:44:32 -0700 | [diff] [blame] | 26 | let run=1 |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 27 | while [ $count -le 0 -o $run -le $count ]; do |
Thomas Vachuska | 67f1305 | 2016-08-19 12:10:42 -0700 | [diff] [blame] | 28 | export stcTitle="STC Run #$run; " |
Thomas Vachuska | 9efd6b3 | 2016-07-13 15:44:32 -0700 | [diff] [blame] | 29 | printf "Starting run %d...\n" $run |
Thomas Vachuska | 978902a | 2016-08-31 11:05:17 -0700 | [diff] [blame] | 30 | |
| 31 | # If we're running on a borrowed cell, refresh the reservation |
| 32 | [ "$ONOS_CELL" = "borrow" ] && onos-cell $ONOS_CELL 120 >/dev/null |
| 33 | |
| 34 | # Iterate over all listed scenarios |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 35 | for scenario in "${@:-smoke}"; do |
Thomas Vachuska | 8cc5318 | 2016-11-14 13:06:54 -0800 | [diff] [blame] | 36 | if [[ $scenario =~ ^[0-9]*$ ]]; then |
| 37 | printf "Waiting %d seconds...\n" $scenario |
| 38 | sleep $scenario |
| 39 | else |
| 40 | printf "Running scenario %s...\n" $scenario |
| 41 | stc $scenario |
| 42 | fi |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 43 | done |
Thomas Vachuska | 9efd6b3 | 2016-07-13 15:44:32 -0700 | [diff] [blame] | 44 | status=$? |
Thomas Vachuska | 978902a | 2016-08-31 11:05:17 -0700 | [diff] [blame] | 45 | |
Thomas Vachuska | 9efd6b3 | 2016-07-13 15:44:32 -0700 | [diff] [blame] | 46 | printf "Finished run %d...\n" $run |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 47 | [ $status -ne 0 ] && exit $status |
Thomas Vachuska | 9efd6b3 | 2016-07-13 15:44:32 -0700 | [diff] [blame] | 48 | let run=run+1 |
| 49 | done |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 50 | |
| 51 | if [ -n "$doTeardown" ]; then |
| 52 | printf "Tearing down...\n" |
| 53 | stc teardown || exit 1 |
| 54 | fi |