diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestNMProxy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestNMProxy.java index 32ff5724c3..3498ebe40d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestNMProxy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestNMProxy.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.net.InetSocketAddress; +import java.net.SocketException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; @@ -28,6 +29,7 @@ import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.token.Token; +import org.apache.hadoop.test.LambdaTestUtils; import org.apache.hadoop.yarn.api.ContainerManagementProtocol; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; @@ -161,15 +163,10 @@ public void testNMProxyRPCRetry() throws Exception { IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_KEY, 100); // connect to some dummy address so that it can trigger // connection failure and RPC level retires. - newConf.set(YarnConfiguration.NM_ADDRESS, "0.0.0.0:1234"); + newConf.set(YarnConfiguration.NM_ADDRESS, "127.0.0.1:1"); ContainerManagementProtocol proxy = getNMProxy(newConf); - try { - proxy.startContainers(allRequests); - Assert.fail("should get socket exception"); - } catch (IOException e) { - // socket exception should be thrown immediately, without RPC retries. - Assert.assertTrue(e instanceof java.net.SocketException); - } + LambdaTestUtils.intercept(SocketException.class, + () -> proxy.startContainers(allRequests)); } private ContainerManagementProtocol getNMProxy(Configuration conf) {