|
@@ -26,7 +26,6 @@ import static org.junit.Assert.assertTrue;
|
|
|
import static org.mockito.ArgumentMatchers.any;
|
|
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
|
|
import static org.mockito.Mockito.doAnswer;
|
|
|
-import static org.mockito.Mockito.doNothing;
|
|
|
import static org.mockito.Mockito.doThrow;
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
import static org.mockito.Mockito.spy;
|
|
@@ -38,7 +37,6 @@ import java.io.File;
|
|
|
import java.io.FileReader;
|
|
|
import java.io.IOException;
|
|
|
import java.io.LineNumberReader;
|
|
|
-import java.lang.reflect.Field;
|
|
|
import java.net.InetSocketAddress;
|
|
|
import java.net.URI;
|
|
|
import java.net.URISyntaxException;
|
|
@@ -347,8 +345,7 @@ public class TestLinuxContainerExecutorWithMocks {
|
|
|
|
|
|
@Test
|
|
|
public void testContainerLaunchError()
|
|
|
- throws IOException, ContainerExecutionException, URISyntaxException, IllegalAccessException,
|
|
|
- NoSuchFieldException {
|
|
|
+ throws IOException, ContainerExecutionException, URISyntaxException {
|
|
|
|
|
|
final String[] expecetedMessage = {"badcommand", "Exit code: 24"};
|
|
|
final String[] executor = {
|
|
@@ -390,14 +387,6 @@ public class TestLinuxContainerExecutorWithMocks {
|
|
|
dirsHandler.init(conf);
|
|
|
mockExec.setConf(conf);
|
|
|
|
|
|
- //set the private nmContext field without initing the LinuxContainerExecutor
|
|
|
- NodeManager nodeManager = new NodeManager();
|
|
|
- NodeManager.NMContext nmContext =
|
|
|
- nodeManager.createNMContext(null, null, null, false, conf);
|
|
|
- Field lceNmContext = LinuxContainerExecutor.class.getDeclaredField("nmContext");
|
|
|
- lceNmContext.setAccessible(true);
|
|
|
- lceNmContext.set(mockExec, nmContext);
|
|
|
-
|
|
|
String appSubmitter = "nobody";
|
|
|
String cmd = String
|
|
|
.valueOf(PrivilegedOperation.RunAsUserCommand.LAUNCH_CONTAINER.
|
|
@@ -612,6 +601,8 @@ public class TestLinuxContainerExecutorWithMocks {
|
|
|
LinuxContainerRuntime runtime = new DefaultLinuxContainerRuntime(
|
|
|
spyPrivilegedExecutor);
|
|
|
runtime.initialize(conf, null);
|
|
|
+ mockExec = new LinuxContainerExecutor(runtime);
|
|
|
+ mockExec.setConf(conf);
|
|
|
LinuxContainerExecutor lce = new LinuxContainerExecutor(runtime) {
|
|
|
@Override
|
|
|
protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() {
|
|
@@ -619,23 +610,6 @@ public class TestLinuxContainerExecutorWithMocks {
|
|
|
}
|
|
|
};
|
|
|
lce.setConf(conf);
|
|
|
-
|
|
|
- //set the private nmContext field without initing the LinuxContainerExecutor
|
|
|
- NodeManager nodeManager = new NodeManager();
|
|
|
- NodeManager.NMContext nmContext =
|
|
|
- nodeManager.createNMContext(null, null, null, false, conf);
|
|
|
- NodeManager.NMContext spyNmContext = spy(nmContext);
|
|
|
-
|
|
|
- //initialize a mock NodeStatusUpdater
|
|
|
- NodeStatusUpdaterImpl nodeStatusUpdater = mock(NodeStatusUpdaterImpl.class);
|
|
|
- nmContext.setNodeStatusUpdater(nodeStatusUpdater);
|
|
|
- //imitate a void method call on the NodeStatusUpdater when setting NM unhealthy.
|
|
|
- doNothing().when(nodeStatusUpdater).reportException(any());
|
|
|
-
|
|
|
- Field lceNmContext = LinuxContainerExecutor.class.getDeclaredField("nmContext");
|
|
|
- lceNmContext.setAccessible(true);
|
|
|
- lceNmContext.set(lce, nmContext);
|
|
|
-
|
|
|
InetSocketAddress address = InetSocketAddress.createUnresolved(
|
|
|
"localhost", 8040);
|
|
|
Path nmPrivateCTokensPath= new Path("file:///bin/nmPrivateCTokensPath");
|
|
@@ -698,9 +672,6 @@ public class TestLinuxContainerExecutorWithMocks {
|
|
|
assertTrue("Unexpected exception " + e,
|
|
|
e.getMessage().contains("exit code"));
|
|
|
}
|
|
|
-
|
|
|
- //verify that the NM was set unhealthy on PrivilegedOperationException
|
|
|
- verify(nodeStatusUpdater, times(1)).reportException(any());
|
|
|
}
|
|
|
|
|
|
@Test
|