asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Blow (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: Pollquery shouldn't wait > remaining timeout for response
Date Thu, 15 Jun 2017 02:48:59 GMT
Michael Blow has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1839

Change subject: Pollquery shouldn't wait > remaining timeout for response
......................................................................

Pollquery shouldn't wait > remaining timeout for response

Change-Id: I8cf8e6d84ff826d77449c941a1f53b0720fbe683
---
M asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
1 file changed, 21 insertions(+), 4 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/39/1839/1

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..d5a11d5 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.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,27 @@
         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;
+                });
+                LOGGER.log(Level.WARNING, "will wait for " + TimeUnit.MILLISECONDS.toSeconds(limitTime
- System.currentTimeMillis()) + " seconds...");
+                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 +1170,7 @@
                     break;
                 }
                 LOGGER.fine("sleeping " + retryDelaySecs + " second(s) before polling again");
-                Thread.sleep(TimeUnit.SECONDS.toMillis(retryDelaySecs));
+                TimeUnit.SECONDS.sleep(retryDelaySecs);
             }
         }
         if (expectedException) {
@@ -1411,7 +1428,7 @@
                 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());

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1839
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cf8e6d84ff826d77449c941a1f53b0720fbe683
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mblow@apache.org>

Mime
View raw message