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 | 0a4dd38 | 2016-12-07 11:28:04 -0800 | [diff] [blame^] | 35 | let status=0 |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 36 | for scenario in "${@:-smoke}"; do |
Thomas Vachuska | 8cc5318 | 2016-11-14 13:06:54 -0800 | [diff] [blame] | 37 | if [[ $scenario =~ ^[0-9]*$ ]]; then |
| 38 | printf "Waiting %d seconds...\n" $scenario |
| 39 | sleep $scenario |
| 40 | else |
| 41 | printf "Running scenario %s...\n" $scenario |
Thomas Vachuska | 0a4dd38 | 2016-12-07 11:28:04 -0800 | [diff] [blame^] | 42 | stc $scenario || let status=status+$? |
Thomas Vachuska | 8cc5318 | 2016-11-14 13:06:54 -0800 | [diff] [blame] | 43 | fi |
Thomas Vachuska | 0a4dd38 | 2016-12-07 11:28:04 -0800 | [diff] [blame^] | 44 | [ $status -ne 0 ] && break |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 45 | done |
Thomas Vachuska | 978902a | 2016-08-31 11:05:17 -0700 | [diff] [blame] | 46 | |
Thomas Vachuska | 9efd6b3 | 2016-07-13 15:44:32 -0700 | [diff] [blame] | 47 | printf "Finished run %d...\n" $run |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 48 | [ $status -ne 0 ] && exit $status |
Thomas Vachuska | 9efd6b3 | 2016-07-13 15:44:32 -0700 | [diff] [blame] | 49 | let run=run+1 |
| 50 | done |
Thomas Vachuska | 4d5310c | 2016-07-14 12:48:39 -0700 | [diff] [blame] | 51 | |
| 52 | if [ -n "$doTeardown" ]; then |
| 53 | printf "Tearing down...\n" |
| 54 | stc teardown || exit 1 |
| 55 | fi |