[ 
https://issues.apache.org/jira/browse/FLINK-4052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16651932#comment-16651932
 ] 

ASF GitHub Bot commented on FLINK-4052:
---------------------------------------

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


> Unstable test ConnectionUtilsTest
> ---------------------------------
>
>                 Key: FLINK-4052
>                 URL: https://issues.apache.org/jira/browse/FLINK-4052
>             Project: Flink
>          Issue Type: Bug
>          Components: Tests
>    Affects Versions: 1.0.2, 1.3.0
>            Reporter: Stephan Ewen
>            Assignee: Stephan Ewen
>            Priority: Critical
>              Labels: pull-request-available, test-stability
>             Fix For: 1.7.0, 1.6.2, 1.5.5
>
>
> The error is the following:
> {code}
> ConnectionUtilsTest.testReturnLocalHostAddressUsingHeuristics:59 
> expected:<testing-worker-linux-docker-e744e561-3361-linux-13/172.17.5.9> but 
> was:</127.0.0.1>
> {code}
> The probable cause for the failure is that the test tries to select an unused 
> closed port (from the ephemeral range), and then assumes that all connections 
> to that port fail.
> If a concurrent test actually uses that port, connections to the port will 
> succeed.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to