You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by dl...@apache.org on 2017/11/02 03:21:18 UTC

[07/50] [abbrv] incubator-edgent git commit: try more general test tmo desenstization when edgent.build.ci=true

try more general test tmo desenstization when edgent.build.ci=true

- tweek test.topology.TStreamTest.waitForCompletion()
- tweek topology.spi.tester.AbstractTester.complete()
- tweek runtime.etiao.Executable.invokeAction()

The above may eliminate the need for other test specific uses of
edgent.build.ci in: FiltersTest, PlumbingTest, WindowTest, Mqtt,
wsclient.  We'll see.

Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/dc6fbef2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/dc6fbef2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/dc6fbef2

Branch: refs/heads/develop
Commit: dc6fbef267c6f2fa7b1d64eac077b8b09a2b67af
Parents: 907b4e9
Author: Dale LaBossiere <dl...@us.ibm.com>
Authored: Tue Oct 24 12:15:39 2017 -0400
Committer: Dale LaBossiere <dl...@us.ibm.com>
Committed: Tue Oct 24 12:15:39 2017 -0400

----------------------------------------------------------------------
 DEVELOPMENT.md                                  | 14 ++++++++++++
 .../edgent/test/topology/TStreamTest.java       | 20 ++++++++++++++---
 .../apache/edgent/runtime/etiao/Executable.java | 19 ++++++++++++++--
 .../topology/spi/tester/AbstractTester.java     | 23 +++++++++++++++++++-
 4 files changed, 70 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/dc6fbef2/DEVELOPMENT.md
----------------------------------------------------------------------
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
index 9728f80..221f252 100644
--- a/DEVELOPMENT.md
+++ b/DEVELOPMENT.md
@@ -213,6 +213,20 @@ It includes:
 * Testing on Java 8
   - Not all tests may be run, some tests are skipped due to timing issues or if excessive setup is required.
 
+In an attempt to more generally desentize tmo failures
+when the system property edgent.build.ci=true is set
+some runtime and test infrastructure components will 
+bump the normal tmo value (e.g., 10x).
+This affects travis and Jenkins runs (both set edgent.build.ci).
+See:
+
+    * TStreamTest.waitForCompletion()
+    * AbstractTester.complete()
+    * Execuatble.invokeAction()
+    * generally search for uses of edgent.build.ci
+        * maybe remove other test specific uses of it in light of the general change 
+
+The following may now best be avoided:
 If your test randomly fails because, for example, it depends on publicly available test services,
 or is timing dependent, and if timing variances on the Travis CI servers may make it more likely
 for your tests to fail, you may disable the test from being executed on Travis CI using the

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/dc6fbef2/api/topology/src/test/java/org/apache/edgent/test/topology/TStreamTest.java
----------------------------------------------------------------------
diff --git a/api/topology/src/test/java/org/apache/edgent/test/topology/TStreamTest.java b/api/topology/src/test/java/org/apache/edgent/test/topology/TStreamTest.java
index aa35828..0e55fe2 100644
--- a/api/topology/src/test/java/org/apache/edgent/test/topology/TStreamTest.java
+++ b/api/topology/src/test/java/org/apache/edgent/test/topology/TStreamTest.java
@@ -853,15 +853,29 @@ public abstract class TStreamTest extends TopologyAbstractTest {
         Condition<Long> tc = t.getTester().tupleCount(joinsHappened, 100);
         complete(t, tc);      
     }
