You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by sr...@apache.org on 2018/10/16 15:31:23 UTC
[flink] branch master updated: [FLINK-4052] Use non-local
unreachable ip:port in testReturnLocalHostAddressUsingHeuristics
This is an automated email from the ASF dual-hosted git repository.
srichter pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new f195a6e [FLINK-4052] Use non-local unreachable ip:port in testReturnLocalHostAddressUsingHeuristics
f195a6e is described below
commit f195a6ed5cf69ea59c6916cb4ebf0c2485254158
Author: xuewei.linxuewei <xu...@alibaba-inc.com>
AuthorDate: Tue Oct 16 13:58:07 2018 +0800
[FLINK-4052] Use non-local unreachable ip:port in testReturnLocalHostAddressUsingHeuristics
This closes #6853.
Change-Id: If6dfbbde2190dead5e918dbdaf15b551975acd17
---
.../flink/runtime/net/ConnectionUtilsTest.java | 26 ++++++++++------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java
index 3f9ee8e..c945ce2 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java
@@ -43,24 +43,22 @@ public class ConnectionUtilsTest {
@Test
public void testReturnLocalHostAddressUsingHeuristics() throws Exception {
- try (ServerSocket blocker = new ServerSocket(0, 1, InetAddress.getLocalHost())) {
- // the "blocker" server socket simply does not accept connections
- // this address is consequently "unreachable"
- InetSocketAddress unreachable = new InetSocketAddress("localhost", blocker.getLocalPort());
+ // instead of using a unstable localhost:port as "unreachable" to cause Test fails unstably
+ // using a Absolutely unreachable outside ip:port
+ InetSocketAddress unreachable = new InetSocketAddress("8.8.8.8", 0xFFFF);
- final long start = System.nanoTime();
- InetAddress add = ConnectionUtils.findConnectingAddress(unreachable, 2000, 400);
+ final long start = System.nanoTime();
+ InetAddress add = ConnectionUtils.findConnectingAddress(unreachable, 2000, 400);
- // check that it did not take forever (max 30 seconds)
- // this check can unfortunately not be too tight, or it will be flaky on some CI infrastructure
- assertTrue(System.nanoTime() - start < 30_000_000_000L);
+ // check that it did not take forever (max 30 seconds)
+ // this check can unfortunately not be too tight, or it will be flaky on some CI infrastructure
+ assertTrue(System.nanoTime() - start < 30_000_000_000L);
- // we should have found a heuristic address
- assertNotNull(add);
+ // we should have found a heuristic address
+ assertNotNull(add);
- // make sure that we returned the InetAddress.getLocalHost as a heuristic
- assertEquals(InetAddress.getLocalHost(), add);
- }
+ // make sure that we returned the InetAddress.getLocalHost as a heuristic
+ assertEquals(InetAddress.getLocalHost(), add);
}
@Test