|
26 | 26 | import static org.mockito.ArgumentMatchers.any; |
27 | 27 | import static org.mockito.ArgumentMatchers.anyBoolean; |
28 | 28 | import static org.mockito.Mockito.doAnswer; |
29 | | -import static org.mockito.Mockito.doNothing; |
30 | 29 | import static org.mockito.Mockito.doThrow; |
31 | 30 | import static org.mockito.Mockito.mock; |
32 | 31 | import static org.mockito.Mockito.spy; |
|
38 | 37 | import java.io.FileReader; |
39 | 38 | import java.io.IOException; |
40 | 39 | import java.io.LineNumberReader; |
41 | | -import java.lang.reflect.Field; |
42 | 40 | import java.net.InetSocketAddress; |
43 | 41 | import java.net.URI; |
44 | 42 | import java.net.URISyntaxException; |
@@ -347,8 +345,7 @@ public void testStartLocalizer() throws IOException { |
347 | 345 |
|
348 | 346 | @Test |
349 | 347 | public void testContainerLaunchError() |
350 | | - throws IOException, ContainerExecutionException, URISyntaxException, IllegalAccessException, |
351 | | - NoSuchFieldException { |
| 348 | + throws IOException, ContainerExecutionException, URISyntaxException { |
352 | 349 |
|
353 | 350 | final String[] expecetedMessage = {"badcommand", "Exit code: 24"}; |
354 | 351 | final String[] executor = { |
@@ -390,14 +387,6 @@ public Object answer(InvocationOnMock invocationOnMock) |
390 | 387 | dirsHandler.init(conf); |
391 | 388 | mockExec.setConf(conf); |
392 | 389 |
|
393 | | - //set the private nmContext field without initing the LinuxContainerExecutor |
394 | | - NodeManager nodeManager = new NodeManager(); |
395 | | - NodeManager.NMContext nmContext = |
396 | | - nodeManager.createNMContext(null, null, null, false, conf); |
397 | | - Field lceNmContext = LinuxContainerExecutor.class.getDeclaredField("nmContext"); |
398 | | - lceNmContext.setAccessible(true); |
399 | | - lceNmContext.set(mockExec, nmContext); |
400 | | - |
401 | 390 | String appSubmitter = "nobody"; |
402 | 391 | String cmd = String |
403 | 392 | .valueOf(PrivilegedOperation.RunAsUserCommand.LAUNCH_CONTAINER. |
@@ -612,30 +601,15 @@ public void testNoExitCodeFromPrivilegedOperation() throws Exception { |
612 | 601 | LinuxContainerRuntime runtime = new DefaultLinuxContainerRuntime( |
613 | 602 | spyPrivilegedExecutor); |
614 | 603 | runtime.initialize(conf, null); |
| 604 | + mockExec = new LinuxContainerExecutor(runtime); |
| 605 | + mockExec.setConf(conf); |
615 | 606 | LinuxContainerExecutor lce = new LinuxContainerExecutor(runtime) { |
616 | 607 | @Override |
617 | 608 | protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() { |
618 | 609 | return spyPrivilegedExecutor; |
619 | 610 | } |
620 | 611 | }; |
621 | 612 | lce.setConf(conf); |
622 | | - |
623 | | - //set the private nmContext field without initing the LinuxContainerExecutor |
624 | | - NodeManager nodeManager = new NodeManager(); |
625 | | - NodeManager.NMContext nmContext = |
626 | | - nodeManager.createNMContext(null, null, null, false, conf); |
627 | | - NodeManager.NMContext spyNmContext = spy(nmContext); |
628 | | - |
629 | | - //initialize a mock NodeStatusUpdater |
630 | | - NodeStatusUpdaterImpl nodeStatusUpdater = mock(NodeStatusUpdaterImpl.class); |
631 | | - nmContext.setNodeStatusUpdater(nodeStatusUpdater); |
632 | | - //imitate a void method call on the NodeStatusUpdater when setting NM unhealthy. |
633 | | - doNothing().when(nodeStatusUpdater).reportException(any()); |
634 | | - |
635 | | - Field lceNmContext = LinuxContainerExecutor.class.getDeclaredField("nmContext"); |
636 | | - lceNmContext.setAccessible(true); |
637 | | - lceNmContext.set(lce, nmContext); |
638 | | - |
639 | 613 | InetSocketAddress address = InetSocketAddress.createUnresolved( |
640 | 614 | "localhost", 8040); |
641 | 615 | Path nmPrivateCTokensPath= new Path("file:///bin/nmPrivateCTokensPath"); |
@@ -698,9 +672,6 @@ protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() { |
698 | 672 | assertTrue("Unexpected exception " + e, |
699 | 673 | e.getMessage().contains("exit code")); |
700 | 674 | } |
701 | | - |
702 | | - //verify that the NM was set unhealthy on PrivilegedOperationException |
703 | | - verify(nodeStatusUpdater, times(1)).reportException(any()); |
704 | 675 | } |
705 | 676 |
|
706 | 677 | @Test |
|
0 commit comments