[NO ISSUE] Fix logging in NCServiceIT
This test had a strange logging setup; the logging
for the actual IT was not configured to log outside
of /tmp, and the NCService processes had no log4j2
configuration set.
Change-Id: I4a5944891adf6b073dee01e8418b2449e1179949
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3195
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-server/pom.xml b/hyracks-fullstack/hyracks/hyracks-server/pom.xml
index 8b59870..1a94210 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/pom.xml
+++ b/hyracks-fullstack/hyracks/hyracks-server/pom.xml
@@ -185,5 +185,9 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/NCServiceIT.java b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/NCServiceIT.java
index 4983ba1..544d414 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/NCServiceIT.java
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/NCServiceIT.java
@@ -19,16 +19,24 @@
package org.apache.hyracks.test.server;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintWriter;
import java.net.InetAddress;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
import java.util.Iterator;
+import org.apache.commons.io.FileUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
+import org.apache.hyracks.test.server.process.HyracksCCProcess;
+import org.apache.hyracks.test.server.process.HyracksNCServiceProcess;
import org.apache.hyracks.test.server.process.HyracksVirtualCluster;
import org.apache.hyracks.util.file.FileUtil;
import org.apache.logging.log4j.LogManager;
@@ -55,8 +63,13 @@
@BeforeClass
public static void setUp() throws Exception {
cluster = new HyracksVirtualCluster(new File(APP_HOME), null);
- cluster.addNCService(new File(RESOURCE_DIR, "nc-red.conf"), new File(LOG_DIR, "nc-red.log"));
- cluster.addNCService(new File(RESOURCE_DIR, "nc-blue.conf"), new File(LOG_DIR, "nc-blue.log"));
+ File tempConf = new File(TARGET_DIR, "cc.conf");
+ FileUtils.copyFile(new File(RESOURCE_DIR, "cc.conf"), tempConf);
+ Files.write(tempConf.toPath(), ("log.dir: " + LOG_DIR).getBytes(), StandardOpenOption.APPEND);
+ File log4jPath = new File(FileUtil.joinPath("..", "..", "src", "test", "resources", "log4j2-hyracks-test.xml"));
+
+ cluster.addNCService(new File(RESOURCE_DIR, "nc-red.conf"), new File(LOG_DIR, "nc-red.log"), log4jPath);
+ cluster.addNCService(new File(RESOURCE_DIR, "nc-blue.conf"), new File(LOG_DIR, "nc-blue.log"), log4jPath);
try {
Thread.sleep(2000);
@@ -64,7 +77,7 @@
}
// Start CC
- cluster.start(new File(RESOURCE_DIR, "cc.conf"), new File(LOG_DIR, "cc.log"));
+ cluster.start(tempConf, new File(LOG_DIR, "cc.log"), log4jPath);
try {
Thread.sleep(10000);
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksCCProcess.java b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksCCProcess.java
index b39def5..2ac6f2b 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksCCProcess.java
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksCCProcess.java
@@ -32,6 +32,11 @@
this.workingDir = workingDir;
}
+ public HyracksCCProcess(File configFile, File logFile, File appHome, File workingDir, File log4jPath) {
+ this(configFile, logFile, appHome, workingDir);
+ args.add("-Dlog4j.configurationFile=file://" + log4jPath.getAbsolutePath());
+ }
+
@Override
protected String getMainClassName() {
return CCDriver.class.getName();
@@ -41,7 +46,8 @@
@SuppressWarnings("squid:CommentedOutCodeLine")
protected void addJvmArgs(List<String> cList) {
// CC needs more than default memory
- cList.add("-Xmx1024m");
+ args.add("-Xmx1024m");
+ cList.addAll(args);
// cList.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005");
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksNCServiceProcess.java b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksNCServiceProcess.java
index 67fea0f..d0e0244 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksNCServiceProcess.java
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksNCServiceProcess.java
@@ -32,6 +32,11 @@
this.workingDir = workingDir;
}
+ public HyracksNCServiceProcess(File configFile, File logFile, File appHome, File workingDir, File log4jPath) {
+ this(configFile, logFile, appHome, workingDir);
+ args.add("-Dlog4j.configurationFile=file://" + log4jPath.getAbsolutePath());
+ }
+
@Override
protected String getMainClassName() {
return NCService.class.getName();
@@ -40,6 +45,8 @@
@Override
protected void addJvmArgs(List<String> cList) {
// NCService needs little memory
- cList.add("-Xmx128m");
+ args.add("-Xmx128m");
+ cList.addAll(args);
}
+
}
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksServerProcess.java b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksServerProcess.java
index d157c6f..a8c363b 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksServerProcess.java
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksServerProcess.java
@@ -37,6 +37,7 @@
protected File logFile = null;
protected File appHome = null;
protected File workingDir = null;
+ protected List<String> args = new ArrayList<>();
public void start() throws IOException {
String[] cmd = buildCommand();
@@ -114,6 +115,10 @@
protected void addCmdLineArgs(List<String> cList) {
}
+ public void addArg(String arg) {
+ args.add(arg);
+ }
+
protected abstract String getMainClassName();
private final String getClasspath() {
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksVirtualCluster.java b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksVirtualCluster.java
index fc7bf73..6c77628 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksVirtualCluster.java
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksVirtualCluster.java
@@ -35,11 +35,14 @@
/**
* Construct a Hyracks-based cluster.
- * @param appHome - path to the installation root of the Hyracks application.
- * At least bin/hyracksnc (or the equivalent NC script for
- * the application) must exist in this directory.
- * @param workingDir - directory to use as CWD for all child processes. May
- * be null, in which case the CWD of the invoking process is used.
+ *
+ * @param appHome
+ * - path to the installation root of the Hyracks application.
+ * At least bin/hyracksnc (or the equivalent NC script for
+ * the application) must exist in this directory.
+ * @param workingDir
+ * - directory to use as CWD for all child processes. May
+ * be null, in which case the CWD of the invoking process is used.
*/
public HyracksVirtualCluster(File appHome, File workingDir) {
this.appHome = appHome;
@@ -48,8 +51,11 @@
/**
* Creates and starts an NCService.
- * @param configFile - full path to an ncservice.conf. May be null to accept all defaults.
- * @throws IOException - if there are errors starting the process.
+ *
+ * @param configFile
+ * - full path to an ncservice.conf. May be null to accept all defaults.
+ * @throws IOException
+ * - if there are errors starting the process.
*/
public HyracksNCServiceProcess addNCService(File configFile, File logFile) throws IOException {
HyracksNCServiceProcess proc = new HyracksNCServiceProcess(configFile, logFile, appHome, workingDir);
@@ -59,11 +65,30 @@
}
/**
+ * Creates and starts an NCService.
+ *
+ * @param configFile
+ * - full path to an ncservice.conf. May be null to accept all defaults.
+ * @throws IOException
+ * - if there are errors starting the process.
+ */
+ public HyracksNCServiceProcess addNCService(File configFile, File logFile, File log4jConfig) throws IOException {
+ HyracksNCServiceProcess proc =
+ new HyracksNCServiceProcess(configFile, logFile, appHome, workingDir, log4jConfig);
+ proc.start();
+ ncProcs.add(proc);
+ return proc;
+ }
+
+ /**
* Starts the CC, initializing the cluster. Expects that any NCs referenced
* in the cluster configuration have already been started with addNCService().
- * @param ccConfigFile - full path to a cluster conf file. May be null to accept all
- * defaults, although this is seldom useful since there are no NCs.
- * @throws IOException - if there are errors starting the process.
+ *
+ * @param ccConfigFile
+ * - full path to a cluster conf file. May be null to accept all
+ * defaults, although this is seldom useful since there are no NCs.
+ * @throws IOException
+ * - if there are errors starting the process.
*/
public HyracksCCProcess start(File ccConfigFile, File logFile) throws IOException {
ccProc = new HyracksCCProcess(ccConfigFile, logFile, appHome, workingDir);
@@ -72,6 +97,22 @@
}
/**
+ * Starts the CC, initializing the cluster. Expects that any NCs referenced
+ * in the cluster configuration have already been started with addNCService().
+ *
+ * @param ccConfigFile
+ * - full path to a cluster conf file. May be null to accept all
+ * defaults, although this is seldom useful since there are no NCs.
+ * @throws IOException
+ * - if there are errors starting the process.
+ */
+ public HyracksCCProcess start(File ccConfigFile, File logFile, File log4jConfig) throws IOException {
+ ccProc = new HyracksCCProcess(ccConfigFile, logFile, appHome, workingDir, log4jConfig);
+ ccProc.start();
+ return ccProc;
+ }
+
+ /**
* Stops all processes in the cluster.
* QQQ Someday this should probably do a graceful stop of NCs rather than
* killing the NCService.
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/cc.conf b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/cc.conf
index 419b8ca..9c80c7d 100644
--- a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/cc.conf
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/cc.conf
@@ -29,3 +29,4 @@
address = 127.0.0.1
console.listen.port = 12345
+[common]
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 9ddf4df..6eb38dd 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
@@ -18,5 +18,3 @@
[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 f854479..286bd32 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
@@ -18,5 +18,3 @@
[ncservice]
address=127.0.0.1
port=9090
-logdir=-
-