Ian Maxon has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/3189

Change subject: [NO ISSUE] Fix logging in NCServiceIT
......................................................................

[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
---
M 
hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/NCServiceIT.java
M 
hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksCCProcess.java
M 
hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksNCServiceProcess.java
M 
hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksServerProcess.java
M 
hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/test/server/process/HyracksVirtualCluster.java
M 
hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/cc.conf
A 
hyracks-fullstack/hyracks/hyracks-server/src/test/resources/log4j2-hyracks-test.xml
M hyracks-fullstack/pom.xml
8 files changed, 116 insertions(+), 15 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/89/3189/1

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..d955aed 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,17 @@
     @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);
+        String log4jPath = "-Dlog4j.configurationFile="
+                + FileUtil.joinPath(".", "src", "test", "resources", 
"log4j2-hyracks-test.xml");
+        HyracksNCServiceProcess red =
+                cluster.addNCService(new File(RESOURCE_DIR, "nc-red.conf"), 
new File(LOG_DIR, "nc-red.log"));
+        red.addArg(log4jPath);
+        HyracksNCServiceProcess blue =
+                cluster.addNCService(new File(RESOURCE_DIR, "nc-blue.conf"), 
new File(LOG_DIR, "nc-blue.log"));
+        blue.addArg(log4jPath);
 
         try {
             Thread.sleep(2000);
@@ -64,7 +81,9 @@
         }
 
         // Start CC
-        cluster.start(new File(RESOURCE_DIR, "cc.conf"), new File(LOG_DIR, 
"cc.log"));
+        HyracksCCProcess cc = cluster.init(new File(TARGET_DIR, "cc.conf"), 
new File(LOG_DIR, "cc.log"));
+        cc.addArg(log4jPath);
+        cc.start();
 
         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..4f0d27c 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
@@ -19,6 +19,7 @@
 package org.apache.hyracks.test.server.process;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.hyracks.control.cc.CCDriver;
@@ -30,6 +31,7 @@
         this.logFile = logFile;
         this.appHome = appHome;
         this.workingDir = workingDir;
+        args = new ArrayList<>();
     }
 
     @Override
@@ -41,7 +43,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..31249cd 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
@@ -19,6 +19,7 @@
 package org.apache.hyracks.test.server.process;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.hyracks.control.nc.service.NCService;
@@ -30,6 +31,7 @@
         this.logFile = logFile;
         this.appHome = appHome;
         this.workingDir = workingDir;
+        args = new ArrayList<>();
     }
 
     @Override
@@ -40,6 +42,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..6665639 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
@@ -38,6 +38,8 @@
     protected File appHome = null;
     protected File workingDir = null;
 
+    List<String> args;
+
     public void start() throws IOException {
         String[] cmd = buildCommand();
         if (LOGGER.isInfoEnabled()) {
@@ -114,6 +116,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..62e5d26 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);
@@ -61,9 +67,12 @@
     /**
      * 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 +81,22 @@
     }
 
     /**
+     * Returns the CC process for the configured cluster, without starting.
+     * 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 init(File ccConfigFile, File logFile) throws 
IOException {
+        ccProc = new HyracksCCProcess(ccConfigFile, logFile, appHome, 
workingDir);
+        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/log4j2-hyracks-test.xml
 
b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/log4j2-hyracks-test.xml
new file mode 100644
index 0000000..a8141ee
--- /dev/null
+++ 
b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/log4j2-hyracks-test.xml
@@ -0,0 +1,41 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in complianceo
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+<Configuration status="WARN">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - 
%msg%n"/>
+    </Console>
+    <File name="InfoLog" fileName="target/info.log">
+      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - 
%msg%n"/>
+    </File>
+    <Console name="ConsoleTest" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %c{1} - %msg%n"/>
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Root level="WARN">
+      <AppenderRef ref="InfoLog"/>
+    </Root>
+    <Logger name="org.apache.hyracks.control.nc.service" level="INFO"/>
+    <Logger name="org.apache.hyracks" level="INFO"/>
+    <Logger name="org.apache.hyracks.test" level="INFO">
+      <AppenderRef ref="ConsoleTest"/>
+    </Logger>
+  </Loggers>
+</Configuration>
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>

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/3189
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a5944891adf6b073dee01e8418b2449e1179949
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: release-0.9.4.1-pre-rc
Gerrit-Owner: Ian Maxon <ima...@apache.org>

Reply via email to