Skip to content

Commit a6bea1b

Browse files
committed
testMockFailToSendNoConnectRule should wait for connection close to bubble up and disconnect the node
elastic#25521 changed channel closing to be handled async on anything but transport stop. This means it may take a while before calling `connection.close()` and the node being removed from the `connectedNodes` list (but the connection is immediately unusuable). Fixes elastic#25686
1 parent 0724024 commit a6bea1b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.elasticsearch.action.ActionListenerResponseHandler;
3131
import org.elasticsearch.action.support.PlainActionFuture;
3232
import org.elasticsearch.cluster.node.DiscoveryNode;
33-
import org.elasticsearch.cluster.service.ClusterService;
3433
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
3534
import org.elasticsearch.common.io.stream.StreamInput;
3635
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -80,7 +79,6 @@
8079
import java.util.concurrent.atomic.AtomicBoolean;
8180
import java.util.concurrent.atomic.AtomicInteger;
8281
import java.util.concurrent.atomic.AtomicReference;
83-
import java.util.stream.Collector;
8482
import java.util.stream.Collectors;
8583

8684
import static java.util.Collections.emptyMap;
@@ -1418,7 +1416,7 @@ public String executor() {
14181416
assertThat(version0Response.value1, equalTo(1));
14191417
}
14201418

1421-
public void testMockFailToSendNoConnectRule() throws IOException {
1419+
public void testMockFailToSendNoConnectRule() throws Exception {
14221420
serviceA.registerRequestHandler("sayHello", StringMessageRequest::new, ThreadPool.Names.GENERIC,
14231421
(request, channel) -> {
14241422
assertThat("moshe", equalTo(request.message));
@@ -1461,6 +1459,10 @@ public void handleException(TransportException exp) {
14611459
assertThat(((ConnectTransportException)cause).node(), equalTo(nodeA));
14621460
}
14631461

1462+
// wait for the transport to process the sending failure and disconnect from node
1463+
assertBusy(() -> assertFalse(serviceB.nodeConnected(nodeA)));
1464+
1465+
// now try to connect again and see that it fails
14641466
try {
14651467
serviceB.connectToNode(nodeA);
14661468
fail("exception should be thrown");

0 commit comments

Comments
 (0)