Added check for cyclic dependencies.

Changes intent test scenarios to use the key and added dependencies to make them more robust; h2h still fails intermittently due to a bug.

Increased parallelism of the smoke test scenario.

Change-Id: Ib7fed38d17d1b25c5dd854ef1cd4dc777002c5fc
diff --git a/tools/test/bin/onos-check-apps b/tools/test/bin/onos-check-apps
index 9bdf393..dfd6b4e 100755
--- a/tools/test/bin/onos-check-apps
+++ b/tools/test/bin/onos-check-apps
@@ -9,16 +9,26 @@
 aux=/tmp/stc-$$.log
 trap "rm -f $aux $aux.1 $aux.2 2>/dev/null" EXIT
 
-onos ${1:-$OCI} "onos:apps -s -a" | grep -v /bin/client > $aux
-cat $aux
+for attempt in {1..3}; do
+    onos ${1:-$OCI} "onos:apps -s -a" | grep -v /bin/client > $aux
+    cat $aux
 
-# Normalize the installed apps
-cut -c7- $aux | grep -v '/bin/client' | cut -d\  -f1 | sort > $aux.1
+    # Normalize the installed apps
+    cut -c7- $aux | grep -v '/bin/client' | cut -d\  -f1 | sort > $aux.1
 
-# Normalize the expected apps
-apps=${2:-$ONOS_APPS}
-apps=${apps:-drivers,openflow}
-(for app in ${apps//,/ }; do echo org.onosproject.$app; done) | sort > $aux.2
+    # Normalize the expected apps
+    apps=${2:-$ONOS_APPS}
+    apps=${apps:-drivers,openflow}
+    (for app in ${apps//,/ }; do echo org.onosproject.$app; done) | sort > $aux.2
 
-# Check for differences
-diff $aux.1 $aux.2
+    # Check for differences
+    case ${3:-equals} in
+    equals) diff $aux.1 $aux.2;;
+    includes) [ $(egrep -c -f $aux.2 $aux.1) -eq $(wc -l $aux.2 | sed "s|$aux.2||g") ];;
+    excludes) ! egrep -f $aux.2 $aux.1;;
+    esac
+
+    [ $? -eq 0 ] && exit 0 || sleep 1
+done
+
+exit 1;
diff --git a/tools/test/bin/onos-check-intent b/tools/test/bin/onos-check-intent
index 55410ad..e332dc5 100755
--- a/tools/test/bin/onos-check-intent
+++ b/tools/test/bin/onos-check-intent
@@ -13,9 +13,9 @@
 echo onos-check-intent: $*
 
 set -x
-for i in 1 2 3; do
-    onos $target "onos:intents" > $aux
-    ( cat $aux | grep "id=$2" | grep "state=$3" ) && cat $aux && exit 0
+for i in {1..10}; do
+    onos $target "onos:intents" | tee $aux
+    ( cat $aux | grep "key=$2" | grep "state=$3" ) && cat $aux && exit 0
     sleep 1
 done
 
diff --git a/tools/test/bin/onos-create-intent b/tools/test/bin/onos-create-intent
index 6482103..d1c0b93 100755
--- a/tools/test/bin/onos-create-intent
+++ b/tools/test/bin/onos-create-intent
@@ -18,15 +18,5 @@
 
 set -x
 
-onos $target "onos:add-${type}-intent" "${arg1}" "${arg2}" >> $aux
-result=$?
-cat $aux
-
-if [ $result -eq 0 ]; then
-    id=$(cat $aux | sed -e "1d" | sed -e "s/^[a-zA-Z]*{//" | sed -e "s/,.*$//" | sed -e "s/^...//")
-    echo @stc ${name}Id=${id}
-fi
-
-
-exit $result
+onos $target "onos:add-${type}-intent" --key $name "${arg1}" "${arg2}"