You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/10/14 16:28:11 UTC

[commons-rng] 02/03: Change stress test application process timeout to 60s from 1s.

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

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git

commit 418977c44a13e2ec044056f6aa2cb69eb0c12bab
Author: aherbert <ah...@apache.org>
AuthorDate: Mon Oct 14 12:46:23 2019 +0100

    Change stress test application process timeout to 60s from 1s.
    
    PractRand may take longer to shutdown when large memory allocation has
    occurred.
---
 .../org/apache/commons/rng/examples/stress/ProcessUtils.java     | 5 ++++-
 .../apache/commons/rng/examples/stress/StressTestCommand.java    | 9 +++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ProcessUtils.java b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ProcessUtils.java
index 3c94cc0..35e60a5 100644
--- a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ProcessUtils.java
+++ b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ProcessUtils.java
@@ -98,7 +98,8 @@ final class ProcessUtils {
      * Get the exit value from the process, waiting at most for the given time, otherwise
      * kill the process and return {@code null}.
      *
-     * <p>This should be used when it is expected the process has completed.</p>
+     * <p>This should be used when it is expected the process has completed. If the timeout
+     * expires an error message is logged before the process is killed.</p>
      *
      * @param process The process.
      * @param timeoutMillis The timeout (in milliseconds).
@@ -124,6 +125,8 @@ final class ProcessUtils {
             remaining = timeoutMillis - (System.currentTimeMillis() - startTime);
         }
 
+        LogUtils.error("Failed to obtain exit value after %d ms, forcing termination", timeoutMillis);
+
         // Not finished so kill it
         process.destroy();
 
diff --git a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/StressTestCommand.java b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/StressTestCommand.java
index 4b155ba..300b605 100644
--- a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/StressTestCommand.java
+++ b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/StressTestCommand.java
@@ -835,8 +835,13 @@ class StressTestCommand implements Callable<Void> {
 
             bytesUsed *= cmd.bufferSize;
 
-            // Get the exit value
-            return ProcessUtils.getExitValue(testingProcess);
+            // Get the exit value.
+            // Wait for up to 60 seconds.
+            // If an application does not exit after this time then something is wrong.
+            // Dieharder and TestU01 BigCrush exit within 1 second.
+            // PractRand has been observed to take longer than 1 second. It calls std::exit(0)
+            // when failing a test so the length of time may be related to freeing memory.
+            return ProcessUtils.getExitValue(testingProcess, TimeUnit.SECONDS.toMillis(60));
         }
 
         /**