Relax timeout in NodeConnectionsServiceTests (#42934)

Today we assert that the connection thread is blocked by the time the test gets
to the barrier, but in fact this is not a valid assertion. The following
`Thread.sleep()` will cause the test to fail reasonably often.

```diff
diff --git a/server/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java
index 193cde3180d..0e57211cec4 100644
--- a/server/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java
+++ b/server/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java
@@ -364,6 +364,7 @@ public class NodeConnectionsServiceTests extends ESTestCase {
             final CheckedRunnable<Exception> connectionBlock = nodeConnectionBlocks.get(node);
             if (connectionBlock != null) {
                 try {
+                    Thread.sleep(50);
                     connectionBlock.run();
                 } catch (Exception e) {
                     throw new AssertionError(e);
```

This change relaxes the test to allow some time for the connection thread to
hit the barrier.

Fixes #40170
This commit is contained in:
David Turner 2019-06-07 10:38:19 +01:00
parent 090d42d3e6
commit 5929803413
1 changed files with 1 additions and 1 deletions

View File

@ -255,7 +255,7 @@ public class NodeConnectionsServiceTests extends ESTestCase {
// once the connection is unblocked we successfully connect to it.
nodeConnectionBlocks.clear();
connectionBarrier.await(0, TimeUnit.SECONDS);
connectionBarrier.await(10, TimeUnit.SECONDS);
future3.actionGet();
assertConnectedExactlyToNodes(nodes01);