From 789e2261057a3e4945ef7dcef3d85ebf0c788d65 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Sat, 16 Nov 2019 21:20:16 +0100 Subject: [PATCH] Fix Broken Network Disruption in SnapshotResiliencyTests 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. --- .../snapshots/SnapshotResiliencyTests.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java index a5f49edcd79c7..bcedef6f39b30 100644 --- a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java @@ -71,6 +71,7 @@ import org.elasticsearch.action.search.SearchTransportService; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.ActionFilters; +import org.elasticsearch.action.support.ActionTestUtils; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.support.AutoCreateIndex; import org.elasticsearch.action.support.DestructiveOperations; @@ -713,7 +714,7 @@ private final class TestClusterNodes { private final Map nodes = new LinkedHashMap<>(); /** - * Node ids that are disconnected from all other nodes. + * Node names that are disconnected from all other nodes. */ private final Set disconnectedNodes = new HashSet<>(); @@ -793,11 +794,11 @@ public Optional randomDataNode(String... excludedNames) { } public void disconnectNode(TestClusterNode node) { - if (disconnectedNodes.contains(node.node.getId())) { + if (disconnectedNodes.contains(node.node.getName())) { return; } testClusterNodes.nodes.values().forEach(n -> n.transportService.getConnectionManager().disconnectFromNode(node.node)); - disconnectedNodes.add(node.node.getId()); + disconnectedNodes.add(node.node.getName()); } public void clearNetworkDisruptions() { @@ -807,7 +808,8 @@ public void clearNetworkDisruptions() { if (testClusterNodes.nodes.containsKey(nodeName)) { final DiscoveryNode node = testClusterNodes.nodes.get(nodeName).node; testClusterNodes.nodes.values().forEach( - n -> n.transportService.openConnection(node, null, ActionListener.wrap(() -> {}))); + n -> n.transportService.openConnection(node, null, + ActionTestUtils.assertNoFailureListener(c -> logger.debug("--> Connected [{}] to [{}]", n.node, node)))); } }); } @@ -900,7 +902,7 @@ protected ConnectionStatus getConnectionStatus(DiscoveryNode destination) { if (nodes.containsKey(node.getName()) == false || nodes.containsKey(destination.getName()) == false) { return ConnectionStatus.DISCONNECTED; } - return disconnectedNodes.contains(node.getId()) || disconnectedNodes.contains(destination.getId()) + return disconnectedNodes.contains(node.getName()) || disconnectedNodes.contains(destination.getName()) ? ConnectionStatus.DISCONNECTED : ConnectionStatus.CONNECTED; }