Enable ExecutionTestUtil to Handle Different IntegrationUtil Implementations

Change-Id: I34ed919b39789c2254d63961c1628dd7b60f5ff2
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1105
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java
index 03ed3c4..e17eb2f 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java
@@ -83,6 +83,7 @@
                 }
             };
             ncStartThread.start();
+            ncStartThread.join();
         }
         hcc = new HyracksConnection(cc.getConfig().clientNetIpAddress, cc.getConfig().clientNetPort);
         ncs = nodeControllers.toArray(new NodeControllerService[nodeControllers.size()]);
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTestUtil.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTestUtil.java
index 3195c39..c73be7a 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTestUtil.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTestUtil.java
@@ -44,15 +44,16 @@
 
     protected static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml";
 
-    protected static TestGroup FailedGroup;
+    public static TestGroup FailedGroup;
 
     public static AsterixHyracksIntegrationUtil integrationUtil = new AsterixHyracksIntegrationUtil();
 
     public static List<ILibraryManager> setUp(boolean cleanup) throws Exception {
-        return setUp(cleanup, TEST_CONFIG_FILE_NAME);
+        return setUp(cleanup, TEST_CONFIG_FILE_NAME, integrationUtil, true);
     }
 
-    public static List<ILibraryManager> setUp(boolean cleanup, String configFile) throws Exception {
+    public static List<ILibraryManager> setUp(boolean cleanup, String configFile,
+            AsterixHyracksIntegrationUtil integrationUtil, boolean startHdfs) throws Exception {
         System.out.println("Starting setup");
         if (LOGGER.isLoggable(Level.INFO)) {
             LOGGER.info("Starting setup");
@@ -68,7 +69,9 @@
             LOGGER.info("initializing HDFS");
         }
 
-        HDFSCluster.getInstance().setup();
+        if (startHdfs) {
+            HDFSCluster.getInstance().setup();
+        }
 
         // Set the node resolver to be the identity resolver that expects node
         // names
@@ -92,6 +95,11 @@
     }
 
     public static void tearDown(boolean cleanup) throws Exception {
+        tearDown(cleanup, integrationUtil, true);
+    }
+
+    public static void tearDown(boolean cleanup, AsterixHyracksIntegrationUtil integrationUtil, boolean stopHdfs)
+            throws Exception {
         // validateBufferCacheState(); <-- Commented out until bug is fixed -->
         integrationUtil.deinit(cleanup);
         File outdir = new File(PATH_ACTUAL);
@@ -99,7 +107,9 @@
         if (files == null || files.length == 0) {
             outdir.delete();
         }
-        HDFSCluster.getInstance().cleanup();
+        if (stopHdfs) {
+            HDFSCluster.getInstance().cleanup();
+        }
 
         if (FailedGroup != null && FailedGroup.getTestCase().size() > 0) {
             File temp = File.createTempFile("failed", ".xml");