Check that the DHCP Manager is active before testing its configuration

Change-Id: Id760d58df005060c0f1d0c2ebdde90fe356d2c9f
diff --git a/tools/test/bin/onos-check-component b/tools/test/bin/onos-check-component
new file mode 100755
index 0000000..686d936
--- /dev/null
+++ b/tools/test/bin/onos-check-component
@@ -0,0 +1,23 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Checks whether the given ONOS component has a given state.
+# -----------------------------------------------------------------------------
+
+aux=/tmp/stc-$$.log
+trap "rm -f $aux 2>/dev/null" EXIT
+
+node=$1
+component=$2
+state=$3
+
+for attempt in {1..30}; do
+    onos ${node:-$OCI} scr:list  | grep $component > $aux
+
+    if grep -q $state $aux; then
+        exit 0
+    else
+        sleep 1
+    fi
+done
+
+cat $aux && exit 1
diff --git a/tools/test/scenarios/netcfg.xml b/tools/test/scenarios/netcfg.xml
index caf1e9f..e13705b 100644
--- a/tools/test/scenarios/netcfg.xml
+++ b/tools/test/scenarios/netcfg.xml
@@ -25,8 +25,10 @@
         <!-- Check that the activation was successful -->
         <group name="Netcfg.Check-Dhcp-App-Activated" requires="Netcfg.Activate-Dhcp">
             <parallel var="${OC#}">
-                <step name="Netcfg.Check-Dhcp-App-Activated-${#}" delay="2"
+                <step name="Netcfg.Check-Dhcp-App-Activated-${#}"
                       exec="onos-check-apps ${OC#} drivers,openflow,proxyarp,dhcp includes"/>
+                <step name="Netcfg.Check-Dhcp-Component-Active-${#}"
+                      exec="onos-check-component ${OC#} org.onosproject.dhcp.impl.DhcpManager ACTIVE"/>
             </parallel>
         </group>
 
@@ -37,7 +39,7 @@
         <group name="Query1" requires="Netcfg.Post-1">
             <parallel var="${OC#}" starts="Netcfg.Query-1-${#}">
                 <!-- Check that the values made it into the config for the DHCP server -->
-                <step name="Netcfg.QueryDhcp-1-${#}" delay="2"
+                <step name="Netcfg.QueryDhcp-1-${#}"
                       exec="check-dhcp-netcfg.py ${OC#} ttl=1 lease=2 renew=3 rebind=4 delay=5 timeout=6"/>
             </parallel>
         </group>
@@ -50,7 +52,7 @@
         <group name="Query2" requires="Netcfg.Post-2">
             <parallel var="${OC#}" starts="Netcfg.Query-2-${#}">
                 <!-- Check that the values made it into the config for the DHCP server -->
-                <step name="Netcfg.QueryDhcp-2-${#}" delay="2"
+                <step name="Netcfg.QueryDhcp-2-${#}"
                       exec="check-dhcp-netcfg.py ${OC#} ttl=21 lease=22 renew=23 rebind=24 delay=25 timeout=26"/>
             </parallel>
         </group>