Repository: asterixdb Updated Branches: refs/heads/master 83695b932 -> 7b8e5a2a5
[NO ISSUE][TEST] Restore extension in context on poll completion Change-Id: I2bda5b5065f3684380dbc946c954e32c7dfa0c8b Reviewed-on: https://asterix-gerrit.ics.uci.edu/2303 Sonar-Qube: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Reviewed-by: Murtadha Hubail <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/7b8e5a2a Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/7b8e5a2a Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/7b8e5a2a Branch: refs/heads/master Commit: 7b8e5a2a54a46b86597c01ca91aacd511423ea9f Parents: 83695b9 Author: Michael Blow <[email protected]> Authored: Fri Jan 19 14:26:17 2018 -0500 Committer: Michael Blow <[email protected]> Committed: Fri Jan 19 16:22:15 2018 -0800 ---------------------------------------------------------------------- .../asterix/test/common/TestExecutor.java | 119 ++++++++++--------- 1 file changed, 64 insertions(+), 55 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7b8e5a2a/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 222e098..c3c450c 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 @@ -1275,65 +1275,74 @@ public class TestExecutor { long startTime = System.currentTimeMillis(); long limitTime = startTime + TimeUnit.SECONDS.toMillis(timeoutSecs); ctx.setType(ctx.getType().substring("poll".length())); - boolean expectedException = false; - Exception finalException = null; - LOGGER.debug("polling for up to " + timeoutSecs + " seconds w/ " + retryDelaySecs + " second(s) delay"); - int responsesReceived = 0; - final ExecutorService executorService = Executors.newSingleThreadExecutor(); - while (true) { - try { - 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 if (finalException != null) { - throw new Exception("Poll limit (" + timeoutSecs - + "s) exceeded without obtaining expected result; last exception:", finalException); - } else { - throw new Exception("Poll limit (" + timeoutSecs + "s) exceeded without obtaining expected result"); - - } - } catch (ExecutionException ee) { - Exception e; - if (ee.getCause() instanceof Exception) { - e = (Exception) ee.getCause(); - } else { - e = ee; - } - if (e instanceof ComparisonException) { - LOGGER.log(Level.INFO, "Comparison failure on poll: " + e.getMessage()); - } else { - LOGGER.log(Level.INFO, "received exception on poll", e); - } - responsesReceived++; - if (isExpected(e, cUnit)) { - expectedException = true; - finalException = e; - break; - } - if ((System.currentTimeMillis() > limitTime)) { - finalException = e; + try { + boolean expectedException = false; + Exception finalException = null; + LOGGER.debug("polling for up to " + timeoutSecs + " seconds w/ " + retryDelaySecs + " second(s) delay"); + int responsesReceived = 0; + final ExecutorService executorService = Executors.newSingleThreadExecutor(); + while (true) { + try { + 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 if (finalException != null) { + throw new Exception( + "Poll limit (" + timeoutSecs + + "s) exceeded without obtaining expected result; last exception:", + finalException); + } else { + throw new Exception( + "Poll limit (" + timeoutSecs + "s) exceeded without obtaining expected result"); + + } + } catch (ExecutionException ee) { + Exception e; + if (ee.getCause() instanceof Exception) { + e = (Exception) ee.getCause(); + } else { + e = ee; + } + if (e instanceof ComparisonException) { + LOGGER.log(Level.INFO, "Comparison failure on poll: " + e.getMessage()); + } else { + LOGGER.log(Level.INFO, "received exception on poll", e); + } + responsesReceived++; + if (isExpected(e, cUnit)) { + expectedException = true; + finalException = e; + break; + } + if ((System.currentTimeMillis() > limitTime)) { + finalException = e; + break; + } + LOGGER.debug("sleeping " + retryDelaySecs + " second(s) before polling again"); + TimeUnit.SECONDS.sleep(retryDelaySecs); } - LOGGER.debug("sleeping " + retryDelaySecs + " second(s) before polling again"); - TimeUnit.SECONDS.sleep(retryDelaySecs); } + if (expectedException) { + throw finalException; + } else if (finalException != null) { + throw new Exception("Poll limit (" + timeoutSecs + "s) exceeded without obtaining expected result", + finalException); + } + + } finally { + ctx.setType("poll" + ctx.getType()); } - if (expectedException) { - throw finalException; - } else if (finalException != null) { - throw new Exception("Poll limit (" + timeoutSecs + "s) exceeded without obtaining expected result", - finalException); - } + } public InputStream executeSqlppUpdateOrDdl(String statement, OutputFormat outputFormat) throws Exception {
