Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Checks whether all and only the ONOS apps configured in ONOS_APPS are active. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
Thomas Vachuska | 4cfcc56 | 2015-06-03 09:51:02 -0700 | [diff] [blame] | 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 9 | aux=/tmp/stc-$$.log |
| 10 | trap "rm -f $aux $aux.1 $aux.2 2>/dev/null" EXIT |
| 11 | |
Thomas Vachuska | d2f2dfe | 2016-02-18 13:55:53 -0800 | [diff] [blame] | 12 | for attempt in {1..30}; do |
Thomas Vachuska | 5af2e4f | 2016-12-16 12:07:33 -0800 | [diff] [blame^] | 13 | onos ${1:-$OCI} "onos:apps -s -a" > $aux |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 14 | cat $aux |
Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 15 | |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 16 | # Normalize the installed apps |
Thomas Vachuska | 5af2e4f | 2016-12-16 12:07:33 -0800 | [diff] [blame^] | 17 | cut -c7- $aux | cut -d\ -f1 | sort > $aux.1 |
Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 18 | |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 19 | # Normalize the expected apps |
| 20 | apps=${2:-$ONOS_APPS} |
| 21 | apps=${apps:-drivers,openflow} |
| 22 | (for app in ${apps//,/ }; do echo org.onosproject.$app; done) | sort > $aux.2 |
Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 23 | |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 24 | # Check for differences |
| 25 | case ${3:-equals} in |
| 26 | equals) diff $aux.1 $aux.2;; |
Thomas Vachuska | 4b146a7 | 2015-11-18 12:04:50 -0800 | [diff] [blame] | 27 | includes) [ $(egrep -c -f $aux.2 $aux.1) -ge $(wc -l $aux.2 | sed "s|$aux.2||g") ];; |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 28 | excludes) ! egrep -f $aux.2 $aux.1;; |
| 29 | esac |
| 30 | |
| 31 | [ $? -eq 0 ] && exit 0 || sleep 1 |
| 32 | done |
| 33 | |
| 34 | exit 1; |