geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject [geode] branch develop updated: GEODE-3613: Dumping container logs files in session replication tests
Date Fri, 29 Sep 2017 18:49:21 GMT
This is an automated email from the ASF dual-hosted git repository.

upthewaterspout pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new dcb7af0  GEODE-3613: Dumping container logs files in session replication tests
dcb7af0 is described below

commit dcb7af0ba73ced879446ca061495d3dd995ebeba
Author: Dan Smith <upthewaterspout@apache.org>
AuthorDate: Wed Sep 27 16:44:04 2017 -0700

    GEODE-3613: Dumping container logs files in session replication tests
    
    The session replication tests were generating logs files that were
    getting deleted. In order to debug issues with the session state tests
    we need to information in the log files to show up in the test output.
---
 .../apache/geode/session/tests/CargoTestBase.java  |  1 +
 .../geode/session/tests/ContainerManager.java      |  6 +++++
 .../geode/session/tests/ServerContainer.java       | 29 +++++++++++++++++++---
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/geode-assembly/src/test/java/org/apache/geode/session/tests/CargoTestBase.java
b/geode-assembly/src/test/java/org/apache/geode/session/tests/CargoTestBase.java
index 5dcdd6a..42bf92c 100644
--- a/geode-assembly/src/test/java/org/apache/geode/session/tests/CargoTestBase.java
+++ b/geode-assembly/src/test/java/org/apache/geode/session/tests/CargoTestBase.java
@@ -68,6 +68,7 @@ public abstract class CargoTestBase extends JUnit4CacheTestCase {
    */
   @After
   public void stop() throws IOException {
+    manager.dumpLogs();
     manager.stopAllActiveContainers();
     manager.cleanUp();
   }
diff --git a/geode-assembly/src/test/java/org/apache/geode/session/tests/ContainerManager.java
b/geode-assembly/src/test/java/org/apache/geode/session/tests/ContainerManager.java
index 036c6a5..304cedd 100644
--- a/geode-assembly/src/test/java/org/apache/geode/session/tests/ContainerManager.java
+++ b/geode-assembly/src/test/java/org/apache/geode/session/tests/ContainerManager.java
@@ -122,6 +122,12 @@ public class ContainerManager {
     stopContainers(getActiveContainerIndexes());
   }
 
+  public void dumpLogs() throws IOException {
+    for (ServerContainer container : getActiveContainers()) {
+      container.dumpLogs();
+    }
+  }
+
   /**
    * Set the name of the current test
    *
diff --git a/geode-assembly/src/test/java/org/apache/geode/session/tests/ServerContainer.java
b/geode-assembly/src/test/java/org/apache/geode/session/tests/ServerContainer.java
index 3434180..a1b36fa 100644
--- a/geode-assembly/src/test/java/org/apache/geode/session/tests/ServerContainer.java
+++ b/geode-assembly/src/test/java/org/apache/geode/session/tests/ServerContainer.java
@@ -27,6 +27,7 @@ import org.codehaus.cargo.container.State;
 import org.codehaus.cargo.container.configuration.ConfigurationType;
 import org.codehaus.cargo.container.configuration.LocalConfiguration;
 import org.codehaus.cargo.container.deployable.WAR;
+import org.codehaus.cargo.container.jetty.JettyPropertySet;
 import org.codehaus.cargo.container.property.GeneralPropertySet;
 import org.codehaus.cargo.container.property.LoggingLevel;
 import org.codehaus.cargo.container.property.ServletPropertySet;
@@ -47,6 +48,7 @@ import org.apache.geode.internal.logging.LogService;
  * Subclasses provide setup and configuration of specific containers.
  */
 public abstract class ServerContainer {
+  private final File containerConfigHome;
   private InstalledLocalContainer container;
   private ContainerInstall install;
 
@@ -66,7 +68,7 @@ public abstract class ServerContainer {
 
   public final String DEFAULT_CONF_DIR;
 
-  public static final String DEFAULT_LOGGING_LEVEL = LoggingLevel.HIGH.getLevel();
+  public static final String DEFAULT_LOGGING_LEVEL = LoggingLevel.LOW.getLevel();
   public static final String DEFAULT_LOG_DIR = "cargo_logs/";
   public static final String DEFAULT_CONFIG_DIR = "/tmp/cargo_configs/";
 
@@ -99,8 +101,8 @@ public abstract class ServerContainer {
 
     DEFAULT_CONF_DIR = install.getHome() + "/conf/";
     // Use the default configuration home path if not passed a config home
-    if (containerConfigHome == null)
-      containerConfigHome = new File(DEFAULT_CONFIG_DIR + description);
+    this.containerConfigHome = containerConfigHome == null
+        ? new File(DEFAULT_CONFIG_DIR + description) : containerConfigHome;
 
     // Init the property lists
     cacheProperties = new HashMap<>();
@@ -111,7 +113,7 @@ public abstract class ServerContainer {
     // Create the Cargo Container instance wrapping our physical container
     LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory()
         .createConfiguration(install.getInstallId(), ContainerType.INSTALLED,
-            ConfigurationType.STANDALONE, containerConfigHome.getAbsolutePath());
+            ConfigurationType.STANDALONE, this.containerConfigHome.getAbsolutePath());
     // Set configuration/container logging level
     configuration.setProperty(GeneralPropertySet.LOGGING, loggingLevel);
     // Removes secureRandom generation so that container startup is much faster
@@ -210,6 +212,25 @@ public abstract class ServerContainer {
     container.stop();
   }
 
+  public void dumpLogs() throws IOException {
+    for (File file : logDir.listFiles()) {
+      dumpToStdOut(file);
+    }
+
+    for (File file : new File(containerConfigHome, "logs").listFiles()) {
+      dumpToStdOut(file);
+    }
+  }
+
+  private void dumpToStdOut(final File file) throws IOException {
+    System.out.println("-------------------------------------------");
+    System.out.println(file.getAbsolutePath());
+    System.out.println("-------------------------------------------");
+    FileUtils.copyFile(file, System.out);
+    System.out.println("-------------------------------------------");
+    System.out.println("");
+  }
+
   /**
    * Copies the container configuration (found through {@link #getConfiguration()}) to the
logging
    * directory specified by {@link #logDir}

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message