Github user zsxwing commented on a diff in the pull request:
https://github.com/apache/spark/pull/9227#discussion_r44056308
--- Diff:
network/common/src/test/java/org/apache/spark/network/TransportClientFactorySuite.java
---
@@ -177,4 +177,14 @@ public void closeBlockClientsWithFactory() throws
IOException {
assertFalse(c1.isActive());
assertFalse(c2.isActive());
}
+
+ @Test
+ public void closeIdleConnectionForRequestTimeOut() throws IOException,
InterruptedException {
+ TransportClientFactory factory = context.createClientFactory();
+ TransportClient c1 = factory.createClient(TestUtils.getLocalHost(),
server1.getPort());
+ assertTrue(c1.isActive());
+ Thread.sleep(conf.connectionTimeoutMs());
+ assertFalse(c1.isActive());
--- End diff --
This is flakey. You should check it with a timeout and also use a short
connection timeout to make this test fast, such as
```Java
@Test
public void closeIdleConnectionForRequestTimeOut() throws IOException,
InterruptedException {
TransportConf conf = new TransportConf(new ConfigProvider() {
@Override
public String get(String name) {
if ("spark.shuffle.io.connectionTimeout".equals(name)) {
// We should make sure there is enough time for us to observe the
channel is active
return "1s";
}
String value = System.getProperty(name);
if (value == null) {
throw new NoSuchElementException(name);
}
return value;
}
});
TransportContext context = new TransportContext(conf, new
NoOpRpcHandler());
TransportClientFactory factory = context.createClientFactory();
try {
TransportClient c1 = factory.createClient(TestUtils.getLocalHost(),
server1.getPort());
assertTrue(c1.isActive());
long expiredTime = System.currentTimeMillis() + 10000; // 10 seconds
while (c1.isActive() && System.currentTimeMillis() < expiredTime) {
Thread.sleep(10);
}
assertFalse(c1.isActive());
} finally {
factory.close();
}
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]