mirror of
https://github.com/apache/druid.git
synced 2025-02-09 03:24:55 +00:00
Fix flaky tests in DruidCoordinatorTest (#10157)
* Fix flaky tests in DruidCoordinatorTest * Imporve fail msg * Fix flaky tests in DruidCoordinatorTest
This commit is contained in:
parent
88d20a61a6
commit
54a8fb827d
@ -103,12 +103,10 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
|||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
private DruidNode druidNode;
|
private DruidNode druidNode;
|
||||||
private LatchableServiceEmitter serviceEmitter = new LatchableServiceEmitter();
|
private LatchableServiceEmitter serviceEmitter = new LatchableServiceEmitter();
|
||||||
private boolean serverAddedCountExpected = true;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
serverAddedCountExpected = true;
|
|
||||||
druidServer = EasyMock.createMock(DruidServer.class);
|
druidServer = EasyMock.createMock(DruidServer.class);
|
||||||
serverInventoryView = EasyMock.createMock(SingleServerInventoryView.class);
|
serverInventoryView = EasyMock.createMock(SingleServerInventoryView.class);
|
||||||
segmentsMetadataManager = EasyMock.createNiceMock(SegmentsMetadataManager.class);
|
segmentsMetadataManager = EasyMock.createNiceMock(SegmentsMetadataManager.class);
|
||||||
@ -385,7 +383,6 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
|||||||
druidServer
|
druidServer
|
||||||
);
|
);
|
||||||
assignSegmentLatch.await();
|
assignSegmentLatch.await();
|
||||||
Assert.assertTrue(serverAddedCountExpected);
|
|
||||||
|
|
||||||
final CountDownLatch coordinatorRunLatch = new CountDownLatch(2);
|
final CountDownLatch coordinatorRunLatch = new CountDownLatch(2);
|
||||||
serviceEmitter.latch = coordinatorRunLatch;
|
serviceEmitter.latch = coordinatorRunLatch;
|
||||||
@ -486,7 +483,6 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
|||||||
final CountDownLatch assignSegmentLatchCold = createCountDownLatchAndSetPathChildrenCacheListenerWithLatch(1, pathChildrenCacheCold, dataSegments, coldServer);
|
final CountDownLatch assignSegmentLatchCold = createCountDownLatchAndSetPathChildrenCacheListenerWithLatch(1, pathChildrenCacheCold, dataSegments, coldServer);
|
||||||
assignSegmentLatchHot.await();
|
assignSegmentLatchHot.await();
|
||||||
assignSegmentLatchCold.await();
|
assignSegmentLatchCold.await();
|
||||||
Assert.assertTrue(serverAddedCountExpected);
|
|
||||||
|
|
||||||
final CountDownLatch coordinatorRunLatch = new CountDownLatch(2);
|
final CountDownLatch coordinatorRunLatch = new CountDownLatch(2);
|
||||||
serviceEmitter.latch = coordinatorRunLatch;
|
serviceEmitter.latch = coordinatorRunLatch;
|
||||||
@ -646,7 +642,6 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
|||||||
assignSegmentLatchBroker1.await();
|
assignSegmentLatchBroker1.await();
|
||||||
assignSegmentLatchBroker2.await();
|
assignSegmentLatchBroker2.await();
|
||||||
assignSegmentLatchPeon.await();
|
assignSegmentLatchPeon.await();
|
||||||
Assert.assertTrue(serverAddedCountExpected);
|
|
||||||
|
|
||||||
final CountDownLatch coordinatorRunLatch = new CountDownLatch(2);
|
final CountDownLatch coordinatorRunLatch = new CountDownLatch(2);
|
||||||
serviceEmitter.latch = coordinatorRunLatch;
|
serviceEmitter.latch = coordinatorRunLatch;
|
||||||
@ -679,16 +674,15 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
|||||||
pathChildrenCache.getListenable().addListener(
|
pathChildrenCache.getListenable().addListener(
|
||||||
(CuratorFramework client, PathChildrenCacheEvent event) -> {
|
(CuratorFramework client, PathChildrenCacheEvent event) -> {
|
||||||
if (CuratorUtils.isChildAdded(event)) {
|
if (CuratorUtils.isChildAdded(event)) {
|
||||||
if (countDownLatch.getCount() > 0) {
|
DataSegment segment = findSegmentRelatedToCuratorEvent(segments, event);
|
||||||
DataSegment segment = findSegmentRelatedToCuratorEvent(segments, event);
|
if (segment != null && server.getSegment(segment.getId()) == null) {
|
||||||
if (segment != null) {
|
if (countDownLatch.getCount() > 0) {
|
||||||
server.addDataSegment(segment);
|
server.addDataSegment(segment);
|
||||||
curator.delete().guaranteed().forPath(event.getData().getPath());
|
curator.delete().guaranteed().forPath(event.getData().getPath());
|
||||||
|
countDownLatch.countDown();
|
||||||
|
} else {
|
||||||
|
Assert.fail("The segment path " + event.getData().getPath() + " is not expected");
|
||||||
}
|
}
|
||||||
countDownLatch.countDown();
|
|
||||||
} else {
|
|
||||||
// The segment is assigned to the server more times than expected
|
|
||||||
serverAddedCountExpected = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user