ASTERIXDB-1428: Config-management improvements for AsterixDB
1. Added ability for NC Service to log NC output to file
2. Improve config communication from CC to NC
3. Allow overriding NC command name from CC config (and removed said
option from NC Service config as that's the wrong place to manage it)
4. Improve finding NC command (don't depend on PATH)
5. Create asterixncservice.bat script for Windows
6. Fixed NCServiceIT accordingly
Change-Id: I0f2ad32d489ffc27adbb06aebcc1f22a9fcf784e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/887
Reviewed-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@apache.org>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@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 7f431f6..0cc1031 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
@@ -37,24 +37,24 @@
public class NCServiceIT {
+ private static final String TARGET_DIR = StringUtils
+ .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);
private static final String RESOURCE_DIR = StringUtils
- .join(new String[]{System.getProperty("user.dir"), "src", "test", "resources", "NCServiceIT"},
- File.separator);
+ .join(new String[]{TARGET_DIR, "test-classes", "NCServiceIT"}, File.separator);
private static final String APP_DIR = StringUtils
- .join(new String[]{System.getProperty("user.dir"), "target", "appassembler", "bin"},
- File.separator);
+ .join(new String[]{TARGET_DIR, "appassembler", "bin"}, File.separator);
private static final Logger LOGGER = Logger.getLogger(NCServiceIT.class.getName());
private static List<Process> procs = new ArrayList<>();
@BeforeClass
public static void setUp() throws Exception {
// Start two NC Services - don't read their output as they don't terminate
- procs.add(invoke(APP_DIR + File.separator + "hyracksncservice",
- "-config-file", RESOURCE_DIR + File.separator + "nc-red.conf",
- "-command", APP_DIR + File.separator + "hyracksnc"));
- procs.add(invoke(APP_DIR + File.separator + "hyracksncservice",
- "-config-file", RESOURCE_DIR + File.separator + "nc-blue.conf",
- "-command", APP_DIR + File.separator + "hyracksnc"));
+ 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"));
try {
Thread.sleep(2000);
}
@@ -62,7 +62,7 @@
}
// Start CC
- procs.add(invoke(APP_DIR + File.separator + "hyrackscc",
+ procs.add(invoke("cc.log", APP_DIR + File.separator + "hyrackscc",
"-config-file", RESOURCE_DIR + File.separator + "cc.conf"));
try {
Thread.sleep(10000);
@@ -97,9 +97,12 @@
}
}
- private static Process invoke(String... args) throws Exception {
+ private static Process invoke(String logfile, String... args) throws Exception {
ProcessBuilder pb = new ProcessBuilder(args);
pb.redirectErrorStream(true);
+ File log = new File(LOG_DIR, logfile);
+ log.delete();
+ pb.redirectOutput(ProcessBuilder.Redirect.appendTo(log));
Process p = pb.start();
return p;
}
@@ -112,7 +115,7 @@
JSONObject result = new JSONObject(response);
JSONArray nodes = result.getJSONArray("result");
int numNodes = nodes.length();
- Assert.assertEquals("Wrong number of nodes!", numNodes, 2);
+ Assert.assertEquals("Wrong number of nodes!", 2, numNodes);
for (int i = 0; i < nodes.length(); i++) {
JSONObject node = nodes.getJSONObject(i);
String id = node.getString("node-id");
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-blue.conf b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-blue.conf
index d070b59..1cd1666 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-blue.conf
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-blue.conf
@@ -1,3 +1,5 @@
[ncservice]
address=127.0.0.1
port=9091
+logdir=-
+
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-red.conf b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-red.conf
index 58a8f1d..74b49b0 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-red.conf
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-red.conf
@@ -1,4 +1,5 @@
[ncservice]
address=127.0.0.1
port=9090
+logdir=-