TESTS: Fix Random Fail in MockTcpTransportTests (#33061)

* `foobar.txGet()` appears to return before `serviceB.stop()` returns, causing `ServiceB.close()` to run concurrently with the `stop` call and running into a race codition
* Closes #32863
This commit is contained in:
Armin Braun 2018-08-23 13:19:21 +02:00 committed by GitHub
parent 61f5c188e0
commit 917e5a8c94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -768,6 +768,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
public void testNotifyOnShutdown() throws Exception {
final CountDownLatch latch2 = new CountDownLatch(1);
final CountDownLatch latch3 = new CountDownLatch(1);
try {
serviceA.registerRequestHandler("internal:foobar", StringMessageRequest::new, ThreadPool.Names.GENERIC,
(request, channel, task) -> {
@ -777,6 +778,8 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
serviceB.stop();
} catch (Exception e) {
fail(e.getMessage());
} finally {
latch3.countDown();
}
});
TransportFuture<TransportResponse.Empty> foobar = serviceB.submitRequest(nodeA, "internal:foobar",
@ -788,6 +791,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
} catch (TransportException ex) {
}
latch3.await();
} finally {
serviceB.close(); // make sure we are fully closed here otherwise we might run into assertions down the road
serviceA.disconnectFromNode(nodeB);