Fix race in KafkaIndexTaskTest (#4031)

task.pause(0) can return early before the task is actually paused.
Exception for failure -
java.lang.AssertionError: expected:<PAUSED> but was:<READING>
	at org.junit.Assert.fail(Assert.java:88)
	at org.junit.Assert.failNotEquals(Assert.java:743)
	at org.junit.Assert.assertEquals(Assert.java:118)
	at org.junit.Assert.assertEquals(Assert.java:144)
	at
io.druid.indexing.kafka.KafkaIndexTaskTest.testRunWithOffsetOutOfRangeEx
ceptionAndPause(KafkaIndexTaskTest.java:1229)

To reproduce add Thread.sleep(10000) in beginning of
KafkaIndexTask.possiblypause method.
This commit is contained in:
Nishant Bangarwa 2017-03-09 21:04:46 +05:30 committed by Gian Merlino
parent a5170666b6
commit adbe89e7d6
1 changed files with 3 additions and 1 deletions

View File

@ -1247,7 +1247,9 @@ public class KafkaIndexTaskTest
task.pause(0);
Assert.assertEquals(KafkaIndexTask.Status.PAUSED, task.getStatus());
while (!task.getStatus().equals(KafkaIndexTask.Status.PAUSED)) {
Thread.sleep(25);
}
}
@Test(timeout = 30_000L)