YARN-11187. Remove WhiteBox in yarn module. (#4463)
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
parent
7ec762a5fd
commit
b31b3ea0f6
@ -18,7 +18,6 @@
|
|||||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher;
|
package org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.test.Whitebox;
|
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
import org.apache.hadoop.yarn.api.records.ContainerId;
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
||||||
@ -40,8 +39,6 @@
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -123,10 +120,8 @@ public void setup() throws IllegalArgumentException, IllegalAccessException {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testLaunchContainerEvent()
|
public void testLaunchContainerEvent()
|
||||||
throws IllegalArgumentException, IllegalAccessException {
|
throws IllegalArgumentException {
|
||||||
Map<ContainerId, ContainerLaunch> dummyMap =
|
Map<ContainerId, ContainerLaunch> dummyMap = spy.running;
|
||||||
(Map<ContainerId, ContainerLaunch>) Whitebox.getInternalState(spy,
|
|
||||||
"running");
|
|
||||||
when(event.getType())
|
when(event.getType())
|
||||||
.thenReturn(ContainersLauncherEventType.LAUNCH_CONTAINER);
|
.thenReturn(ContainersLauncherEventType.LAUNCH_CONTAINER);
|
||||||
assertEquals(0, dummyMap.size());
|
assertEquals(0, dummyMap.size());
|
||||||
@ -139,10 +134,8 @@ public void testLaunchContainerEvent()
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testRelaunchContainerEvent()
|
public void testRelaunchContainerEvent()
|
||||||
throws IllegalArgumentException, IllegalAccessException {
|
throws IllegalArgumentException {
|
||||||
Map<ContainerId, ContainerLaunch> dummyMap =
|
Map<ContainerId, ContainerLaunch> dummyMap = spy.running;
|
||||||
(Map<ContainerId, ContainerLaunch>) Whitebox.getInternalState(spy,
|
|
||||||
"running");
|
|
||||||
when(event.getType())
|
when(event.getType())
|
||||||
.thenReturn(ContainersLauncherEventType.RELAUNCH_CONTAINER);
|
.thenReturn(ContainersLauncherEventType.RELAUNCH_CONTAINER);
|
||||||
assertEquals(0, dummyMap.size());
|
assertEquals(0, dummyMap.size());
|
||||||
@ -159,10 +152,8 @@ public void testRelaunchContainerEvent()
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testRecoverContainerEvent()
|
public void testRecoverContainerEvent()
|
||||||
throws IllegalArgumentException, IllegalAccessException {
|
throws IllegalArgumentException {
|
||||||
Map<ContainerId, ContainerLaunch> dummyMap =
|
Map<ContainerId, ContainerLaunch> dummyMap = spy.running;
|
||||||
(Map<ContainerId, ContainerLaunch>) Whitebox.getInternalState(spy,
|
|
||||||
"running");
|
|
||||||
when(event.getType())
|
when(event.getType())
|
||||||
.thenReturn(ContainersLauncherEventType.RECOVER_CONTAINER);
|
.thenReturn(ContainersLauncherEventType.RECOVER_CONTAINER);
|
||||||
assertEquals(0, dummyMap.size());
|
assertEquals(0, dummyMap.size());
|
||||||
@ -178,7 +169,7 @@ public void testRecoverContainerEvent()
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRecoverPausedContainerEvent()
|
public void testRecoverPausedContainerEvent()
|
||||||
throws IllegalArgumentException, IllegalAccessException {
|
throws IllegalArgumentException {
|
||||||
when(event.getType())
|
when(event.getType())
|
||||||
.thenReturn(ContainersLauncherEventType.RECOVER_PAUSED_CONTAINER);
|
.thenReturn(ContainersLauncherEventType.RECOVER_PAUSED_CONTAINER);
|
||||||
spy.handle(event);
|
spy.handle(event);
|
||||||
@ -189,16 +180,14 @@ public void testRecoverPausedContainerEvent()
|
|||||||
@Test
|
@Test
|
||||||
public void testCleanupContainerEvent()
|
public void testCleanupContainerEvent()
|
||||||
throws IllegalArgumentException, IllegalAccessException, IOException {
|
throws IllegalArgumentException, IllegalAccessException, IOException {
|
||||||
Map<ContainerId, ContainerLaunch> dummyMap = Collections
|
spy.running.clear();
|
||||||
.synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
|
spy.running.put(containerId, containerLaunch);
|
||||||
dummyMap.put(containerId, containerLaunch);
|
|
||||||
Whitebox.setInternalState(spy, "running", dummyMap);
|
|
||||||
|
|
||||||
when(event.getType())
|
when(event.getType())
|
||||||
.thenReturn(ContainersLauncherEventType.CLEANUP_CONTAINER);
|
.thenReturn(ContainersLauncherEventType.CLEANUP_CONTAINER);
|
||||||
assertEquals(1, dummyMap.size());
|
assertEquals(1, spy.running.size());
|
||||||
spy.handle(event);
|
spy.handle(event);
|
||||||
assertEquals(0, dummyMap.size());
|
assertEquals(0, spy.running.size());
|
||||||
Mockito.verify(containerLauncher, Mockito.times(1))
|
Mockito.verify(containerLauncher, Mockito.times(1))
|
||||||
.submit(Mockito.any(ContainerCleanup.class));
|
.submit(Mockito.any(ContainerCleanup.class));
|
||||||
}
|
}
|
||||||
@ -206,10 +195,8 @@ public void testCleanupContainerEvent()
|
|||||||
@Test
|
@Test
|
||||||
public void testCleanupContainerForReINITEvent()
|
public void testCleanupContainerForReINITEvent()
|
||||||
throws IllegalArgumentException, IllegalAccessException, IOException {
|
throws IllegalArgumentException, IllegalAccessException, IOException {
|
||||||
Map<ContainerId, ContainerLaunch> dummyMap = Collections
|
spy.running.clear();
|
||||||
.synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
|
spy.running.put(containerId, containerLaunch);
|
||||||
dummyMap.put(containerId, containerLaunch);
|
|
||||||
Whitebox.setInternalState(spy, "running", dummyMap);
|
|
||||||
|
|
||||||
when(event.getType())
|
when(event.getType())
|
||||||
.thenReturn(ContainersLauncherEventType.CLEANUP_CONTAINER_FOR_REINIT);
|
.thenReturn(ContainersLauncherEventType.CLEANUP_CONTAINER_FOR_REINIT);
|
||||||
@ -226,9 +213,6 @@ public void testCleanupContainerForReINITEvent()
|
|||||||
@Test
|
@Test
|
||||||
public void testSignalContainerEvent()
|
public void testSignalContainerEvent()
|
||||||
throws IllegalArgumentException, IllegalAccessException, IOException {
|
throws IllegalArgumentException, IllegalAccessException, IOException {
|
||||||
Map<ContainerId, ContainerLaunch> dummyMap = Collections
|
|
||||||
.synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
|
|
||||||
dummyMap.put(containerId, containerLaunch);
|
|
||||||
|
|
||||||
SignalContainersLauncherEvent dummyEvent =
|
SignalContainersLauncherEvent dummyEvent =
|
||||||
mock(SignalContainersLauncherEvent.class);
|
mock(SignalContainersLauncherEvent.class);
|
||||||
@ -238,7 +222,8 @@ public void testSignalContainerEvent()
|
|||||||
when(containerId.getApplicationAttemptId().getApplicationId())
|
when(containerId.getApplicationAttemptId().getApplicationId())
|
||||||
.thenReturn(appId);
|
.thenReturn(appId);
|
||||||
|
|
||||||
Whitebox.setInternalState(spy, "running", dummyMap);
|
spy.running.clear();
|
||||||
|
spy.running.put(containerId, containerLaunch);
|
||||||
when(dummyEvent.getType())
|
when(dummyEvent.getType())
|
||||||
.thenReturn(ContainersLauncherEventType.SIGNAL_CONTAINER);
|
.thenReturn(ContainersLauncherEventType.SIGNAL_CONTAINER);
|
||||||
when(dummyEvent.getCommand())
|
when(dummyEvent.getCommand())
|
||||||
@ -246,7 +231,7 @@ public void testSignalContainerEvent()
|
|||||||
doNothing().when(containerLaunch)
|
doNothing().when(containerLaunch)
|
||||||
.signalContainer(SignalContainerCommand.GRACEFUL_SHUTDOWN);
|
.signalContainer(SignalContainerCommand.GRACEFUL_SHUTDOWN);
|
||||||
spy.handle(dummyEvent);
|
spy.handle(dummyEvent);
|
||||||
assertEquals(1, dummyMap.size());
|
assertEquals(1, spy.running.size());
|
||||||
Mockito.verify(containerLaunch, Mockito.times(1))
|
Mockito.verify(containerLaunch, Mockito.times(1))
|
||||||
.signalContainer(SignalContainerCommand.GRACEFUL_SHUTDOWN);
|
.signalContainer(SignalContainerCommand.GRACEFUL_SHUTDOWN);
|
||||||
}
|
}
|
||||||
@ -254,30 +239,26 @@ public void testSignalContainerEvent()
|
|||||||
@Test
|
@Test
|
||||||
public void testPauseContainerEvent()
|
public void testPauseContainerEvent()
|
||||||
throws IllegalArgumentException, IllegalAccessException, IOException {
|
throws IllegalArgumentException, IllegalAccessException, IOException {
|
||||||
Map<ContainerId, ContainerLaunch> dummyMap = Collections
|
spy.running.clear();
|
||||||
.synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
|
spy.running.put(containerId, containerLaunch);
|
||||||
dummyMap.put(containerId, containerLaunch);
|
|
||||||
Whitebox.setInternalState(spy, "running", dummyMap);
|
|
||||||
when(event.getType())
|
when(event.getType())
|
||||||
.thenReturn(ContainersLauncherEventType.PAUSE_CONTAINER);
|
.thenReturn(ContainersLauncherEventType.PAUSE_CONTAINER);
|
||||||
doNothing().when(containerLaunch).pauseContainer();
|
doNothing().when(containerLaunch).pauseContainer();
|
||||||
spy.handle(event);
|
spy.handle(event);
|
||||||
assertEquals(1, dummyMap.size());
|
assertEquals(1, spy.running.size());
|
||||||
Mockito.verify(containerLaunch, Mockito.times(1)).pauseContainer();
|
Mockito.verify(containerLaunch, Mockito.times(1)).pauseContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResumeContainerEvent()
|
public void testResumeContainerEvent()
|
||||||
throws IllegalArgumentException, IllegalAccessException, IOException {
|
throws IllegalArgumentException, IllegalAccessException, IOException {
|
||||||
Map<ContainerId, ContainerLaunch> dummyMap = Collections
|
spy.running.clear();
|
||||||
.synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
|
spy.running.put(containerId, containerLaunch);
|
||||||
dummyMap.put(containerId, containerLaunch);
|
|
||||||
Whitebox.setInternalState(spy, "running", dummyMap);
|
|
||||||
when(event.getType())
|
when(event.getType())
|
||||||
.thenReturn(ContainersLauncherEventType.RESUME_CONTAINER);
|
.thenReturn(ContainersLauncherEventType.RESUME_CONTAINER);
|
||||||
doNothing().when(containerLaunch).resumeContainer();
|
doNothing().when(containerLaunch).resumeContainer();
|
||||||
spy.handle(event);
|
spy.handle(event);
|
||||||
assertEquals(1, dummyMap.size());
|
assertEquals(1, spy.running.size());
|
||||||
Mockito.verify(containerLaunch, Mockito.times(1)).resumeContainer();
|
Mockito.verify(containerLaunch, Mockito.times(1)).resumeContainer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user