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

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

zentol closed pull request #5449: [FLINK-8623] 
ConnectionUtilsTest.testReturnLocalHostAddressUsingHeuri…
URL: https://github.com/apache/flink/pull/5449
 
 
   

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 d7c4baae4d1..5ec3f443527 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
@@ -18,6 +18,7 @@
 
 package org.apache.flink.runtime.net;
 
+import org.junit.Assume;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
@@ -26,11 +27,13 @@
 import org.powermock.modules.junit4.PowerMockRunner;
 
 import java.io.IOException;
-import java.net.Inet4Address;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketAddress;
 import java.net.UnknownHostException;
+import java.net.Inet4Address;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -53,13 +56,28 @@ public void testReturnLocalHostAddressUsingHeuristics() 
throws Exception {
                        final long start = System.nanoTime();
                        InetAddress add = 
ConnectionUtils.findConnectingAddress(unreachable, 2000, 400);
 
+                       // we should have found a heuristic address
+                       assertNotNull(add);
+
+                       // make sure that the InetAddress.getLocalHost is not a 
loopback address
+                       
Assume.assumeFalse(InetAddress.getLocalHost().isLoopbackAddress());
+
+                       // make sure the connection address is not a loopback 
address
+                       Assume.assumeFalse(add.isLoopbackAddress());
+
+                       Socket socket = new Socket();
+
+                       SocketAddress socketAddress = new 
InetSocketAddress(add, 0);
+
+                       socket.bind(socketAddress);
+
+                       // check whether can bind to this address
+                       assertTrue(socket.isBound());
+
                        // 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);
-
                        // make sure that we returned the 
InetAddress.getLocalHost as a heuristic
                        assertEquals(InetAddress.getLocalHost(), add);
                }


 

----------------------------------------------------------------
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


> ConnectionUtilsTest.testReturnLocalHostAddressUsingHeuristics unstable on 
> Travis
> --------------------------------------------------------------------------------
>
>                 Key: FLINK-8623
>                 URL: https://issues.apache.org/jira/browse/FLINK-8623
>             Project: Flink
>          Issue Type: Bug
>          Components: Tests
>    Affects Versions: 1.5.0
>            Reporter: Till Rohrmann
>            Priority: Critical
>              Labels: test-stability
>
> {{ConnectionUtilsTest.testReturnLocalHostAddressUsingHeuristics}} fails on 
> Travis: https://travis-ci.org/apache/flink/jobs/339344442



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

Reply via email to