blob: f4b21b7f10a834721101653f564f6a5e75eb78a2 [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 Vachuskad2f2dfe2016-02-18 13:55:53 -080012for attempt in {1..30}; do
Thomas Vachuska5af2e4f2016-12-16 12:07:33 -080013 onos ${1:-$OCI} "onos:apps -s -a" > $aux
Thomas Vachuska1c152872015-08-26 18:41:10 -070014 cat $aux
Thomas Vachuska8189a742015-05-29 10:02:52 -070015
Thomas Vachuska1c152872015-08-26 18:41:10 -070016 # Normalize the installed apps
Thomas Vachuska5af2e4f2016-12-16 12:07:33 -080017 cut -c7- $aux | 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;