+    
+    private static long getTimeoutValue(long timeout, TimeUnit units) {
+        // try to protect the tests from timing out prematurely
+        // in the face of overloaded/slow build/test servers.
+        if (Boolean.getBoolean("edgent.build.ci")) {
+            // could do something like base the decision of the current value of timeout and/or units
+            return timeout * 10;
+        }
+        return timeout;
+    }
 
     private void waitForCompletion(ExecutorCompletionService<Boolean> completer, int numtasks) throws ExecutionException {
         int remainingTasks = numtasks;
+        long getFutureTimeout = 4;
+        TimeUnit getFutureTimeoutUnits = TimeUnit.SECONDS;
+        getFutureTimeout = getTimeoutValue(getFutureTimeout, getFutureTimeoutUnits);
         while (remainingTasks > 0) {
             try {
-                Future<Boolean> completed = completer.poll(4, TimeUnit.SECONDS);
+                Future<Boolean> completed = completer.poll(getFutureTimeout, getFutureTimeoutUnits);
                 if (completed == null) {
-                    System.err.println("Completer timed out");
-                    throw new RuntimeException(new TimeoutException());
+                    String msg = String.format("Completer timed out: %d%s timeout", getFutureTimeout, getFutureTimeoutUnits.toString());
+                    System.err.println(msg);
+                    throw new RuntimeException(new TimeoutException(msg));
                 }
                 else {
                     completed.get();

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/dc6fbef2/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/Executable.java
----------------------------------------------------------------------
diff --git a/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/Executable.java b/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/Executable.java
index 2d3eefd..453003c 100644
--- a/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/Executable.java
+++ b/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/Executable.java
@@ -206,6 +206,16 @@ public class Executable implements RuntimeServices {
             logger.warn("Scheduler could not finish {} tasks", unfinished.size());
         }
     }
+    
+    private static long getTimeoutValue(long timeout, TimeUnit units) {
+        // try to protect the tests from timing out prematurely
+        // in the face of overloaded/slow build/test servers.
+        if (Boolean.getBoolean("edgent.build.ci")) {
+            // could do something like base the decision of the current value of timeout and/or units
+            return timeout * 10;
+        }
+        return timeout;
+    }
 
     private void invokeAction(Consumer<Invocation<?, ?, ?>> action) {
         ExecutorCompletionService<Boolean> completer = new ExecutorCompletionService<>(controlScheduler);
@@ -216,13 +226,18 @@ public class Executable implements RuntimeServices {
             });
         }
 
+        long getFutureTimeout = 10;
+        TimeUnit getFutureTimeoutUnits = TimeUnit.SECONDS;
+        getFutureTimeout = getTimeoutValue(getFutureTimeout, getFutureTimeoutUnits);
+        
         int remainingTasks = invocations.size();
         while (remainingTasks > 0) {
             try {
-                Future<Boolean> completed = completer.poll(10, TimeUnit.SECONDS);
+                Future<Boolean> completed = completer.poll(getFutureTimeout, getFutureTimeoutUnits);
                 if (completed == null) {
                     // TODO during close log exception and wait on the next task to complete
-                    throw new RuntimeException(new TimeoutException());
+                    throw new RuntimeException(new TimeoutException(
+                            String.format("%d%s timeout", getFutureTimeout, getFutureTimeoutUnits.toString())));
                 }
                 else {
                     try {

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/dc6fbef2/spi/topology/src/main/java/org/apache/edgent/topology/spi/tester/AbstractTester.java
----------------------------------------------------------------------
diff --git a/spi/topology/src/main/java/org/apache/edgent/topology/spi/tester/AbstractTester.java b/spi/topology/src/main/java/org/apache/edgent/topology/spi/tester/AbstractTester.java
index 270d3fd..07b72d2 100644
--- a/spi/topology/src/main/java/org/apache/edgent/topology/spi/tester/AbstractTester.java
+++ b/spi/topology/src/main/java/org/apache/edgent/topology/spi/tester/AbstractTester.java
@@ -22,8 +22,8 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.edgent.execution.Job;
-import org.apache.edgent.execution.Submitter;
 import org.apache.edgent.execution.Job.State;
+import org.apache.edgent.execution.Submitter;
 import org.apache.edgent.topology.Topology;
 import org.apache.edgent.topology.tester.Condition;
 import org.apache.edgent.topology.tester.Tester;
@@ -33,6 +33,26 @@ import com.google.gson.JsonObject;
 public abstract class AbstractTester implements Tester { 
     
     private Job job;
+    
+    private static long getTimeoutValue(long timeout, TimeUnit units) {
+        // try to protect the tests from timing out prematurely
+        // in the face of overloaded/slow build/test servers.
+        //
+        // One problem with the following "generally bump the timeout value"
+        // scheme is that there are some tests that expect / test-for something
+        // to NOT happen - within some timeout tolerance.
+        // Ideally we don't want such tests to always take this extra-long timeout.
+        // Not sure what to do about that.  The first step is to just try this and
+        // see if it generally addresses the slow-test-server problem.
+        // Then we can review test execution times to identify those that fall
+        // into this case and then contemplate what to do about them.
+        
+        if (Boolean.getBoolean("edgent.build.ci")) {
+            // could do something like base the decision of the current value of timeout and/or units
+            return timeout * 10;
+        }
+        return timeout;
+    }
 
     @Override
     public boolean complete(Submitter<Topology, ? extends Job> submitter, JsonObject config, Condition<?> endCondition,
@@ -40,6 +60,7 @@ public abstract class AbstractTester implements Tester {
 
         long tmoMsec = Math.max(unit.toMillis(timeout), 1000);
         long maxTime = System.currentTimeMillis() + tmoMsec;
+        tmoMsec = getTimeoutValue(tmoMsec, TimeUnit.MILLISECONDS);
 
         Future<?> future = submitter.submit(topology(), config);
         // wait at most tmoMsec for the submit to create the job