asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: Pollquery shouldn't wait > remaining timeout for response
Date Thu, 15 Jun 2017 16:43:05 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 2534d27c1 -> 455405a4f


Pollquery shouldn't wait > remaining timeout for response

Change-Id: I8cf8e6d84ff826d77449c941a1f53b0720fbe683
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1839
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/455405a4
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/455405a4
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/455405a4

Branch: refs/heads/master
Commit: 455405a4f80017881d7341153c59b37a8ea9ab33
Parents: 2534d27
Author: Michael Blow <mblow@apache.org>
Authored: Wed Jun 14 22:48:26 2017 -0400
Committer: Michael Blow <mblow@apache.org>
Committed: Thu Jun 15 09:42:46 2017 -0700

----------------------------------------------------------------------
 .../asterix/test/common/TestExecutor.java       | 24 ++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/455405a4/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
index edbcc7e..35ab1df 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
@@ -45,9 +45,11 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.function.Predicate;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -1136,12 +1138,26 @@ public class TestExecutor {
         boolean expectedException = false;
         Exception finalException;
         LOGGER.fine("polling for up to " + timeoutSecs + " seconds w/ " + retryDelaySecs
+ " second(s) delay");
+        int responsesReceived = 0;
+        final ExecutorService executorService = Executors.newSingleThreadExecutor();
         while (true) {
             try {
-                executeTestFile(testCaseCtx, ctx, variableCtx, statement, isDmlRecoveryTest,
pb, cUnit, queryCount,
-                        expectedResultFileCtxs, testFile, actualPath);
+                Future<Void> execution = executorService.submit(() -> {
+                    executeTestFile(testCaseCtx, ctx, variableCtx, statement, isDmlRecoveryTest,
pb, cUnit, queryCount,
+                            expectedResultFileCtxs, testFile, actualPath);
+                    return null;
+                });
+                execution.get(limitTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
+                responsesReceived++;
                 finalException = null;
                 break;
+            } catch (TimeoutException e) {
+                if (responsesReceived == 0) {
+                    throw new Exception("Poll limit (" + timeoutSecs + "s) exceeded without
obtaining *any* result from server");
+                } else {
+                    throw new Exception("Poll limit (" + timeoutSecs + "s) exceeded without
obtaining expected result");
+
+                }
             } catch (Exception e) {
                 if (isExpected(e, cUnit)) {
                     expectedException = true;
@@ -1153,7 +1169,7 @@ public class TestExecutor {
                     break;
                 }
                 LOGGER.fine("sleeping " + retryDelaySecs + " second(s) before polling again");
-                Thread.sleep(TimeUnit.SECONDS.toMillis(retryDelaySecs));
+                TimeUnit.SECONDS.sleep(retryDelaySecs);
             }
         }
         if (expectedException) {
@@ -1411,7 +1427,7 @@ public class TestExecutor {
                 try {
                     final HttpClient client = HttpClients.createDefault();
 
-                    final HttpGet get = new HttpGet(createEndpointURI("/admin/cluster", null));
+                    final HttpGet get = new HttpGet(getEndpoint(Servlets.CLUSTER_STATE));
                     final HttpResponse httpResponse = client.execute(get);
                     final int statusCode = httpResponse.getStatusLine().getStatusCode();
                     final String response = EntityUtils.toString(httpResponse.getEntity());


Mime
View raw message