Skip to content

Commit

Permalink
Fix testJoinWaitsForClusterApplier (#87842) (#88205)
Browse files Browse the repository at this point in the history
Block the cluster applier before disrupting the cluster so the victim
node doesn't try and rejoin too soon.

Closes #86974
  • Loading branch information
DaveCTurner committed Jun 30, 2022
1 parent 789d52b commit 9237475
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,7 @@ public void testJoinWaitsForClusterApplier() throws Exception {
final var victimName = randomValueOtherThan(masterName, () -> randomFrom(internalCluster().getNodeNames()));
logger.info("--> master [{}], victim [{}]", masterName, victimName);

// drop the victim from the cluster with a network disruption
final var masterTransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, masterName);
masterTransportService.addFailToSendNoConnectRule(internalCluster().getInstance(TransportService.class, victimName));
logger.info("--> waiting for victim's departure");
ensureStableCluster(2, masterName);

// block the cluster applier thread on the victim
// block the cluster applier thread on the victim (we expect no further cluster state applications at this point)
logger.info("--> blocking victim's applier service");
final var barrier = new CyclicBarrier(2);
internalCluster().getInstance(ClusterService.class, victimName).getClusterApplierService().onNewClusterState("block", () -> {
Expand All @@ -235,6 +229,12 @@ public void testJoinWaitsForClusterApplier() throws Exception {
}, ActionListener.wrap(() -> {}));
barrier.await(10, TimeUnit.SECONDS);

// drop the victim from the cluster with a network disruption
final var masterTransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, masterName);
masterTransportService.addFailToSendNoConnectRule(internalCluster().getInstance(TransportService.class, victimName));
logger.info("--> waiting for victim's departure");
ensureStableCluster(2, masterName);

// verify that the victim sends no joins while the applier is blocked
final var victimTransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, victimName);
victimTransportService.addSendBehavior((connection, requestId, action, request, options) -> {
Expand Down

0 comments on commit 9237475

Please sign in to comment.