Skip to content

Commit e5c3e61

Browse files
ywelschjkakavas
authored andcommitted
Fix testBlockingIncomingRequests (#44939)
Adapted test to take non-blocking nature into account.
1 parent c7e4cbf commit e5c3e61

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,12 +1618,37 @@ public String executor() {
16181618
}
16191619
});
16201620

1621+
latch.await();
16211622
assertFalse(requestProcessed.get());
16221623

16231624
service.acceptIncomingRequests();
1624-
assertBusy(() -> assertTrue(requestProcessed.get()));
16251625

1626-
latch.await();
1626+
CountDownLatch latch2 = new CountDownLatch(1);
1627+
serviceA.sendRequest(connection, "internal:action", new TestRequest(), TransportRequestOptions.EMPTY,
1628+
new TransportResponseHandler<TestResponse>() {
1629+
@Override
1630+
public TestResponse read(StreamInput in) throws IOException {
1631+
return new TestResponse(in);
1632+
}
1633+
1634+
@Override
1635+
public void handleResponse(TestResponse response) {
1636+
latch2.countDown();
1637+
}
1638+
1639+
@Override
1640+
public void handleException(TransportException exp) {
1641+
latch2.countDown();
1642+
}
1643+
1644+
@Override
1645+
public String executor() {
1646+
return ThreadPool.Names.SAME;
1647+
}
1648+
});
1649+
1650+
latch2.await();
1651+
assertBusy(() -> assertTrue(requestProcessed.get()));
16271652
}
16281653
}
16291654
}

0 commit comments

Comments
 (0)