asfgit closed pull request #6853: [FLINK-4052] using non-local unreachable 
ip:port to fix unstable Test testReturnLocalHostAddressUsingHeuristics
URL: https://github.com/apache/flink/pull/6853
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 3f9ee8e6a8d..c945ce234ef 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 @@
 
        @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


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to