blob: d2d9c754047f30d8cf3be15f0ab0404138a60079 [file] [log] [blame]
Thomas Vachuska8189a742015-05-29 10:02:52 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Checks whether all and only the ONOS apps configured in ONOS_APPS are active.
4# -----------------------------------------------------------------------------
5
Thomas Vachuska4cfcc562015-06-03 09:51:02 -07006[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
Thomas Vachuska8189a742015-05-29 10:02:52 -07009aux=/tmp/stc-$$.log
10trap "rm -f $aux $aux.1 $aux.2 2>/dev/null" EXIT
11
Thomas Vachuskac4ee7372016-02-02 16:10:09 -080012for attempt in {1..10}; do
Thomas Vachuska1c152872015-08-26 18:41:10 -070013 onos ${1:-$OCI} "onos:apps -s -a" | grep -v /bin/client > $aux
14 cat $aux
Thomas Vachuska8189a742015-05-29 10:02:52 -070015
Thomas Vachuska1c152872015-08-26 18:41:10 -070016 # Normalize the installed apps
17 cut -c7- $aux | grep -v '/bin/client' | cut -d\ -f1 | sort > $aux.1
Thomas Vachuska8189a742015-05-29 10:02:52 -070018
Thomas Vachuska1c152872015-08-26 18:41:10 -070019 # 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 Vachuska8189a742015-05-29 10:02:52 -070023
Thomas Vachuska1c152872015-08-26 18:41:10 -070024 # Check for differences
25 case ${3:-equals} in
26 equals) diff $aux.1 $aux.2;;
Thomas Vachuska4b146a72015-11-18 12:04:50 -080027 includes) [ $(egrep -c -f $aux.2 $aux.1) -ge $(wc -l $aux.2 | sed "s|$aux.2||g") ];;
Thomas Vachuska1c152872015-08-26 18:41:10 -070028 excludes) ! egrep -f $aux.2 $aux.1;;
29 esac
30
31 [ $? -eq 0 ] && exit 0 || sleep 1
32done
33
34exit 1;