Skip to content

Commit

Permalink
[FLINK-10750][tests] Harden SocketClientSinkTest
Browse files Browse the repository at this point in the history
The tests attempts to re-bind a server to a specific port. If the port is taken the test will fail.
The test is now skipped instead if this happens.

This closes apache#7040.
  • Loading branch information
zentol authored and tillrohrmann committed Nov 7, 2018
1 parent 8d10698 commit dfe7be7
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
import org.apache.flink.util.TestLogger;

import org.apache.commons.io.IOUtils;
import org.junit.AssumptionViolatedException;
import org.junit.Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.BindException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -279,7 +281,12 @@ public Void call() throws Exception {
retryLatch.countDown();

// Restart the server
serverSocket[0] = new ServerSocket(port);
try {
serverSocket[0] = new ServerSocket(port);
} catch (BindException be) {
// some other process may be using this port now
throw new AssumptionViolatedException("Could not bind server to previous port.", be);
}
Socket socket = serverSocket[0].accept();

BufferedReader reader = new BufferedReader(new InputStreamReader(
Expand Down

0 comments on commit dfe7be7

Please sign in to comment.