This is an automated email from the ASF dual-hosted git repository. imaxon pushed a commit to branch release-0.9.4.1 in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 57455048a501eefefd72281315b4e3f4cbe9d668 Author: Ian Maxon <ima...@apache.org> AuthorDate: Tue Feb 12 22:20:25 2019 -0800 [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/3189 Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Michael Blow <mb...@apache.org> --- hyracks-fullstack/hyracks/hyracks-server/pom.xml | 4 ++ .../apache/hyracks/test/server/NCServiceIT.java | 19 +++++-- .../test/server/process/HyracksCCProcess.java | 8 ++- .../server/process/HyracksNCServiceProcess.java | 9 +++- .../test/server/process/HyracksServerProcess.java | 5 ++ .../test/server/process/HyracksVirtualCluster.java | 61 ++++++++++++++++++---- .../src/test/resources/NCServiceIT/cc.conf | 1 + .../src/test/resources/NCServiceIT/nc-blue.conf | 2 - .../src/test/resources/NCServiceIT/nc-red.conf | 2 - hyracks-fullstack/pom.xml | 2 + 10 files changed, 94 insertions(+), 19 deletions(-) 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 @@ public class NCServiceIT { @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 @@ public class NCServiceIT { } // 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 @@ public class HyracksCCProcess extends HyracksServerProcess { 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 @@ public class HyracksCCProcess extends HyracksServerProcess { @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 @@ public class HyracksNCServiceProcess extends HyracksServerProcess { 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 @@ public class HyracksNCServiceProcess extends HyracksServerProcess { @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 @@ abstract class HyracksServerProcess { 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 @@ abstract class HyracksServerProcess { 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 @@ public class HyracksVirtualCluster { /** * 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 @@ public class HyracksVirtualCluster { /** * 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 @@ public class HyracksVirtualCluster { } /** + * 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 @@ public class HyracksVirtualCluster { } /** + * 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 @@ ncservice.port = 9091 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=- - diff --git a/hyracks-fullstack/pom.xml b/hyracks-fullstack/pom.xml index 5987022..f7dc596 100644 --- a/hyracks-fullstack/pom.xml +++ b/hyracks-fullstack/pom.xml @@ -46,6 +46,7 @@ <tag>HEAD</tag> </scm> <properties> + <root.dir>${basedir}</root.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <file.encoding>UTF-8</file.encoding> <source.jdk.version>1.8</source.jdk.version> @@ -54,6 +55,7 @@ <sonar.jacoco.reportPath>${env.PWD}/target/jacoco-merged.exec</sonar.jacoco.reportPath> <source-format.goal>format</source-format.goal> <source-format.skip>false</source-format.skip> + <maven.test.skip>false</maven.test.skip> <skipTests>false</skipTests> <skip.surefire.tests>${skipTests}</skip.surefire.tests> <skip.testResources>${maven.test.skip}</skip.testResources>