This is an automated email from the ASF dual-hosted git repository.
gosullivan pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 3f774fe GEODE-3683: fix intermittent failure of
CacheConnectionTimeoutJUnitTest
3f774fe is described below
commit 3f774fe753a7146c05c87fd560354bb6871e543b
Author: Galen O'Sullivan <[email protected]>
AuthorDate: Thu Sep 21 18:37:33 2017 -0700
GEODE-3683: fix intermittent failure of CacheConnectionTimeoutJUnitTest
The old condition wasn't quite right. I don't think Awaitility is
actually the right thing to use here.
---
.../CacheConnectionTimeoutJUnitTest.java | 37 ++++++++++------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git
a/geode-protobuf/src/test/java/org/apache/geode/protocol/acceptance/CacheConnectionTimeoutJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/protocol/acceptance/CacheConnectionTimeoutJUnitTest.java
index f7362c0..5e50042 100644
---
a/geode-protobuf/src/test/java/org/apache/geode/protocol/acceptance/CacheConnectionTimeoutJUnitTest.java
+++
b/geode-protobuf/src/test/java/org/apache/geode/protocol/acceptance/CacheConnectionTimeoutJUnitTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Properties;
@@ -130,26 +131,22 @@ public class CacheConnectionTimeoutJUnitTest {
MessageUtil.makePutRequestMessage(serializationService, TEST_KEY,
TEST_VALUE, TEST_REGION,
ProtobufUtilities.createMessageHeader(TEST_PUT_CORRELATION_ID));
- long timeout = maximumTimeBetweenPings + monitorInterval + pollInterval;
-
- // wait for client to get disconnected
- Awaitility.await().atMost(timeout, TimeUnit.MILLISECONDS)
- .pollInterval(pollInterval, TimeUnit.MILLISECONDS)
- .pollDelay(maximumTimeBetweenPings + monitorInterval,
TimeUnit.MILLISECONDS).until(() -> {
- try {
- /*
- * send a PUT message
- *
- * Note: The `await` will run this at an interval larger than the
maximum timeout
- * allowed between pings. This is so that we have better
validation that we are actually
- * timing out connections after `maximumTimeBetweenPings` and not
some other larger time
- * that's smaller than `timeout`
- */
- protobufProtocolSerializer.serialize(putMessage, outputStream);
- assertEquals(-1, socket.getInputStream().read());
- } catch (IOException expected) {
- }
- });
+ InputStream inputStream = socket.getInputStream();
+
+ // Better to wait a bit later for jitter and pass the test, than to have
intermittent failures.
+ long delay = maximumTimeBetweenPings + (maximumTimeBetweenPings / 2) +
monitorInterval;
+
+ protobufProtocolSerializer.serialize(putMessage, outputStream);
+ protobufProtocolSerializer.deserialize(inputStream);
+
+ // In this case, I think Thread.sleep is actually the right choice. This is
+ // not right for Awaitility because it is not a condition that will be
+ // eventually satisfied; rather, it is a condition that we expect to be met
+ // after a specific amount of time.
+ Thread.sleep(delay);
+
+ // should be disconnected, expecting EOF.
+ assertEquals(-1, inputStream.read());
}
@Test
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].