This is an automated email from the ASF dual-hosted git repository.
onichols pushed a commit to branch support/1.14
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/support/1.14 by this push:
new 9099e1f GEODE-9877: Use ServerSocket to create interfering port
(#7180)
9099e1f is described below
commit 9099e1fe70b02886ec7d65d21d8b9c0e60b94677
Author: Jens Deppe <[email protected]>
AuthorDate: Thu Dec 9 12:25:13 2021 -0800
GEODE-9877: Use ServerSocket to create interfering port (#7180)
- For some unknown reason `startupFailsGivenPortAlreadyInUse` started to
fail after a seemingly innocuous Ubuntu base image bump. The problem
may also have been triggered by arbitrary test ordering changes since
the test did not fail on its own, but only in conjunction with running
other tests beforehand.
Specifically, the test was failing when binding the interfering port
(bind exception). The port used was always in the TIME_WAIT state left
from previous tests.
Using a `ServerSocket`, instead of a regular socket, fixes the problem
since it actually 'uses' the port and implicitly allows for port
reuse.
- Use ServerSocket consistently. Rename test to be more appropriate
(cherry picked from commit 310c647da6ee4cc4a1eadc6df174d998e69afb31)
---
.../internal/executor/GeodeRedisServerStartUpAcceptanceTest.java | 6 +++---
.../org/apache/geode/redis/GeodeRedisServerStartupDUnitTest.java | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git
a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/GeodeRedisServerStartUpAcceptanceTest.java
b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/GeodeRedisServerStartUpAcceptanceTest.java
index 385a5a7..7cb2659 100644
---
a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/GeodeRedisServerStartUpAcceptanceTest.java
+++
b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/GeodeRedisServerStartUpAcceptanceTest.java
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.net.Socket;
+import java.net.ServerSocket;
import org.junit.Rule;
import org.junit.Test;
@@ -47,7 +47,7 @@ public class GeodeRedisServerStartUpAcceptanceTest {
"--compatible-with-redis-port", String.valueOf(port));
GfshExecution execution;
- try (Socket interferingSocket = new Socket()) {
+ try (ServerSocket interferingSocket = new ServerSocket()) {
interferingSocket.bind(new InetSocketAddress("localhost", port));
execution = GfshScript.of(startServerCommand)
.expectFailure()
@@ -69,7 +69,7 @@ public class GeodeRedisServerStartUpAcceptanceTest {
"--compatible-with-redis-port", String.valueOf(port));
GfshExecution execution;
- try (Socket interferingSocket = new Socket()) {
+ try (ServerSocket interferingSocket = new ServerSocket()) {
interferingSocket.bind(new InetSocketAddress("0.0.0.0", port));
execution = GfshScript.of(startServerCommand)
.expectFailure()
diff --git
a/geode-apis-compatible-with-redis/src/distributedTest/java/org/apache/geode/redis/GeodeRedisServerStartupDUnitTest.java
b/geode-apis-compatible-with-redis/src/distributedTest/java/org/apache/geode/redis/GeodeRedisServerStartupDUnitTest.java
index 135bded..2cae34e 100644
---
a/geode-apis-compatible-with-redis/src/distributedTest/java/org/apache/geode/redis/GeodeRedisServerStartupDUnitTest.java
+++
b/geode-apis-compatible-with-redis/src/distributedTest/java/org/apache/geode/redis/GeodeRedisServerStartupDUnitTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.net.InetSocketAddress;
-import java.net.Socket;
+import java.net.ServerSocket;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -95,7 +95,7 @@ public class GeodeRedisServerStartupDUnitTest {
int port = AvailablePortHelper.getRandomAvailableTCPPort();
addIgnoredException("Could not start server compatible with Redis");
- try (Socket interferingSocket = new Socket()) {
+ try (ServerSocket interferingSocket = new ServerSocket()) {
interferingSocket.bind(new InetSocketAddress("localhost", port));
assertThatThrownBy(() -> cluster.startServerVM(0, s -> s
.withProperty(REDIS_PORT, "" + port)