ASTERIXDB-1482: Added NCServiceExecutionIT, HyracksVirtualCluster.

NCServiceExecutionIT runs all execution tests against a local cluster
managed by the NCService deployment framework.

HyracksVirtualCluster offers programmatic NCService deployment
control along with improved HyracksNCProcess/HyracksCCProcess.

Further fixes and improvements:

    1. Fix handling of iodevices/storagedir (ASTERIXDB-1482)
    2. Proper handling of [nc] default section in all cases
    3. Ensure asterixnc, etc. scripts are executable
    4. Consolidate Ini handling
    5. Pruned some dead code, including VirtualClusterDriver
    6. A bit of refactoring and extended commenting

Change-Id: If3eb450782a595cf85d04a2c2e9cc732564e65e6
Reviewed-on: https://asterix-gerrit.ics.uci.edu/958
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/server/test/NCServiceIT.java b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/server/test/NCServiceIT.java
index bd99c8c..9a231a0 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/server/test/NCServiceIT.java
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/server/test/NCServiceIT.java
@@ -23,6 +23,7 @@
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.hyracks.server.process.HyracksVirtualCluster;
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.junit.AfterClass;
@@ -30,6 +31,7 @@
 import org.junit.Test;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.List;
@@ -38,23 +40,29 @@
 public class NCServiceIT {
 
     private static final String TARGET_DIR = StringUtils
-            .join(new String[]{System.getProperty("basedir"), "target"}, File.separator);
+            .join(new String[] { System.getProperty("basedir"), "target" }, File.separator);
     private static final String LOG_DIR = StringUtils
-            .join(new String[]{TARGET_DIR, "surefire-reports"}, File.separator);
+            .join(new String[] { TARGET_DIR, "failsafe-reports" }, File.separator);
     private static final String RESOURCE_DIR = StringUtils
-            .join(new String[]{TARGET_DIR, "test-classes", "NCServiceIT"}, File.separator);
-    private static final String APP_DIR = StringUtils
-            .join(new String[]{TARGET_DIR, "appassembler", "bin"}, File.separator);
+            .join(new String[] { TARGET_DIR, "test-classes", "NCServiceIT" }, File.separator);
+    private static final String APP_HOME = StringUtils
+            .join(new String[] { TARGET_DIR, "appassembler" }, File.separator);
     private static final Logger LOGGER = Logger.getLogger(NCServiceIT.class.getName());
-    private static List<Process> procs = new ArrayList<>();
+
+    private static HyracksVirtualCluster cluster = null;
 
     @BeforeClass
     public static void setUp() throws Exception {
-        // Start two NC Services - don't read their output as they don't terminate
-        procs.add(invoke("nc-red.log", APP_DIR + File.separator + "hyracksncservice",
-                "-config-file", RESOURCE_DIR + File.separator + "nc-red.conf"));
-        procs.add(invoke("nc-blue.log", APP_DIR + File.separator + "hyracksncservice",
-                "-config-file", RESOURCE_DIR + File.separator + "nc-blue.conf"));
+        cluster = new HyracksVirtualCluster(new File(APP_HOME), null);
+        cluster.addNC(
+                new File(RESOURCE_DIR, "nc-red.conf"),
+                new File(LOG_DIR, "nc-red.log")
+        );
+        cluster.addNC(
+                new File(RESOURCE_DIR, "nc-blue.conf"),
+                new File(LOG_DIR, "nc-blue.log")
+        );
+
         try {
             Thread.sleep(2000);
         }
@@ -62,8 +70,11 @@
         }
 
         // Start CC
-        procs.add(invoke("cc.log", APP_DIR + File.separator + "hyrackscc",
-                "-config-file", RESOURCE_DIR + File.separator + "cc.conf"));
+        cluster.start(
+                new File(RESOURCE_DIR, "cc.conf"),
+                new File(LOG_DIR, "cc.log")
+        );
+
         try {
             Thread.sleep(10000);
         }
@@ -72,11 +83,8 @@
     }
 
     @AfterClass
-    public static void tearDown() throws Exception {
-        for (Process p : procs) {
-            p.destroy();
-            p.waitFor();
-        }
+    public static void tearDown() throws IOException {
+        cluster.stop();
     }
 
     private static String getHttp(String url) throws Exception {
@@ -97,18 +105,6 @@
         }
     }
 
-    private static Process invoke(String logfile, String... args) throws Exception {
-        ProcessBuilder pb = new ProcessBuilder(args);
-        pb.redirectErrorStream(true);
-        File logDir = new File(LOG_DIR);
-        logDir.mkdirs();
-        File log = new File(logDir, logfile);
-        log.delete();
-        pb.redirectOutput(ProcessBuilder.Redirect.appendTo(log));
-        Process p = pb.start();
-        return p;
-    }
-
     @Test
     public void IsNodelistCorrect() throws Exception {
         // Ping the nodelist HTTP API
@@ -138,5 +134,4 @@
             tearDown();
         }
     }
-
 }
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/logging.properties b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/logging.properties
index c888bb1..e9f84796 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/logging.properties
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/logging.properties
@@ -46,8 +46,8 @@
 # Note that the ConsoleHandler also has a separate level
 # setting to limit messages printed to the console.
 
-.level= WARNING
-# .level= INFO
+# .level= WARNING
+.level= INFO
 # .level= FINE
 # .level = FINEST