Carmelo Cascone | 4c3364b | 2018-12-13 15:56:34 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Checks whether the given pipeconfs are registered. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
| 9 | aux=/tmp/stc/stc-$$.log |
| 10 | trap "rm -f $aux $aux.1 $aux.2 2>/dev/null" EXIT |
| 11 | |
| 12 | for attempt in {1..30}; do |
| 13 | onos ${1:-$OCI} "onos:pipeconfs -s" > $aux |
| 14 | cat $aux |
| 15 | |
| 16 | # Normalize the registered pipeconfs |
| 17 | cut -d '=' -f2 $aux | sort > $aux.1 |
| 18 | |
| 19 | # Expected pipeconfs |
| 20 | pipeconfs=${2-org.onosproject.pipelines.basic} |
| 21 | (for pipeconf in ${pipeconfs//,/ }; do echo ${pipeconf}; done) | sort > $aux.2 |
| 22 | |
| 23 | # Check for differences |
| 24 | case ${3:-equals} in |
| 25 | equals) diff $aux.1 $aux.2;; |
| 26 | includes) [ $(egrep -c -f $aux.2 $aux.1) -ge $(wc -l $aux.2 | sed "s|$aux.2||g") ];; |
| 27 | excludes) ! egrep -f $aux.2 $aux.1;; |
| 28 | esac |
| 29 | |
| 30 | [ $? -eq 0 ] && exit 0 || sleep 1 |
| 31 | done |
| 32 | |
| 33 | exit 1; |