blob: ab33823bdc2736046a4d4795ed05a80d3aee2d47 [file] [log] [blame]
Thomas Vachuska9efd6b32016-07-13 15:44:32 -07001#!/bin/bash
2#-------------------------------------------------------------------------------
3# Loops the System Test Coordinator invocations while success/until failure.
4#-------------------------------------------------------------------------------
5
Thomas Vachuska4d5310c2016-07-14 12:48:39 -07006count=0
7unset doSetup doTeardown
8
9# Scan arguments for user/password or other options...
10while getopts c:st o; do
11 case "$o" in
12 c) count=$OPTARG;;
13 s) doSetup=true;;
14 t) toTeardown=true;;
15 esac
16done
17let OPC=$OPTIND-1
18shift $OPC
19
20if [ -n "$doSetup" ]; then
21 printf "Setting up...\n"
22 stc setup || exit 1
23fi
24
Thomas Vachuska978902a2016-08-31 11:05:17 -070025# Iterate the specified number of times, or indefinitely if count not given
Thomas Vachuska9efd6b32016-07-13 15:44:32 -070026let run=1
Thomas Vachuska4d5310c2016-07-14 12:48:39 -070027while [ $count -le 0 -o $run -le $count ]; do
Thomas Vachuska67f13052016-08-19 12:10:42 -070028 export stcTitle="STC Run #$run; "
Thomas Vachuska9efd6b32016-07-13 15:44:32 -070029 printf "Starting run %d...\n" $run
Thomas Vachuska978902a2016-08-31 11:05:17 -070030
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 Vachuska0a4dd382016-12-07 11:28:04 -080035 let status=0
Thomas Vachuska4d5310c2016-07-14 12:48:39 -070036 for scenario in "${@:-smoke}"; do
Thomas Vachuska8cc53182016-11-14 13:06:54 -080037 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 Vachuska0a4dd382016-12-07 11:28:04 -080042 stc $scenario || let status=status+$?
Thomas Vachuska8cc53182016-11-14 13:06:54 -080043 fi
Thomas Vachuska0a4dd382016-12-07 11:28:04 -080044 [ $status -ne 0 ] && break
Thomas Vachuska4d5310c2016-07-14 12:48:39 -070045 done
Thomas Vachuska978902a2016-08-31 11:05:17 -070046
Thomas Vachuska9efd6b32016-07-13 15:44:32 -070047 printf "Finished run %d...\n" $run
Thomas Vachuska4d5310c2016-07-14 12:48:39 -070048 [ $status -ne 0 ] && exit $status
Thomas Vachuska9efd6b32016-07-13 15:44:32 -070049 let run=run+1
50done
Thomas Vachuska4d5310c2016-07-14 12:48:39 -070051
52if [ -n "$doTeardown" ]; then
53 printf "Tearing down...\n"
54 stc teardown || exit 1
55fi