Skip to content

Commit 4b31e70

Browse files
Fix Broken Network Disruption in SnapshotResiliencyTests (#49216) (#49232)
The network disruption was acting on node ids and node names which made reconnects not work. Moved all usages to node names to fix this. Since the map of all nodes in the test is indexed by name this was easier to work with.
1 parent c5d7ad2 commit 4b31e70

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import org.elasticsearch.action.search.SearchTransportService;
7272
import org.elasticsearch.action.search.TransportSearchAction;
7373
import org.elasticsearch.action.support.ActionFilters;
74+
import org.elasticsearch.action.support.ActionTestUtils;
7475
import org.elasticsearch.action.support.ActiveShardCount;
7576
import org.elasticsearch.action.support.AutoCreateIndex;
7677
import org.elasticsearch.action.support.DestructiveOperations;
@@ -713,7 +714,7 @@ private final class TestClusterNodes {
713714
private final Map<String, TestClusterNode> nodes = new LinkedHashMap<>();
714715

715716
/**
716-
* Node ids that are disconnected from all other nodes.
717+
* Node names that are disconnected from all other nodes.
717718
*/
718719
private final Set<String> disconnectedNodes = new HashSet<>();
719720

@@ -793,11 +794,11 @@ public Optional<TestClusterNode> randomDataNode(String... excludedNames) {
793794
}
794795

795796
public void disconnectNode(TestClusterNode node) {
796-
if (disconnectedNodes.contains(node.node.getId())) {
797+
if (disconnectedNodes.contains(node.node.getName())) {
797798
return;
798799
}
799800
testClusterNodes.nodes.values().forEach(n -> n.transportService.getConnectionManager().disconnectFromNode(node.node));
800-
disconnectedNodes.add(node.node.getId());
801+
disconnectedNodes.add(node.node.getName());
801802
}
802803

803804
public void clearNetworkDisruptions() {
@@ -806,7 +807,9 @@ public void clearNetworkDisruptions() {
806807
disconnectedNodes.forEach(nodeName -> {
807808
if (testClusterNodes.nodes.containsKey(nodeName)) {
808809
final DiscoveryNode node = testClusterNodes.nodes.get(nodeName).node;
809-
testClusterNodes.nodes.values().forEach(n -> n.transportService.openConnection(node, null));
810+
testClusterNodes.nodes.values().forEach(
811+
n -> n.transportService.openConnection(node, null,
812+
ActionTestUtils.assertNoFailureListener(c -> logger.debug("--> Connected [{}] to [{}]", n.node, node))));
810813
}
811814
});
812815
}
@@ -899,7 +902,7 @@ protected ConnectionStatus getConnectionStatus(DiscoveryNode destination) {
899902
if (nodes.containsKey(node.getName()) == false || nodes.containsKey(destination.getName()) == false) {
900903
return ConnectionStatus.DISCONNECTED;
901904
}
902-
return disconnectedNodes.contains(node.getId()) || disconnectedNodes.contains(destination.getId())
905+
return disconnectedNodes.contains(node.getName()) || disconnectedNodes.contains(destination.getName())
903906
? ConnectionStatus.DISCONNECTED : ConnectionStatus.CONNECTED;
904907
}
905908

0 commit comments

Comments
 (0)