From 4c4047165f626e9dbcae42bdcd00c916a8ec8069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Fri, 13 Jun 2014 11:28:48 -0700 Subject: [PATCH] fix query cancellation test race condition --- .../io/druid/query/ChainedExecutionQueryRunnerTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/processing/src/test/java/io/druid/query/ChainedExecutionQueryRunnerTest.java b/processing/src/test/java/io/druid/query/ChainedExecutionQueryRunnerTest.java index f2555dd7214..a8c464a8703 100644 --- a/processing/src/test/java/io/druid/query/ChainedExecutionQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/ChainedExecutionQueryRunnerTest.java @@ -243,7 +243,9 @@ public class ChainedExecutionQueryRunnerTest Assert.assertTrue(future.isCancelled()); Assert.assertTrue(runner1.hasStarted); Assert.assertTrue(runner2.hasStarted); - Assert.assertFalse(runner3.hasStarted); + Assert.assertTrue(runner1.interrupted); + Assert.assertTrue(runner2.interrupted); + Assert.assertTrue(!runner3.hasStarted || runner3.interrupted); Assert.assertFalse(runner1.hasCompleted); Assert.assertFalse(runner2.hasCompleted); Assert.assertFalse(runner3.hasCompleted); @@ -256,6 +258,7 @@ public class ChainedExecutionQueryRunnerTest private final CountDownLatch latch; private boolean hasStarted = false; private boolean hasCompleted = false; + private boolean interrupted = false; public DyingQueryRunner(CountDownLatch latch) { @@ -268,6 +271,7 @@ public class ChainedExecutionQueryRunnerTest hasStarted = true; latch.countDown(); if (Thread.interrupted()) { + interrupted = true; throw new QueryInterruptedException("I got killed"); } @@ -276,6 +280,7 @@ public class ChainedExecutionQueryRunnerTest Thread.sleep(500); } catch (InterruptedException e) { + interrupted = true; throw new QueryInterruptedException("I got killed"); }