From 64b225ad0bc5114397639b9c4154fc77b2454882 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 30 Jun 2022 11:45:06 +0100 Subject: [PATCH] Fix testJoinWaitsForClusterApplier (#87842) Block the cluster applier before disrupting the cluster so the victim node doesn't try and rejoin too soon. Closes #86974 --- .../discovery/DiscoveryDisruptionIT.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java index 07c1ddfe3280e..9694a11eb4d6e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java @@ -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", () -> { @@ -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) -> {