STC stacktrace fixes

- Shut down openflow meta app before driver test,
  was causing port collision issues with openflow server

- Fixed NPE in Network config store

- reordered tests to insure proper sequencing

Change-Id: Ib39330153f543ee960b8631a0dc9246ee4251851
diff --git a/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java b/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java
index 7a812c9..64beb93 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java
@@ -173,9 +173,12 @@
     private void processExistingConfigs(ConfigFactory configFactory) {
         ImmutableSet.copyOf(configs.keySet()).forEach(k -> {
             if (Objects.equals(configFactory.configClass().getName(), k.configClass)) {
-                JsonNode json = configs.remove(k).value();
-                configs.put(key(k.subject, configFactory.configKey()), json);
-                log.debug("Set config pending: {}, {}", k.subject, k.configClass);
+                Versioned<JsonNode> remove = configs.remove(k);
+                if (remove != null) {
+                    JsonNode json = remove.value();
+                    configs.put(key(k.subject, configFactory.configKey()), json);
+                    log.debug("Set config pending: {}, {}", k.subject, k.configClass);
+                }
             }
         });
     }
diff --git a/tools/test/scenarios/drivers-test.xml b/tools/test/scenarios/drivers-test.xml
index 1514014..f3488a7 100644
--- a/tools/test/scenarios/drivers-test.xml
+++ b/tools/test/scenarios/drivers-test.xml
@@ -27,6 +27,10 @@
         <step name="DriversTest.CheckDefault" requires="^"
               exec="test '${defaultDriver}' != ''"/>
 
+        <!-- Deactivate openfow app - prevents spawning multiple controllers -->
+        <step name="DriversTest.DeactivateOpenflowApp" requires="^"
+              exec="onos ${OCI} onos:app deactivate org.onosproject.openflow"/>
+
         <!-- Deactivate drivers app -->
         <step name="DriversTest.DeactivateDriversApp" requires="^"
               exec="onos ${OCI} onos:app deactivate org.onosproject.drivers"/>
@@ -37,6 +41,10 @@
         <step name="DriversTest.AfterDeactivateFindDefault" requires="^"
               exec="onos-find-driver ${OC1} default defaultInactive" env="!"/>
 
+        <!-- Reactivate openflow apps -->
+        <step name="DriversTest.ActivateOpenflowApp" requires="^"
+              exec="onos ${OCI} onos:app activate org.onosproject.openflow"/>
+
         <!-- Reactivate all drivers -->
         <step name="DriversTest.ActivateDriversApp" requires="^"
               exec="onos ${OCI} onos:app activate org.onosproject.drivers"/>
diff --git a/tools/test/scenarios/smoke.xml b/tools/test/scenarios/smoke.xml
index 70cd1ce..cc3f662 100644
--- a/tools/test/scenarios/smoke.xml
+++ b/tools/test/scenarios/smoke.xml
@@ -23,18 +23,18 @@
     <import file="${ONOS_SCENARIOS}/net-smoke.xml"/>
     <dependency name="Net-Smoke" requires="Setup"/>
 
-    <import file="${ONOS_SCENARIOS}/meta-apps-test.xml"/>
-    <dependency name="Meta-App" requires="Setup,~Net-Smoke"/>
-
     <import file="${ONOS_SCENARIOS}/archetypes.xml"/>
     <dependency name="Archetypes" requires="Setup,~Net-Smoke"/>
 
-    <import file="${ONOS_SCENARIOS}/netcfg.xml"/>
-    <dependency name="Netcfg" requires="Setup,~Meta-App"/>
-
     <import file="${ONOS_SCENARIOS}/drivers-test.xml"/>
     <dependency name="Drivers-Test" requires="Setup,~Net-Smoke,~Archetypes"/>
 
+    <import file="${ONOS_SCENARIOS}/meta-apps-test.xml"/>
+    <dependency name="Meta-App" requires="Setup,~Net-Smoke,~Drivers-Test"/>
+
+    <import file="${ONOS_SCENARIOS}/netcfg.xml"/>
+    <dependency name="Netcfg" requires="Setup,~Meta-App"/>
+
     <import file="${ONOS_SCENARIOS}/wrapup.xml"/>
     <dependency name="Wrapup" requires="~Archetypes,~Setup,~Net-Smoke,~Drivers-Test,~Meta-App,~Netcfg"/>
 </scenario>