You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2019/01/22 19:56:28 UTC

[geode] branch develop updated: GEODE-6297: Add Process info to Launcher status failure msg

This is an automated email from the ASF dual-hosted git repository.

klund 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 654dc3b  GEODE-6297: Add Process info to Launcher status failure msg
654dc3b is described below

commit 654dc3bac3e50e66f33385bdbc38c88750061aa9
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Fri Jan 18 17:13:04 2019 -0800

    GEODE-6297: Add Process info to Launcher status failure msg
    
    This will provide some details about if the process is actually
    alive or not when FileProcessController.status throws
    IllegalStateException.
    
    When the test fails again, if Process is not alive then the
    underlying cause is probably something like a BindException
    preventing the startup of the Locator process.
    
    This info will also apply to GEODE-6183 which is nearly
    identical.
    
    I'm including the change in ServerLauncherRemoteIntegrationTestCase
    as well in case there's ever a similar failure starting up a
    server.
---
 .../LocatorLauncherRemoteIntegrationTestCase.java  | 23 ++++++++++++++++++----
 .../ServerLauncherRemoteIntegrationTestCase.java   | 23 ++++++++++++++++++----
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTestCase.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTestCase.java
index fa7559e..34f8f31 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTestCase.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTestCase.java
@@ -17,6 +17,7 @@ package org.apache.geode.distributed;
 import static java.util.concurrent.TimeUnit.MINUTES;
 import static org.apache.geode.internal.DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY;
 import static org.apache.geode.internal.process.ProcessUtils.isProcessAlive;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.File;
@@ -36,7 +37,6 @@ import org.apache.geode.distributed.LocatorLauncher.Command;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.process.ProcessStreamReader;
 import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
-import org.apache.geode.test.awaitility.GeodeAwaitility;
 
 /**
  * Abstract base class for integration tests of {@link LocatorLauncher} as an application main in a
@@ -88,7 +88,7 @@ public abstract class LocatorLauncherRemoteIntegrationTestCase
   }
 
   protected void assertStopOf(final Process process) {
-    GeodeAwaitility.await().untilAsserted(() -> assertThat(process.isAlive()).isFalse());
+    await().untilAsserted(() -> assertThat(process.isAlive()).isFalse());
   }
 
   /**
@@ -195,12 +195,27 @@ public abstract class LocatorLauncherRemoteIntegrationTestCase
 
   @Override
   protected LocatorLauncher awaitStart(final LocatorLauncher launcher) {
-    GeodeAwaitility.await()
-        .untilAsserted(() -> assertThat(launcher.status().getStatus()).isEqualTo(Status.ONLINE));
+    await().untilAsserted(() -> {
+      try {
+        assertThat(launcher.status().getStatus()).isEqualTo(Status.ONLINE);
+      } catch (Exception e) {
+        throw new AssertionError(statusFailedWithException(e), e);
+      }
+    });
     assertThat(process.isAlive()).isTrue();
     return launcher;
   }
 
+  protected String statusFailedWithException(Exception e) {
+    StringBuilder sb = new StringBuilder();
+    sb.append("Status failed with exception: ");
+    sb.append("process.isAlive()=").append(process.isAlive());
+    sb.append(", processErrReader").append(processErrReader);
+    sb.append(", processOutReader").append(processOutReader);
+    sb.append(", message").append(e.getMessage());
+    return sb.toString();
+  }
+
   private InputListener createBindExceptionListener(final String name,
       final AtomicBoolean threwBindException) {
     return createExpectedListener(name, BindException.class.getName(), threwBindException);
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTestCase.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTestCase.java
index 25e503a..4cb241d 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTestCase.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTestCase.java
@@ -20,6 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
 import static org.apache.geode.internal.cache.AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY;
 import static org.apache.geode.internal.process.ProcessUtils.isProcessAlive;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.File;
@@ -36,7 +37,6 @@ import org.junit.Before;
 import org.apache.geode.distributed.AbstractLauncher.Status;
 import org.apache.geode.internal.process.ProcessStreamReader;
 import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
-import org.apache.geode.test.awaitility.GeodeAwaitility;
 
 /**
  * Abstract base class for integration tests of {@link ServerLauncher} as an application main in a
@@ -99,7 +99,7 @@ public abstract class ServerLauncherRemoteIntegrationTestCase
   }
 
   protected void assertStopOf(final Process process) {
-    GeodeAwaitility.await().untilAsserted(() -> assertThat(process.isAlive()).isFalse());
+    await().untilAsserted(() -> assertThat(process.isAlive()).isFalse());
   }
 
   protected void assertThatPidIsAlive(final int pid) {
@@ -197,12 +197,27 @@ public abstract class ServerLauncherRemoteIntegrationTestCase
 
   @Override
   protected ServerLauncher awaitStart(final ServerLauncher launcher) {
-    GeodeAwaitility.await()
-        .untilAsserted(() -> assertThat(launcher.status().getStatus()).isEqualTo(Status.ONLINE));
+    await().untilAsserted(() -> {
+      try {
+        assertThat(launcher.status().getStatus()).isEqualTo(Status.ONLINE);
+      } catch (Exception e) {
+        throw new AssertionError(statusFailedWithException(e), e);
+      }
+    });
     assertThat(process.isAlive()).isTrue();
     return launcher;
   }
 
+  private String statusFailedWithException(Exception e) {
+    StringBuilder sb = new StringBuilder();
+    sb.append("Status failed with exception: ");
+    sb.append("process.isAlive()=").append(process.isAlive());
+    sb.append(", processErrReader").append(processErrReader);
+    sb.append(", processOutReader").append(processOutReader);
+    sb.append(", message").append(e.getMessage());
+    return sb.toString();
+  }
+
   private InputListener createBindExceptionListener(final String name,
       final AtomicBoolean threwBindException) {
     return createExpectedListener(name, BindException.class.getName(), threwBindException);