You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by aa...@apache.org on 2022/10/06 14:13:48 UTC

[hadoop] branch trunk updated: YARN-11187. Remove WhiteBox in yarn module. (#4463)

This is an automated email from the ASF dual-hosted git repository.

aajisaka pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new b31b3ea0f6c YARN-11187. Remove WhiteBox in yarn module. (#4463)
b31b3ea0f6c is described below

commit b31b3ea0f6c155343b506ed90562a86758883668
Author: slfan1989 <55...@users.noreply.github.com>
AuthorDate: Thu Oct 6 22:13:33 2022 +0800

    YARN-11187. Remove WhiteBox in yarn module. (#4463)
    
    Signed-off-by: Akira Ajisaka <aa...@apache.org>
---
 .../launcher/TestContainersLauncher.java           | 63 ++++++++--------------
 1 file changed, 22 insertions(+), 41 deletions(-)

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/launcher/TestContainersLauncher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainersLauncher.java
index f48d7855695..d1b16507317 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainersLauncher.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainersLauncher.java
@@ -18,7 +18,6 @@
 package org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher;
 
 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.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
@@ -40,8 +39,6 @@ import org.mockito.MockitoAnnotations;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -123,10 +120,8 @@ public class TestContainersLauncher {
   @SuppressWarnings("unchecked")
   @Test
   public void testLaunchContainerEvent()
-      throws IllegalArgumentException, IllegalAccessException {
-    Map<ContainerId, ContainerLaunch> dummyMap =
-        (Map<ContainerId, ContainerLaunch>) Whitebox.getInternalState(spy,
-            "running");
+      throws IllegalArgumentException {
+    Map<ContainerId, ContainerLaunch> dummyMap = spy.running;
     when(event.getType())
         .thenReturn(ContainersLauncherEventType.LAUNCH_CONTAINER);
     assertEquals(0, dummyMap.size());
@@ -139,10 +134,8 @@ public class TestContainersLauncher {
   @SuppressWarnings("unchecked")
   @Test
   public void testRelaunchContainerEvent()
-      throws IllegalArgumentException, IllegalAccessException {
-    Map<ContainerId, ContainerLaunch> dummyMap =
-        (Map<ContainerId, ContainerLaunch>) Whitebox.getInternalState(spy,
-            "running");
+      throws IllegalArgumentException {
+    Map<ContainerId, ContainerLaunch> dummyMap = spy.running;
     when(event.getType())
         .thenReturn(ContainersLauncherEventType.RELAUNCH_CONTAINER);
     assertEquals(0, dummyMap.size());
@@ -159,10 +152,8 @@ public class TestContainersLauncher {
   @SuppressWarnings("unchecked")
   @Test
   public void testRecoverContainerEvent()
-      throws IllegalArgumentException, IllegalAccessException {
-    Map<ContainerId, ContainerLaunch> dummyMap =
-        (Map<ContainerId, ContainerLaunch>) Whitebox.getInternalState(spy,
-            "running");
+      throws IllegalArgumentException {
+    Map<ContainerId, ContainerLaunch> dummyMap = spy.running;
     when(event.getType())
         .thenReturn(ContainersLauncherEventType.RECOVER_CONTAINER);
     assertEquals(0, dummyMap.size());
@@ -178,7 +169,7 @@ public class TestContainersLauncher {
 
   @Test
   public void testRecoverPausedContainerEvent()
-      throws IllegalArgumentException, IllegalAccessException {
+      throws IllegalArgumentException {
     when(event.getType())
         .thenReturn(ContainersLauncherEventType.RECOVER_PAUSED_CONTAINER);
     spy.handle(event);
@@ -189,16 +180,14 @@ public class TestContainersLauncher {
   @Test
   public void testCleanupContainerEvent()
       throws IllegalArgumentException, IllegalAccessException, IOException {
-    Map<ContainerId, ContainerLaunch> dummyMap = Collections
-        .synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
-    dummyMap.put(containerId, containerLaunch);
-    Whitebox.setInternalState(spy, "running", dummyMap);
+    spy.running.clear();
+    spy.running.put(containerId, containerLaunch);
 
     when(event.getType())
         .thenReturn(ContainersLauncherEventType.CLEANUP_CONTAINER);
-    assertEquals(1, dummyMap.size());
+    assertEquals(1, spy.running.size());
     spy.handle(event);
-    assertEquals(0, dummyMap.size());
+    assertEquals(0, spy.running.size());
     Mockito.verify(containerLauncher, Mockito.times(1))
         .submit(Mockito.any(ContainerCleanup.class));
   }
@@ -206,10 +195,8 @@ public class TestContainersLauncher {
   @Test
   public void testCleanupContainerForReINITEvent()
       throws IllegalArgumentException, IllegalAccessException, IOException {
-    Map<ContainerId, ContainerLaunch> dummyMap = Collections
-        .synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
-    dummyMap.put(containerId, containerLaunch);
-    Whitebox.setInternalState(spy, "running", dummyMap);
+    spy.running.clear();
+    spy.running.put(containerId, containerLaunch);
 
     when(event.getType())
         .thenReturn(ContainersLauncherEventType.CLEANUP_CONTAINER_FOR_REINIT);
@@ -226,9 +213,6 @@ public class TestContainersLauncher {
   @Test
   public void testSignalContainerEvent()
       throws IllegalArgumentException, IllegalAccessException, IOException {
-    Map<ContainerId, ContainerLaunch> dummyMap = Collections
-        .synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
-    dummyMap.put(containerId, containerLaunch);
 
     SignalContainersLauncherEvent dummyEvent =
         mock(SignalContainersLauncherEvent.class);
@@ -238,7 +222,8 @@ public class TestContainersLauncher {
     when(containerId.getApplicationAttemptId().getApplicationId())
         .thenReturn(appId);
 
-    Whitebox.setInternalState(spy, "running", dummyMap);
+    spy.running.clear();
+    spy.running.put(containerId, containerLaunch);
     when(dummyEvent.getType())
         .thenReturn(ContainersLauncherEventType.SIGNAL_CONTAINER);
     when(dummyEvent.getCommand())
@@ -246,7 +231,7 @@ public class TestContainersLauncher {
     doNothing().when(containerLaunch)
         .signalContainer(SignalContainerCommand.GRACEFUL_SHUTDOWN);
     spy.handle(dummyEvent);
-    assertEquals(1, dummyMap.size());
+    assertEquals(1, spy.running.size());
     Mockito.verify(containerLaunch, Mockito.times(1))
         .signalContainer(SignalContainerCommand.GRACEFUL_SHUTDOWN);
   }
@@ -254,30 +239,26 @@ public class TestContainersLauncher {
   @Test
   public void testPauseContainerEvent()
       throws IllegalArgumentException, IllegalAccessException, IOException {
-    Map<ContainerId, ContainerLaunch> dummyMap = Collections
-        .synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
-    dummyMap.put(containerId, containerLaunch);
-    Whitebox.setInternalState(spy, "running", dummyMap);
+    spy.running.clear();
+    spy.running.put(containerId, containerLaunch);
     when(event.getType())
         .thenReturn(ContainersLauncherEventType.PAUSE_CONTAINER);
     doNothing().when(containerLaunch).pauseContainer();
     spy.handle(event);
-    assertEquals(1, dummyMap.size());
+    assertEquals(1, spy.running.size());
     Mockito.verify(containerLaunch, Mockito.times(1)).pauseContainer();
   }
 
   @Test
   public void testResumeContainerEvent()
       throws IllegalArgumentException, IllegalAccessException, IOException {
-    Map<ContainerId, ContainerLaunch> dummyMap = Collections
-        .synchronizedMap(new HashMap<ContainerId, ContainerLaunch>());
-    dummyMap.put(containerId, containerLaunch);
-    Whitebox.setInternalState(spy, "running", dummyMap);
+    spy.running.clear();
+    spy.running.put(containerId, containerLaunch);
     when(event.getType())
         .thenReturn(ContainersLauncherEventType.RESUME_CONTAINER);
     doNothing().when(containerLaunch).resumeContainer();
     spy.handle(event);
-    assertEquals(1, dummyMap.size());
+    assertEquals(1, spy.running.size());
     Mockito.verify(containerLaunch, Mockito.times(1)).resumeContainer();
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org