YARN-10455. TestNMProxy.testNMProxyRPCRetry is not consistent. Contributed by Ahmed Hussein

This commit is contained in:
Jim Brennan 2020-10-08 18:46:47 +00:00
parent f83e07a20f
commit deb35a32ba

View File

@ -20,6 +20,7 @@
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketException;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
@ -28,6 +29,7 @@
import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token; 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.ContainerManagementProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; 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); IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_KEY, 100);
// connect to some dummy address so that it can trigger // connect to some dummy address so that it can trigger
// connection failure and RPC level retires. // 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); ContainerManagementProtocol proxy = getNMProxy(newConf);
try { LambdaTestUtils.intercept(SocketException.class,
proxy.startContainers(allRequests); () -> 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);
}
} }
private ContainerManagementProtocol getNMProxy(Configuration conf) { private ContainerManagementProtocol getNMProxy(Configuration conf) {