You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by pn...@apache.org on 2023/01/27 09:15:03 UTC
[flink] 02/03: [FLINK-26082][runtime] Refactor ServerTransportErrorHandlingTest and ClientTransportErrorHandlingTest according to `initServerAndClient` method changes.
This is an automated email from the ASF dual-hosted git repository.
pnowojski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 399bcef57db394d57e188cc646c95f2b1d3a4890
Author: Anton Kalashnikov <ak...@gmail.com>
AuthorDate: Wed Jan 25 17:19:09 2023 +0100
[FLINK-26082][runtime] Refactor ServerTransportErrorHandlingTest and ClientTransportErrorHandlingTest according to `initServerAndClient` method changes.
---
.../netty/ClientTransportErrorHandlingTest.java | 5 ++---
.../netty/ServerTransportErrorHandlingTest.java | 26 +---------------------
2 files changed, 3 insertions(+), 28 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/ClientTransportErrorHandlingTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/ClientTransportErrorHandlingTest.java
index fae2163c97e..c8ae23cac08 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/ClientTransportErrorHandlingTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/ClientTransportErrorHandlingTest.java
@@ -51,7 +51,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static org.apache.flink.runtime.io.network.netty.NettyTestUtil.connect;
-import static org.apache.flink.runtime.io.network.netty.NettyTestUtil.createConfig;
import static org.apache.flink.runtime.io.network.netty.NettyTestUtil.initServerAndClient;
import static org.apache.flink.runtime.io.network.netty.NettyTestUtil.shutdown;
import static org.assertj.core.api.Assertions.assertThat;
@@ -89,7 +88,7 @@ class ClientTransportErrorHandlingTest {
// We need a real server and client in this test, because Netty's EmbeddedChannel is
// not failing the ChannelPromise of failed writes.
- NettyServerAndClient serverAndClient = initServerAndClient(protocol, createConfig());
+ NettyServerAndClient serverAndClient = initServerAndClient(protocol);
Channel ch = connect(serverAndClient);
@@ -238,7 +237,7 @@ class ClientTransportErrorHandlingTest {
}
};
- NettyServerAndClient serverAndClient = initServerAndClient(protocol, createConfig());
+ NettyServerAndClient serverAndClient = initServerAndClient(protocol);
Channel ch = connect(serverAndClient);
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/ServerTransportErrorHandlingTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/ServerTransportErrorHandlingTest.java
index b922eee236d..55985168ac7 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/ServerTransportErrorHandlingTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/ServerTransportErrorHandlingTest.java
@@ -26,7 +26,6 @@ import org.apache.flink.runtime.io.network.partition.ResultSubpartitionView;
import org.apache.flink.runtime.io.network.partition.consumer.InputChannelID;
import org.apache.flink.runtime.io.network.util.TestPooledBufferProvider;
import org.apache.flink.testutils.TestingUtils;
-import org.apache.flink.util.ExceptionUtils;
import org.apache.flink.shaded.netty4.io.netty.channel.Channel;
import org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler;
@@ -37,12 +36,10 @@ import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import java.net.BindException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static org.apache.flink.runtime.io.network.netty.NettyTestUtil.connect;
-import static org.apache.flink.runtime.io.network.netty.NettyTestUtil.createConfig;
import static org.apache.flink.runtime.io.network.netty.NettyTestUtil.initServerAndClient;
import static org.apache.flink.runtime.io.network.netty.NettyTestUtil.shutdown;
import static org.junit.Assert.fail;
@@ -52,7 +49,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ServerTransportErrorHandlingTest {
- private static final int NETTY_INIT_MAX_RETRY_TIMES = 20;
/** Verifies remote closes trigger the release of all resources. */
@Test
@@ -104,27 +100,7 @@ public class ServerTransportErrorHandlingTest {
NettyTestUtil.NettyServerAndClient serverAndClient = null;
try {
- for (int retry = 0; retry < NETTY_INIT_MAX_RETRY_TIMES; retry++) {
- try {
- serverAndClient = initServerAndClient(protocol, createConfig());
- break;
- } catch (Exception e) {
- if (retry >= NETTY_INIT_MAX_RETRY_TIMES - 1) {
- throw new RuntimeException(
- "Failed to initialize netty server and client, retried "
- + retry
- + " times.",
- e);
- }
- if (e instanceof BindException
- || ExceptionUtils.findThrowableWithMessage(e, "Address already in use")
- .isPresent()) {
- continue;
- }
- throw e;
- }
- }
-
+ serverAndClient = initServerAndClient(protocol);
Channel ch = connect(serverAndClient);
// Write something to trigger close by server