Verify REST app is up before issuing API calls

Change-Id: Ibe4f3752996a1fdeda5f2bd901083c4b6864bd02
diff --git a/tools/test/bin/onos-check-apps b/tools/test/bin/onos-check-apps
index 710c002..1fd7546 100755
--- a/tools/test/bin/onos-check-apps
+++ b/tools/test/bin/onos-check-apps
@@ -9,6 +9,14 @@
 aux=/tmp/stc/stc-$$.log
 trap "rm -f $aux $aux.1 $aux.2 2>/dev/null" EXIT
 
+echo $app | grep '.'
+
+if [ $? != 0 ]; then
+    appnameextra=
+else
+    appname=org.onosproject.
+fi
+
 for attempt in {1..30}; do
     onos ${1:-$OCI} "onos:apps -s -a" > $aux
     cat $aux
@@ -19,7 +27,7 @@
     # 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
+    (for app in ${apps//,/ }; do echo ${appnameextra}${app}; done) | sort > $aux.2
 
     # Check for differences
     case ${3:-equals} in
diff --git a/tools/test/scenarios/archetypes.xml b/tools/test/scenarios/archetypes.xml
index 6218c00..1dc3b41 100644
--- a/tools/test/scenarios/archetypes.xml
+++ b/tools/test/scenarios/archetypes.xml
@@ -94,8 +94,15 @@
               exec="mvn clean install"/>
         <step name="Install-REST-App" requires="^,~Verify-UI-Topo"
               exec="onos-app ${OCI} reinstall! target/test-app-1.2.3.oar"/>
+        <group name="Check-REST-App" >
+            <parallel var="${OC#}">
+                <step name="Check-REST-Apps-${#}"
+                      requires="Install-REST-App"
+                      exec="onos-check-apps ${OC#} org.foo.app includes"/>
+            </parallel>
+        </group>
         <group name="Verify-REST"
-            requires="Install-REST-App" delay="2" >
+            requires="Install-REST-App,Check-REST-App" delay="2" >
             <parallel var="${OC#}">
                 <step name="Verify-REST-CLI-${#}"
                       exec="onos ${OC#} sample" include="Hello World"/>