浏览代码

YARN-11262. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-server-resourcemanager Part3. (#7485)

YARN-11262. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-server-resourcemanager Part3.

Co-authored-by: Chris Nauroth <cnauroth@apache.org>
Co-authored-by: Hualong Zhang <hualong.z@hotmail.com>
Reviewed-by: Chris Nauroth <cnauroth@apache.org>
Reviewed-by: Hualong Zhang <hualong.z@hotmail.com>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
slfan1989 3 月之前
父节点
当前提交
6e844030c9
共有 88 个文件被更改,包括 4109 次插入3729 次删除
  1. 5 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml
  2. 2 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ACLsTestBase.java
  3. 3 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java
  4. 60 53
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/TestActivitiesManager.java
  5. 9 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerPreemptionTestBase.java
  6. 2 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueCalculationTestBase.java
  7. 8 9
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueHelpers.java
  8. 6 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerTestUtilities.java
  9. 8 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/QueueAssertionBuilder.java
  10. 6 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAMAllocatedToNonExclusivePartition.java
  11. 357 271
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAbsoluteResourceConfiguration.java
  12. 25 20
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAbsoluteResourceWithAutoQueue.java
  13. 18 17
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationLimits.java
  14. 87 84
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationLimitsByPartition.java
  15. 73 69
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriority.java
  16. 6 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriorityACLConfiguration.java
  17. 8 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriorityACLs.java
  18. 41 38
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAutoCreatedQueueDeletionPolicy.java
  19. 46 44
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAutoCreatedQueueTemplate.java
  20. 22 28
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCSAllocateCustomResource.java
  21. 4 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCSMaxRunningAppsEnforcer.java
  22. 10 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCSQueueStore.java
  23. 214 208
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java
  24. 1 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAmbiguousLeafs.java
  25. 144 139
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerApps.java
  26. 106 82
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAsyncScheduling.java
  27. 9 10
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAutoCreatedQueueBase.java
  28. 8 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAutoCreatedQueuePreemption.java
  29. 48 49
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAutoQueueCreation.java
  30. 115 109
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerConfigValidator.java
  31. 4 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerConfiguration.java
  32. 10 12
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerDynamicBehavior.java
  33. 66 59
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerLazyPreemption.java
  34. 28 21
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerMaxParallelApps.java
  35. 59 51
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerMultiNodes.java
  36. 20 17
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerMultiNodesWithPreemption.java
  37. 236 232
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNewQueueAutoCreation.java
  38. 51 50
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNewQueueAutoCreationWithCapacityVectors.java
  39. 69 62
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNodeLabelUpdate.java
  40. 43 41
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNodes.java
  41. 17 11
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerPerf.java
  42. 4 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerQueueACLs.java
  43. 18 18
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerQueueMappingFactory.java
  44. 216 224
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerQueues.java
  45. 1 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerSchedulingRequestUpdate.java
  46. 73 66
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerSurgicalPreemption.java
  47. 40 29
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerWeightMode.java
  48. 38 36
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerWithMultiResourceTypes.java
  49. 4 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerWorkflowPriorityMapping.java
  50. 6 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestChildQueueOrder.java
  51. 45 43
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestConfigurationProperties.java
  52. 142 126
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java
  53. 113 106
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java
  54. 42 41
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestIncreaseAllocationExpirer.java
  55. 78 79
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java
  56. 16 12
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestMixedQueueResourceCalculation.java
  57. 186 177
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestNodeLabelContainerAllocation.java
  58. 72 68
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java
  59. 19 18
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueCapacities.java
  60. 23 21
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueCapacityVector.java
  61. 20 16
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueConfigurationAutoRefreshPolicy.java
  62. 4 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueManagementDynamicEditPolicy.java
  63. 23 19
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueMappings.java
  64. 204 184
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueParsing.java
  65. 56 50
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueuePath.java
  66. 42 36
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueState.java
  67. 27 25
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueStateManager.java
  68. 8 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservationQueue.java
  69. 22 23
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java
  70. 28 27
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestResourceVector.java
  71. 132 100
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestSchedulingRequestContainerAllocation.java
  72. 42 25
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestSchedulingRequestContainerAllocationAsync.java
  73. 1 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestUniformQueueResourceCalculation.java
  74. 10 11
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestUsersManager.java
  75. 14 11
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestWorkPreservingRMRestartForNodeLabel.java
  76. 7 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/ConfigurationStoreBaseTest.java
  77. 6 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/PersistentConfigurationStoreBaseTest.java
  78. 7 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestConfigurationUpdateAssembler.java
  79. 17 19
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestFSSchedulerConfigurationStore.java
  80. 2 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestInMemoryConfigurationStore.java
  81. 20 21
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestLeveldbConfigurationStore.java
  82. 8 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java
  83. 41 40
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestQueueCapacityConfigParser.java
  84. 95 86
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestZKConfigurationStore.java
  85. 67 52
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/placement/TestMappingRuleCreator.java
  86. 10 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/placement/converter/TestLegacyMappingRuleToJson.java
  87. 3 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/policy/TestPriorityUtilizationQueueOrderingPolicy.java
  88. 3 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/queuemanagement/TestDeactivatedLeafQueuesByLabel.java

+ 5 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml

@@ -271,7 +271,11 @@
       <groupId>org.glassfish.jersey.media</groupId>
       <groupId>org.glassfish.jersey.media</groupId>
       <artifactId>jersey-media-json-jettison</artifactId>
       <artifactId>jersey-media-json-jettison</artifactId>
     </dependency>
     </dependency>
-
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-junit-jupiter</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
     <dependency>
       <groupId>com.github.stefanbirkner</groupId>
       <groupId>com.github.stefanbirkner</groupId>
       <artifactId>system-rules</artifactId>
       <artifactId>system-rules</artifactId>

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ACLsTestBase.java

@@ -24,6 +24,7 @@ import java.security.PrivilegedExceptionAction;
 
 
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePath;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePath;
+import org.junit.jupiter.api.BeforeEach;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
@@ -33,7 +34,6 @@ import org.apache.hadoop.service.Service.STATE;
 import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
 import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.ipc.YarnRPC;
 import org.apache.hadoop.yarn.ipc.YarnRPC;
-import org.junit.Before;
 
 
 public abstract class ACLsTestBase {
 public abstract class ACLsTestBase {
 
 
@@ -65,7 +65,7 @@ public abstract class ACLsTestBase {
   YarnRPC rpc;
   YarnRPC rpc;
   InetSocketAddress rmAddress;
   InetSocketAddress rmAddress;
 
 
-  @Before
+  @BeforeEach
   public void setup() throws InterruptedException, IOException {
   public void setup() throws InterruptedException, IOException {
     conf = createConfiguration();
     conf = createConfiguration();
     rpc = YarnRPC.create(conf);
     rpc = YarnRPC.create(conf);

+ 3 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java

@@ -41,8 +41,8 @@ import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 
 
 public abstract class QueueACLsTestBase extends ACLsTestBase {
 public abstract class QueueACLsTestBase extends ACLsTestBase {
 
 
@@ -59,7 +59,7 @@ public abstract class QueueACLsTestBase extends ACLsTestBase {
   abstract public void updateConfigWithDAndD1Queues(String rootAcl,
   abstract public void updateConfigWithDAndD1Queues(String rootAcl,
       String queueDAcl, String queueD1Acl) throws IOException;
       String queueDAcl, String queueD1Acl) throws IOException;
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (resourceManager != null) {
     if (resourceManager != null) {
       resourceManager.stop();
       resourceManager.stop();

+ 60 - 53
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/activities/TestActivitiesManager.java

@@ -55,18 +55,22 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaS
 import org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts;
 import org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts;
 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppActivitiesInfo;
 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppActivitiesInfo;
 import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
 import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
-import org.apache.hadoop.util.SystemClock;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.hadoop.yarn.util.SystemClock;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
 
 
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
-import org.mockito.Mockito;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
 
 
 /**
 /**
  * Test class for {@link ActivitiesManager}.
  * Test class for {@link ActivitiesManager}.
@@ -89,26 +93,26 @@ public class TestActivitiesManager {
 
 
   private ThreadPoolExecutor threadPoolExecutor;
   private ThreadPoolExecutor threadPoolExecutor;
 
 
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
-    rmContext = Mockito.mock(RMContext.class);
+    rmContext = mock(RMContext.class);
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
-    Mockito.when(rmContext.getYarnConfiguration()).thenReturn(conf);
-    ResourceScheduler scheduler = Mockito.mock(ResourceScheduler.class);
-    Mockito.when(scheduler.getMinimumResourceCapability())
+    when(rmContext.getYarnConfiguration()).thenReturn(conf);
+    ResourceScheduler scheduler = mock(ResourceScheduler.class);
+    when(scheduler.getMinimumResourceCapability())
         .thenReturn(Resources.none());
         .thenReturn(Resources.none());
-    Mockito.when(rmContext.getScheduler()).thenReturn(scheduler);
-    LeafQueue mockQueue = Mockito.mock(LeafQueue.class);
+    when(rmContext.getScheduler()).thenReturn(scheduler);
+    LeafQueue mockQueue = mock(LeafQueue.class);
     Map<ApplicationId, RMApp> rmApps = new ConcurrentHashMap<>();
     Map<ApplicationId, RMApp> rmApps = new ConcurrentHashMap<>();
-    Mockito.doReturn(rmApps).when(rmContext).getRMApps();
+    doReturn(rmApps).when(rmContext).getRMApps();
     apps = new ArrayList<>();
     apps = new ArrayList<>();
     for (int i = 0; i < NUM_APPS; i++) {
     for (int i = 0; i < NUM_APPS; i++) {
       ApplicationAttemptId appAttemptId =
       ApplicationAttemptId appAttemptId =
           TestUtils.getMockApplicationAttemptId(i, 0);
           TestUtils.getMockApplicationAttemptId(i, 0);
-      RMApp mockApp = Mockito.mock(RMApp.class);
-      Mockito.doReturn(appAttemptId.getApplicationId()).when(mockApp)
+      RMApp mockApp = mock(RMApp.class);
+      doReturn(appAttemptId.getApplicationId()).when(mockApp)
           .getApplicationId();
           .getApplicationId();
-      Mockito.doReturn(FinalApplicationStatus.UNDEFINED).when(mockApp)
+      doReturn(FinalApplicationStatus.UNDEFINED).when(mockApp)
           .getFinalApplicationStatus();
           .getFinalApplicationStatus();
       rmApps.put(appAttemptId.getApplicationId(), mockApp);
       rmApps.put(appAttemptId.getApplicationId(), mockApp);
       FiCaSchedulerApp app =
       FiCaSchedulerApp app =
@@ -163,12 +167,12 @@ public class TestActivitiesManager {
     }
     }
     // Check activities for all nodes should be recorded and every node should
     // Check activities for all nodes should be recorded and every node should
     // have only one allocation information.
     // have only one allocation information.
-    Assert.assertEquals(NUM_NODES,
+    assertEquals(NUM_NODES,
         activitiesManager.historyNodeAllocations.size());
         activitiesManager.historyNodeAllocations.size());
     for (List<List<NodeAllocation>> nodeAllocationsForThisNode :
     for (List<List<NodeAllocation>> nodeAllocationsForThisNode :
         activitiesManager.historyNodeAllocations.values()) {
         activitiesManager.historyNodeAllocations.values()) {
-      Assert.assertEquals(1, nodeAllocationsForThisNode.size());
-      Assert.assertEquals(1, nodeAllocationsForThisNode.get(0).size());
+      assertEquals(1, nodeAllocationsForThisNode.size());
+      assertEquals(1, nodeAllocationsForThisNode.get(0).size());
     }
     }
   }
   }
 
 
@@ -207,7 +211,7 @@ public class TestActivitiesManager {
       future.get();
       future.get();
     }
     }
     // Check activities for multi-nodes should be recorded only once
     // Check activities for multi-nodes should be recorded only once
-    Assert.assertEquals(1, activitiesManager.historyNodeAllocations.size());
+    assertEquals(1, activitiesManager.historyNodeAllocations.size());
   }
   }
 
 
 
 
@@ -254,13 +258,14 @@ public class TestActivitiesManager {
     Queue<AppAllocation> appAllocations =
     Queue<AppAllocation> appAllocations =
         activitiesManager.completedAppAllocations
         activitiesManager.completedAppAllocations
             .get(randomApp.getApplicationId());
             .get(randomApp.getApplicationId());
-    Assert.assertEquals(nTasks, appAllocations.size());
+    assertEquals(nTasks, appAllocations.size());
     for(AppAllocation aa : appAllocations) {
     for(AppAllocation aa : appAllocations) {
-      Assert.assertEquals(NUM_NODES, aa.getAllocationAttempts().size());
+      assertEquals(NUM_NODES, aa.getAllocationAttempts().size());
     }
     }
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testAppActivitiesTTL() throws Exception {
   public void testAppActivitiesTTL() throws Exception {
     long cleanupIntervalMs = 100;
     long cleanupIntervalMs = 100;
     long appActivitiesTTL = 1000;
     long appActivitiesTTL = 1000;
@@ -295,7 +300,7 @@ public class TestActivitiesManager {
     AppActivitiesInfo appActivitiesInfo = newActivitiesManager
     AppActivitiesInfo appActivitiesInfo = newActivitiesManager
         .getAppActivitiesInfo(app.getApplicationId(), null, null, null, -1,
         .getAppActivitiesInfo(app.getApplicationId(), null, null, null, -1,
             false, 3);
             false, 3);
-    Assert.assertEquals(numActivities,
+    assertEquals(numActivities,
         appActivitiesInfo.getAllocations().size());
         appActivitiesInfo.getAllocations().size());
     // sleep until all app activities expired
     // sleep until all app activities expired
     Thread.sleep(cleanupIntervalMs + appActivitiesTTL);
     Thread.sleep(cleanupIntervalMs + appActivitiesTTL);
@@ -303,11 +308,12 @@ public class TestActivitiesManager {
     appActivitiesInfo = newActivitiesManager
     appActivitiesInfo = newActivitiesManager
         .getAppActivitiesInfo(app.getApplicationId(), null, null, null, -1,
         .getAppActivitiesInfo(app.getApplicationId(), null, null, null, -1,
             false, 3);
             false, 3);
-    Assert.assertEquals(0,
+    assertEquals(0,
         appActivitiesInfo.getAllocations().size());
         appActivitiesInfo.getAllocations().size());
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testAppActivitiesPerformance() {
   public void testAppActivitiesPerformance() {
     // start recording activities for first app
     // start recording activities for first app
     SchedulerApplicationAttempt app = apps.get(0);
     SchedulerApplicationAttempt app = apps.get(0);
@@ -343,12 +349,12 @@ public class TestActivitiesManager {
       AppActivitiesInfo appActivitiesInfo = activitiesManager
       AppActivitiesInfo appActivitiesInfo = activitiesManager
           .getAppActivitiesInfo(app.getApplicationId(), null, null, null, -1,
           .getAppActivitiesInfo(app.getApplicationId(), null, null, null, -1,
               false, 100);
               false, 100);
-      Assert.assertEquals(numActivities,
+      assertEquals(numActivities,
           appActivitiesInfo.getAllocations().size());
           appActivitiesInfo.getAllocations().size());
-      Assert.assertEquals(1,
+      assertEquals(1,
           appActivitiesInfo.getAllocations().get(0).getChildren()
           appActivitiesInfo.getAllocations().get(0).getChildren()
               .size());
               .size());
-      Assert.assertEquals(numNodes,
+      assertEquals(numNodes,
           appActivitiesInfo.getAllocations().get(0).getChildren()
           appActivitiesInfo.getAllocations().get(0).getChildren()
               .get(0).getChildren().size());
               .get(0).getChildren().size());
       return null;
       return null;
@@ -361,15 +367,15 @@ public class TestActivitiesManager {
       AppActivitiesInfo appActivitiesInfo = activitiesManager
       AppActivitiesInfo appActivitiesInfo = activitiesManager
           .getAppActivitiesInfo(app.getApplicationId(), null, null,
           .getAppActivitiesInfo(app.getApplicationId(), null, null,
               RMWSConsts.ActivitiesGroupBy.DIAGNOSTIC, -1, false, 100);
               RMWSConsts.ActivitiesGroupBy.DIAGNOSTIC, -1, false, 100);
-      Assert.assertEquals(numActivities,
+      assertEquals(numActivities,
           appActivitiesInfo.getAllocations().size());
           appActivitiesInfo.getAllocations().size());
-      Assert.assertEquals(1,
+      assertEquals(1,
           appActivitiesInfo.getAllocations().get(0).getChildren()
           appActivitiesInfo.getAllocations().get(0).getChildren()
               .size());
               .size());
-      Assert.assertEquals(1,
+      assertEquals(1,
           appActivitiesInfo.getAllocations().get(0).getChildren()
           appActivitiesInfo.getAllocations().get(0).getChildren()
               .get(0).getChildren().size());
               .get(0).getChildren().size());
-      Assert.assertEquals(numNodes,
+      assertEquals(numNodes,
           appActivitiesInfo.getAllocations().get(0).getChildren()
           appActivitiesInfo.getAllocations().get(0).getChildren()
               .get(0).getChildren().get(0).getNodeIds().size());
               .get(0).getChildren().get(0).getNodeIds().size());
       return null;
       return null;
@@ -382,14 +388,14 @@ public class TestActivitiesManager {
       AppActivitiesInfo appActivitiesInfo = activitiesManager
       AppActivitiesInfo appActivitiesInfo = activitiesManager
           .getAppActivitiesInfo(app.getApplicationId(), null, null,
           .getAppActivitiesInfo(app.getApplicationId(), null, null,
               RMWSConsts.ActivitiesGroupBy.DIAGNOSTIC, -1, true, 100);
               RMWSConsts.ActivitiesGroupBy.DIAGNOSTIC, -1, true, 100);
-      Assert.assertEquals(1, appActivitiesInfo.getAllocations().size());
-      Assert.assertEquals(1,
+      assertEquals(1, appActivitiesInfo.getAllocations().size());
+      assertEquals(1,
           appActivitiesInfo.getAllocations().get(0).getChildren()
           appActivitiesInfo.getAllocations().get(0).getChildren()
               .size());
               .size());
-      Assert.assertEquals(1,
+      assertEquals(1,
           appActivitiesInfo.getAllocations().get(0).getChildren()
           appActivitiesInfo.getAllocations().get(0).getChildren()
               .get(0).getChildren().size());
               .get(0).getChildren().size());
-      Assert.assertEquals(numNodes,
+      assertEquals(numNodes,
           appActivitiesInfo.getAllocations().get(0).getChildren()
           appActivitiesInfo.getAllocations().get(0).getChildren()
               .get(0).getChildren().get(0).getNodeIds().size());
               .get(0).getChildren().get(0).getNodeIds().size());
       return null;
       return null;
@@ -398,7 +404,8 @@ public class TestActivitiesManager {
         testingTimes);
         testingTimes);
   }
   }
 
 
-  @Test (timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testAppActivitiesMaxQueueLengthUpdate()
   public void testAppActivitiesMaxQueueLengthUpdate()
       throws TimeoutException, InterruptedException {
       throws TimeoutException, InterruptedException {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
@@ -413,46 +420,46 @@ public class TestActivitiesManager {
     for (int i = 0; i < numNodes; i++) {
     for (int i = 0; i < numNodes; i++) {
       mockNodes.put(NodeId.newInstance("node" + i, 0), mock(RMNode.class));
       mockNodes.put(NodeId.newInstance("node" + i, 0), mock(RMNode.class));
     }
     }
-    CapacityScheduler cs = Mockito.mock(CapacityScheduler.class);
-    RMContext mockRMContext = Mockito.mock(RMContext.class);
-    Mockito.when(mockRMContext.getRMNodes()).thenReturn(mockNodes);
-    Mockito.when(mockRMContext.getYarnConfiguration()).thenReturn(conf);
-    Mockito.when(mockRMContext.getScheduler()).thenReturn(cs);
+    CapacityScheduler cs = mock(CapacityScheduler.class);
+    RMContext mockRMContext = mock(RMContext.class);
+    when(mockRMContext.getRMNodes()).thenReturn(mockNodes);
+    when(mockRMContext.getYarnConfiguration()).thenReturn(conf);
+    when(mockRMContext.getScheduler()).thenReturn(cs);
     /*
     /*
      * Test for async-scheduling with multi-node placement disabled
      * Test for async-scheduling with multi-node placement disabled
      */
      */
-    Mockito.when(cs.isMultiNodePlacementEnabled()).thenReturn(false);
+    when(cs.isMultiNodePlacementEnabled()).thenReturn(false);
     int numAsyncSchedulerThreads = 3;
     int numAsyncSchedulerThreads = 3;
-    Mockito.when(cs.getNumAsyncSchedulerThreads())
+    when(cs.getNumAsyncSchedulerThreads())
         .thenReturn(numAsyncSchedulerThreads);
         .thenReturn(numAsyncSchedulerThreads);
     ActivitiesManager newActivitiesManager =
     ActivitiesManager newActivitiesManager =
         new ActivitiesManager(mockRMContext);
         new ActivitiesManager(mockRMContext);
-    Assert.assertEquals(1,
+    assertEquals(1,
         newActivitiesManager.getAppActivitiesMaxQueueLength());
         newActivitiesManager.getAppActivitiesMaxQueueLength());
     newActivitiesManager.init(conf);
     newActivitiesManager.init(conf);
     newActivitiesManager.start();
     newActivitiesManager.start();
     GenericTestUtils.waitFor(
     GenericTestUtils.waitFor(
         () -> newActivitiesManager.getAppActivitiesMaxQueueLength()
         () -> newActivitiesManager.getAppActivitiesMaxQueueLength()
             == numNodes * numAsyncSchedulerThreads, 100, 3000);
             == numNodes * numAsyncSchedulerThreads, 100, 3000);
-    Assert.assertEquals(15,
+    assertEquals(15,
         newActivitiesManager.getAppActivitiesMaxQueueLength());
         newActivitiesManager.getAppActivitiesMaxQueueLength());
     /*
     /*
      * Test for HB-driven scheduling with multi-node placement disabled
      * Test for HB-driven scheduling with multi-node placement disabled
      */
      */
-    Mockito.when(cs.getNumAsyncSchedulerThreads()).thenReturn(0);
+    when(cs.getNumAsyncSchedulerThreads()).thenReturn(0);
     GenericTestUtils.waitFor(
     GenericTestUtils.waitFor(
         () -> newActivitiesManager.getAppActivitiesMaxQueueLength()
         () -> newActivitiesManager.getAppActivitiesMaxQueueLength()
             == numNodes * 1.2, 100, 3000);
             == numNodes * 1.2, 100, 3000);
-    Assert.assertEquals(6,
+    assertEquals(6,
         newActivitiesManager.getAppActivitiesMaxQueueLength());
         newActivitiesManager.getAppActivitiesMaxQueueLength());
     /*
     /*
      * Test for scheduling with multi-node placement enabled
      * Test for scheduling with multi-node placement enabled
      */
      */
-    Mockito.when(cs.isMultiNodePlacementEnabled()).thenReturn(true);
+    when(cs.isMultiNodePlacementEnabled()).thenReturn(true);
     GenericTestUtils.waitFor(
     GenericTestUtils.waitFor(
         () -> newActivitiesManager.getAppActivitiesMaxQueueLength()
         () -> newActivitiesManager.getAppActivitiesMaxQueueLength()
             == configuredAppActivitiesMaxQueueLength, 100, 3000);
             == configuredAppActivitiesMaxQueueLength, 100, 3000);
-    Assert.assertEquals(1,
+    assertEquals(1,
         newActivitiesManager.getAppActivitiesMaxQueueLength());
         newActivitiesManager.getAppActivitiesMaxQueueLength());
   }
   }
 
 
@@ -480,8 +487,8 @@ public class TestActivitiesManager {
 
 
     public TestingActivitiesManager(RMContext rmContext) {
     public TestingActivitiesManager(RMContext rmContext) {
       super(rmContext);
       super(rmContext);
-      super.completedNodeAllocations = Mockito.spy(new ConcurrentHashMap<>());
-      Mockito.doAnswer((invocationOnMock) -> {
+      super.completedNodeAllocations = spy(new ConcurrentHashMap<>());
+      doAnswer((invocationOnMock) -> {
         NodeId nodeId = (NodeId) invocationOnMock.getArguments()[0];
         NodeId nodeId = (NodeId) invocationOnMock.getArguments()[0];
         List<NodeAllocation> nodeAllocations =
         List<NodeAllocation> nodeAllocations =
             (List<NodeAllocation>) invocationOnMock.getArguments()[1];
             (List<NodeAllocation>) invocationOnMock.getArguments()[1];

+ 9 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerPreemptionTestBase.java

@@ -32,10 +32,11 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
-import org.apache.hadoop.util.Clock;
-import org.junit.Assert;
-import org.junit.Before;
+import org.apache.hadoop.yarn.util.Clock;
+import org.junit.jupiter.api.BeforeEach;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -49,7 +50,7 @@ public class CapacitySchedulerPreemptionTestBase {
 
 
   Clock clock;
   Clock clock;
 
 
-  @Before
+  @BeforeEach
   void setUp() throws Exception {
   void setUp() throws Exception {
     conf = new CapacitySchedulerConfiguration();
     conf = new CapacitySchedulerConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -106,7 +107,7 @@ public class CapacitySchedulerPreemptionTestBase {
       waitNum++;
       waitNum++;
     }
     }
 
 
-    Assert.fail();
+    fail();
   }
   }
 
 
   public void waitNumberOfReservedContainersFromApp(FiCaSchedulerApp app,
   public void waitNumberOfReservedContainersFromApp(FiCaSchedulerApp app,
@@ -122,7 +123,7 @@ public class CapacitySchedulerPreemptionTestBase {
       waitNum++;
       waitNum++;
     }
     }
 
 
-    Assert.fail();
+    fail();
   }
   }
 
 
   public void waitNumberOfLiveContainersOnNodeFromApp(FiCaSchedulerNode node,
   public void waitNumberOfLiveContainersOnNodeFromApp(FiCaSchedulerNode node,
@@ -144,7 +145,7 @@ public class CapacitySchedulerPreemptionTestBase {
       waitNum++;
       waitNum++;
     }
     }
 
 
-    Assert.fail(
+    fail(
         "Check #live-container-on-node-from-app, actual=" + total + " expected="
         "Check #live-container-on-node-from-app, actual=" + total + " expected="
             + expected);
             + expected);
   }
   }
@@ -160,6 +161,6 @@ public class CapacitySchedulerPreemptionTestBase {
       }
       }
     }
     }
 
 
-    Assert.assertEquals(expected, total);
+    assertEquals(expected, total);
   }
   }
 }
 }

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueCalculationTestBase.java

@@ -26,7 +26,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NullRMNodeLabels
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
@@ -52,7 +52,7 @@ public class CapacitySchedulerQueueCalculationTestBase {
   protected CapacitySchedulerConfiguration csConf;
   protected CapacitySchedulerConfiguration csConf;
   protected NullRMNodeLabelsManager mgr;
   protected NullRMNodeLabelsManager mgr;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     csConf = new CapacitySchedulerConfiguration();
     csConf = new CapacitySchedulerConfiguration();
     csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,

+ 8 - 9
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueHelpers.java

@@ -21,9 +21,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
-import org.junit.Assert;
-
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 
 public final class CapacitySchedulerQueueHelpers {
 public final class CapacitySchedulerQueueHelpers {
 
 
@@ -386,18 +385,18 @@ public final class CapacitySchedulerQueueHelpers {
     CSQueue rootQueue = cs.getRootQueue();
     CSQueue rootQueue = cs.getRootQueue();
     for (Map.Entry<String, ExpectedCapacities> entry : capacities.entrySet()) {
     for (Map.Entry<String, ExpectedCapacities> entry : capacities.entrySet()) {
       CSQueue queue = findQueue(rootQueue, entry.getKey());
       CSQueue queue = findQueue(rootQueue, entry.getKey());
-      Assert.assertNotNull(queue);
+      assertNotNull(queue);
       assertQueueCapacities(queue, entry.getValue());
       assertQueueCapacities(queue, entry.getValue());
     }
     }
   }
   }
 
 
   public static void assertQueueCapacities(CSQueue q, ExpectedCapacities capacities) {
   public static void assertQueueCapacities(CSQueue q, ExpectedCapacities capacities) {
     final float epsilon = 1e-4f;
     final float epsilon = 1e-4f;
-    assertEquals("capacity", capacities.getCapacity(), q.getCapacity(), epsilon);
-    assertEquals("absolute capacity", capacities.getAbsCapacity(),
-        q.getAbsoluteCapacity(), epsilon);
-    assertEquals("maximum capacity", 1.0f, q.getMaximumCapacity(), epsilon);
-    assertEquals("absolute maximum capacity", 1.0f, q.getAbsoluteMaximumCapacity(), epsilon);
+    assertEquals(capacities.getCapacity(), q.getCapacity(), epsilon, "capacity");
+    assertEquals(capacities.getAbsCapacity(),
+        q.getAbsoluteCapacity(), epsilon, "absolute capacity");
+    assertEquals(1.0f, q.getMaximumCapacity(), epsilon, "maximum capacity");
+    assertEquals(1.0f, q.getAbsoluteMaximumCapacity(), epsilon, "absolute maximum capacity");
   }
   }
 
 
   public static CSQueue findQueue(CSQueue root, String queuePath) {
   public static CSQueue findQueue(CSQueue root, String queuePath) {

+ 6 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerTestUtilities.java

@@ -52,13 +52,14 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEv
 import org.apache.hadoop.yarn.server.resourcemanager.security.AppPriorityACLsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.security.AppPriorityACLsManager;
 import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
-import org.junit.Assert;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Set;
 import java.util.Set;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfAmbiguousQueue;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfAmbiguousQueue;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfiguration;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfiguration;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -84,7 +85,7 @@ public final class CapacitySchedulerTestUtilities {
       String label) {
       String label) {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = cs.getQueue(queueName);
     CSQueue queue = cs.getQueue(queueName);
-    Assert.assertEquals(
+    assertEquals(
         memory,
         memory,
         queue.getQueueResourceUsage()
         queue.getQueueResourceUsage()
             .getPending(label == null ? RMNodeLabelsManager.NO_LABEL : label)
             .getPending(label == null ? RMNodeLabelsManager.NO_LABEL : label)
@@ -96,7 +97,7 @@ public final class CapacitySchedulerTestUtilities {
       String label) {
       String label) {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = cs.getQueue(queueName);
     CSQueue queue = cs.getQueue(queueName);
-    Assert.assertTrue(queue.getQueueResourceUsage()
+    assertTrue(queue.getQueueResourceUsage()
         .getPending(label == null ? RMNodeLabelsManager.NO_LABEL : label)
         .getPending(label == null ? RMNodeLabelsManager.NO_LABEL : label)
         .getMemorySize() > 0);
         .getMemorySize() > 0);
   }
   }
@@ -230,11 +231,11 @@ public final class CapacitySchedulerTestUtilities {
   }
   }
 
 
   public static void checkApplicationResourceUsage(int expected, Application application) {
   public static void checkApplicationResourceUsage(int expected, Application application) {
-    Assert.assertEquals(expected, application.getUsedResources().getMemorySize());
+    assertEquals(expected, application.getUsedResources().getMemorySize());
   }
   }
 
 
   public static void checkNodeResourceUsage(int expected, NodeManager node) {
   public static void checkNodeResourceUsage(int expected, NodeManager node) {
-    Assert.assertEquals(expected, node.getUsed().getMemorySize());
+    assertEquals(expected, node.getUsed().getMemorySize());
     node.checkResourceUsage();
     node.checkResourceUsage();
   }
   }
 }
 }

+ 8 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/QueueAssertionBuilder.java

@@ -20,7 +20,6 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueResourceQuotas;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueResourceQuotas;
-import org.junit.Assert;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashMap;
@@ -32,6 +31,8 @@ import java.util.function.Supplier;
 
 
 import static org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager.NO_LABEL;
 import static org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager.NO_LABEL;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
 /**
  * Provides a fluent API to assert resource and capacity attributes of queues.
  * Provides a fluent API to assert resource and capacity attributes of queues.
@@ -141,7 +142,7 @@ class QueueAssertionBuilder {
           BiFunction<QueueResourceQuotas, String, Resource> assertion, String messageInfo) {
           BiFunction<QueueResourceQuotas, String, Resource> assertion, String messageInfo) {
         CSQueue queue = cs.getQueue(queuePath.getFullPath());
         CSQueue queue = cs.getQueue(queuePath.getFullPath());
         if (queue == null) {
         if (queue == null) {
-          Assert.fail("Queue " + queuePath + " is not found");
+          fail("Queue " + queuePath + " is not found");
         }
         }
 
 
         assertionType = messageInfo;
         assertionType = messageInfo;
@@ -152,7 +153,7 @@ class QueueAssertionBuilder {
           BiFunction<QueueCapacities, String, Float> assertion, String messageInfo) {
           BiFunction<QueueCapacities, String, Float> assertion, String messageInfo) {
         CSQueue queue = cs.getQueue(queuePath.getFullPath());
         CSQueue queue = cs.getQueue(queuePath.getFullPath());
         if (queue == null) {
         if (queue == null) {
-          Assert.fail("Queue " + queuePath + " is not found");
+          fail("Queue " + queuePath + " is not found");
         }
         }
         assertionType = messageInfo;
         assertionType = messageInfo;
         valueSupplier = () -> assertion.apply(queue.getQueueCapacities(), label);
         valueSupplier = () -> assertion.apply(queue.getQueueCapacities(), label);
@@ -187,14 +188,14 @@ class QueueAssertionBuilder {
           String errorMessage = String.format(RESOURCE_ASSERTION_ERROR_MESSAGE,
           String errorMessage = String.format(RESOURCE_ASSERTION_ERROR_MESSAGE,
               assertion.assertionType, assertionEntry.getKey(),
               assertion.assertionType, assertionEntry.getKey(),
               assertion.expectedResource.toString(), assertion.label);
               assertion.expectedResource.toString(), assertion.label);
-          Assert.assertEquals(errorMessage, assertion.expectedResource,
-              assertion.resourceSupplier.get());
+          assertEquals(assertion.expectedResource,
+              assertion.resourceSupplier.get(), errorMessage);
         } else {
         } else {
           String errorMessage = String.format(ASSERTION_ERROR_MESSAGE,
           String errorMessage = String.format(ASSERTION_ERROR_MESSAGE,
               assertion.assertionType, assertionEntry.getKey(), assertion.expectedValue,
               assertion.assertionType, assertionEntry.getKey(), assertion.expectedValue,
               assertion.label);
               assertion.label);
-          Assert.assertEquals(errorMessage, assertion.expectedValue,
-              assertion.valueSupplier.get(), EPSILON);
+          assertEquals(assertion.expectedValue,
+              assertion.valueSupplier.get(), EPSILON, errorMessage);
         }
         }
       }
       }
     }
     }

+ 6 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAMAllocatedToNonExclusivePartition.java

@@ -18,6 +18,8 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Set;
 import java.util.Set;
@@ -42,9 +44,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerState;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 
 
@@ -52,7 +53,7 @@ public class TestAMAllocatedToNonExclusivePartition {
   private Configuration conf;
   private Configuration conf;
   private RMNodeLabelsManager mgr;
   private RMNodeLabelsManager mgr;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -120,7 +121,7 @@ public class TestAMAllocatedToNonExclusivePartition {
     // Request a container and it also should be allocated to non-partition node of h1
     // Request a container and it also should be allocated to non-partition node of h1
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm1.waitForState(nm1, containerId, RMContainerState.ALLOCATED));
+    assertTrue(rm1.waitForState(nm1, containerId, RMContainerState.ALLOCATED));
 
 
     rm1.close();
     rm1.close();
   }
   }

+ 357 - 271
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAbsoluteResourceConfiguration.java

@@ -17,6 +17,11 @@
 */
 */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.HashSet;
@@ -32,8 +37,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestAbsoluteResourceConfiguration {
 public class TestAbsoluteResourceConfiguration {
 
 
@@ -225,24 +229,24 @@ public class TestAbsoluteResourceConfiguration {
     CapacitySchedulerConfiguration csConf = setupSimpleQueueConfiguration(false);
     CapacitySchedulerConfiguration csConf = setupSimpleQueueConfiguration(false);
     setupMinMaxResourceConfiguration(csConf);
     setupMinMaxResourceConfiguration(csConf);
 
 
-    Assert.assertEquals("Min resource configured for QUEUEA is not correct",
-        QUEUE_A_MINRES,
-        csConf.getMinimumResourceRequirement("", QUEUEA_FULL, resourceTypes));
-    Assert.assertEquals("Max resource configured for QUEUEA is not correct",
-        QUEUE_A_MAXRES,
-        csConf.getMaximumResourceRequirement("", QUEUEA_FULL, resourceTypes));
-    Assert.assertEquals("Min resource configured for QUEUEB is not correct",
-        QUEUE_B_MINRES,
-        csConf.getMinimumResourceRequirement("", QUEUEB_FULL, resourceTypes));
-    Assert.assertEquals("Max resource configured for QUEUEB is not correct",
-        QUEUE_B_MAXRES,
-        csConf.getMaximumResourceRequirement("", QUEUEB_FULL, resourceTypes));
-    Assert.assertEquals("Min resource configured for QUEUEC is not correct",
-        QUEUE_C_MINRES,
-        csConf.getMinimumResourceRequirement("", QUEUEC_FULL, resourceTypes));
-    Assert.assertEquals("Max resource configured for QUEUEC is not correct",
-        QUEUE_C_MAXRES,
-        csConf.getMaximumResourceRequirement("", QUEUEC_FULL, resourceTypes));
+    assertEquals(QUEUE_A_MINRES,
+        csConf.getMinimumResourceRequirement("", QUEUEA_FULL, resourceTypes),
+        "Min resource configured for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        csConf.getMaximumResourceRequirement("", QUEUEA_FULL, resourceTypes),
+        "Max resource configured for QUEUEA is not correct");
+    assertEquals(QUEUE_B_MINRES,
+        csConf.getMinimumResourceRequirement("", QUEUEB_FULL, resourceTypes),
+        "Min resource configured for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        csConf.getMaximumResourceRequirement("", QUEUEB_FULL, resourceTypes),
+        "Max resource configured for QUEUEB is not correct");
+    assertEquals(QUEUE_C_MINRES,
+        csConf.getMinimumResourceRequirement("", QUEUEC_FULL, resourceTypes),
+        "Min resource configured for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        csConf.getMaximumResourceRequirement("", QUEUEC_FULL, resourceTypes),
+        "Max resource configured for QUEUEC is not correct");
 
 
     csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
         ResourceScheduler.class);
         ResourceScheduler.class);
@@ -268,13 +272,13 @@ public class TestAbsoluteResourceConfiguration {
     cs.getRootQueue().updateClusterResource(cs.getClusterResource(),
     cs.getRootQueue().updateClusterResource(cs.getClusterResource(),
         new ResourceLimits(cs.getClusterResource()));
         new ResourceLimits(cs.getClusterResource()));
 
 
-    Assert.assertEquals(QUEUE_D_TEMPL_MINRES,
+    assertEquals(QUEUE_D_TEMPL_MINRES,
         d1.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
         d1.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals(QUEUE_D_TEMPL_MINRES,
+    assertEquals(QUEUE_D_TEMPL_MINRES,
         d1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
         d1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals(QUEUE_D_TEMPL_MAXRES,
+    assertEquals(QUEUE_D_TEMPL_MAXRES,
         d1.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
         d1.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals(QUEUE_D_TEMPL_MAXRES,
+    assertEquals(QUEUE_D_TEMPL_MAXRES,
         d1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
         d1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
 
 
     /**
     /**
@@ -289,22 +293,22 @@ public class TestAbsoluteResourceConfiguration {
     cs.getRootQueue().updateClusterResource(cs.getClusterResource(),
     cs.getRootQueue().updateClusterResource(cs.getClusterResource(),
         new ResourceLimits(cs.getClusterResource()));
         new ResourceLimits(cs.getClusterResource()));
 
 
-    Assert.assertEquals(Resource.newInstance(0, 0),
+    assertEquals(Resource.newInstance(0, 0),
         d2.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
         d2.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals(Resource.newInstance(0, 0),
+    assertEquals(Resource.newInstance(0, 0),
         d2.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
         d2.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals(QUEUE_D_TEMPL_MAXRES,
+    assertEquals(QUEUE_D_TEMPL_MAXRES,
         d2.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
         d2.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals(QUEUE_D_TEMPL_MAXRES,
+    assertEquals(QUEUE_D_TEMPL_MAXRES,
         d2.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
         d2.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
 
 
-    Assert.assertEquals(QUEUE_D_TEMPL_MINRES,
+    assertEquals(QUEUE_D_TEMPL_MINRES,
         d1.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
         d1.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals(QUEUE_D_TEMPL_MINRES,
+    assertEquals(QUEUE_D_TEMPL_MINRES,
         d1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
         d1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals(QUEUE_D_TEMPL_MAXRES,
+    assertEquals(QUEUE_D_TEMPL_MAXRES,
         d1.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
         d1.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals(QUEUE_D_TEMPL_MAXRES,
+    assertEquals(QUEUE_D_TEMPL_MAXRES,
         d1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
         d1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
 
 
     rm.close();
     rm.close();
@@ -336,9 +340,10 @@ public class TestAbsoluteResourceConfiguration {
     Resource resParent = cs.getQueue(QUEUEA_FULL.getFullPath()).getEffectiveCapacity("");
     Resource resParent = cs.getQueue(QUEUEA_FULL.getFullPath()).getEffectiveCapacity("");
 
 
     // Check if there is no overcommitment on behalf of the child queues
     // Check if there is no overcommitment on behalf of the child queues
-    Assert.assertTrue(String.format("Summarized resource %s of all children is greater than " +
-        "their parent's %s", res, resParent),
-        Resources.lessThan(cs.getResourceCalculator(), cs.getClusterResource(), res, resParent));
+    assertTrue(Resources.lessThan(cs.getResourceCalculator(),
+        cs.getClusterResource(), res, resParent),
+        String.format("Summarized resource %s of all children is greater than " +
+        "their parent's %s", res, resParent));
     rm.stop();
     rm.stop();
   }
   }
 
 
@@ -364,37 +369,49 @@ public class TestAbsoluteResourceConfiguration {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
 
 
     LeafQueue qA = (LeafQueue) cs.getQueue(QUEUEA);
     LeafQueue qA = (LeafQueue) cs.getQueue(QUEUEA);
-    Assert.assertNotNull(qA);
-    Assert.assertEquals("Min resource configured for QUEUEA is not correct",
-        QUEUE_A_MINRES, qA.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEA is not correct",
-        QUEUE_A_MAXRES, qA.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEA is not correct",
-        QUEUE_A_MINRES, qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA is not correct",
-        QUEUE_A_MAXRES, qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertNotNull(qA);
+    assertEquals(QUEUE_A_MINRES,
+        qA.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MINRES,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA is not correct");
 
 
     LeafQueue qB = (LeafQueue) cs.getQueue(QUEUEB);
     LeafQueue qB = (LeafQueue) cs.getQueue(QUEUEB);
-    Assert.assertNotNull(qB);
-    Assert.assertEquals("Min resource configured for QUEUEB is not correct",
-        QUEUE_B_MINRES, qB.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEB is not correct",
-        QUEUE_B_MAXRES, qB.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEB is not correct",
-        QUEUE_B_MINRES, qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEB is not correct",
-        QUEUE_B_MAXRES, qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertNotNull(qB);
+    assertEquals(QUEUE_B_MINRES,
+        qB.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MINRES,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEB is not correct");
 
 
     LeafQueue qC = (LeafQueue) cs.getQueue(QUEUEC);
     LeafQueue qC = (LeafQueue) cs.getQueue(QUEUEC);
-    Assert.assertNotNull(qC);
-    Assert.assertEquals("Min resource configured for QUEUEC is not correct",
-        QUEUE_C_MINRES, qC.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEC is not correct",
-        QUEUE_C_MAXRES, qC.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEC is not correct",
-        QUEUE_C_MINRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEC is not correct",
-        QUEUE_C_MAXRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertNotNull(qC);
+    assertEquals(QUEUE_C_MINRES,
+        qC.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        qC.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MINRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEC is not correct");
 
 
     rm.stop();
     rm.stop();
   }
   }
@@ -440,7 +457,7 @@ public class TestAbsoluteResourceConfiguration {
     try {
     try {
       cs.reinitialize(csConf1, rm.getRMContext());
       cs.reinitialize(csConf1, rm.getRMContext());
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.fail();
+      fail();
     }
     }
     rm.stop();
     rm.stop();
 
 
@@ -456,38 +473,50 @@ public class TestAbsoluteResourceConfiguration {
     cs = (CapacityScheduler) rm.getResourceScheduler();
     cs = (CapacityScheduler) rm.getResourceScheduler();
 
 
     LeafQueue qA1 = (LeafQueue) cs.getQueue(QUEUEA1);
     LeafQueue qA1 = (LeafQueue) cs.getQueue(QUEUEA1);
-    Assert.assertEquals("Effective Min resource for QUEUEA1 is not correct",
-        QUEUE_A1_MINRES, qA1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA1 is not correct",
-        QUEUE_A_MAXRES, qA1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertEquals(QUEUE_A1_MINRES,
+        qA1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA1 is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA1 is not correct");
 
 
     LeafQueue qA2 = (LeafQueue) cs.getQueue(QUEUEA2);
     LeafQueue qA2 = (LeafQueue) cs.getQueue(QUEUEA2);
-    Assert.assertEquals("Effective Min resource for QUEUEA2 is not correct",
-        QUEUE_A2_MINRES, qA2.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA2 is not correct",
-        QUEUE_A_MAXRES, qA2.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertEquals(QUEUE_A2_MINRES,
+        qA2.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA2 is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA2.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA2 is not correct");
 
 
     LeafQueue qB1 = (LeafQueue) cs.getQueue(QUEUEB1);
     LeafQueue qB1 = (LeafQueue) cs.getQueue(QUEUEB1);
-    Assert.assertNotNull(qB1);
-    Assert.assertEquals("Min resource configured for QUEUEB1 is not correct",
-        QUEUE_B1_MINRES, qB1.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEB1 is not correct",
-        QUEUE_B_MAXRES, qB1.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEB1 is not correct",
-        QUEUE_B1_MINRES, qB1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEB1 is not correct",
-        QUEUE_B_MAXRES, qB1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertNotNull(qB1);
+    assertEquals(QUEUE_B1_MINRES,
+        qB1.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEB1 is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB1.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEB1 is not correct");
+    assertEquals(QUEUE_B1_MINRES,
+        qB1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEB1 is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEB1 is not correct");
 
 
     LeafQueue qC = (LeafQueue) cs.getQueue(QUEUEC);
     LeafQueue qC = (LeafQueue) cs.getQueue(QUEUEC);
-    Assert.assertNotNull(qC);
-    Assert.assertEquals("Min resource configured for QUEUEC is not correct",
-        QUEUE_C_MINRES, qC.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEC is not correct",
-        QUEUE_C_MAXRES, qC.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEC is not correct",
-        QUEUE_C_MINRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEC is not correct",
-        QUEUE_C_MAXRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertNotNull(qC);
+    assertEquals(QUEUE_C_MINRES,
+        qC.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        qC.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MINRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEC is not correct");
 
 
     // 3. Create a new config and make sure one queue's min resource is more
     // 3. Create a new config and make sure one queue's min resource is more
     // than its max resource configured.
     // than its max resource configured.
@@ -500,10 +529,10 @@ public class TestAbsoluteResourceConfiguration {
 
 
     try {
     try {
       cs.reinitialize(csConf3, rm.getRMContext());
       cs.reinitialize(csConf3, rm.getRMContext());
-      Assert.fail();
+      fail();
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e instanceof IOException);
-      Assert.assertEquals(
+      assertTrue(e instanceof IOException);
+      assertEquals(
           "Failed to re-init queues : Min resource configuration "
           "Failed to re-init queues : Min resource configuration "
               + "<memory:153600, vCores:30> is greater than its "
               + "<memory:153600, vCores:30> is greater than its "
               + "max value:<memory:40960, vCores:10> "
               + "max value:<memory:40960, vCores:10> "
@@ -521,15 +550,14 @@ public class TestAbsoluteResourceConfiguration {
 
 
     try {
     try {
       cs.reinitialize(csConf4, rm.getRMContext());
       cs.reinitialize(csConf4, rm.getRMContext());
-      Assert.fail();
+      fail();
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e instanceof IOException);
-      Assert
-          .assertEquals(
-              "Failed to re-init queues : Max resource configuration "
-                  + "<memory:204800, vCores:30> is greater than parents max value:"
-                  + "<memory:153600, vCores:30> in queue:root.queueB.queueB1",
-              e.getMessage());
+      assertTrue(e instanceof IOException);
+      assertEquals(
+          "Failed to re-init queues : Max resource configuration "
+           + "<memory:204800, vCores:30> is greater than parents max value:"
+           + "<memory:153600, vCores:30> in queue:root.queueB.queueB1",
+           e.getMessage());
     }
     }
     rm.stop();
     rm.stop();
   }
   }
@@ -575,13 +603,13 @@ public class TestAbsoluteResourceConfiguration {
     try {
     try {
       cs.reinitialize(csConf, rm.getRMContext());
       cs.reinitialize(csConf, rm.getRMContext());
       if (csConf.isLegacyQueueMode()) {
       if (csConf.isLegacyQueueMode()) {
-        Assert.fail("legacy queue mode does not support mixed queue modes");
+        fail("legacy queue mode does not support mixed queue modes");
       }
       }
     } catch (IOException e) {
     } catch (IOException e) {
       if (!csConf.isLegacyQueueMode()) {
       if (!csConf.isLegacyQueueMode()) {
-        Assert.fail("new queue mode supports mixed queue modes");
+        fail("new queue mode supports mixed queue modes");
       }
       }
-      Assert.assertTrue(e.getMessage().contains("Failed to re-init queues"));
+      assertTrue(e.getMessage().contains("Failed to re-init queues"));
     }
     }
 
 
     // 2. Create a new config and make sure one queue's min resource is more
     // 2. Create a new config and make sure one queue's min resource is more
@@ -596,13 +624,13 @@ public class TestAbsoluteResourceConfiguration {
     try {
     try {
       cs.reinitialize(csConf1, rm.getRMContext());
       cs.reinitialize(csConf1, rm.getRMContext());
       if (csConf.isLegacyQueueMode()) {
       if (csConf.isLegacyQueueMode()) {
-        Assert.fail("legacy queue mode enforces that parent.capacity >= sum(children.capacity)");
+        fail("legacy queue mode enforces that parent.capacity >= sum(children.capacity)");
       }
       }
     } catch (IOException e) {
     } catch (IOException e) {
       if (!csConf.isLegacyQueueMode()) {
       if (!csConf.isLegacyQueueMode()) {
-        Assert.fail("new queue mode allows that parent.capacity >= sum(children.capacity)");
+        fail("new queue mode allows that parent.capacity >= sum(children.capacity)");
       }
       }
-      Assert.assertEquals("Failed to re-init queues : Parent Queues capacity: "
+      assertEquals("Failed to re-init queues : Parent Queues capacity: "
           + "<memory:51200, vCores:5> is less than to its children:"
           + "<memory:51200, vCores:5> is less than to its children:"
           + "<memory:102400, vCores:10> for queue:queueA", e.getMessage());
           + "<memory:102400, vCores:10> for queue:queueA", e.getMessage());
     }
     }
@@ -656,7 +684,7 @@ public class TestAbsoluteResourceConfiguration {
     try {
     try {
       cs.reinitialize(csConf, rm.getRMContext());
       cs.reinitialize(csConf, rm.getRMContext());
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.fail(e.getMessage());
+      fail(e.getMessage());
     }
     }
     rm.stop();
     rm.stop();
   }
   }
@@ -692,9 +720,10 @@ public class TestAbsoluteResourceConfiguration {
     Resource childrenResource = root.getChildQueues().stream().map(q -> q.getEffectiveCapacity(
     Resource childrenResource = root.getChildQueues().stream().map(q -> q.getEffectiveCapacity(
         X_LABEL)).reduce(Resources::add).orElse(Resource.newInstance(0, 0));
         X_LABEL)).reduce(Resources::add).orElse(Resource.newInstance(0, 0));
 
 
-    Assert.assertTrue("Children of root have more resource than overall cluster resource",
-        Resources.greaterThan(cs.getResourceCalculator(), cs.getClusterResource(),
-            root.getEffectiveCapacity(X_LABEL), childrenResource));
+    assertTrue(Resources.greaterThan(cs.getResourceCalculator(),
+        cs.getClusterResource(),
+        root.getEffectiveCapacity(X_LABEL), childrenResource),
+        "Children of root have more resource than overall cluster resource");
     rm.stop();
     rm.stop();
   }
   }
 
 
@@ -721,37 +750,49 @@ public class TestAbsoluteResourceConfiguration {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
 
 
     LeafQueue qA = (LeafQueue) cs.getQueue(QUEUEA);
     LeafQueue qA = (LeafQueue) cs.getQueue(QUEUEA);
-    Assert.assertNotNull(qA);
-    Assert.assertEquals("Min resource configured for QUEUEA is not correct",
-        QUEUE_A_MINRES, qA.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEA is not correct",
-        QUEUE_A_MAXRES, qA.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEA is not correct",
-        QUEUE_A_MINRES, qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA is not correct",
-        QUEUE_A_MAXRES, qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertNotNull(qA);
+    assertEquals(QUEUE_A_MINRES,
+        qA.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MINRES,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA is not correct");
 
 
     LeafQueue qB = (LeafQueue) cs.getQueue(QUEUEB);
     LeafQueue qB = (LeafQueue) cs.getQueue(QUEUEB);
-    Assert.assertNotNull(qB);
-    Assert.assertEquals("Min resource configured for QUEUEB is not correct",
-        QUEUE_B_MINRES, qB.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEB is not correct",
-        QUEUE_B_MAXRES, qB.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEB is not correct",
-        QUEUE_B_MINRES, qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEB is not correct",
-        QUEUE_B_MAXRES, qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertNotNull(qB);
+    assertEquals(QUEUE_B_MINRES,
+        qB.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MINRES,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEB is not correct");
 
 
     LeafQueue qC = (LeafQueue) cs.getQueue(QUEUEC);
     LeafQueue qC = (LeafQueue) cs.getQueue(QUEUEC);
-    Assert.assertNotNull(qC);
-    Assert.assertEquals("Min resource configured for QUEUEC is not correct",
-        QUEUE_C_MINRES, qC.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEC is not correct",
-        QUEUE_C_MAXRES, qC.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEC is not correct",
-        QUEUE_C_MINRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEC is not correct",
-        QUEUE_C_MAXRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertNotNull(qC);
+    assertEquals(QUEUE_C_MINRES,
+        qC.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        qC.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MINRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEC is not correct");
 
 
     // unregister one NM.
     // unregister one NM.
     rm.unRegisterNode(nm1);
     rm.unRegisterNode(nm1);
@@ -759,20 +800,26 @@ public class TestAbsoluteResourceConfiguration {
     // After loosing one NM, effective min res of queueA will become just
     // After loosing one NM, effective min res of queueA will become just
     // above half. Hence A's min will be 60Gi and 6 cores and max will be
     // above half. Hence A's min will be 60Gi and 6 cores and max will be
     // 128GB and 20 cores.
     // 128GB and 20 cores.
-    Assert.assertEquals("Effective Min resource for QUEUEA is not correct",
-        QUEUEA_REDUCED, qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA is not correct",
-        QUEUEMAX_REDUCED, qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-
-    Assert.assertEquals("Effective Min resource for QUEUEB is not correct",
-        QUEUEB_REDUCED, qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEB is not correct",
-        QUEUEMAX_REDUCED, qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-
-    Assert.assertEquals("Effective Min resource for QUEUEC is not correct",
-        QUEUEC_REDUCED, qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEC is not correct",
-        QUEUEMAX_REDUCED, qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
+    assertEquals(QUEUEA_REDUCED,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA is not correct");
+    assertEquals(QUEUEMAX_REDUCED,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA is not correct");
+
+    assertEquals(QUEUEB_REDUCED,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEB is not correct");
+    assertEquals(QUEUEMAX_REDUCED,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEB is not correct");
+
+    assertEquals(QUEUEC_REDUCED,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEC is not correct");
+    assertEquals(QUEUEMAX_REDUCED,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEC is not correct");
 
 
     rm.stop();
     rm.stop();
   }
   }
@@ -800,83 +847,110 @@ public class TestAbsoluteResourceConfiguration {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
 
 
     ParentQueue qA = (ParentQueue) cs.getQueue(QUEUEA);
     ParentQueue qA = (ParentQueue) cs.getQueue(QUEUEA);
-    Assert.assertNotNull(qA);
-    Assert.assertEquals("Min resource configured for QUEUEA is not correct",
-        QUEUE_A_MINRES, qA.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEA is not correct",
-        QUEUE_A_MAXRES, qA.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEA is not correct",
-        QUEUE_A_MINRES, qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA is not correct",
-        QUEUE_A_MAXRES, qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEA is not correct",
-        0.4, qA.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEA is not correct",
-        0.8, qA.getAbsoluteMaximumCapacity(), DELTA);
+    assertNotNull(qA);
+    assertEquals(QUEUE_A_MINRES,
+        qA.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MINRES,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA is not correct");
+    assertEquals(0.4,
+        qA.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEA is not correct");
+    assertEquals(0.8,
+        qA.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEA is not correct");
 
 
     ParentQueue qB = (ParentQueue) cs.getQueue(QUEUEB);
     ParentQueue qB = (ParentQueue) cs.getQueue(QUEUEB);
-    Assert.assertNotNull(qB);
-    Assert.assertEquals("Min resource configured for QUEUEB is not correct",
-        QUEUE_B_MINRES, qB.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEB is not correct",
-        QUEUE_B_MAXRES, qB.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEB is not correct",
-        QUEUE_B_MINRES, qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEB is not correct",
-        QUEUE_B_MAXRES, qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEB is not correct",
-        0.2, qB.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEB is not correct",
-        0.6, qB.getAbsoluteMaximumCapacity(), DELTA);
+    assertNotNull(qB);
+    assertEquals(QUEUE_B_MINRES,
+        qB.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MINRES,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEB is not correct");
+    assertEquals(0.2,
+        qB.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEB is not correct");
+    assertEquals(0.6, qB.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEB is not correct");
 
 
     LeafQueue qC = (LeafQueue) cs.getQueue(QUEUEC);
     LeafQueue qC = (LeafQueue) cs.getQueue(QUEUEC);
-    Assert.assertNotNull(qC);
-    Assert.assertEquals("Min resource configured for QUEUEC is not correct",
-        QUEUE_C_MINRES, qC.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEC is not correct",
-        QUEUE_C_MAXRES, qC.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEC is not correct",
-        QUEUE_C_MINRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEC is not correct",
-        QUEUE_C_MAXRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEC is not correct",
-        0.1, qC.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEC is not correct",
-        0.6, qC.getAbsoluteMaximumCapacity(), DELTA);
+    assertNotNull(qC);
+    assertEquals(QUEUE_C_MINRES,
+        qC.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        qC.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MINRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEC is not correct");
+    assertEquals(0.1,
+        qC.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEC is not correct");
+    assertEquals(0.6,
+        qC.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEC is not correct");
 
 
     LeafQueue qA1 = (LeafQueue) cs.getQueue(QUEUEA1);
     LeafQueue qA1 = (LeafQueue) cs.getQueue(QUEUEA1);
-    Assert.assertEquals("Effective Min resource for QUEUEA1 is not correct",
-        QUEUE_A1_MINRES, qA1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA1 is not correct",
-        QUEUE_A_MAXRES, qA1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEA1 is not correct",
-        0.2, qA1.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEA1 is not correct",
-        0.8, qA1.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(QUEUE_A1_MINRES,
+        qA1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA1 is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA1 is not correct");
+    assertEquals(0.2,
+        qA1.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEA1 is not correct");
+    assertEquals(0.8,
+        qA1.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEA1 is not correct");
 
 
     LeafQueue qA2 = (LeafQueue) cs.getQueue(QUEUEA2);
     LeafQueue qA2 = (LeafQueue) cs.getQueue(QUEUEA2);
-    Assert.assertEquals("Effective Min resource for QUEUEA2 is not correct",
-        QUEUE_A2_MINRES, qA2.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA2 is not correct",
-        QUEUE_A_MAXRES, qA2.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEA2 is not correct",
-        0.2, qA2.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEA2 is not correct",
-        0.8, qA2.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(QUEUE_A2_MINRES,
+        qA2.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA2 is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA2.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA2 is not correct");
+    assertEquals(0.2, qA2.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEA2 is not correct");
+    assertEquals(0.8, qA2.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEA2 is not correct");
 
 
     LeafQueue qB1 = (LeafQueue) cs.getQueue(QUEUEB1);
     LeafQueue qB1 = (LeafQueue) cs.getQueue(QUEUEB1);
-    Assert.assertEquals("Min resource configured for QUEUEB1 is not correct",
-        QUEUE_B1_MINRES, qB1.usageTracker.getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals("Max resource configured for QUEUEB1 is not correct",
-        QUEUE_B_MAXRES, qB1.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource());
-    Assert.assertEquals("Effective Min resource for QUEUEB1 is not correct",
-        QUEUE_B1_MINRES, qB1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEB1 is not correct",
-        QUEUE_B_MAXRES, qB1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEB1 is not correct",
-        0.16, qB1.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEB1 is not correct",
-        0.6, qB1.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(QUEUE_B1_MINRES,
+        qB1.usageTracker.getQueueResourceQuotas().getConfiguredMinResource(),
+        "Min resource configured for QUEUEB1 is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB1.usageTracker.getQueueResourceQuotas().getConfiguredMaxResource(),
+        "Max resource configured for QUEUEB1 is not correct");
+    assertEquals(QUEUE_B1_MINRES,
+        qB1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEB1 is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEB1 is not correct");
+    assertEquals(0.16, qB1.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEB1 is not correct");
+    assertEquals(0.6, qB1.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEB1 is not correct");
 
 
     // add new NM.
     // add new NM.
     rm.registerNode("127.0.0.3:1234", 125 * GB, 20);
     rm.registerNode("127.0.0.3:1234", 125 * GB, 20);
@@ -884,59 +958,71 @@ public class TestAbsoluteResourceConfiguration {
     // There will be no change in effective resource when nodes are added.
     // There will be no change in effective resource when nodes are added.
     // Since configured capacity was based on initial node capacity, a
     // Since configured capacity was based on initial node capacity, a
     // re configurations is needed to use this added capacity.
     // re configurations is needed to use this added capacity.
-    Assert.assertEquals("Effective Min resource for QUEUEA is not correct",
-        QUEUE_A_MINRES, qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA is not correct",
-        QUEUE_A_MAXRES, qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEA is not correct",
-        0.266, qA.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEA is not correct",
-        0.533, qA.getAbsoluteMaximumCapacity(), DELTA);
-
-    Assert.assertEquals("Effective Min resource for QUEUEB is not correct",
-        QUEUE_B_MINRES, qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEB is not correct",
-        QUEUE_B_MAXRES, qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEB is not correct",
-        0.133, qB.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEB is not correct",
-        0.4, qB.getAbsoluteMaximumCapacity(), DELTA);
-
-    Assert.assertEquals("Effective Min resource for QUEUEC is not correct",
-        QUEUE_C_MINRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEC is not correct",
-        QUEUE_C_MAXRES, qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEC is not correct",
-        0.066, qC.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEC is not correct",
-        0.4, qC.getAbsoluteMaximumCapacity(), DELTA);
-
-    Assert.assertEquals("Effective Min resource for QUEUEB1 is not correct",
-        QUEUE_B1_MINRES, qB1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEB1 is not correct",
-        QUEUE_B_MAXRES, qB1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEB1 is not correct",
-        0.106, qB1.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEB1 is not correct",
-        0.4, qB1.getAbsoluteMaximumCapacity(), DELTA);
-
-    Assert.assertEquals("Effective Min resource for QUEUEA1 is not correct",
-        QUEUE_A1_MINRES, qA1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA1 is not correct",
-        QUEUE_A_MAXRES, qA1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEA1 is not correct",
-        0.133, qA1.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEA1 is not correct",
-        0.533, qA1.getAbsoluteMaximumCapacity(), DELTA);
-
-    Assert.assertEquals("Effective Min resource for QUEUEA2 is not correct",
-        QUEUE_A2_MINRES, qA2.usageTracker.getQueueResourceQuotas().getEffectiveMinResource());
-    Assert.assertEquals("Effective Max resource for QUEUEA2 is not correct",
-        QUEUE_A_MAXRES, qA2.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource());
-    Assert.assertEquals("Absolute capacity for QUEUEA2 is not correct",
-        0.133, qA2.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Absolute Max capacity for QUEUEA2 is not correct",
-            0.533, qA2.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(QUEUE_A_MINRES,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA is not correct");
+    assertEquals(0.266, qA.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEA is not correct");
+    assertEquals(0.533, qA.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEA is not correct");
+
+    assertEquals(QUEUE_B_MINRES,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEB is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEB is not correct");
+    assertEquals(0.133, qB.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEB is not correct");
+    assertEquals(0.4, qB.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEB is not correct");
+
+    assertEquals(QUEUE_C_MINRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEC is not correct");
+    assertEquals(QUEUE_C_MAXRES,
+        qC.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEC is not correct");
+    assertEquals(0.066, qC.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEC is not correct");
+    assertEquals(0.4, qC.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEC is not correct");
+
+    assertEquals(QUEUE_B1_MINRES,
+        qB1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEB1 is not correct");
+    assertEquals(QUEUE_B_MAXRES,
+        qB1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEB1 is not correct");
+    assertEquals(0.106, qB1.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEB1 is not correct");
+    assertEquals(0.4, qB1.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEB1 is not correct");
+
+    assertEquals(QUEUE_A1_MINRES,
+        qA1.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA1 is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA1.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA1 is not correct");
+    assertEquals(0.133, qA1.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEA1 is not correct");
+    assertEquals(0.533, qA1.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEA1 is not correct");
+
+    assertEquals(QUEUE_A2_MINRES,
+        qA2.usageTracker.getQueueResourceQuotas().getEffectiveMinResource(),
+        "Effective Min resource for QUEUEA2 is not correct");
+    assertEquals(QUEUE_A_MAXRES,
+        qA2.usageTracker.getQueueResourceQuotas().getEffectiveMaxResource(),
+        "Effective Max resource for QUEUEA2 is not correct");
+    assertEquals(0.133, qA2.getAbsoluteCapacity(), DELTA,
+        "Absolute capacity for QUEUEA2 is not correct");
+    assertEquals(0.533, qA2.getAbsoluteMaximumCapacity(), DELTA,
+        "Absolute Max capacity for QUEUEA2 is not correct");
 
 
     rm.stop();
     rm.stop();
   }
   }

+ 25 - 20
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAbsoluteResourceWithAutoQueue.java

@@ -20,10 +20,11 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
 import static org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager.NO_LABEL;
 import static org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager.NO_LABEL;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.HashSet;
@@ -45,9 +46,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.queuemanagement.GuaranteedOrZeroCapacityOverTimePolicy;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.queuemanagement.GuaranteedOrZeroCapacityOverTimePolicy;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy.FifoOrderingPolicy;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.policy.FifoOrderingPolicy;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -95,13 +97,13 @@ public class TestAbsoluteResourceWithAutoQueue
   private static final Resource QUEUE_D_MAXRES =
   private static final Resource QUEUE_D_MAXRES =
       Resource.newInstance(150 * GB, 20);
       Resource.newInstance(150 * GB, 20);
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
 
 
     accessibleNodeLabelsOnC.add(NO_LABEL);
     accessibleNodeLabelsOnC.add(NO_LABEL);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (mockRM != null) {
     if (mockRM != null) {
       mockRM.stop();
       mockRM.stop();
@@ -163,7 +165,8 @@ public class TestAbsoluteResourceWithAutoQueue
     return csConf;
     return csConf;
   }
   }
 
 
-  @Test(timeout = 20000)
+  @Test
+  @Timeout(value = 20)
   public void testAutoCreateLeafQueueCreation() throws Exception {
   public void testAutoCreateLeafQueueCreation() throws Exception {
 
 
     try {
     try {
@@ -287,20 +290,22 @@ public class TestAbsoluteResourceWithAutoQueue
     }
     }
   }
   }
 
 
-  @Test(expected = Exception.class)
+  @Test
   public void testValidateLeafQueueTemplateConfigurations() {
   public void testValidateLeafQueueTemplateConfigurations() {
+    assertThrows(Exception.class, () -> {
+      CapacitySchedulerConfiguration csConf = setupSimpleQueueConfiguration(true);
 
 
-    CapacitySchedulerConfiguration csConf = setupSimpleQueueConfiguration(true);
-
-    csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
-        ResourceScheduler.class);
+      csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
+          ResourceScheduler.class);
 
 
-    mockRM = new MockRM(csConf);
-    fail("Exception should be thrown as leaf queue template configuration is "
-        + "not same as Parent configuration");
+      mockRM = new MockRM(csConf);
+      fail("Exception should be thrown as leaf queue template configuration is "
+          + "not same as Parent configuration");
+    });
   }
   }
 
 
-  @Test(timeout = 20000)
+  @Test
+  @Timeout(value = 20)
   public void testApplicationRunningWithDRF() throws Exception {
   public void testApplicationRunningWithDRF() throws Exception {
     CapacitySchedulerConfiguration csConf =
     CapacitySchedulerConfiguration csConf =
         setupSimpleQueueConfiguration(false);
         setupSimpleQueueConfiguration(false);
@@ -329,7 +334,7 @@ public class TestAbsoluteResourceWithAutoQueue
     cs = (CapacityScheduler) mockRM.getResourceScheduler();
     cs = (CapacityScheduler) mockRM.getResourceScheduler();
     AutoCreatedLeafQueue autoCreatedLeafQueue =
     AutoCreatedLeafQueue autoCreatedLeafQueue =
         (AutoCreatedLeafQueue) cs.getQueue(TEST_GROUPUSER);
         (AutoCreatedLeafQueue) cs.getQueue(TEST_GROUPUSER);
-    assertNotNull("Auto Creation of Queue failed", autoCreatedLeafQueue);
+    assertNotNull(autoCreatedLeafQueue, "Auto Creation of Queue failed");
     ManagedParentQueue parentQueue = (ManagedParentQueue) cs.getQueue(QUEUED);
     ManagedParentQueue parentQueue = (ManagedParentQueue) cs.getQueue(QUEUED);
     assertEquals(parentQueue, autoCreatedLeafQueue.getParent());
     assertEquals(parentQueue, autoCreatedLeafQueue.getParent());
   }
   }

+ 18 - 17
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationLimits.java

@@ -19,9 +19,9 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.setQueueHandler;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.setQueueHandler;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
@@ -75,10 +75,10 @@ import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.PREFIX;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.PREFIX;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.mockito.ArgumentMatchers;
 import org.mockito.ArgumentMatchers;
-import org.mockito.Mockito;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
@@ -100,7 +100,7 @@ public class TestApplicationLimits {
   private CapacitySchedulerContext csContext;
   private CapacitySchedulerContext csContext;
 
 
   
   
-  @Before
+  @BeforeEach
   public void setUp() throws IOException {
   public void setUp() throws IOException {
     CapacitySchedulerConfiguration csConf = 
     CapacitySchedulerConfiguration csConf = 
         new CapacitySchedulerConfiguration();
         new CapacitySchedulerConfiguration();
@@ -635,16 +635,16 @@ public class TestApplicationLimits {
     when(amResourceRequest.getCapability()).thenReturn(amResource);
     when(amResourceRequest.getCapability()).thenReturn(amResource);
     when(rmApp.getAMResourceRequests()).thenReturn(
     when(rmApp.getAMResourceRequests()).thenReturn(
         Collections.singletonList(amResourceRequest));
         Collections.singletonList(amResourceRequest));
-    Mockito.doReturn(rmApp)
+    doReturn(rmApp)
         .when(spyApps).get(ArgumentMatchers.<ApplicationId>any());
         .when(spyApps).get(ArgumentMatchers.<ApplicationId>any());
     when(spyRMContext.getRMApps()).thenReturn(spyApps);
     when(spyRMContext.getRMApps()).thenReturn(spyApps);
     RMAppAttempt rmAppAttempt = mock(RMAppAttempt.class);
     RMAppAttempt rmAppAttempt = mock(RMAppAttempt.class);
     when(rmApp.getRMAppAttempt(any()))
     when(rmApp.getRMAppAttempt(any()))
         .thenReturn(rmAppAttempt);
         .thenReturn(rmAppAttempt);
     when(rmApp.getCurrentAppAttempt()).thenReturn(rmAppAttempt);
     when(rmApp.getCurrentAppAttempt()).thenReturn(rmAppAttempt);
-    Mockito.doReturn(rmApp)
+    doReturn(rmApp)
         .when(spyApps).get(ArgumentMatchers.<ApplicationId>any());
         .when(spyApps).get(ArgumentMatchers.<ApplicationId>any());
-    Mockito.doReturn(true).when(spyApps)
+    doReturn(true).when(spyApps)
         .containsKey(ArgumentMatchers.<ApplicationId>any());
         .containsKey(ArgumentMatchers.<ApplicationId>any());
 
 
     Priority priority_1 = TestUtils.createMockPriority(1);
     Priority priority_1 = TestUtils.createMockPriority(1);
@@ -781,7 +781,8 @@ public class TestApplicationLimits {
     return set;
     return set;
   }
   }
 
 
-  @Test(timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testApplicationLimitSubmit() throws Exception {
   public void testApplicationLimitSubmit() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -985,14 +986,14 @@ public class TestApplicationLimits {
     Resource expectedAmLimit = Resources.multiply(capacity,
     Resource expectedAmLimit = Resources.multiply(capacity,
         queueA.getMaxAMResourcePerQueuePercent());
         queueA.getMaxAMResourcePerQueuePercent());
     Resource amLimit = queueA.calculateAndGetAMResourceLimit();
     Resource amLimit = queueA.calculateAndGetAMResourceLimit();
-    assertTrue("AM memory limit is less than expected: Expected: " +
+    assertTrue(amLimit.getMemorySize() >= expectedAmLimit.getMemorySize(),
+        "AM memory limit is less than expected: Expected: " +
         expectedAmLimit.getMemorySize() + "; Computed: "
         expectedAmLimit.getMemorySize() + "; Computed: "
-        + amLimit.getMemorySize(),
-        amLimit.getMemorySize() >= expectedAmLimit.getMemorySize());
-    assertTrue("AM vCore limit is less than expected: Expected: " +
+        + amLimit.getMemorySize());
+    assertTrue(amLimit.getVirtualCores() >= expectedAmLimit.getVirtualCores(),
+        "AM vCore limit is less than expected: Expected: " +
         expectedAmLimit.getVirtualCores() + "; Computed: "
         expectedAmLimit.getVirtualCores() + "; Computed: "
-        + amLimit.getVirtualCores(),
-        amLimit.getVirtualCores() >= expectedAmLimit.getVirtualCores());
+        + amLimit.getVirtualCores());
   }
   }
 
 
   private CapacitySchedulerContext createCSContext(CapacitySchedulerConfiguration csConf,
   private CapacitySchedulerContext createCSContext(CapacitySchedulerConfiguration csConf,

+ 87 - 84
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationLimitsByPartition.java

@@ -17,9 +17,11 @@
  */
  */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
@@ -66,11 +68,10 @@ import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.mockito.ArgumentMatchers;
 import org.mockito.ArgumentMatchers;
-import org.mockito.Mockito;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
@@ -94,7 +95,7 @@ public class TestApplicationLimitsByPartition {
   private final ResourceCalculator resourceCalculator =
   private final ResourceCalculator resourceCalculator =
       new DefaultResourceCalculator();
       new DefaultResourceCalculator();
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws IOException {
   public void setUp() throws IOException {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -123,7 +124,8 @@ public class TestApplicationLimitsByPartition {
         RMNodeLabelsManager.EMPTY_STRING_SET));
         RMNodeLabelsManager.EMPTY_STRING_SET));
   }
   }
 
 
-  @Test(timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testAMResourceLimitWithLabels() throws Exception {
   public void testAMResourceLimitWithLabels() throws Exception {
     /*
     /*
      * Test Case:
      * Test Case:
@@ -198,22 +200,22 @@ public class TestApplicationLimitsByPartition {
 
 
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
-    Assert.assertNotNull(leafQueue);
+    assertNotNull(leafQueue);
 
 
     // Only one AM will be activated here and second AM will be still
     // Only one AM will be activated here and second AM will be still
     // pending.
     // pending.
-    Assert.assertEquals(2, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(1, leafQueue.getNumPendingApplications());
-    Assert.assertTrue("AM diagnostics not set properly", app1.getDiagnostics()
-        .toString().contains(AMState.ACTIVATED.getDiagnosticMessage()));
-    Assert.assertTrue("AM diagnostics not set properly", app2.getDiagnostics()
-        .toString().contains(AMState.ACTIVATED.getDiagnosticMessage()));
-    Assert.assertTrue("AM diagnostics not set properly",
-        pendingApp.getDiagnostics().toString()
-            .contains(AMState.INACTIVATED.getDiagnosticMessage()));
-    Assert.assertTrue("AM diagnostics not set properly",
-        pendingApp.getDiagnostics().toString().contains(
-            CSAMContainerLaunchDiagnosticsConstants.QUEUE_AM_RESOURCE_LIMIT_EXCEED));
+    assertEquals(2, leafQueue.getNumActiveApplications());
+    assertEquals(1, leafQueue.getNumPendingApplications());
+    assertTrue(app1.getDiagnostics().toString().contains(
+        AMState.ACTIVATED.getDiagnosticMessage()), "AM diagnostics not set properly");
+    assertTrue(app2.getDiagnostics().toString().contains(AMState.ACTIVATED.getDiagnosticMessage()),
+        "AM diagnostics not set properly");
+    assertTrue(pendingApp.getDiagnostics().toString()
+        .contains(AMState.INACTIVATED.getDiagnosticMessage()),
+        "AM diagnostics not set properly");
+    assertTrue(pendingApp.getDiagnostics().toString().contains(
+        CSAMContainerLaunchDiagnosticsConstants.QUEUE_AM_RESOURCE_LIMIT_EXCEED),
+        "AM diagnostics not set properly");
 
 
     // Now verify the same test case in Queue C1 where label is not configured.
     // Now verify the same test case in Queue C1 where label is not configured.
     // Submit an app to Queue C1 with empty label
     // Submit an app to Queue C1 with empty label
@@ -253,29 +255,30 @@ public class TestApplicationLimitsByPartition {
     pendingApp = MockRMAppSubmitter.submit(rm1, data);
     pendingApp = MockRMAppSubmitter.submit(rm1, data);
 
 
     leafQueue = (LeafQueue) cs.getQueue("c1");
     leafQueue = (LeafQueue) cs.getQueue("c1");
-    Assert.assertNotNull(leafQueue);
+    assertNotNull(leafQueue);
 
 
     // 2 apps will be activated, third one will be pending as am-limit
     // 2 apps will be activated, third one will be pending as am-limit
     // is reached.
     // is reached.
-    Assert.assertEquals(2, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(1, leafQueue.getNumPendingApplications());
-    Assert.assertTrue("AM diagnostics not set properly",
-        pendingApp.getDiagnostics().toString()
-            .contains(AMState.INACTIVATED.getDiagnosticMessage()));
-    Assert.assertTrue("AM diagnostics not set properly",
-        pendingApp.getDiagnostics().toString().contains(
-            CSAMContainerLaunchDiagnosticsConstants.QUEUE_AM_RESOURCE_LIMIT_EXCEED));
+    assertEquals(2, leafQueue.getNumActiveApplications());
+    assertEquals(1, leafQueue.getNumPendingApplications());
+    assertTrue(pendingApp.getDiagnostics().toString()
+        .contains(AMState.INACTIVATED.getDiagnosticMessage()),
+        "AM diagnostics not set properly");
+    assertTrue(pendingApp.getDiagnostics().toString().contains(
+        CSAMContainerLaunchDiagnosticsConstants.QUEUE_AM_RESOURCE_LIMIT_EXCEED),
+        "AM diagnostics not set properly");
 
 
     rm1.killApp(app3.getApplicationId());
     rm1.killApp(app3.getApplicationId());
     Thread.sleep(1000);
     Thread.sleep(1000);
 
 
     // After killing one running app, pending app will also get activated.
     // After killing one running app, pending app will also get activated.
-    Assert.assertEquals(2, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(0, leafQueue.getNumPendingApplications());
+    assertEquals(2, leafQueue.getNumActiveApplications());
+    assertEquals(0, leafQueue.getNumPendingApplications());
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testAtleastOneAMRunPerPartition() throws Exception {
   public void testAtleastOneAMRunPerPartition() throws Exception {
     /*
     /*
      * Test Case:
      * Test Case:
@@ -343,11 +346,11 @@ public class TestApplicationLimitsByPartition {
 
 
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
-    Assert.assertNotNull(leafQueue);
+    assertNotNull(leafQueue);
 
 
     // Only 1 app will be activated as am-limit for partition "x" is 0.15
     // Only 1 app will be activated as am-limit for partition "x" is 0.15
-    Assert.assertEquals(1, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(1, leafQueue.getNumPendingApplications());
+    assertEquals(1, leafQueue.getNumActiveApplications());
+    assertEquals(1, leafQueue.getNumPendingApplications());
 
 
     // Now verify the same test case in Queue C1 which takes default label
     // Now verify the same test case in Queue C1 which takes default label
     // to see queue level am-resource-limit is still working as expected.
     // to see queue level am-resource-limit is still working as expected.
@@ -379,15 +382,16 @@ public class TestApplicationLimitsByPartition {
     MockRMAppSubmitter.submit(rm1, data);
     MockRMAppSubmitter.submit(rm1, data);
 
 
     leafQueue = (LeafQueue) cs.getQueue("c1");
     leafQueue = (LeafQueue) cs.getQueue("c1");
-    Assert.assertNotNull(leafQueue);
+    assertNotNull(leafQueue);
 
 
     // 1 app will be activated (and it has AM resource more than queue limit)
     // 1 app will be activated (and it has AM resource more than queue limit)
-    Assert.assertEquals(1, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(1, leafQueue.getNumPendingApplications());
+    assertEquals(1, leafQueue.getNumActiveApplications());
+    assertEquals(1, leafQueue.getNumPendingApplications());
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testDefaultAMLimitFromQueueForPartition() throws Exception {
   public void testDefaultAMLimitFromQueueForPartition() throws Exception {
     /*
     /*
      * Test Case:
      * Test Case:
@@ -446,24 +450,25 @@ public class TestApplicationLimitsByPartition {
 
 
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
-    Assert.assertNotNull(leafQueue);
+    assertNotNull(leafQueue);
 
 
     // Only 1 app will be activated as am-limit for queue is 0.2 and same is
     // Only 1 app will be activated as am-limit for queue is 0.2 and same is
     // used for partition "x" also.
     // used for partition "x" also.
-    Assert.assertEquals(1, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(1, leafQueue.getNumPendingApplications());
-    Assert.assertTrue("AM diagnostics not set properly", app1.getDiagnostics()
-        .toString().contains(AMState.ACTIVATED.getDiagnosticMessage()));
-    Assert.assertTrue("AM diagnostics not set properly",
-        pendingApp.getDiagnostics().toString()
-            .contains(AMState.INACTIVATED.getDiagnosticMessage()));
-    Assert.assertTrue("AM diagnostics not set properly",
-        pendingApp.getDiagnostics().toString()
-            .contains(CSAMContainerLaunchDiagnosticsConstants.QUEUE_AM_RESOURCE_LIMIT_EXCEED));
+    assertEquals(1, leafQueue.getNumActiveApplications());
+    assertEquals(1, leafQueue.getNumPendingApplications());
+    assertTrue(app1.getDiagnostics().toString().contains(AMState.ACTIVATED.getDiagnosticMessage()),
+        "AM diagnostics not set properly");
+    assertTrue(pendingApp.getDiagnostics().toString()
+        .contains(AMState.INACTIVATED.getDiagnosticMessage()),
+        "AM diagnostics not set properly");
+    assertTrue(pendingApp.getDiagnostics().toString()
+        .contains(CSAMContainerLaunchDiagnosticsConstants.QUEUE_AM_RESOURCE_LIMIT_EXCEED),
+        "AM diagnostics not set properly");
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testUserAMResourceLimitWithLabels() throws Exception {
   public void testUserAMResourceLimitWithLabels() throws Exception {
     /*
     /*
      * Test Case:
      * Test Case:
@@ -533,12 +538,12 @@ public class TestApplicationLimitsByPartition {
 
 
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
-    Assert.assertNotNull(leafQueue);
+    assertNotNull(leafQueue);
 
 
     // Verify active applications count in this queue.
     // Verify active applications count in this queue.
-    Assert.assertEquals(2, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(1, leafQueue.getNumActiveApplications(user_0));
-    Assert.assertEquals(0, leafQueue.getNumPendingApplications());
+    assertEquals(2, leafQueue.getNumActiveApplications());
+    assertEquals(1, leafQueue.getNumActiveApplications(user_0));
+    assertEquals(0, leafQueue.getNumPendingApplications());
 
 
     // Submit 3rd app to Queue A1 for label X for user1. Now user1 will have
     // Submit 3rd app to Queue A1 for label X for user1. Now user1 will have
     // 2 applications (2 GB resource) and user0 will have one app (1GB).
     // 2 applications (2 GB resource) and user0 will have one app (1GB).
@@ -573,19 +578,19 @@ public class TestApplicationLimitsByPartition {
     RMApp pendingApp = MockRMAppSubmitter.submit(rm1, data);
     RMApp pendingApp = MockRMAppSubmitter.submit(rm1, data);
 
 
     // Verify active applications count per user and also in queue level.
     // Verify active applications count per user and also in queue level.
-    Assert.assertEquals(3, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(1, leafQueue.getNumActiveApplications(user_0));
-    Assert.assertEquals(2, leafQueue.getNumActiveApplications(user_1));
-    Assert.assertEquals(1, leafQueue.getNumPendingApplications(user_1));
-    Assert.assertEquals(1, leafQueue.getNumPendingApplications());
+    assertEquals(3, leafQueue.getNumActiveApplications());
+    assertEquals(1, leafQueue.getNumActiveApplications(user_0));
+    assertEquals(2, leafQueue.getNumActiveApplications(user_1));
+    assertEquals(1, leafQueue.getNumPendingApplications(user_1));
+    assertEquals(1, leafQueue.getNumPendingApplications());
 
 
     //verify Diagnostic messages
     //verify Diagnostic messages
-    Assert.assertTrue("AM diagnostics not set properly",
-        pendingApp.getDiagnostics().toString()
-            .contains(AMState.INACTIVATED.getDiagnosticMessage()));
-    Assert.assertTrue("AM diagnostics not set properly",
-        pendingApp.getDiagnostics().toString().contains(
-            CSAMContainerLaunchDiagnosticsConstants.USER_AM_RESOURCE_LIMIT_EXCEED));
+    assertTrue(pendingApp.getDiagnostics().toString()
+        .contains(AMState.INACTIVATED.getDiagnosticMessage()),
+        "AM diagnostics not set properly");
+    assertTrue(pendingApp.getDiagnostics().toString().contains(
+        CSAMContainerLaunchDiagnosticsConstants.USER_AM_RESOURCE_LIMIT_EXCEED),
+        "AM diagnostics not set properly");
     rm1.close();
     rm1.close();
   }
   }
 
 
@@ -684,7 +689,7 @@ public class TestApplicationLimitsByPartition {
 
 
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a1");
-    Assert.assertNotNull(leafQueue);
+    assertNotNull(leafQueue);
 
 
     /*
     /*
      *  capacity of queue A  -> 50% for label Y
      *  capacity of queue A  -> 50% for label Y
@@ -696,8 +701,8 @@ public class TestApplicationLimitsByPartition {
      *  AM resource percent config for queue A1 -> 0.25
      *  AM resource percent config for queue A1 -> 0.25
      *        ==> 2.5Gb (3 Gb) is max-am-resource-limit
      *        ==> 2.5Gb (3 Gb) is max-am-resource-limit
      */
      */
-    Assert.assertEquals(2, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(1, leafQueue.getNumPendingApplications());
+    assertEquals(2, leafQueue.getNumActiveApplications());
+    assertEquals(1, leafQueue.getNumPendingApplications());
 
 
     // Submit app3 with 1Gb AM resource to Queue B1 (no_label)
     // Submit app3 with 1Gb AM resource to Queue B1 (no_label)
     MockRMAppSubmissionData data1 =
     MockRMAppSubmissionData data1 =
@@ -723,7 +728,7 @@ public class TestApplicationLimitsByPartition {
     MockRMAppSubmitter.submit(rm1, data);
     MockRMAppSubmitter.submit(rm1, data);
 
 
     leafQueue = (LeafQueue) cs.getQueue("b1");
     leafQueue = (LeafQueue) cs.getQueue("b1");
-    Assert.assertNotNull(leafQueue);
+    assertNotNull(leafQueue);
 
 
     /*
     /*
      *  capacity of queue B  -> 90% for queue
      *  capacity of queue B  -> 90% for queue
@@ -738,8 +743,8 @@ public class TestApplicationLimitsByPartition {
      *
      *
      *  Only one app will be activated and all othe will be pending.
      *  Only one app will be activated and all othe will be pending.
      */
      */
-    Assert.assertEquals(1, leafQueue.getNumActiveApplications());
-    Assert.assertEquals(1, leafQueue.getNumPendingApplications());
+    assertEquals(1, leafQueue.getNumActiveApplications());
+    assertEquals(1, leafQueue.getNumPendingApplications());
 
 
     rm1.close();
     rm1.close();
   }
   }
@@ -824,16 +829,16 @@ public class TestApplicationLimitsByPartition {
     when(amResourceRequest.getCapability()).thenReturn(amResource);
     when(amResourceRequest.getCapability()).thenReturn(amResource);
     when(rmApp.getAMResourceRequests()).thenReturn(
     when(rmApp.getAMResourceRequests()).thenReturn(
         Collections.singletonList(amResourceRequest));
         Collections.singletonList(amResourceRequest));
-    Mockito.doReturn(rmApp)
+    doReturn(rmApp)
         .when(spyApps).get(ArgumentMatchers.<ApplicationId>any());
         .when(spyApps).get(ArgumentMatchers.<ApplicationId>any());
     when(spyRMContext.getRMApps()).thenReturn(spyApps);
     when(spyRMContext.getRMApps()).thenReturn(spyApps);
     RMAppAttempt rmAppAttempt = mock(RMAppAttempt.class);
     RMAppAttempt rmAppAttempt = mock(RMAppAttempt.class);
     when(rmApp.getRMAppAttempt(any()))
     when(rmApp.getRMAppAttempt(any()))
         .thenReturn(rmAppAttempt);
         .thenReturn(rmAppAttempt);
     when(rmApp.getCurrentAppAttempt()).thenReturn(rmAppAttempt);
     when(rmApp.getCurrentAppAttempt()).thenReturn(rmAppAttempt);
-    Mockito.doReturn(rmApp)
+    doReturn(rmApp)
         .when(spyApps).get(ArgumentMatchers.<ApplicationId>any());
         .when(spyApps).get(ArgumentMatchers.<ApplicationId>any());
-    Mockito.doReturn(true).when(spyApps)
+    doReturn(true).when(spyApps)
         .containsKey(ArgumentMatchers.<ApplicationId>any());
         .containsKey(ArgumentMatchers.<ApplicationId>any());
 
 
     Priority priority_1 = TestUtils.createMockPriority(1);
     Priority priority_1 = TestUtils.createMockPriority(1);
@@ -1008,19 +1013,17 @@ public class TestApplicationLimitsByPartition {
             .withQueue(queueName)
             .withQueue(queueName)
             .build());
             .build());
 
 
-    Assert.assertEquals("PendingApplications should be 1", 1,
-        queueA.getNumPendingApplications());
-    Assert.assertEquals("Active applications should be 2", 2,
-        queueA.getNumActiveApplications());
+    assertEquals(1, queueA.getNumPendingApplications(), "PendingApplications should be 1");
+    assertEquals(2, queueA.getNumActiveApplications(), "Active applications should be 2");
     // AMLimit is 2048,7
     // AMLimit is 2048,7
-    Assert.assertEquals(2048,
+    assertEquals(2048,
         queueA.getQueueResourceUsage().getAMLimit().getMemorySize());
         queueA.getQueueResourceUsage().getAMLimit().getMemorySize());
-    Assert.assertEquals(7,
+    assertEquals(7,
         queueA.getQueueResourceUsage().getAMLimit().getVirtualCores());
         queueA.getQueueResourceUsage().getAMLimit().getVirtualCores());
     // Used AM Resource is 2048,2
     // Used AM Resource is 2048,2
-    Assert.assertEquals(2048,
+    assertEquals(2048,
         queueA.getQueueResourceUsage().getAMUsed().getMemorySize());
         queueA.getQueueResourceUsage().getAMUsed().getMemorySize());
-    Assert.assertEquals(2,
+    assertEquals(2,
         queueA.getQueueResourceUsage().getAMUsed().getVirtualCores());
         queueA.getQueueResourceUsage().getAMUsed().getVirtualCores());
 
 
     rm.close();
     rm.close();

+ 73 - 69
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriority.java

@@ -19,6 +19,8 @@
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -58,16 +60,16 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptR
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEvent;
 import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.server.utils.BuilderUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 public class TestApplicationPriority {
 public class TestApplicationPriority {
   private final int GB = 1024;
   private final int GB = 1024;
 
 
   private YarnConfiguration conf;
   private YarnConfiguration conf;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -85,7 +87,7 @@ public class TestApplicationPriority {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
 
 
     LeafQueue q = (LeafQueue) cs.getQueue("default");
     LeafQueue q = (LeafQueue) cs.getQueue("default");
-    Assert.assertNotNull(q);
+    assertNotNull(q);
 
 
     String host = "127.0.0.1";
     String host = "127.0.0.1";
     RMNode node = MockNodes.newNodeInfo(0, MockNodes.newResource(16 * GB), 1,
     RMNode node = MockNodes.newNodeInfo(0, MockNodes.newResource(16 * GB), 1,
@@ -176,14 +178,14 @@ public class TestApplicationPriority {
     List<Container> allocated1 = am1.allocateAndWaitForContainers("127.0.0.1",
     List<Container> allocated1 = am1.allocateAndWaitForContainers("127.0.0.1",
         7, 2 * GB, nm1);
         7, 2 * GB, nm1);
 
 
-    Assert.assertEquals(7, allocated1.size());
-    Assert.assertEquals(2 * GB, allocated1.get(0).getResource().getMemorySize());
+    assertEquals(7, allocated1.size());
+    assertEquals(2 * GB, allocated1.get(0).getResource().getMemorySize());
 
 
     // check node report, 15 GB used (1 AM and 7 containers) and 1 GB available
     // check node report, 15 GB used (1 AM and 7 containers) and 1 GB available
     SchedulerNodeReport report_nm1 = rm.getResourceScheduler().getNodeReport(
     SchedulerNodeReport report_nm1 = rm.getResourceScheduler().getNodeReport(
         nm1.getNodeId());
         nm1.getNodeId());
-    Assert.assertEquals(15 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(1 * GB,
+    assertEquals(15 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(1 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     // Submit the second app App2 with priority 8 (Higher than App1)
     // Submit the second app App2 with priority 8 (Higher than App1)
@@ -200,8 +202,8 @@ public class TestApplicationPriority {
 
 
     // check node report, 16 GB used and 0 GB available
     // check node report, 16 GB used and 0 GB available
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(16 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(16 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(0 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     // get scheduler
     // get scheduler
@@ -223,8 +225,8 @@ public class TestApplicationPriority {
 
 
     // check node report, 12 GB used and 4 GB available
     // check node report, 12 GB used and 4 GB available
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(12 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(4 * GB,
+    assertEquals(12 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(4 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     // send updated request for App1
     // send updated request for App1
@@ -236,12 +238,12 @@ public class TestApplicationPriority {
         2, 2 * GB, nm1);
         2, 2 * GB, nm1);
 
 
     // App2 has got 2 containers now.
     // App2 has got 2 containers now.
-    Assert.assertEquals(2, allocated2.size());
+    assertEquals(2, allocated2.size());
 
 
     // check node report, 16 GB used and 0 GB available
     // check node report, 16 GB used and 0 GB available
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(16 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(16 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(0 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     rm.stop();
     rm.stop();
@@ -274,14 +276,14 @@ public class TestApplicationPriority {
     List<Container> allocated1 = am1.allocateAndWaitForContainers("127.0.0.1",
     List<Container> allocated1 = am1.allocateAndWaitForContainers("127.0.0.1",
         7, 1 * GB, nm1);
         7, 1 * GB, nm1);
 
 
-    Assert.assertEquals(7, allocated1.size());
-    Assert.assertEquals(1 * GB, allocated1.get(0).getResource().getMemorySize());
+    assertEquals(7, allocated1.size());
+    assertEquals(1 * GB, allocated1.get(0).getResource().getMemorySize());
 
 
     // check node report, 8 GB used (1 AM and 7 containers) and 0 GB available
     // check node report, 8 GB used (1 AM and 7 containers) and 0 GB available
     SchedulerNodeReport report_nm1 = rm.getResourceScheduler().getNodeReport(
     SchedulerNodeReport report_nm1 = rm.getResourceScheduler().getNodeReport(
         nm1.getNodeId());
         nm1.getNodeId());
-    Assert.assertEquals(8 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(8 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(0 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     // Submit the second app App2 with priority 7
     // Submit the second app App2 with priority 7
@@ -316,8 +318,8 @@ public class TestApplicationPriority {
 
 
     // check node report, 1 GB used and 7 GB available
     // check node report, 1 GB used and 7 GB available
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(1 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(7 * GB,
+    assertEquals(1 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(7 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     rm.stop();
     rm.stop();
@@ -342,7 +344,7 @@ public class TestApplicationPriority {
     RMApp app1 = MockRMAppSubmitter.submit(rm, data);
     RMApp app1 = MockRMAppSubmitter.submit(rm, data);
 
 
     // Application submission should be successful and verify priority
     // Application submission should be successful and verify priority
-    Assert.assertEquals(app1.getApplicationSubmissionContext().getPriority(),
+    assertEquals(app1.getApplicationSubmissionContext().getPriority(),
         maxPriority);
         maxPriority);
     rm.stop();
     rm.stop();
   }
   }
@@ -383,7 +385,7 @@ public class TestApplicationPriority {
         .get(app1.getApplicationId()).getCurrentAppAttempt();
         .get(app1.getApplicationId()).getCurrentAppAttempt();
 
 
     // Verify whether the new priority is updated
     // Verify whether the new priority is updated
-    Assert.assertEquals(appPriority2, schedulerAppAttempt.getPriority());
+    assertEquals(appPriority2, schedulerAppAttempt.getPriority());
   }
   }
 
 
   @Test
   @Test
@@ -425,11 +427,12 @@ public class TestApplicationPriority {
 
 
     // Verify whether priority 15 is reset to 10
     // Verify whether priority 15 is reset to 10
     Priority appPriority3 = Priority.newInstance(10);
     Priority appPriority3 = Priority.newInstance(10);
-    Assert.assertEquals(appPriority3, schedulerAppAttempt.getPriority());
+    assertEquals(appPriority3, schedulerAppAttempt.getPriority());
     rm.stop();
     rm.stop();
   }
   }
 
 
-  @Test(timeout = 180000)
+  @Test
+  @Timeout(value = 180)
   public void testRMRestartWithChangeInPriority() throws Exception {
   public void testRMRestartWithChangeInPriority() throws Exception {
     conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
     conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
     conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED,
     conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED,
@@ -481,14 +484,14 @@ public class TestApplicationPriority {
     nm1.setResourceTrackerService(rm2.getResourceTrackerService());
     nm1.setResourceTrackerService(rm2.getResourceTrackerService());
 
 
     // Verify RM Apps after this restart
     // Verify RM Apps after this restart
-    Assert.assertEquals(1, rm2.getRMContext().getRMApps().size());
+    assertEquals(1, rm2.getRMContext().getRMApps().size());
 
 
     // get scheduler app
     // get scheduler app
     RMApp loadedApp = rm2.getRMContext().getRMApps()
     RMApp loadedApp = rm2.getRMContext().getRMApps()
         .get(app1.getApplicationId());
         .get(app1.getApplicationId());
 
 
     // Verify whether priority 15 is reset to 10
     // Verify whether priority 15 is reset to 10
-    Assert.assertEquals(appPriority2, loadedApp.getApplicationPriority());
+    assertEquals(appPriority2, loadedApp.getApplicationPriority());
 
 
     rm2.stop();
     rm2.stop();
     rm1.stop();
     rm1.stop();
@@ -521,15 +524,15 @@ public class TestApplicationPriority {
     List<Container> allocated1 = am1.allocateAndWaitForContainers("127.0.0.1",
     List<Container> allocated1 = am1.allocateAndWaitForContainers("127.0.0.1",
         NUM_CONTAINERS, 2 * GB, nm1);
         NUM_CONTAINERS, 2 * GB, nm1);
 
 
-    Assert.assertEquals(7, allocated1.size());
-    Assert.assertEquals(2 * GB,
+    assertEquals(7, allocated1.size());
+    assertEquals(2 * GB,
         allocated1.get(0).getResource().getMemorySize());
         allocated1.get(0).getResource().getMemorySize());
 
 
     // check node report, 15 GB used (1 AM and 7 containers) and 1 GB available
     // check node report, 15 GB used (1 AM and 7 containers) and 1 GB available
     SchedulerNodeReport report_nm1 =
     SchedulerNodeReport report_nm1 =
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(15 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(1 * GB,
+    assertEquals(15 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(1 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     // Submit the second app App2 with priority 8 (Higher than App1)
     // Submit the second app App2 with priority 8 (Higher than App1)
@@ -546,8 +549,8 @@ public class TestApplicationPriority {
 
 
     // check node report, 16 GB used and 0 GB available
     // check node report, 16 GB used and 0 GB available
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(16 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(16 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(0 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     // get scheduler
     // get scheduler
@@ -571,8 +574,8 @@ public class TestApplicationPriority {
 
 
     // check node report, 12 GB used and 4 GB available
     // check node report, 12 GB used and 4 GB available
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(12 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(4 * GB,
+    assertEquals(12 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(4 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     // add request for containers App1
     // add request for containers App1
@@ -582,11 +585,11 @@ public class TestApplicationPriority {
     List<Container> allocated2 = am2.allocateAndWaitForContainers("127.0.0.1",
     List<Container> allocated2 = am2.allocateAndWaitForContainers("127.0.0.1",
         2, 2 * GB, nm1);
         2, 2 * GB, nm1);
 
 
-    Assert.assertEquals(2, allocated2.size());
+    assertEquals(2, allocated2.size());
     // check node report, 16 GB used and 0 GB available
     // check node report, 16 GB used and 0 GB available
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(16 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(16 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(0 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     // kill 1 more
     // kill 1 more
@@ -604,8 +607,8 @@ public class TestApplicationPriority {
 
 
     // check node report, 14 GB used and 2 GB available
     // check node report, 14 GB used and 2 GB available
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
     report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(14 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(2 * GB,
+    assertEquals(14 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(2 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
 
 
     // Change the priority of App1 to 3 (lowest)
     // Change the priority of App1 to 3 (lowest)
@@ -623,9 +626,9 @@ public class TestApplicationPriority {
     List<Container> allocated3 = am1.allocateAndWaitForContainers("127.0.0.1",
     List<Container> allocated3 = am1.allocateAndWaitForContainers("127.0.0.1",
         1, 2 * GB, nm1);
         1, 2 * GB, nm1);
 
 
-    Assert.assertEquals(1, allocated3.size());
+    assertEquals(1, allocated3.size());
     // Now App1 will have 5 containers and 1 AM. App2 will have 2 containers.
     // Now App1 will have 5 containers and 1 AM. App2 will have 2 containers.
-    Assert.assertEquals(6, schedulerAppAttemptApp1.getLiveContainers().size());
+    assertEquals(6, schedulerAppAttemptApp1.getLiveContainers().size());
     rm.stop();
     rm.stop();
   }
   }
 
 
@@ -689,8 +692,8 @@ public class TestApplicationPriority {
     am2.registerAppAttempt();
     am2.registerAppAttempt();
 
 
     rm1.drainEvents();
     rm1.drainEvents();
-    Assert.assertEquals(2, defaultQueue.getNumActiveApplications());
-    Assert.assertEquals(0, defaultQueue.getNumPendingApplications());
+    assertEquals(2, defaultQueue.getNumActiveApplications());
+    assertEquals(0, defaultQueue.getNumPendingApplications());
 
 
     // App-3 with priority 7 submitted and scheduled. But not activated since
     // App-3 with priority 7 submitted and scheduled. But not activated since
     // AMResourceLimit threshold
     // AMResourceLimit threshold
@@ -702,22 +705,22 @@ public class TestApplicationPriority {
     RMApp app3 = MockRMAppSubmitter.submit(rm1, data);
     RMApp app3 = MockRMAppSubmitter.submit(rm1, data);
 
 
     rm1.drainEvents();
     rm1.drainEvents();
-    Assert.assertEquals(2, defaultQueue.getNumActiveApplications());
-    Assert.assertEquals(1, defaultQueue.getNumPendingApplications());
+    assertEquals(2, defaultQueue.getNumActiveApplications());
+    assertEquals(1, defaultQueue.getNumPendingApplications());
 
 
     Iterator<FiCaSchedulerApp> iterator =
     Iterator<FiCaSchedulerApp> iterator =
         defaultQueue.getOrderingPolicy().getSchedulableEntities().iterator();
         defaultQueue.getOrderingPolicy().getSchedulableEntities().iterator();
     FiCaSchedulerApp fcApp2 = iterator.next();
     FiCaSchedulerApp fcApp2 = iterator.next();
-    Assert.assertEquals(app2.getCurrentAppAttempt().getAppAttemptId(),
+    assertEquals(app2.getCurrentAppAttempt().getAppAttemptId(),
         fcApp2.getApplicationAttemptId());
         fcApp2.getApplicationAttemptId());
 
 
     FiCaSchedulerApp fcApp1 = iterator.next();
     FiCaSchedulerApp fcApp1 = iterator.next();
-    Assert.assertEquals(app1.getCurrentAppAttempt().getAppAttemptId(),
+    assertEquals(app1.getCurrentAppAttempt().getAppAttemptId(),
         fcApp1.getApplicationAttemptId());
         fcApp1.getApplicationAttemptId());
 
 
     iterator = defaultQueue.getPendingApplications().iterator();
     iterator = defaultQueue.getPendingApplications().iterator();
     FiCaSchedulerApp fcApp3 = iterator.next();
     FiCaSchedulerApp fcApp3 = iterator.next();
-    Assert.assertEquals(app3.getCurrentAppAttempt().getAppAttemptId(),
+    assertEquals(app3.getCurrentAppAttempt().getAppAttemptId(),
         fcApp3.getApplicationAttemptId());
         fcApp3.getApplicationAttemptId());
 
 
     // create new RM to represent restart and recover state
     // create new RM to represent restart and recover state
@@ -729,7 +732,7 @@ public class TestApplicationPriority {
     nm1.setResourceTrackerService(rm2.getResourceTrackerService());
     nm1.setResourceTrackerService(rm2.getResourceTrackerService());
 
 
     // Verify RM Apps after this restart
     // Verify RM Apps after this restart
-    Assert.assertEquals(3, rm2.getRMContext().getRMApps().size());
+    assertEquals(3, rm2.getRMContext().getRMApps().size());
 
 
     rm2.drainEvents();
     rm2.drainEvents();
     scheduler = rm2.getRMContext().getScheduler();
     scheduler = rm2.getRMContext().getScheduler();
@@ -747,8 +750,8 @@ public class TestApplicationPriority {
 
 
     // Before NM registration, AMResourceLimit threshold is 0. So no
     // Before NM registration, AMResourceLimit threshold is 0. So no
     // applications get activated.
     // applications get activated.
-    Assert.assertEquals(0, defaultQueue.getNumActiveApplications());
-    Assert.assertEquals(3, defaultQueue.getNumPendingApplications());
+    assertEquals(0, defaultQueue.getNumActiveApplications());
+    assertEquals(3, defaultQueue.getNumPendingApplications());
 
 
     // NM resync to new RM
     // NM resync to new RM
     nm1.registerNode();
     nm1.registerNode();
@@ -763,31 +766,32 @@ public class TestApplicationPriority {
       Thread.sleep(50);
       Thread.sleep(50);
     }
     }
 
 
-    Assert.assertEquals(2, defaultQueue.getNumActiveApplications());
-    Assert.assertEquals(1, defaultQueue.getNumPendingApplications());
+    assertEquals(2, defaultQueue.getNumActiveApplications());
+    assertEquals(1, defaultQueue.getNumPendingApplications());
 
 
     // verify for order of activated applications iterator
     // verify for order of activated applications iterator
     iterator =
     iterator =
         defaultQueue.getOrderingPolicy().getSchedulableEntities().iterator();
         defaultQueue.getOrderingPolicy().getSchedulableEntities().iterator();
     fcApp2 = iterator.next();
     fcApp2 = iterator.next();
-    Assert.assertEquals(app2.getCurrentAppAttempt().getAppAttemptId(),
+    assertEquals(app2.getCurrentAppAttempt().getAppAttemptId(),
         fcApp2.getApplicationAttemptId());
         fcApp2.getApplicationAttemptId());
 
 
     fcApp1 = iterator.next();
     fcApp1 = iterator.next();
-    Assert.assertEquals(app1.getCurrentAppAttempt().getAppAttemptId(),
+    assertEquals(app1.getCurrentAppAttempt().getAppAttemptId(),
         fcApp1.getApplicationAttemptId());
         fcApp1.getApplicationAttemptId());
 
 
     // verify for pending application iterator. It should be app-3 attempt
     // verify for pending application iterator. It should be app-3 attempt
     iterator = defaultQueue.getPendingApplications().iterator();
     iterator = defaultQueue.getPendingApplications().iterator();
     fcApp3 = iterator.next();
     fcApp3 = iterator.next();
-    Assert.assertEquals(app3.getCurrentAppAttempt().getAppAttemptId(),
+    assertEquals(app3.getCurrentAppAttempt().getAppAttemptId(),
         fcApp3.getApplicationAttemptId());
         fcApp3.getApplicationAttemptId());
 
 
     rm2.stop();
     rm2.stop();
     rm1.stop();
     rm1.stop();
   }
   }
 
 
-  @Test(timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testUpdatePriorityOnPendingAppAndKillAttempt() throws Exception {
   public void testUpdatePriorityOnPendingAppAndKillAttempt() throws Exception {
     int maxPriority = 10;
     int maxPriority = 10;
     int appPriority = 5;
     int appPriority = 5;
@@ -812,8 +816,8 @@ public class TestApplicationPriority {
         ((LeafQueue) defaultQueue).getOrderingPolicy().getSchedulableEntities();
         ((LeafQueue) defaultQueue).getOrderingPolicy().getSchedulableEntities();
 
 
     // Verify app is in pending state
     // Verify app is in pending state
-    Assert.assertEquals("Pending apps should be 1", 1, appsPending.size());
-    Assert.assertEquals("Active apps should be 0", 0, activeApps.size());
+    assertEquals(1, appsPending.size(), "Pending apps should be 1");
+    assertEquals(0, activeApps.size(), "Active apps should be 0");
 
 
     // kill app1 which is pending
     // kill app1 which is pending
     killAppAndVerifyOrderingPolicy(rm, defaultQueue, 0, 0, app1);
     killAppAndVerifyOrderingPolicy(rm, defaultQueue, 0, 0, app1);
@@ -826,8 +830,8 @@ public class TestApplicationPriority {
         MockRMAppSubmissionData.Builder.createWithMemory(1024, rm)
         MockRMAppSubmissionData.Builder.createWithMemory(1024, rm)
             .withAppPriority(Priority.newInstance(appPriority)).build();
             .withAppPriority(Priority.newInstance(appPriority)).build();
     RMApp app2 = MockRMAppSubmitter.submit(rm, data2);
     RMApp app2 = MockRMAppSubmitter.submit(rm, data2);
-    Assert.assertEquals("Pending apps should be 0", 0, appsPending.size());
-    Assert.assertEquals("Active apps should be 1", 1, activeApps.size());
+    assertEquals(0, appsPending.size(), "Pending apps should be 0");
+    assertEquals(1, activeApps.size(), "Active apps should be 1");
     MockRMAppSubmissionData data1 =
     MockRMAppSubmissionData data1 =
         MockRMAppSubmissionData.Builder.createWithMemory(1024, rm)
         MockRMAppSubmissionData.Builder.createWithMemory(1024, rm)
             .withAppPriority(Priority.newInstance(appPriority)).build();
             .withAppPriority(Priority.newInstance(appPriority)).build();
@@ -836,8 +840,8 @@ public class TestApplicationPriority {
         MockRMAppSubmissionData.Builder.createWithMemory(1024, rm)
         MockRMAppSubmissionData.Builder.createWithMemory(1024, rm)
             .withAppPriority(Priority.newInstance(appPriority)).build();
             .withAppPriority(Priority.newInstance(appPriority)).build();
     RMApp app4 = MockRMAppSubmitter.submit(rm, data);
     RMApp app4 = MockRMAppSubmitter.submit(rm, data);
-    Assert.assertEquals("Pending apps should be 2", 2, appsPending.size());
-    Assert.assertEquals("Active apps should be 1", 1, activeApps.size());
+    assertEquals(2, appsPending.size(), "Pending apps should be 2");
+    assertEquals(1, activeApps.size(), "Active apps should be 1");
     // kill app3, pending apps should reduce to 1
     // kill app3, pending apps should reduce to 1
     killAppAndVerifyOrderingPolicy(rm, defaultQueue, 1, 1, app3);
     killAppAndVerifyOrderingPolicy(rm, defaultQueue, 1, 1, app3);
     // kill app2, running apps is killed and pending added to running
     // kill app2, running apps is killed and pending added to running
@@ -865,10 +869,10 @@ public class TestApplicationPriority {
         ((LeafQueue) defaultQueue).getPendingApplications();
         ((LeafQueue) defaultQueue).getPendingApplications();
     Collection<FiCaSchedulerApp> activeApps =
     Collection<FiCaSchedulerApp> activeApps =
         ((LeafQueue) defaultQueue).getApplications();
         ((LeafQueue) defaultQueue).getApplications();
-    Assert.assertEquals("Pending apps should be " + appsPendingExpected,
-        appsPendingExpected, appsPending.size());
-    Assert.assertEquals("Active apps should be " + activeAppsExpected,
-        activeAppsExpected, activeApps.size());
+    assertEquals(appsPendingExpected, appsPending.size(),
+        "Pending apps should be " + appsPendingExpected);
+    assertEquals(activeAppsExpected, activeApps.size(),
+        "Active apps should be " + activeAppsExpected);
   }
   }
 
 
 }
 }

+ 6 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriorityACLConfiguration.java

@@ -17,11 +17,12 @@
 */
 */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 import java.util.List;
 import java.util.List;
 
 
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.api.records.Priority;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 
 
 public class TestApplicationPriorityACLConfiguration {
 public class TestApplicationPriorityACLConfiguration {
@@ -117,10 +118,10 @@ public class TestApplicationPriorityACLConfiguration {
     AppPriorityACLGroup group = pGroup.get(0);
     AppPriorityACLGroup group = pGroup.get(0);
     String aclString = queueUser + " " + queueGroup;
     String aclString = queueUser + " " + queueGroup;
 
 
-    Assert.assertEquals(aclString.trim(),
+    assertEquals(aclString.trim(),
         group.getACLList().getAclString().trim());
         group.getACLList().getAclString().trim());
-    Assert.assertEquals(maxPriority, group.getMaxPriority().getPriority());
-    Assert.assertEquals(defaultPriority,
+    assertEquals(maxPriority, group.getMaxPriority().getPriority());
+    assertEquals(defaultPriority,
         group.getDefaultPriority().getPriority());
         group.getDefaultPriority().getPriority());
   }
   }
 }
 }

+ 8 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriorityACLs.java

@@ -37,9 +37,11 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.resourcemanager.ACLsTestBase;
 import org.apache.hadoop.yarn.server.resourcemanager.ACLsTestBase;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestApplicationPriorityACLs extends ACLsTestBase {
 public class TestApplicationPriorityACLs extends ACLsTestBase {
 
 
@@ -143,9 +145,9 @@ public class TestApplicationPriorityACLs extends ACLsTestBase {
         .newInstance(appSubmissionContext);
         .newInstance(appSubmissionContext);
     try {
     try {
       submitterClient.submitApplication(submitRequest);
       submitterClient.submitApplication(submitRequest);
-      Assert.fail();
+      fail();
     } catch (YarnException ex) {
     } catch (YarnException ex) {
-      Assert.assertTrue(ex.getCause() instanceof RemoteException);
+      assertTrue(ex.getCause() instanceof RemoteException);
     }
     }
   }
   }
 
 
@@ -167,10 +169,10 @@ public class TestApplicationPriorityACLs extends ACLsTestBase {
     try {
     try {
       GetApplicationReportResponse response = submitterClient
       GetApplicationReportResponse response = submitterClient
           .getApplicationReport(request);
           .getApplicationReport(request);
-      Assert.assertEquals(response.getApplicationReport().getPriority(),
+      assertEquals(response.getApplicationReport().getPriority(),
           Priority.newInstance(priority));
           Priority.newInstance(priority));
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("Application submission should not fail.");
+      fail("Application submission should not fail.");
     }
     }
   }
   }
 
 

+ 41 - 38
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAutoCreatedQueueDeletionPolicy.java

@@ -32,12 +32,15 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptS
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptRemovedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptRemovedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppRemovedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppRemovedSchedulerEvent;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerNewQueueAutoCreation.MAX_MEMORY;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerNewQueueAutoCreation.MAX_MEMORY;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestAutoCreatedQueueDeletionPolicy
 public class TestAutoCreatedQueueDeletionPolicy
     extends TestCapacitySchedulerAutoCreatedQueueBase {
     extends TestCapacitySchedulerAutoCreatedQueueBase {
@@ -61,7 +64,7 @@ public class TestAutoCreatedQueueDeletionPolicy
       /
       /
     a1
     a1
   */
   */
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     csConf = new CapacitySchedulerConfiguration();
     csConf = new CapacitySchedulerConfiguration();
     csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -81,7 +84,7 @@ public class TestAutoCreatedQueueDeletionPolicy
     csConf.setAutoExpiredDeletionTime(1);
     csConf.setAutoExpiredDeletionTime(1);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (mockRM != null) {
     if (mockRM != null) {
       mockRM.stop();
       mockRM.stop();
@@ -94,14 +97,14 @@ public class TestAutoCreatedQueueDeletionPolicy
     // Make sure e not null
     // Make sure e not null
     AbstractCSQueue e = (AbstractCSQueue) cs.
     AbstractCSQueue e = (AbstractCSQueue) cs.
         getQueue("root.e");
         getQueue("root.e");
-    Assert.assertNotNull(e);
-    Assert.assertTrue(e.isDynamicQueue());
+    assertNotNull(e);
+    assertTrue(e.isDynamicQueue());
 
 
     // Make sure e1 not null
     // Make sure e1 not null
     AbstractCSQueue e1 =  (AbstractCSQueue)cs.
     AbstractCSQueue e1 =  (AbstractCSQueue)cs.
         getQueue("root.e.e1");
         getQueue("root.e.e1");
-    Assert.assertNotNull(e1);
-    Assert.assertTrue(e1.isDynamicQueue());
+    assertNotNull(e1);
+    assertTrue(e1.isDynamicQueue());
     // signal it because of without submit created
     // signal it because of without submit created
     e1.setLastSubmittedTimestamp(Time.monotonicNow());
     e1.setLastSubmittedTimestamp(Time.monotonicNow());
 
 
@@ -115,8 +118,8 @@ public class TestAutoCreatedQueueDeletionPolicy
     // Make sure user0 not null
     // Make sure user0 not null
     AbstractCSQueue user0 = (AbstractCSQueue) cs
     AbstractCSQueue user0 = (AbstractCSQueue) cs
         .getQueue("root.e.user_0");
         .getQueue("root.e.user_0");
-    Assert.assertNotNull(user0);
-    Assert.assertTrue(user0.isDynamicQueue());
+    assertNotNull(user0);
+    assertTrue(user0.isDynamicQueue());
     // Make app finished
     // Make app finished
     AppAttemptRemovedSchedulerEvent event =
     AppAttemptRemovedSchedulerEvent event =
         new AppAttemptRemovedSchedulerEvent(user0AppAttemptId,
         new AppAttemptRemovedSchedulerEvent(user0AppAttemptId,
@@ -127,7 +130,7 @@ public class TestAutoCreatedQueueDeletionPolicy
     cs.handle(rEvent);
     cs.handle(rEvent);
 
 
     // There are no apps in user0
     // There are no apps in user0
-    Assert.assertEquals(user0.getNumApplications(), 0);
+    assertEquals(user0.getNumApplications(), 0);
 
 
     // Wait the time expired.
     // Wait the time expired.
     long l1 = user0.getLastSubmittedTimestamp();
     long l1 = user0.getLastSubmittedTimestamp();
@@ -148,29 +151,29 @@ public class TestAutoCreatedQueueDeletionPolicy
     // Make sure user_0 , e1 queue
     // Make sure user_0 , e1 queue
     // will be scheduled to mark for deletion
     // will be scheduled to mark for deletion
     // because it is expired for deletion.
     // because it is expired for deletion.
-    Assert.assertEquals(policy.getMarkedForDeletion().size(), 2);
-    Assert.assertTrue(policy.
+    assertEquals(policy.getMarkedForDeletion().size(), 2);
+    assertTrue(policy.
         getMarkedForDeletion().contains("root.e.user_0"));
         getMarkedForDeletion().contains("root.e.user_0"));
-    Assert.assertTrue(policy.
+    assertTrue(policy.
         getMarkedForDeletion().contains("root.e.e1"));
         getMarkedForDeletion().contains("root.e.e1"));
     // Make sure the send for deletion is empty for first mark.
     // Make sure the send for deletion is empty for first mark.
-    Assert.assertEquals(policy.getSentForDeletion().size(), 0);
+    assertEquals(policy.getSentForDeletion().size(), 0);
 
 
     // Make sure user_0 , e1 queue will be scheduled to send for deletion
     // Make sure user_0 , e1 queue will be scheduled to send for deletion
     policy.prepareForAutoDeletion();
     policy.prepareForAutoDeletion();
-    Assert.assertEquals(policy.getMarkedForDeletion().size(), 0);
-    Assert.assertEquals(policy.getSentForDeletion().size(), 2);
+    assertEquals(policy.getMarkedForDeletion().size(), 0);
+    assertEquals(policy.getSentForDeletion().size(), 2);
 
 
     // Make sure e1, user0 not null before trigger remove.
     // Make sure e1, user0 not null before trigger remove.
     e1 = (AbstractCSQueue) cs.getQueue("root.e.e1");
     e1 = (AbstractCSQueue) cs.getQueue("root.e.e1");
-    Assert.assertNotNull(e1);
+    assertNotNull(e1);
     user0 =  (AbstractCSQueue)cs.getQueue("root.e.user_0");
     user0 =  (AbstractCSQueue)cs.getQueue("root.e.user_0");
-    Assert.assertNotNull(user0);
+    assertNotNull(user0);
 
 
     // Make sure e1, user0 will be null after trigger remove.
     // Make sure e1, user0 will be null after trigger remove.
     policy.triggerAutoDeletionForExpiredQueues();
     policy.triggerAutoDeletionForExpiredQueues();
-    Assert.assertEquals(policy.getMarkedForDeletion().size(), 0);
-    Assert.assertEquals(policy.getSentForDeletion().size(), 0);
+    assertEquals(policy.getMarkedForDeletion().size(), 0);
+    assertEquals(policy.getSentForDeletion().size(), 0);
 
 
     // Wait e1, user0 auto deleted.
     // Wait e1, user0 auto deleted.
     GenericTestUtils.waitFor(()-> cs.getQueue(
     GenericTestUtils.waitFor(()-> cs.getQueue(
@@ -180,13 +183,13 @@ public class TestAutoCreatedQueueDeletionPolicy
         "root.e.user_0") == null,
         "root.e.user_0") == null,
         100, 2000);
         100, 2000);
     e1 = (AbstractCSQueue) cs.getQueue("root.e.e1");
     e1 = (AbstractCSQueue) cs.getQueue("root.e.e1");
-    Assert.assertNull(e1);
+    assertNull(e1);
     user0 =  (AbstractCSQueue)cs.getQueue("root.e.user_0");
     user0 =  (AbstractCSQueue)cs.getQueue("root.e.user_0");
-    Assert.assertNull(user0);
+    assertNull(user0);
 
 
     // Make sure e is not null, before schedule.
     // Make sure e is not null, before schedule.
     e = (AbstractCSQueue) cs.getQueue("root.e");
     e = (AbstractCSQueue) cs.getQueue("root.e");
-    Assert.assertNotNull(e);
+    assertNotNull(e);
 
 
     // Expired for e
     // Expired for e
     // Wait e marked for deletion.
     // Wait e marked for deletion.
@@ -198,29 +201,29 @@ public class TestAutoCreatedQueueDeletionPolicy
     }, 100, 2000);
     }, 100, 2000);
     policy.editSchedule();
     policy.editSchedule();
     e = (AbstractCSQueue) cs.getQueue("root.e");
     e = (AbstractCSQueue) cs.getQueue("root.e");
-    Assert.assertNotNull(e);
-    Assert.assertEquals(policy.getMarkedForDeletion().size(), 1);
-    Assert.assertEquals(policy.getSentForDeletion().size(), 0);
-    Assert.assertTrue(policy.getMarkedForDeletion().contains("root.e"));
+    assertNotNull(e);
+    assertEquals(policy.getMarkedForDeletion().size(), 1);
+    assertEquals(policy.getSentForDeletion().size(), 0);
+    assertTrue(policy.getMarkedForDeletion().contains("root.e"));
 
 
     // Make sure e queue will be scheduled to send for deletion
     // Make sure e queue will be scheduled to send for deletion
     policy.prepareForAutoDeletion();
     policy.prepareForAutoDeletion();
-    Assert.assertEquals(policy.getMarkedForDeletion().size(), 0);
-    Assert.assertEquals(policy.getSentForDeletion().size(), 1);
+    assertEquals(policy.getMarkedForDeletion().size(), 0);
+    assertEquals(policy.getSentForDeletion().size(), 1);
 
 
     // Make sure e not null before trigger remove.
     // Make sure e not null before trigger remove.
     e = (AbstractCSQueue) cs.getQueue("root.e");
     e = (AbstractCSQueue) cs.getQueue("root.e");
-    Assert.assertNotNull(e);
+    assertNotNull(e);
 
 
     // Make sure e will be null after trigger remove.
     // Make sure e will be null after trigger remove.
     policy.triggerAutoDeletionForExpiredQueues();
     policy.triggerAutoDeletionForExpiredQueues();
     // Wait e1 auto deleted.
     // Wait e1 auto deleted.
     GenericTestUtils.waitFor(()-> cs.getQueue(
     GenericTestUtils.waitFor(()-> cs.getQueue(
         "root.e") == null, 100, 2000);
         "root.e") == null, 100, 2000);
-    Assert.assertEquals(policy.getMarkedForDeletion().size(), 0);
-    Assert.assertEquals(policy.getSentForDeletion().size(), 0);
+    assertEquals(policy.getMarkedForDeletion().size(), 0);
+    assertEquals(policy.getSentForDeletion().size(), 0);
     e = (AbstractCSQueue) cs.getQueue("root.e");
     e = (AbstractCSQueue) cs.getQueue("root.e");
-    Assert.assertNull(e);
+    assertNull(e);
   }
   }
 
 
   public void prepareForSchedule() throws Exception{
   public void prepareForSchedule() throws Exception{
@@ -228,8 +231,8 @@ public class TestAutoCreatedQueueDeletionPolicy
 
 
     policy.editSchedule();
     policy.editSchedule();
     // There are no queues should be scheduled
     // There are no queues should be scheduled
-    Assert.assertEquals(policy.getMarkedForDeletion().size(), 0);
-    Assert.assertEquals(policy.getSentForDeletion().size(), 0);
+    assertEquals(policy.getMarkedForDeletion().size(), 0);
+    assertEquals(policy.getSentForDeletion().size(), 0);
 
 
     createQueue("root.e.e1");
     createQueue("root.e.e1");
   }
   }

+ 46 - 44
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAutoCreatedQueueTemplate.java

@@ -18,9 +18,12 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.AUTO_CREATE_CHILD_QUEUE_AUTO_REMOVAL_ENABLE;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.AUTO_CREATE_CHILD_QUEUE_AUTO_REMOVAL_ENABLE;
 
 
@@ -37,7 +40,7 @@ public class TestAutoCreatedQueueTemplate {
 
 
   private CapacitySchedulerConfiguration conf;
   private CapacitySchedulerConfiguration conf;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new CapacitySchedulerConfiguration();
     conf = new CapacitySchedulerConfiguration();
     conf.setQueues(ROOT, new String[]{"a"});
     conf.setQueues(ROOT, new String[]{"a"});
@@ -53,8 +56,8 @@ public class TestAutoCreatedQueueTemplate {
         new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB);
         new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
 
 
-    Assert.assertEquals("weight is not set", 6f,
-        conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6);
+    assertEquals(6f, conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC),
+        10e-6, "weight is not set");
 
 
   }
   }
 
 
@@ -65,8 +68,8 @@ public class TestAutoCreatedQueueTemplate {
         new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB);
         new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
 
 
-    Assert.assertEquals("weight is not set", 6f,
-        conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6);
+    assertEquals(6f, conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6,
+        "weight is not set");
 
 
   }
   }
 
 
@@ -80,10 +83,10 @@ public class TestAutoCreatedQueueTemplate {
     new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB)
     new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB)
             .setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
             .setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
 
 
-    Assert.assertEquals("weight is not set", 6f,
-            conf.getNonLabeledQueueWeight(TEST_QUEUE_AB), 10e-6);
-    Assert.assertEquals("weight is not set", 5f,
-            conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6);
+    assertEquals(6f, conf.getNonLabeledQueueWeight(TEST_QUEUE_AB), 10e-6,
+        "weight is not set");
+    assertEquals(5f, conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6,
+        "weight is not set");
   }
   }
 
 
   @Test
   @Test
@@ -93,8 +96,8 @@ public class TestAutoCreatedQueueTemplate {
         new AutoCreatedQueueTemplate(conf, ROOT);
         new AutoCreatedQueueTemplate(conf, ROOT);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_A);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_A);
 
 
-    Assert.assertEquals("weight is set", -1f,
-        conf.getNonLabeledQueueWeight(TEST_QUEUE_A), 10e-6);
+    assertEquals(-1f, conf.getNonLabeledQueueWeight(TEST_QUEUE_A), 10e-6,
+        "weight is set");
   }
   }
 
 
   @Test
   @Test
@@ -104,8 +107,7 @@ public class TestAutoCreatedQueueTemplate {
         new AutoCreatedQueueTemplate(conf, ROOT);
         new AutoCreatedQueueTemplate(conf, ROOT);
     template.setTemplateEntriesForChild(conf, ROOT);
     template.setTemplateEntriesForChild(conf, ROOT);
 
 
-    Assert.assertEquals("weight is set", -1f,
-        conf.getNonLabeledQueueWeight(ROOT), 10e-6);
+    assertEquals(-1f, conf.getNonLabeledQueueWeight(ROOT), 10e-6, "weight is set");
   }
   }
 
 
   @Test
   @Test
@@ -115,8 +117,9 @@ public class TestAutoCreatedQueueTemplate {
         new AutoCreatedQueueTemplate(conf, TEST_QUEUE_A);
         new AutoCreatedQueueTemplate(conf, TEST_QUEUE_A);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_A);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_A);
 
 
-    Assert.assertEquals("acl_submit_applications is set", "user",
-        template.getTemplateProperties().get("acl_submit_applications"));
+    assertEquals("user",
+        template.getTemplateProperties().get("acl_submit_applications"),
+        "acl_submit_applications is set");
   }
   }
 
 
   @Test
   @Test
@@ -129,9 +132,8 @@ public class TestAutoCreatedQueueTemplate {
         new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB);
         new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
 
 
-    Assert.assertEquals(
-        "explicit template does not have the highest precedence", 6f,
-        conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6);
+    assertEquals(6f, conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6,
+        "explicit template does not have the highest precedence");
 
 
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
         new CapacitySchedulerConfiguration();
         new CapacitySchedulerConfiguration();
@@ -140,8 +142,8 @@ public class TestAutoCreatedQueueTemplate {
         new AutoCreatedQueueTemplate(newConf, TEST_QUEUE_AB);
         new AutoCreatedQueueTemplate(newConf, TEST_QUEUE_AB);
     template.setTemplateEntriesForChild(newConf, TEST_QUEUE_ABC);
     template.setTemplateEntriesForChild(newConf, TEST_QUEUE_ABC);
 
 
-    Assert.assertEquals("precedence is invalid", 4f,
-        newConf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6);
+    assertEquals(4f, newConf.getNonLabeledQueueWeight(TEST_QUEUE_ABC),
+        10e-6, "precedence is invalid");
   }
   }
 
 
   @Test
   @Test
@@ -151,8 +153,8 @@ public class TestAutoCreatedQueueTemplate {
     AutoCreatedQueueTemplate template =
     AutoCreatedQueueTemplate template =
         new AutoCreatedQueueTemplate(conf, ROOT);
         new AutoCreatedQueueTemplate(conf, ROOT);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_A);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_A);
-    Assert.assertEquals("root property is not set", 2f,
-        conf.getNonLabeledQueueWeight(TEST_QUEUE_A), 10e-6);
+    assertEquals(2f, conf.getNonLabeledQueueWeight(TEST_QUEUE_A), 10e-6,
+        "root property is not set");
   }
   }
 
 
   @Test
   @Test
@@ -169,17 +171,17 @@ public class TestAutoCreatedQueueTemplate {
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_A);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_A);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_B, true);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_B, true);
 
 
-    Assert.assertNull("default-node-label-expression is set for parent",
-        conf.getDefaultNodeLabelExpression(TEST_QUEUE_A));
-    Assert.assertEquals("default-node-label-expression is not set for leaf",
-        "test", conf.getDefaultNodeLabelExpression(TEST_QUEUE_B));
-    Assert.assertFalse("auto queue removal is not disabled for parent",
-        conf.isAutoExpiredDeletionEnabled(TEST_QUEUE_A));
-    Assert.assertEquals("weight should not be overridden when set by " +
-            "queue type specific template",
-        10f, conf.getNonLabeledQueueWeight(TEST_QUEUE_B), 10e-6);
-    Assert.assertEquals("weight should be set by common template",
-        2f, conf.getNonLabeledQueueWeight(TEST_QUEUE_A), 10e-6);
+    assertNull(conf.getDefaultNodeLabelExpression(TEST_QUEUE_A),
+        "default-node-label-expression is set for parent");
+    assertEquals("test", conf.getDefaultNodeLabelExpression(TEST_QUEUE_B),
+        "default-node-label-expression is not set for leaf");
+    assertFalse(conf.isAutoExpiredDeletionEnabled(TEST_QUEUE_A),
+        "auto queue removal is not disabled for parent");
+    assertEquals(10f, conf.getNonLabeledQueueWeight(TEST_QUEUE_B),
+        10e-6, "weight should not be overridden when set by " +
+        "queue type specific template");
+    assertEquals(2f, conf.getNonLabeledQueueWeight(TEST_QUEUE_A), 10e-6,
+        "weight should be set by common template");
 
 
   }
   }
 
 
@@ -195,10 +197,10 @@ public class TestAutoCreatedQueueTemplate {
     new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB)
     new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB)
         .setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
         .setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
 
 
-    Assert.assertEquals("weight is not set", 6f,
-        conf.getNonLabeledQueueWeight(TEST_QUEUE_AB), 10e-6);
-    Assert.assertEquals("weight is not set", 5f,
-        conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6);
+    assertEquals(6f, conf.getNonLabeledQueueWeight(TEST_QUEUE_AB), 10e-6,
+        "weight is not set");
+    assertEquals(5f, conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6,
+        "weight is not set");
   }
   }
 
 
   @Test
   @Test
@@ -209,8 +211,8 @@ public class TestAutoCreatedQueueTemplate {
     new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB)
     new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB)
         .setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
         .setTemplateEntriesForChild(conf, TEST_QUEUE_ABC);
 
 
-    Assert.assertEquals("weight is set incorrectly", -1f,
-        conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6);
+    assertEquals(-1f, conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6,
+        "weight is set incorrectly");
   }
   }
 
 
   @Test
   @Test
@@ -221,8 +223,8 @@ public class TestAutoCreatedQueueTemplate {
         new AutoCreatedQueueTemplate(conf, invalidPath);
         new AutoCreatedQueueTemplate(conf, invalidPath);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_AB);
     template.setTemplateEntriesForChild(conf, TEST_QUEUE_AB);
 
 
-    Assert.assertEquals("weight is set using invalid queue path", -1f,
-        conf.getNonLabeledQueueWeight(TEST_QUEUE_AB), 10e-6);
+    assertEquals(-1f, conf.getNonLabeledQueueWeight(TEST_QUEUE_AB),
+        10e-6, "weight is set using invalid queue path");
   }
   }
 
 
   private String getTemplateKey(QueuePath queuePath, String entryKey) {
   private String getTemplateKey(QueuePath queuePath, String entryKey) {

+ 22 - 28
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCSAllocateCustomResource.java

@@ -44,10 +44,9 @@ import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -63,7 +62,8 @@ import java.util.stream.Collectors;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.FPGA_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.FPGA_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.GPU_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.GPU_URI;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION_MB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION_MB;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
 
 /**
 /**
  * Test case for custom resource container allocation.
  * Test case for custom resource container allocation.
@@ -85,7 +85,7 @@ public class TestCSAllocateCustomResource {
   private ClusterNodeTracker<FiCaSchedulerNode> nodeTracker;
   private ClusterNodeTracker<FiCaSchedulerNode> nodeTracker;
   private ClusterMetrics metrics;
   private ClusterMetrics metrics;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -94,7 +94,7 @@ public class TestCSAllocateCustomResource {
     mgr.init(conf);
     mgr.init(conf);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (resourceTypesFile != null && resourceTypesFile.exists()) {
     if (resourceTypesFile != null && resourceTypesFile.exists()) {
       resourceTypesFile.delete();
       resourceTypesFile.delete();
@@ -162,7 +162,7 @@ public class TestCSAllocateCustomResource {
     // Do nm heartbeats 1 times, will allocate a container on nm1
     // Do nm heartbeats 1 times, will allocate a container on nm1
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     rm.drainEvents();
     rm.drainEvents();
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
     rm.close();
     rm.close();
   }
   }
 
 
@@ -193,12 +193,12 @@ public class TestCSAllocateCustomResource {
 
 
     // Ensure the method can get custom resource type from
     // Ensure the method can get custom resource type from
     // CapacitySchedulerConfiguration
     // CapacitySchedulerConfiguration
-    Assert.assertNotEquals(0,
+    assertNotEquals(0,
         ResourceUtils
         ResourceUtils
             .fetchMaximumAllocationFromConfig(cs.getConfiguration())
             .fetchMaximumAllocationFromConfig(cs.getConfiguration())
             .getResourceValue("yarn.io/gpu"));
             .getResourceValue("yarn.io/gpu"));
     // Ensure custom resource type exists in queue's maximumAllocation
     // Ensure custom resource type exists in queue's maximumAllocation
-    Assert.assertNotEquals(0,
+    assertNotEquals(0,
         cs.getMaximumResourceCapability("a")
         cs.getMaximumResourceCapability("a")
             .getResourceValue("yarn.io/gpu"));
             .getResourceValue("yarn.io/gpu"));
     rm.close();
     rm.close();
@@ -236,26 +236,20 @@ public class TestCSAllocateCustomResource {
     }
     }
 
 
     // Check GPU inc related cluster metrics.
     // Check GPU inc related cluster metrics.
-    assertEquals("Cluster Capability Memory incorrect",
-        metrics.getCapabilityMB(), (4096 * 8));
-    assertEquals("Cluster Capability Vcores incorrect",
-        metrics.getCapabilityVirtualCores(), 4 * 8);
-    assertEquals("Cluster Capability GPUs incorrect",
-        (metrics.getCustomResourceCapability()
-            .get(GPU_URI)).longValue(), 4 * 8);
+    assertEquals(metrics.getCapabilityMB(), (4096 * 8), "Cluster Capability Memory incorrect");
+    assertEquals(metrics.getCapabilityVirtualCores(), 4 * 8, "Cluster Capability Vcores incorrect");
+    assertEquals((metrics.getCustomResourceCapability()
+        .get(GPU_URI)).longValue(), 4 * 8, "Cluster Capability GPUs incorrect");
 
 
     for (RMNode rmNode : rmNodes) {
     for (RMNode rmNode : rmNodes) {
       nodeTracker.removeNode(rmNode.getNodeID());
       nodeTracker.removeNode(rmNode.getNodeID());
     }
     }
 
 
     // Check GPU dec related cluster metrics.
     // Check GPU dec related cluster metrics.
-    assertEquals("Cluster Capability Memory incorrect",
-        metrics.getCapabilityMB(), 0);
-    assertEquals("Cluster Capability Vcores incorrect",
-        metrics.getCapabilityVirtualCores(), 0);
-    assertEquals("Cluster Capability GPUs incorrect",
-        (metrics.getCustomResourceCapability()
-            .get(GPU_URI)).longValue(), 0);
+    assertEquals(metrics.getCapabilityMB(), 0, "Cluster Capability Memory incorrect");
+    assertEquals(metrics.getCapabilityVirtualCores(), 0, "Cluster Capability Vcores incorrect");
+    assertEquals((metrics.getCustomResourceCapability()
+        .get(GPU_URI)).longValue(), 0, "Cluster Capability GPUs incorrect");
     ClusterMetrics.destroy();
     ClusterMetrics.destroy();
     rm.stop();
     rm.stop();
   }
   }
@@ -317,17 +311,17 @@ public class TestCSAllocateCustomResource {
 
 
     // Check the gpu resource conf is right.
     // Check the gpu resource conf is right.
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
-    Assert.assertEquals(aMINRES,
+    assertEquals(aMINRES,
         cs.getConfiguration().
         cs.getConfiguration().
             getMinimumResourceRequirement("", A, resourceTypes));
             getMinimumResourceRequirement("", A, resourceTypes));
-    Assert.assertEquals(aMAXRES,
+    assertEquals(aMAXRES,
         cs.getConfiguration().
         cs.getConfiguration().
             getMaximumResourceRequirement("", A, resourceTypes));
             getMaximumResourceRequirement("", A, resourceTypes));
 
 
     // Check the gpu resource of queue is right.
     // Check the gpu resource of queue is right.
-    Assert.assertEquals(aMINRES, cs.getQueue("root.a").
+    assertEquals(aMINRES, cs.getQueue("root.a").
         getQueueResourceQuotas().getConfiguredMinResource());
         getQueueResourceQuotas().getConfiguredMinResource());
-    Assert.assertEquals(aMAXRES, cs.getQueue("root.a").
+    assertEquals(aMAXRES, cs.getQueue("root.a").
         getQueueResourceQuotas().getConfiguredMaxResource());
         getQueueResourceQuotas().getConfiguredMaxResource());
 
 
     rm.close();
     rm.close();

+ 4 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCSMaxRunningAppsEnforcer.java

@@ -18,7 +18,7 @@
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.PREFIX;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.PREFIX;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
@@ -43,8 +43,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaS
 import org.apache.hadoop.yarn.server.resourcemanager.security.AppPriorityACLsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.security.AppPriorityACLsManager;
 import org.apache.hadoop.yarn.util.ControlledClock;
 import org.apache.hadoop.yarn.util.ControlledClock;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 public class TestCSMaxRunningAppsEnforcer {
 public class TestCSMaxRunningAppsEnforcer {
   private CapacitySchedulerQueueManager queueManager;
   private CapacitySchedulerQueueManager queueManager;
@@ -56,7 +56,7 @@ public class TestCSMaxRunningAppsEnforcer {
   private ActivitiesManager activitiesManager;
   private ActivitiesManager activitiesManager;
   private CapacitySchedulerConfiguration csConfig;
   private CapacitySchedulerConfiguration csConfig;
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     csConfig = new CapacitySchedulerConfiguration();
     csConfig = new CapacitySchedulerConfiguration();
     rmContext = mock(RMContext.class);
     rmContext = mock(RMContext.class);

+ 10 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCSQueueStore.java

@@ -24,13 +24,18 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 
 public class TestCSQueueStore {
 public class TestCSQueueStore {
 
 
@@ -41,7 +46,7 @@ public class TestCSQueueStore {
   private CapacitySchedulerContext csContext;
   private CapacitySchedulerContext csContext;
   private CapacitySchedulerQueueContext queueContext;
   private CapacitySchedulerQueueContext queueContext;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws IOException {
   public void setUp() throws IOException {
     CapacitySchedulerConfiguration csConf =
     CapacitySchedulerConfiguration csConf =
             new CapacitySchedulerConfiguration();
             new CapacitySchedulerConfiguration();

文件差异内容过多而无法显示
+ 214 - 208
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java


+ 1 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAmbiguousLeafs.java

@@ -25,7 +25,7 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
 import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 

+ 144 - 139
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerApps.java

@@ -86,10 +86,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedule
 import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.MockNM.createMockNodeStatus;
 import static org.apache.hadoop.yarn.server.resourcemanager.MockNM.createMockNodeStatus;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.A;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.A;
@@ -110,9 +110,11 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.C
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.setUpMove;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.setUpMove;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.setUpMoveAmbiguousQueue;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.setUpMoveAmbiguousQueue;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.stopResourceManager;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.stopResourceManager;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -123,13 +125,13 @@ public class TestCapacitySchedulerApps {
   private ResourceManager resourceManager = null;
   private ResourceManager resourceManager = null;
   private RMContext mockContext;
   private RMContext mockContext;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     resourceManager = createResourceManager();
     resourceManager = createResourceManager();
     mockContext = createMockRMContext();
     mockContext = createMockRMContext();
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     stopResourceManager(resourceManager);
     stopResourceManager(resourceManager);
   }
   }
@@ -161,7 +163,7 @@ public class TestCapacitySchedulerApps {
     assertTrue(appsInRoot.contains(application2.getApplicationAttemptId()));
     assertTrue(appsInRoot.contains(application2.getApplicationAttemptId()));
     assertEquals(3, appsInRoot.size());
     assertEquals(3, appsInRoot.size());
 
 
-    Assert.assertNull(scheduler.getAppsInQueue("nonexistentqueue"));
+    assertNull(scheduler.getAppsInQueue("nonexistentqueue"));
   }
   }
 
 
   @Test
   @Test
@@ -178,7 +180,7 @@ public class TestCapacitySchedulerApps {
     SchedulerApplication<SchedulerApplicationAttempt> app =
     SchedulerApplication<SchedulerApplicationAttempt> app =
         TestSchedulerUtils.verifyAppAddedAndRemovedFromScheduler(
         TestSchedulerUtils.verifyAppAddedAndRemovedFromScheduler(
             cs.getSchedulerApplications(), cs, "a1");
             cs.getSchedulerApplications(), cs, "a1");
-    Assert.assertEquals("a1", app.getQueue().getQueueName());
+    assertEquals("a1", app.getQueue().getQueueName());
   }
   }
 
 
   @Test
   @Test
@@ -211,7 +213,7 @@ public class TestCapacitySchedulerApps {
     String queue =
     String queue =
         scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
         scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
             .getQueueName();
             .getQueueName();
-    Assert.assertEquals("a1", queue);
+    assertEquals("a1", queue);
 
 
     List<ApplicationAttemptId> appsInRoot = scheduler.getAppsInQueue("root");
     List<ApplicationAttemptId> appsInRoot = scheduler.getAppsInQueue("root");
     assertTrue(appsInRoot.contains(appAttemptId));
     assertTrue(appsInRoot.contains(appAttemptId));
@@ -258,7 +260,7 @@ public class TestCapacitySchedulerApps {
     // now kill the app
     // now kill the app
     try {
     try {
       scheduler.killAllAppsInQueue("DOES_NOT_EXIST");
       scheduler.killAllAppsInQueue("DOES_NOT_EXIST");
-      Assert.fail();
+      fail();
     } catch (YarnException e) {
     } catch (YarnException e) {
       // expected
       // expected
     }
     }
@@ -280,7 +282,8 @@ public class TestCapacitySchedulerApps {
 
 
   // Test to ensure that we don't carry out reservation on nodes
   // Test to ensure that we don't carry out reservation on nodes
   // that have no CPU available when using the DominantResourceCalculator
   // that have no CPU available when using the DominantResourceCalculator
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testAppReservationWithDominantResourceCalculator() throws Exception {
   public void testAppReservationWithDominantResourceCalculator() throws Exception {
     CapacitySchedulerConfiguration csconf =
     CapacitySchedulerConfiguration csconf =
         new CapacitySchedulerConfiguration();
         new CapacitySchedulerConfiguration();
@@ -309,8 +312,8 @@ public class TestCapacitySchedulerApps {
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
 
 
     // check node report
     // check node report
-    Assert.assertEquals(1 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(9 * GB, reportNm1.getAvailableResource().getMemorySize());
+    assertEquals(1 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(9 * GB, reportNm1.getAvailableResource().getMemorySize());
 
 
     // add request for containers
     // add request for containers
     am1.addRequests(new String[]{"127.0.0.1", "127.0.0.2"}, 1 * GB, 1, 1);
     am1.addRequests(new String[]{"127.0.0.1", "127.0.0.2"}, 1 * GB, 1, 1);
@@ -323,8 +326,8 @@ public class TestCapacitySchedulerApps {
     ApplicationResourceUsageReport report =
     ApplicationResourceUsageReport report =
         rm.getResourceScheduler().getAppResourceUsageReport(
         rm.getResourceScheduler().getAppResourceUsageReport(
             attempt1.getAppAttemptId());
             attempt1.getAppAttemptId());
-    Assert.assertEquals(0, allocResponse.getAllocatedContainers().size());
-    Assert.assertEquals(0, report.getNumReservedContainers());
+    assertEquals(0, allocResponse.getAllocatedContainers().size());
+    assertEquals(0, report.getNumReservedContainers());
 
 
     // container should get allocated on this node
     // container should get allocated on this node
     nm2.nodeHeartbeat(true);
     nm2.nodeHeartbeat(true);
@@ -336,8 +339,8 @@ public class TestCapacitySchedulerApps {
     report =
     report =
         rm.getResourceScheduler().getAppResourceUsageReport(
         rm.getResourceScheduler().getAppResourceUsageReport(
             attempt1.getAppAttemptId());
             attempt1.getAppAttemptId());
-    Assert.assertEquals(1, allocResponse.getAllocatedContainers().size());
-    Assert.assertEquals(0, report.getNumReservedContainers());
+    assertEquals(1, allocResponse.getAllocatedContainers().size());
+    assertEquals(0, report.getNumReservedContainers());
     rm.stop();
     rm.stop();
   }
   }
 
 
@@ -347,7 +350,7 @@ public class TestCapacitySchedulerApps {
     AbstractYarnScheduler scheduler =
     AbstractYarnScheduler scheduler =
         (AbstractYarnScheduler) rm.getResourceScheduler();
         (AbstractYarnScheduler) rm.getResourceScheduler();
     QueueMetrics metrics = scheduler.getRootQueueMetrics();
     QueueMetrics metrics = scheduler.getRootQueueMetrics();
-    Assert.assertEquals(0, metrics.getAppsPending());
+    assertEquals(0, metrics.getAppsPending());
     // submit an app
     // submit an app
     MockRMAppSubmissionData data =
     MockRMAppSubmissionData data =
         MockRMAppSubmissionData.Builder.createWithMemory(GB, rm)
         MockRMAppSubmissionData.Builder.createWithMemory(GB, rm)
@@ -364,7 +367,7 @@ public class TestCapacitySchedulerApps {
     String queue =
     String queue =
         scheduler.getApplicationAttempt(appsInA.get(0)).getQueue()
         scheduler.getApplicationAttempt(appsInA.get(0)).getQueue()
             .getQueueName();
             .getQueueName();
-    Assert.assertEquals("a", queue);
+    assertEquals("a", queue);
 
 
     // now move the app
     // now move the app
     scheduler.moveApplication(app.getApplicationId(), "a1");
     scheduler.moveApplication(app.getApplicationId(), "a1");
@@ -373,7 +376,7 @@ public class TestCapacitySchedulerApps {
     queue =
     queue =
         scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
         scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
             .getQueueName();
             .getQueueName();
-    Assert.assertEquals("a1", queue);
+    assertEquals("a1", queue);
 
 
     appsInA = scheduler.getAppsInQueue("root.a.a");
     appsInA = scheduler.getAppsInQueue("root.a.a");
     assertTrue(appsInA.isEmpty());
     assertTrue(appsInA.isEmpty());
@@ -387,7 +390,7 @@ public class TestCapacitySchedulerApps {
     AbstractYarnScheduler scheduler =
     AbstractYarnScheduler scheduler =
         (AbstractYarnScheduler) rm.getResourceScheduler();
         (AbstractYarnScheduler) rm.getResourceScheduler();
     QueueMetrics metrics = scheduler.getRootQueueMetrics();
     QueueMetrics metrics = scheduler.getRootQueueMetrics();
-    Assert.assertEquals(0, metrics.getAppsPending());
+    assertEquals(0, metrics.getAppsPending());
     // submit an app
     // submit an app
     MockRMAppSubmissionData data =
     MockRMAppSubmissionData data =
         MockRMAppSubmissionData.Builder.createWithMemory(GB, rm)
         MockRMAppSubmissionData.Builder.createWithMemory(GB, rm)
@@ -407,7 +410,7 @@ public class TestCapacitySchedulerApps {
     String queue =
     String queue =
         scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
         scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
             .getQueueName();
             .getQueueName();
-    Assert.assertEquals("a1", queue);
+    assertEquals("a1", queue);
 
 
     List<ApplicationAttemptId> appsInA = scheduler.getAppsInQueue("a");
     List<ApplicationAttemptId> appsInA = scheduler.getAppsInQueue("a");
     assertTrue(appsInA.contains(appAttemptId));
     assertTrue(appsInA.contains(appAttemptId));
@@ -434,7 +437,7 @@ public class TestCapacitySchedulerApps {
     queue =
     queue =
         scheduler.getApplicationAttempt(appsInB1.get(0)).getQueue()
         scheduler.getApplicationAttempt(appsInB1.get(0)).getQueue()
             .getQueueName();
             .getQueueName();
-    Assert.assertEquals("b1", queue);
+    assertEquals("b1", queue);
 
 
     appsInB = scheduler.getAppsInQueue("b");
     appsInB = scheduler.getAppsInQueue("b");
     assertTrue(appsInB.contains(appAttemptId));
     assertTrue(appsInB.contains(appAttemptId));
@@ -562,7 +565,7 @@ public class TestCapacitySchedulerApps {
   private void assertOneAppInQueue(AbstractYarnScheduler scheduler, String queueName) {
   private void assertOneAppInQueue(AbstractYarnScheduler scheduler, String queueName) {
     List<ApplicationAttemptId> apps = scheduler.getAppsInQueue(queueName);
     List<ApplicationAttemptId> apps = scheduler.getAppsInQueue(queueName);
     assertEquals(1, apps.size());
     assertEquals(1, apps.size());
-    Assert.assertEquals(queueName,
+    assertEquals(queueName,
         scheduler.getApplicationAttempt(apps.get(0)).getQueue().getQueueName());
         scheduler.getApplicationAttempt(apps.get(0)).getQueue().getQueueName());
   }
   }
 
 
@@ -780,82 +783,83 @@ public class TestCapacitySchedulerApps {
 
 
   }
   }
 
 
-  @Test(expected = YarnException.class)
+  @Test
   public void testMoveAppViolateQueueState() throws Exception {
   public void testMoveAppViolateQueueState() throws Exception {
-    resourceManager = new ResourceManager() {
-      @Override
-      protected RMNodeLabelsManager createNodeLabelManager() {
-        RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
-        mgr.init(getConfig());
-        return mgr;
-      }
-    };
-    CapacitySchedulerConfiguration csConf =
-        new CapacitySchedulerConfiguration();
-    setupQueueConfiguration(csConf);
-    StringBuilder qState = new StringBuilder();
-    qState.append(CapacitySchedulerConfiguration.PREFIX).append(B)
-        .append(CapacitySchedulerConfiguration.DOT)
-        .append(CapacitySchedulerConfiguration.STATE);
-    csConf.set(qState.toString(), QueueState.STOPPED.name());
-    YarnConfiguration conf = new YarnConfiguration(csConf);
-    conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
-        ResourceScheduler.class);
-    resourceManager.init(conf);
-    resourceManager.getRMContext().getContainerTokenSecretManager()
-        .rollMasterKey();
-    resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey();
-    ((AsyncDispatcher) resourceManager.getRMContext().getDispatcher()).start();
-    mockContext = mock(RMContext.class);
-    when(mockContext.getConfigurationProvider()).thenReturn(
-        new LocalConfigurationProvider());
-
-    ResourceScheduler scheduler = resourceManager.getResourceScheduler();
-
-    NodeStatus mockNodeStatus = createMockNodeStatus();
-
-    // Register node1
-    String host0 = "host_0";
-    NodeManager nm0 =
-        registerNode(resourceManager, host0, 1234, 2345, NetworkTopology.DEFAULT_RACK,
-            Resources.createResource(6 * GB, 1), mockNodeStatus);
-
-    // ResourceRequest priorities
-    Priority priority0 = Priority.newInstance(0);
-    Priority priority1 = Priority.newInstance(1);
-
-    // Submit application_0
-    Application application0 =
-        new Application("user_0", "a1", resourceManager);
-    application0.submit(); // app + app attempt event sent to scheduler
-
-    application0.addNodeManager(host0, 1234, nm0);
-
-    Resource capability00 = Resources.createResource(3 * GB, 1);
-    application0.addResourceRequestSpec(priority1, capability00);
-
-    Resource capability01 = Resources.createResource(2 * GB, 1);
-    application0.addResourceRequestSpec(priority0, capability01);
-
-    Task task00 =
-        new Task(application0, priority1, new String[]{host0});
-    application0.addTask(task00);
-
-    // Send resource requests to the scheduler
-    application0.schedule(); // allocate
-
-    // task_0_0 allocated
-    nodeUpdate(resourceManager, nm0);
-
-    // Get allocations from the scheduler
-    application0.schedule(); // task_0_0
-    checkApplicationResourceUsage(3 * GB, application0);
-
-    checkNodeResourceUsage(3 * GB, nm0);
-    // b2 queue contains 3GB consumption app,
-    // add another 3GB will hit max capacity limit on queue b
-    scheduler.moveApplication(application0.getApplicationId(), "b1");
-
+    assertThrows(YarnException.class, () -> {
+      resourceManager = new ResourceManager() {
+        @Override
+        protected RMNodeLabelsManager createNodeLabelManager() {
+          RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
+          mgr.init(getConfig());
+          return mgr;
+        }
+      };
+      CapacitySchedulerConfiguration csConf =
+          new CapacitySchedulerConfiguration();
+      setupQueueConfiguration(csConf);
+      StringBuilder qState = new StringBuilder();
+      qState.append(CapacitySchedulerConfiguration.PREFIX).append(B)
+          .append(CapacitySchedulerConfiguration.DOT)
+          .append(CapacitySchedulerConfiguration.STATE);
+      csConf.set(qState.toString(), QueueState.STOPPED.name());
+      YarnConfiguration conf = new YarnConfiguration(csConf);
+      conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
+          ResourceScheduler.class);
+      resourceManager.init(conf);
+      resourceManager.getRMContext().getContainerTokenSecretManager()
+          .rollMasterKey();
+      resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey();
+      ((AsyncDispatcher) resourceManager.getRMContext().getDispatcher()).start();
+      mockContext = mock(RMContext.class);
+      when(mockContext.getConfigurationProvider()).thenReturn(
+          new LocalConfigurationProvider());
+
+      ResourceScheduler scheduler = resourceManager.getResourceScheduler();
+
+      NodeStatus mockNodeStatus = createMockNodeStatus();
+
+      // Register node1
+      String host0 = "host_0";
+      NodeManager nm0 =
+          registerNode(resourceManager, host0, 1234, 2345, NetworkTopology.DEFAULT_RACK,
+          Resources.createResource(6 * GB, 1), mockNodeStatus);
+
+      // ResourceRequest priorities
+      Priority priority0 = Priority.newInstance(0);
+      Priority priority1 = Priority.newInstance(1);
+
+      // Submit application_0
+      Application application0 =
+          new Application("user_0", "a1", resourceManager);
+      application0.submit(); // app + app attempt event sent to scheduler
+
+      application0.addNodeManager(host0, 1234, nm0);
+
+      Resource capability00 = Resources.createResource(3 * GB, 1);
+      application0.addResourceRequestSpec(priority1, capability00);
+
+      Resource capability01 = Resources.createResource(2 * GB, 1);
+      application0.addResourceRequestSpec(priority0, capability01);
+
+      Task task00 =
+           new Task(application0, priority1, new String[]{host0});
+      application0.addTask(task00);
+
+      // Send resource requests to the scheduler
+      application0.schedule(); // allocate
+
+      // task_0_0 allocated
+      nodeUpdate(resourceManager, nm0);
+
+      // Get allocations from the scheduler
+      application0.schedule(); // task_0_0
+      checkApplicationResourceUsage(3 * GB, application0);
+
+      checkNodeResourceUsage(3 * GB, nm0);
+      // b2 queue contains 3GB consumption app,
+      // add another 3GB will hit max capacity limit on queue b
+      scheduler.moveApplication(application0.getApplicationId(), "b1");
+    });
   }
   }
 
 
   @Test
   @Test
@@ -1064,10 +1068,10 @@ public class TestCapacitySchedulerApps {
           RMAppAttemptState.FINISHED, true));
           RMAppAttemptState.FINISHED, true));
     }
     }
 
 
-    Assert.assertEquals("No pending app should remain for root queue", 0,
-        cs.getRootQueueMetrics().getAppsPending());
-    Assert.assertEquals("No running application should remain for root queue", 0,
-        cs.getRootQueueMetrics().getAppsRunning());
+    assertEquals(0, cs.getRootQueueMetrics().getAppsPending(),
+        "No pending app should remain for root queue");
+    assertEquals(0, cs.getRootQueueMetrics().getAppsRunning(),
+        "No running application should remain for root queue");
 
 
     rm.stop();
     rm.stop();
   }
   }
@@ -1105,7 +1109,7 @@ public class TestCapacitySchedulerApps {
     // now move the app
     // now move the app
     try {
     try {
       scheduler.moveAllApps("a1", "DOES_NOT_EXIST");
       scheduler.moveAllApps("a1", "DOES_NOT_EXIST");
-      Assert.fail();
+      fail();
     } catch (YarnException e) {
     } catch (YarnException e) {
       // expected
       // expected
     }
     }
@@ -1149,7 +1153,7 @@ public class TestCapacitySchedulerApps {
     // now move the app
     // now move the app
     try {
     try {
       scheduler.moveAllApps("DOES_NOT_EXIST", "b1");
       scheduler.moveAllApps("DOES_NOT_EXIST", "b1");
-      Assert.fail();
+      fail();
     } catch (YarnException e) {
     } catch (YarnException e) {
       // expected
       // expected
     }
     }
@@ -1315,7 +1319,8 @@ public class TestCapacitySchedulerApps {
     rm.close();
     rm.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testMoveAttemptNotAdded() throws Exception {
   public void testMoveAttemptNotAdded() throws Exception {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -1363,11 +1368,11 @@ public class TestCapacitySchedulerApps {
     CSQueue queueA = cs.getQueue("a");
     CSQueue queueA = cs.getQueue("a");
     CSQueue queueA1 = cs.getQueue("a1");
     CSQueue queueA1 = cs.getQueue("a1");
     CSQueue queueB1 = cs.getQueue("b1");
     CSQueue queueB1 = cs.getQueue("b1");
-    Assert.assertEquals(1, rootQ.getNumApplications());
-    Assert.assertEquals(0, queueA.getNumApplications());
-    Assert.assertEquals(1, queueB.getNumApplications());
-    Assert.assertEquals(0, queueA1.getNumApplications());
-    Assert.assertEquals(1, queueB1.getNumApplications());
+    assertEquals(1, rootQ.getNumApplications());
+    assertEquals(0, queueA.getNumApplications());
+    assertEquals(1, queueB.getNumApplications());
+    assertEquals(0, queueA1.getNumApplications());
+    assertEquals(1, queueB1.getNumApplications());
 
 
     rm.close();
     rm.close();
   }
   }
@@ -1421,9 +1426,9 @@ public class TestCapacitySchedulerApps {
     // Move application to queue b1
     // Move application to queue b1
     sch.moveApplication(appAttemptId.getApplicationId(), "b1");
     sch.moveApplication(appAttemptId.getApplicationId(), "b1");
     // Check queue metrics after move
     // Check queue metrics after move
-    Assert.assertEquals(0, queueA1.getNumApplications());
-    Assert.assertEquals(1, queueB.getNumApplications());
-    Assert.assertEquals(0, queueB1.getNumApplications());
+    assertEquals(0, queueA1.getNumApplications());
+    assertEquals(1, queueB.getNumApplications());
+    assertEquals(0, queueB1.getNumApplications());
 
 
     // Release attempt add event
     // Release attempt add event
     ApplicationAttemptId appAttemptId2 =
     ApplicationAttemptId appAttemptId2 =
@@ -1433,27 +1438,27 @@ public class TestCapacitySchedulerApps {
     sch.handle(addAttemptEvent2);
     sch.handle(addAttemptEvent2);
 
 
     // Check metrics after attempt added
     // Check metrics after attempt added
-    Assert.assertEquals(0, queueA1.getNumApplications());
-    Assert.assertEquals(1, queueB.getNumApplications());
-    Assert.assertEquals(1, queueB1.getNumApplications());
+    assertEquals(0, queueA1.getNumApplications());
+    assertEquals(1, queueB.getNumApplications());
+    assertEquals(1, queueB1.getNumApplications());
 
 
 
 
     QueueMetrics queueB1M = queueB1.getMetrics();
     QueueMetrics queueB1M = queueB1.getMetrics();
     QueueMetrics queueBM = queueB.getMetrics();
     QueueMetrics queueBM = queueB.getMetrics();
     // Verify allocation MB of current state
     // Verify allocation MB of current state
-    Assert.assertEquals(0, queueA1M.getAllocatedMB());
-    Assert.assertEquals(0, queueA1M.getAllocatedVirtualCores());
-    Assert.assertEquals(1024, queueB1M.getAllocatedMB());
-    Assert.assertEquals(1, queueB1M.getAllocatedVirtualCores());
+    assertEquals(0, queueA1M.getAllocatedMB());
+    assertEquals(0, queueA1M.getAllocatedVirtualCores());
+    assertEquals(1024, queueB1M.getAllocatedMB());
+    assertEquals(1, queueB1M.getAllocatedVirtualCores());
 
 
     // remove attempt
     // remove attempt
     sch.handle(new AppAttemptRemovedSchedulerEvent(appAttemptId2,
     sch.handle(new AppAttemptRemovedSchedulerEvent(appAttemptId2,
         RMAppAttemptState.FINISHED, false));
         RMAppAttemptState.FINISHED, false));
 
 
-    Assert.assertEquals(0, queueA1M.getAllocatedMB());
-    Assert.assertEquals(0, queueA1M.getAllocatedVirtualCores());
-    Assert.assertEquals(0, queueB1M.getAllocatedMB());
-    Assert.assertEquals(0, queueB1M.getAllocatedVirtualCores());
+    assertEquals(0, queueA1M.getAllocatedMB());
+    assertEquals(0, queueA1M.getAllocatedVirtualCores());
+    assertEquals(0, queueB1M.getAllocatedMB());
+    assertEquals(0, queueB1M.getAllocatedVirtualCores());
 
 
     verifyQueueMetrics(queueB1M);
     verifyQueueMetrics(queueB1M);
     verifyQueueMetrics(queueBM);
     verifyQueueMetrics(queueBM);
@@ -1475,16 +1480,16 @@ public class TestCapacitySchedulerApps {
     rm.start();
     rm.start();
 
 
     RMApp noParentQueueApp = submitAppAndWaitForState(rm, "q", RMAppState.FAILED);
     RMApp noParentQueueApp = submitAppAndWaitForState(rm, "q", RMAppState.FAILED);
-    Assert.assertEquals(RMAppState.FAILED, noParentQueueApp.getState());
+    assertEquals(RMAppState.FAILED, noParentQueueApp.getState());
 
 
     RMApp ambiguousQueueApp = submitAppAndWaitForState(rm, "b", RMAppState.FAILED);
     RMApp ambiguousQueueApp = submitAppAndWaitForState(rm, "b", RMAppState.FAILED);
-    Assert.assertEquals(RMAppState.FAILED, ambiguousQueueApp.getState());
+    assertEquals(RMAppState.FAILED, ambiguousQueueApp.getState());
 
 
     RMApp emptyPartQueueApp = submitAppAndWaitForState(rm, "root..a1", RMAppState.FAILED);
     RMApp emptyPartQueueApp = submitAppAndWaitForState(rm, "root..a1", RMAppState.FAILED);
-    Assert.assertEquals(RMAppState.FAILED, emptyPartQueueApp.getState());
+    assertEquals(RMAppState.FAILED, emptyPartQueueApp.getState());
 
 
     RMApp failedAutoQueue = submitAppAndWaitForState(rm, "root.a.b.c.d", RMAppState.FAILED);
     RMApp failedAutoQueue = submitAppAndWaitForState(rm, "root.a.b.c.d", RMAppState.FAILED);
-    Assert.assertEquals(RMAppState.FAILED, failedAutoQueue.getState());
+    assertEquals(RMAppState.FAILED, failedAutoQueue.getState());
   }
   }
 
 
   private RMApp submitAppAndWaitForState(MockRM rm, String b, RMAppState state) throws Exception {
   private RMApp submitAppAndWaitForState(MockRM rm, String b, RMAppState state) throws Exception {
@@ -1531,13 +1536,13 @@ public class TestCapacitySchedulerApps {
   }
   }
 
 
   private void verifyQueueMetrics(QueueMetrics queue) {
   private void verifyQueueMetrics(QueueMetrics queue) {
-    Assert.assertEquals(0, queue.getPendingMB());
-    Assert.assertEquals(0, queue.getActiveUsers());
-    Assert.assertEquals(0, queue.getActiveApps());
-    Assert.assertEquals(0, queue.getAppsPending());
-    Assert.assertEquals(0, queue.getAppsRunning());
-    Assert.assertEquals(0, queue.getAllocatedMB());
-    Assert.assertEquals(0, queue.getAllocatedVirtualCores());
+    assertEquals(0, queue.getPendingMB());
+    assertEquals(0, queue.getActiveUsers());
+    assertEquals(0, queue.getActiveApps());
+    assertEquals(0, queue.getAppsPending());
+    assertEquals(0, queue.getAppsRunning());
+    assertEquals(0, queue.getAllocatedMB());
+    assertEquals(0, queue.getAllocatedVirtualCores());
   }
   }
 
 
   private Configuration getCapacityConfiguration(Configuration config) {
   private Configuration getCapacityConfiguration(Configuration config) {

+ 106 - 82
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAsyncScheduling.java

@@ -18,6 +18,17 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.anyBoolean;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.spy;
+
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
@@ -65,11 +76,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.Candida
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimpleCandidateNodeSet;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimpleCandidateNodeSet;
 import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
 import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.junit.contrib.java.lang.system.internal.NoExitSecurityManager;
 import org.junit.contrib.java.lang.system.internal.NoExitSecurityManager;
-import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.mockito.stubbing.Answer;
 
 
@@ -91,7 +101,7 @@ public class TestCapacitySchedulerAsyncScheduling {
           "org.apache.hadoop.yarn.server.resourcemanager.scheduler" +
           "org.apache.hadoop.yarn.server.resourcemanager.scheduler" +
                   ".placement.ResourceUsageMultiNodeLookupPolicy";
                   ".placement.ResourceUsageMultiNodeLookupPolicy";
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -102,22 +112,26 @@ public class TestCapacitySchedulerAsyncScheduling {
     mgr.init(conf);
     mgr.init(conf);
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testSingleThreadAsyncContainerAllocation() throws Exception {
   public void testSingleThreadAsyncContainerAllocation() throws Exception {
     testAsyncContainerAllocation(1);
     testAsyncContainerAllocation(1);
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testTwoThreadsAsyncContainerAllocation() throws Exception {
   public void testTwoThreadsAsyncContainerAllocation() throws Exception {
     testAsyncContainerAllocation(2);
     testAsyncContainerAllocation(2);
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testThreeThreadsAsyncContainerAllocation() throws Exception {
   public void testThreeThreadsAsyncContainerAllocation() throws Exception {
     testAsyncContainerAllocation(3);
     testAsyncContainerAllocation(3);
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testAsyncContainerAllocationWithMultiNode() throws Exception {
   public void testAsyncContainerAllocationWithMultiNode() throws Exception {
     conf.set(CapacitySchedulerConfiguration.MULTI_NODE_SORTING_POLICIES,
     conf.set(CapacitySchedulerConfiguration.MULTI_NODE_SORTING_POLICIES,
             "resource-based");
             "resource-based");
@@ -132,7 +146,8 @@ public class TestCapacitySchedulerAsyncScheduling {
     testAsyncContainerAllocation(2);
     testAsyncContainerAllocation(2);
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testAsyncThreadNames() throws Exception {
   public void testAsyncThreadNames() throws Exception {
     conf.setInt(
     conf.setInt(
         CapacitySchedulerConfiguration.SCHEDULE_ASYNCHRONOUSLY_MAXIMUM_THREAD,
         CapacitySchedulerConfiguration.SCHEDULE_ASYNCHRONOUSLY_MAXIMUM_THREAD,
@@ -156,7 +171,7 @@ public class TestCapacitySchedulerAsyncScheduling {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     for (CapacityScheduler.AsyncScheduleThread thread :
     for (CapacityScheduler.AsyncScheduleThread thread :
         cs.getAsyncSchedulerThreads()) {
         cs.getAsyncSchedulerThreads()) {
-      Assert.assertTrue(thread.getName()
+      assertTrue(thread.getName()
           .startsWith("AsyncCapacitySchedulerThread"));
           .startsWith("AsyncCapacitySchedulerThread"));
     }
     }
   }
   }
@@ -228,7 +243,7 @@ public class TestCapacitySchedulerAsyncScheduling {
       waitTime -= 50;
       waitTime -= 50;
     }
     }
 
 
-    Assert.assertEquals(
+    assertEquals(
         rm.getResourceScheduler().getRootQueueMetrics().getAllocatedMB(),
         rm.getResourceScheduler().getRootQueueMetrics().getAllocatedMB(),
         totalAsked);
         totalAsked);
 
 
@@ -236,7 +251,7 @@ public class TestCapacitySchedulerAsyncScheduling {
     // required
     // required
     waitTime = 2000; // ms
     waitTime = 2000; // ms
     while (waitTime > 0) {
     while (waitTime > 0) {
-      Assert.assertEquals(
+      assertEquals(
           rm.getResourceScheduler().getRootQueueMetrics().getAllocatedMB(),
           rm.getResourceScheduler().getRootQueueMetrics().getAllocatedMB(),
           totalAsked);
           totalAsked);
       waitTime -= 50;
       waitTime -= 50;
@@ -247,7 +262,8 @@ public class TestCapacitySchedulerAsyncScheduling {
   }
   }
 
 
   // Testcase for YARN-6714
   // Testcase for YARN-6714
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testCommitProposalForFailedAppAttempt()
   public void testCommitProposalForFailedAppAttempt()
       throws Exception {
       throws Exception {
     // disable async-scheduling for simulating complex since scene
     // disable async-scheduling for simulating complex since scene
@@ -270,7 +286,7 @@ public class TestCapacitySchedulerAsyncScheduling {
             .nodeCount() < 2) {
             .nodeCount() < 2) {
       Thread.sleep(10);
       Thread.sleep(10);
     }
     }
-    Assert.assertEquals(2,
+    assertEquals(2,
         ((AbstractYarnScheduler) rm.getRMContext().getScheduler())
         ((AbstractYarnScheduler) rm.getRMContext().getScheduler())
             .getNodeTracker().nodeCount());
             .getNodeTracker().nodeCount());
     CapacityScheduler scheduler =
     CapacityScheduler scheduler =
@@ -303,8 +319,8 @@ public class TestCapacitySchedulerAsyncScheduling {
 
 
     // nm1 runs 1 container(app1-container_01/AM)
     // nm1 runs 1 container(app1-container_01/AM)
     // nm2 runs 1 container(app1-container_02)
     // nm2 runs 1 container(app1-container_02)
-    Assert.assertEquals(1, sn1.getNumContainers());
-    Assert.assertEquals(1, sn2.getNumContainers());
+    assertEquals(1, sn1.getNumContainers());
+    assertEquals(1, sn2.getNumContainers());
 
 
     // kill app attempt1
     // kill app attempt1
     scheduler.handle(
     scheduler.handle(
@@ -345,14 +361,16 @@ public class TestCapacitySchedulerAsyncScheduling {
     ResourceCommitRequest request =
     ResourceCommitRequest request =
         new ResourceCommitRequest(null, reservedProposals, null);
         new ResourceCommitRequest(null, reservedProposals, null);
     scheduler.tryCommit(scheduler.getClusterResource(), request, true);
     scheduler.tryCommit(scheduler.getClusterResource(), request, true);
-    Assert.assertNull("Outdated proposal should not be accepted!",
-        sn2.getReservedContainer());
+    assertNull(sn2.getReservedContainer(),
+        "Outdated proposal should not be accepted!");
 
 
     rm.stop();
     rm.stop();
   }
   }
 
 
   // Testcase for YARN-6678
   // Testcase for YARN-6678
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
+  @SuppressWarnings("checkstyle:methodlength")
   public void testCommitOutdatedReservedProposal() throws Exception {
   public void testCommitOutdatedReservedProposal() throws Exception {
     // disable async-scheduling for simulating complex since scene
     // disable async-scheduling for simulating complex since scene
     Configuration disableAsyncConf = new Configuration(conf);
     Configuration disableAsyncConf = new Configuration(conf);
@@ -373,7 +391,7 @@ public class TestCapacitySchedulerAsyncScheduling {
       waitTime -= 10;
       waitTime -= 10;
       Thread.sleep(10);
       Thread.sleep(10);
     }
     }
-    Assert.assertEquals(2,
+    assertEquals(2,
         ((AbstractYarnScheduler) rm.getRMContext().getScheduler())
         ((AbstractYarnScheduler) rm.getRMContext().getScheduler())
             .getNodeTracker().nodeCount());
             .getNodeTracker().nodeCount());
 
 
@@ -415,8 +433,8 @@ public class TestCapacitySchedulerAsyncScheduling {
     // nm1 runs 3 containers(app1-container_01/AM, app1-container_02,
     // nm1 runs 3 containers(app1-container_01/AM, app1-container_02,
     //                       app2-container_01/AM)
     //                       app2-container_01/AM)
     // nm2 runs 1 container(app1-container_03)
     // nm2 runs 1 container(app1-container_03)
-    Assert.assertEquals(3, sn1.getNumContainers());
-    Assert.assertEquals(1, sn2.getNumContainers());
+    assertEquals(3, sn1.getNumContainers());
+    assertEquals(1, sn2.getNumContainers());
 
 
     // reserve 1 container(app1-container_04) for app1 on nm1
     // reserve 1 container(app1-container_04) for app1 on nm1
     ResourceRequest rr2 = ResourceRequest
     ResourceRequest rr2 = ResourceRequest
@@ -430,15 +448,15 @@ public class TestCapacitySchedulerAsyncScheduling {
       waitTime -= 10;
       waitTime -= 10;
       Thread.sleep(10);
       Thread.sleep(10);
     }
     }
-    Assert.assertNotNull(sn1.getReservedContainer());
+    assertNotNull(sn1.getReservedContainer());
 
 
     final CapacityScheduler cs = (CapacityScheduler) scheduler;
     final CapacityScheduler cs = (CapacityScheduler) scheduler;
-    final CapacityScheduler spyCs = Mockito.spy(cs);
+    final CapacityScheduler spyCs = spy(cs);
     final AtomicBoolean isFirstReserve = new AtomicBoolean(true);
     final AtomicBoolean isFirstReserve = new AtomicBoolean(true);
     final AtomicBoolean isChecked = new AtomicBoolean(false);
     final AtomicBoolean isChecked = new AtomicBoolean(false);
     // handle CapacityScheduler#tryCommit,
     // handle CapacityScheduler#tryCommit,
     // reproduce the process that can raise IllegalStateException before
     // reproduce the process that can raise IllegalStateException before
-    Mockito.doAnswer(new Answer<Object>() {
+    doAnswer(new Answer<Object>() {
       public Object answer(InvocationOnMock invocation) throws Exception {
       public Object answer(InvocationOnMock invocation) throws Exception {
         ResourceCommitRequest request =
         ResourceCommitRequest request =
             (ResourceCommitRequest) invocation.getArguments()[1];
             (ResourceCommitRequest) invocation.getArguments()[1];
@@ -452,7 +470,7 @@ public class TestCapacitySchedulerAsyncScheduling {
                       ContainerState.COMPLETE, "",
                       ContainerState.COMPLETE, "",
                       ContainerExitStatus.KILLED_BY_RESOURCEMANAGER),
                       ContainerExitStatus.KILLED_BY_RESOURCEMANAGER),
               RMContainerEventType.KILL);
               RMContainerEventType.KILL);
-          Assert.assertEquals(0, sn2.getCopiedListOfRunningContainers().size());
+          assertEquals(0, sn2.getCopiedListOfRunningContainers().size());
           // unreserve app1-container_04 on nm1
           // unreserve app1-container_04 on nm1
           // and allocate app1-container_05 on nm2
           // and allocate app1-container_05 on nm2
           cs.handle(new NodeUpdateSchedulerEvent(sn2.getRMNode()));
           cs.handle(new NodeUpdateSchedulerEvent(sn2.getRMNode()));
@@ -462,8 +480,8 @@ public class TestCapacitySchedulerAsyncScheduling {
             waitTime -= 10;
             waitTime -= 10;
             Thread.sleep(10);
             Thread.sleep(10);
           }
           }
-          Assert.assertEquals(1, sn2.getCopiedListOfRunningContainers().size());
-          Assert.assertNull(sn1.getReservedContainer());
+          assertEquals(1, sn2.getCopiedListOfRunningContainers().size());
+          assertNull(sn1.getReservedContainer());
 
 
           // reserve app2-container_02 on nm1
           // reserve app2-container_02 on nm1
           ResourceRequest rr3 = ResourceRequest
           ResourceRequest rr3 = ResourceRequest
@@ -476,7 +494,7 @@ public class TestCapacitySchedulerAsyncScheduling {
             waitTime -= 10;
             waitTime -= 10;
             Thread.sleep(10);
             Thread.sleep(10);
           }
           }
-          Assert.assertNotNull(sn1.getReservedContainer());
+          assertNotNull(sn1.getReservedContainer());
 
 
           // call real apply
           // call real apply
           try {
           try {
@@ -484,7 +502,7 @@ public class TestCapacitySchedulerAsyncScheduling {
                 (ResourceCommitRequest) invocation.getArguments()[1], true);
                 (ResourceCommitRequest) invocation.getArguments()[1], true);
           } catch (Exception e) {
           } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
-            Assert.fail();
+            fail();
           }
           }
           isChecked.set(true);
           isChecked.set(true);
         } else {
         } else {
@@ -493,8 +511,8 @@ public class TestCapacitySchedulerAsyncScheduling {
         }
         }
         return null;
         return null;
       }
       }
-    }).when(spyCs).tryCommit(Mockito.any(Resource.class),
-        Mockito.any(ResourceCommitRequest.class), Mockito.anyBoolean());
+    }).when(spyCs).tryCommit(any(Resource.class),
+        any(ResourceCommitRequest.class), anyBoolean());
 
 
     spyCs.handle(new NodeUpdateSchedulerEvent(sn1.getRMNode()));
     spyCs.handle(new NodeUpdateSchedulerEvent(sn1.getRMNode()));
 
 
@@ -506,7 +524,8 @@ public class TestCapacitySchedulerAsyncScheduling {
     rm.stop();
     rm.stop();
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testNodeResourceOverAllocated()
   public void testNodeResourceOverAllocated()
       throws Exception {
       throws Exception {
     // disable async-scheduling for simulating complex scene
     // disable async-scheduling for simulating complex scene
@@ -529,7 +548,7 @@ public class TestCapacitySchedulerAsyncScheduling {
             .nodeCount() < 2) {
             .nodeCount() < 2) {
       Thread.sleep(10);
       Thread.sleep(10);
     }
     }
-    Assert.assertEquals(2,
+    assertEquals(2,
         ((AbstractYarnScheduler) rm.getRMContext().getScheduler())
         ((AbstractYarnScheduler) rm.getRMContext().getScheduler())
             .getNodeTracker().nodeCount());
             .getNodeTracker().nodeCount());
     CapacityScheduler scheduler =
     CapacityScheduler scheduler =
@@ -584,8 +603,8 @@ public class TestCapacitySchedulerAsyncScheduling {
       scheduler.tryCommit(scheduler.getClusterResource(), request, true);
       scheduler.tryCommit(scheduler.getClusterResource(), request, true);
     }
     }
     // make sure node resource can't be over-allocated!
     // make sure node resource can't be over-allocated!
-    Assert.assertTrue("Node resource is Over-allocated!",
-        sn1.getUnallocatedResource().getMemorySize() > 0);
+    assertTrue(sn1.getUnallocatedResource().getMemorySize() > 0,
+        "Node resource is Over-allocated!");
     rm.stop();
     rm.stop();
   }
   }
 
 
@@ -666,9 +685,9 @@ public class TestCapacitySchedulerAsyncScheduling {
     // Make sure that NM5-9 don't have non-AM containers.
     // Make sure that NM5-9 don't have non-AM containers.
     for (int i = 0; i < 9; i++) {
     for (int i = 0; i < 9; i++) {
       if (i < 5) {
       if (i < 5) {
-        Assert.assertTrue(checkNumNonAMContainersOnNode(cs, nms.get(i)) > 0);
+        assertTrue(checkNumNonAMContainersOnNode(cs, nms.get(i)) > 0);
       } else {
       } else {
-        Assert.assertTrue(checkNumNonAMContainersOnNode(cs, nms.get(i)) == 0);
+        assertTrue(checkNumNonAMContainersOnNode(cs, nms.get(i)) == 0);
       }
       }
     }
     }
 
 
@@ -741,12 +760,12 @@ public class TestCapacitySchedulerAsyncScheduling {
           new RMNodeEvent(rmNode.getNodeID(),
           new RMNodeEvent(rmNode.getNodeID(),
               RMNodeEventType.GRACEFUL_DECOMMISSION));
               RMNodeEventType.GRACEFUL_DECOMMISSION));
       rm.drainEvents();
       rm.drainEvents();
-      Assert.assertEquals(NodeState.DECOMMISSIONING, rmNode.getState());
+      assertEquals(NodeState.DECOMMISSIONING, rmNode.getState());
       boolean shouldSkip =
       boolean shouldSkip =
           cs.shouldSkipNodeSchedule(cs.getNode(nms.get(i).getNodeId()),
           cs.shouldSkipNodeSchedule(cs.getNode(nms.get(i).getNodeId()),
               cs, true);
               cs, true);
       // make sure should skip
       // make sure should skip
-      Assert.assertTrue(shouldSkip);
+      assertTrue(shouldSkip);
     }
     }
 
 
     for (int i = 5; i < 9; i++) {
     for (int i = 5; i < 9; i++) {
@@ -754,7 +773,7 @@ public class TestCapacitySchedulerAsyncScheduling {
           cs.shouldSkipNodeSchedule(cs.getNode(nms.get(i).getNodeId()),
           cs.shouldSkipNodeSchedule(cs.getNode(nms.get(i).getNodeId()),
               cs, true);
               cs, true);
       // make sure should not skip
       // make sure should not skip
-      Assert.assertFalse(shouldSkip);
+      assertFalse(shouldSkip);
     }
     }
 
 
     pauseNMHeartbeat();
     pauseNMHeartbeat();
@@ -773,9 +792,9 @@ public class TestCapacitySchedulerAsyncScheduling {
     //Make sure that NM 0-5 don't have non-AM containers.
     //Make sure that NM 0-5 don't have non-AM containers.
     for (int i = 0; i < 9; i++) {
     for (int i = 0; i < 9; i++) {
       if (i < 5) {
       if (i < 5) {
-        Assert.assertTrue(checkNumNonAMContainersOnNode(cs, nms.get(i)) == 0);
+        assertTrue(checkNumNonAMContainersOnNode(cs, nms.get(i)) == 0);
       } else {
       } else {
-        Assert.assertTrue(checkNumNonAMContainersOnNode(cs, nms.get(i)) > 0);
+        assertTrue(checkNumNonAMContainersOnNode(cs, nms.get(i)) > 0);
       }
       }
     }
     }
     rm.close();
     rm.close();
@@ -817,7 +836,8 @@ public class TestCapacitySchedulerAsyncScheduling {
   }
   }
 
 
   // Testcase for YARN-8127
   // Testcase for YARN-8127
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testCommitDuplicatedAllocateFromReservedProposals()
   public void testCommitDuplicatedAllocateFromReservedProposals()
       throws Exception {
       throws Exception {
     // disable async-scheduling for simulating complex scene
     // disable async-scheduling for simulating complex scene
@@ -837,7 +857,7 @@ public class TestCapacitySchedulerAsyncScheduling {
             .nodeCount() < 2) {
             .nodeCount() < 2) {
       Thread.sleep(10);
       Thread.sleep(10);
     }
     }
-    Assert.assertEquals(2,
+    assertEquals(2,
         ((AbstractYarnScheduler) rm.getRMContext().getScheduler())
         ((AbstractYarnScheduler) rm.getRMContext().getScheduler())
             .getNodeTracker().nodeCount());
             .getNodeTracker().nodeCount());
     CapacityScheduler cs =
     CapacityScheduler cs =
@@ -867,8 +887,8 @@ public class TestCapacitySchedulerAsyncScheduling {
     // nm1 runs 2 container(container_01/AM, container_02)
     // nm1 runs 2 container(container_01/AM, container_02)
     allocateAndLaunchContainers(am, nm1, rm, 1,
     allocateAndLaunchContainers(am, nm1, rm, 1,
         Resources.createResource(6 * GB), 0, 2);
         Resources.createResource(6 * GB), 0, 2);
-    Assert.assertEquals(2, sn1.getNumContainers());
-    Assert.assertEquals(1 * GB, sn1.getUnallocatedResource().getMemorySize());
+    assertEquals(2, sn1.getNumContainers());
+    assertEquals(1 * GB, sn1.getUnallocatedResource().getMemorySize());
 
 
     // app asks 5 * 2G container
     // app asks 5 * 2G container
     // nm1 reserves 1 * 2G containers
     // nm1 reserves 1 * 2G containers
@@ -876,7 +896,7 @@ public class TestCapacitySchedulerAsyncScheduling {
         .newInstance(Priority.newInstance(0), "*",
         .newInstance(Priority.newInstance(0), "*",
             Resources.createResource(2 * GB), 5)), null);
             Resources.createResource(2 * GB), 5)), null);
     cs.handle(new NodeUpdateSchedulerEvent(sn1.getRMNode()));
     cs.handle(new NodeUpdateSchedulerEvent(sn1.getRMNode()));
-    Assert.assertEquals(1, schedulerApp.getReservedContainers().size());
+    assertEquals(1, schedulerApp.getReservedContainers().size());
 
 
     // rm kills 1 * 6G container_02
     // rm kills 1 * 6G container_02
     for (RMContainer rmContainer : sn1.getCopiedListOfRunningContainers()) {
     for (RMContainer rmContainer : sn1.getCopiedListOfRunningContainers()) {
@@ -888,13 +908,13 @@ public class TestCapacitySchedulerAsyncScheduling {
             RMContainerEventType.KILL);
             RMContainerEventType.KILL);
       }
       }
     }
     }
-    Assert.assertEquals(7 * GB, sn1.getUnallocatedResource().getMemorySize());
+    assertEquals(7 * GB, sn1.getUnallocatedResource().getMemorySize());
 
 
-    final CapacityScheduler spyCs = Mockito.spy(cs);
+    final CapacityScheduler spyCs = spy(cs);
     // handle CapacityScheduler#tryCommit, submit duplicated proposals
     // handle CapacityScheduler#tryCommit, submit duplicated proposals
     // that do allocation for reserved container for three times,
     // that do allocation for reserved container for three times,
     // to simulate that case in YARN-8127
     // to simulate that case in YARN-8127
-    Mockito.doAnswer(new Answer<Object>() {
+    doAnswer(new Answer<Object>() {
       public Boolean answer(InvocationOnMock invocation) throws Exception {
       public Boolean answer(InvocationOnMock invocation) throws Exception {
         ResourceCommitRequest request =
         ResourceCommitRequest request =
             (ResourceCommitRequest) invocation.getArguments()[1];
             (ResourceCommitRequest) invocation.getArguments()[1];
@@ -905,14 +925,14 @@ public class TestCapacitySchedulerAsyncScheduling {
                 (ResourceCommitRequest) invocation.getArguments()[1],
                 (ResourceCommitRequest) invocation.getArguments()[1],
                 (Boolean) invocation.getArguments()[2]);
                 (Boolean) invocation.getArguments()[2]);
           }
           }
-          Assert.assertEquals(2, sn1.getCopiedListOfRunningContainers().size());
-          Assert.assertEquals(5 * GB,
+          assertEquals(2, sn1.getCopiedListOfRunningContainers().size());
+          assertEquals(5 * GB,
               sn1.getUnallocatedResource().getMemorySize());
               sn1.getUnallocatedResource().getMemorySize());
         }
         }
         return true;
         return true;
       }
       }
-    }).when(spyCs).tryCommit(Mockito.any(Resource.class),
-        Mockito.any(ResourceCommitRequest.class), Mockito.anyBoolean());
+    }).when(spyCs).tryCommit(any(Resource.class),
+        any(ResourceCommitRequest.class), anyBoolean());
 
 
     spyCs.handle(new NodeUpdateSchedulerEvent(sn1.getRMNode()));
     spyCs.handle(new NodeUpdateSchedulerEvent(sn1.getRMNode()));
 
 
@@ -920,7 +940,8 @@ public class TestCapacitySchedulerAsyncScheduling {
   }
   }
 
 
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testReleaseOutdatedReservedContainer() throws Exception {
   public void testReleaseOutdatedReservedContainer() throws Exception {
     /*
     /*
      * Submit a application, reserved container_02 on nm1,
      * Submit a application, reserved container_02 on nm1,
@@ -966,8 +987,8 @@ public class TestCapacitySchedulerAsyncScheduling {
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
 
 
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertEquals(1, schedulerApp1.getReservedContainers().size());
-    Assert.assertEquals(9 * GB,
+    assertEquals(1, schedulerApp1.getReservedContainers().size());
+    assertEquals(9 * GB,
         defaultQueue.getQueueResourceUsage().getUsed().getMemorySize());
         defaultQueue.getQueueResourceUsage().getUsed().getMemorySize());
 
 
     RMContainer reservedContainer =
     RMContainer reservedContainer =
@@ -977,19 +998,20 @@ public class TestCapacitySchedulerAsyncScheduling {
             sn2, sn1, cs.getRMContext(), reservedContainer);
             sn2, sn1, cs.getRMContext(), reservedContainer);
     boolean tryCommitResult = cs.tryCommit(cs.getClusterResource(),
     boolean tryCommitResult = cs.tryCommit(cs.getClusterResource(),
         allocateFromSameReservedContainerProposal1, true);
         allocateFromSameReservedContainerProposal1, true);
-    Assert.assertTrue(tryCommitResult);
+    assertTrue(tryCommitResult);
     ResourceCommitRequest allocateFromSameReservedContainerProposal2 =
     ResourceCommitRequest allocateFromSameReservedContainerProposal2 =
         createAllocateFromReservedProposal(4, allocateResource, schedulerApp1,
         createAllocateFromReservedProposal(4, allocateResource, schedulerApp1,
             sn3, sn1, cs.getRMContext(), reservedContainer);
             sn3, sn1, cs.getRMContext(), reservedContainer);
     tryCommitResult = cs.tryCommit(cs.getClusterResource(),
     tryCommitResult = cs.tryCommit(cs.getClusterResource(),
         allocateFromSameReservedContainerProposal2, true);
         allocateFromSameReservedContainerProposal2, true);
-    Assert.assertFalse("This proposal should be rejected because "
-        + "it try to release an outdated reserved container", tryCommitResult);
+    assertFalse(tryCommitResult, "This proposal should be rejected because "
+        + "it try to release an outdated reserved container");
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testCommitProposalsForUnusableNode() throws Exception {
   public void testCommitProposalsForUnusableNode() throws Exception {
     // disable async-scheduling for simulating complex scene
     // disable async-scheduling for simulating complex scene
     Configuration disableAsyncConf = new Configuration(conf);
     Configuration disableAsyncConf = new Configuration(conf);
@@ -1047,17 +1069,17 @@ public class TestCapacitySchedulerAsyncScheduling {
             Resources.createResource(8 * GB), 1)), null);
             Resources.createResource(8 * GB), 1)), null);
 
 
     List<Object> reservedProposalParts = new ArrayList<>();
     List<Object> reservedProposalParts = new ArrayList<>();
-    final CapacityScheduler spyCs = Mockito.spy(cs);
+    final CapacityScheduler spyCs = spy(cs);
     // handle CapacityScheduler#tryCommit
     // handle CapacityScheduler#tryCommit
-    Mockito.doAnswer(new Answer<Object>() {
+    doAnswer(new Answer<Object>() {
       public Boolean answer(InvocationOnMock invocation) throws Exception {
       public Boolean answer(InvocationOnMock invocation) throws Exception {
         for (Object argument : invocation.getArguments()) {
         for (Object argument : invocation.getArguments()) {
           reservedProposalParts.add(argument);
           reservedProposalParts.add(argument);
         }
         }
         return false;
         return false;
       }
       }
-    }).when(spyCs).tryCommit(Mockito.any(Resource.class),
-        Mockito.any(ResourceCommitRequest.class), Mockito.anyBoolean());
+    }).when(spyCs).tryCommit(any(Resource.class),
+        any(ResourceCommitRequest.class), anyBoolean());
 
 
     spyCs.handle(new NodeUpdateSchedulerEvent(sn1.getRMNode()));
     spyCs.handle(new NodeUpdateSchedulerEvent(sn1.getRMNode()));
 
 
@@ -1066,19 +1088,20 @@ public class TestCapacitySchedulerAsyncScheduling {
     cs.getRMContext().getDispatcher().getEventHandler().handle(
     cs.getRMContext().getDispatcher().getEventHandler().handle(
         new RMNodeEvent(nm1.getNodeId(), RMNodeEventType.DECOMMISSION));
         new RMNodeEvent(nm1.getNodeId(), RMNodeEventType.DECOMMISSION));
     rm.drainEvents();
     rm.drainEvents();
-    Assert.assertEquals(NodeState.DECOMMISSIONED, rmNode1.getState());
-    Assert.assertNull(cs.getNode(nm1.getNodeId()));
+    assertEquals(NodeState.DECOMMISSIONED, rmNode1.getState());
+    assertNull(cs.getNode(nm1.getNodeId()));
 
 
     // try commit after nm1 decommissioned
     // try commit after nm1 decommissioned
     boolean isSuccess =
     boolean isSuccess =
         cs.tryCommit((Resource) reservedProposalParts.get(0),
         cs.tryCommit((Resource) reservedProposalParts.get(0),
             (ResourceCommitRequest) reservedProposalParts.get(1),
             (ResourceCommitRequest) reservedProposalParts.get(1),
             (Boolean) reservedProposalParts.get(2));
             (Boolean) reservedProposalParts.get(2));
-    Assert.assertFalse(isSuccess);
+    assertFalse(isSuccess);
     rm.stop();
     rm.stop();
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testAsyncScheduleThreadExit() throws Exception {
   public void testAsyncScheduleThreadExit() throws Exception {
     // init RM & NM
     // init RM & NM
     final MockRM rm = new MockRM(conf);
     final MockRM rm = new MockRM(conf);
@@ -1138,7 +1161,8 @@ public class TestCapacitySchedulerAsyncScheduling {
     return new ResourceCommitRequest(allocateProposals, null, null);
     return new ResourceCommitRequest(allocateProposals, null, null);
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testReturnNullWhenGetSchedulerContainer() throws Exception {
   public void testReturnNullWhenGetSchedulerContainer() throws Exception {
     // disable async-scheduling for simulating complex scenario
     // disable async-scheduling for simulating complex scenario
     Configuration disableAsyncConf = new Configuration(conf);
     Configuration disableAsyncConf = new Configuration(conf);
@@ -1181,10 +1205,10 @@ public class TestCapacitySchedulerAsyncScheduling {
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 1));
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 1));
 
 
     // spy CapacityScheduler
     // spy CapacityScheduler
-    final CapacityScheduler spyCs = Mockito.spy(cs);
+    final CapacityScheduler spyCs = spy(cs);
     // hook CapacityScheduler#submitResourceCommitRequest
     // hook CapacityScheduler#submitResourceCommitRequest
     List<CSAssignment> assignmentSnapshots = new ArrayList<>();
     List<CSAssignment> assignmentSnapshots = new ArrayList<>();
-    Mockito.doAnswer(new Answer<Object>() {
+    doAnswer(new Answer<Object>() {
       public Boolean answer(InvocationOnMock invocation) throws Exception {
       public Boolean answer(InvocationOnMock invocation) throws Exception {
         CSAssignment assignment = (CSAssignment) invocation.getArguments()[1];
         CSAssignment assignment = (CSAssignment) invocation.getArguments()[1];
         if (cs.getNode(nm1.getNodeId()) != null) {
         if (cs.getNode(nm1.getNodeId()) != null) {
@@ -1192,8 +1216,8 @@ public class TestCapacitySchedulerAsyncScheduling {
           cs.getRMContext().getDispatcher().getEventHandler().handle(
           cs.getRMContext().getDispatcher().getEventHandler().handle(
               new RMNodeEvent(nm1.getNodeId(), RMNodeEventType.DECOMMISSION));
               new RMNodeEvent(nm1.getNodeId(), RMNodeEventType.DECOMMISSION));
           rm.drainEvents();
           rm.drainEvents();
-          Assert.assertEquals(NodeState.DECOMMISSIONED, rmNode1.getState());
-          Assert.assertNull(cs.getNode(nm1.getNodeId()));
+          assertEquals(NodeState.DECOMMISSIONED, rmNode1.getState());
+          assertNull(cs.getNode(nm1.getNodeId()));
           assignmentSnapshots.add(assignment);
           assignmentSnapshots.add(assignment);
         } else {
         } else {
           // add am container on nm1 to containersToKill
           // add am container on nm1 to containersToKill
@@ -1205,15 +1229,15 @@ public class TestCapacitySchedulerAsyncScheduling {
             assignment);
             assignment);
         return false;
         return false;
       }
       }
-    }).when(spyCs).submitResourceCommitRequest(Mockito.any(Resource.class),
-        Mockito.any(CSAssignment.class));
+    }).when(spyCs).submitResourceCommitRequest(any(Resource.class),
+        any(CSAssignment.class));
 
 
     // allocation on nm1, test return null when get scheduler container
     // allocation on nm1, test return null when get scheduler container
     CandidateNodeSet<FiCaSchedulerNode> candidateNodeSet =
     CandidateNodeSet<FiCaSchedulerNode> candidateNodeSet =
         new SimpleCandidateNodeSet(sn1);
         new SimpleCandidateNodeSet(sn1);
     spyCs.allocateContainersToNode(candidateNodeSet, false);
     spyCs.allocateContainersToNode(candidateNodeSet, false);
     // make sure unconfirmed resource is decreased correctly
     // make sure unconfirmed resource is decreased correctly
-    Assert.assertTrue(spyCs.getApplicationAttempt(am1.getApplicationAttemptId())
+    assertTrue(spyCs.getApplicationAttempt(am1.getApplicationAttemptId())
         .hasPendingResourceRequest(RMNodeLabelsManager.NO_LABEL,
         .hasPendingResourceRequest(RMNodeLabelsManager.NO_LABEL,
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY));
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY));
 
 
@@ -1223,7 +1247,7 @@ public class TestCapacitySchedulerAsyncScheduling {
         new SimpleCandidateNodeSet(sn2);
         new SimpleCandidateNodeSet(sn2);
     spyCs.allocateContainersToNode(candidateNodeSet, false);
     spyCs.allocateContainersToNode(candidateNodeSet, false);
     // make sure unconfirmed resource is decreased correctly
     // make sure unconfirmed resource is decreased correctly
-    Assert.assertTrue(spyCs.getApplicationAttempt(am1.getApplicationAttemptId())
+    assertTrue(spyCs.getApplicationAttempt(am1.getApplicationAttemptId())
         .hasPendingResourceRequest(RMNodeLabelsManager.NO_LABEL,
         .hasPendingResourceRequest(RMNodeLabelsManager.NO_LABEL,
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY));
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY));
 
 
@@ -1266,7 +1290,7 @@ public class TestCapacitySchedulerAsyncScheduling {
     ContainerId lastContainerId = ContainerId
     ContainerId lastContainerId = ContainerId
         .newContainerId(am.getApplicationAttemptId(),
         .newContainerId(am.getApplicationAttemptId(),
             startContainerId + nContainer - 1);
             startContainerId + nContainer - 1);
-    Assert.assertTrue(
+    assertTrue(
         rm.waitForState(nm, lastContainerId, RMContainerState.ALLOCATED));
         rm.waitForState(nm, lastContainerId, RMContainerState.ALLOCATED));
     // Acquire them, and NM report RUNNING
     // Acquire them, and NM report RUNNING
     am.allocate(null, null);
     am.allocate(null, null);
@@ -1281,7 +1305,7 @@ public class TestCapacitySchedulerAsyncScheduling {
         rmContainer.handle(
         rmContainer.handle(
             new RMContainerEvent(containerId, RMContainerEventType.LAUNCHED));
             new RMContainerEvent(containerId, RMContainerEventType.LAUNCHED));
       } else {
       } else {
-        Assert.fail("Cannot find RMContainer");
+        fail("Cannot find RMContainer");
       }
       }
       rm.waitForState(nm,
       rm.waitForState(nm,
           ContainerId.newContainerId(am.getApplicationAttemptId(), cId),
           ContainerId.newContainerId(am.getApplicationAttemptId(), cId),

+ 9 - 10
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAutoCreatedQueueBase.java

@@ -72,9 +72,8 @@ import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.util.Records;
 import org.apache.hadoop.yarn.util.Records;
 import org.apache.hadoop.yarn.util.YarnVersionInfo;
 import org.apache.hadoop.yarn.util.YarnVersionInfo;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -96,10 +95,10 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
     .capacity.CapacitySchedulerConfiguration.DOT;
     .capacity.CapacitySchedulerConfiguration.DOT;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
     .capacity.CapacitySchedulerConfiguration.FAIR_APP_ORDERING_POLICY;
     .capacity.CapacitySchedulerConfiguration.FAIR_APP_ORDERING_POLICY;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestCapacitySchedulerAutoCreatedQueueBase {
 public class TestCapacitySchedulerAutoCreatedQueueBase {
 
 
@@ -226,7 +225,7 @@ public class TestCapacitySchedulerAutoCreatedQueueBase {
     }
     }
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     QueueMetrics.clearQueueMetrics();
     QueueMetrics.clearQueueMetrics();
     CapacitySchedulerConfiguration conf = setupSchedulerConfiguration();
     CapacitySchedulerConfiguration conf = setupSchedulerConfiguration();
@@ -521,7 +520,7 @@ public class TestCapacitySchedulerAutoCreatedQueueBase {
     conf.setAutoQueueCreationV2Enabled(C, true);
     conf.setAutoQueueCreationV2Enabled(C, true);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     if (mockRM != null) {
     if (mockRM != null) {
       mockRM.stop();
       mockRM.stop();
@@ -696,7 +695,7 @@ public class TestCapacitySchedulerAutoCreatedQueueBase {
             .withAmLabel(nodeLabel)
             .withAmLabel(nodeLabel)
             .build();
             .build();
     RMApp app = MockRMAppSubmitter.submit(mockRM, data);
     RMApp app = MockRMAppSubmitter.submit(mockRM, data);
-    Assert.assertEquals(app.getAmNodeLabelExpression(), nodeLabel);
+    assertEquals(app.getAmNodeLabelExpression(), nodeLabel);
     // check preconditions
     // check preconditions
     List<ApplicationAttemptId> appsInC = cs.getAppsInQueue(PARENT_QUEUE);
     List<ApplicationAttemptId> appsInC = cs.getAppsInQueue(PARENT_QUEUE);
     assertEquals(1, appsInC.size());
     assertEquals(1, appsInC.size());

+ 8 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAutoCreatedQueuePreemption.java

@@ -17,8 +17,9 @@
  */
  */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
     .capacity.TestCapacitySchedulerAutoCreatedQueueBase.C;
     .capacity.TestCapacitySchedulerAutoCreatedQueueBase.C;
@@ -47,7 +48,7 @@ public class TestCapacitySchedulerAutoCreatedQueuePreemption
     extends TestCapacitySchedulerSurgicalPreemption {
     extends TestCapacitySchedulerSurgicalPreemption {
 
 
   @Override
   @Override
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     super.setUp();
     super.setUp();
   }
   }
@@ -128,7 +129,8 @@ public class TestCapacitySchedulerAutoCreatedQueuePreemption
     return conf;
     return conf;
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testSimpleSurgicalPreemptionOnAutoCreatedLeafQueues()
   public void testSimpleSurgicalPreemptionOnAutoCreatedLeafQueues()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -162,7 +164,8 @@ public class TestCapacitySchedulerAutoCreatedQueuePreemption
     testSimpleSurgicalPreemption(USER1, USER2, USER1, USER2);
     testSimpleSurgicalPreemption(USER1, USER2, USER1, USER2);
   }
   }
 
 
-  @Test(timeout = 600000)
+  @Test
+  @Timeout(value = 600)
   public void
   public void
       testPreemptionFromHighestPriorityManagedParentQueueAndOldestContainer()
       testPreemptionFromHighestPriorityManagedParentQueueAndOldestContainer()
       throws Exception {
       throws Exception {

+ 48 - 49
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAutoQueueCreation.java

@@ -73,8 +73,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.security
     .RMContainerTokenSecretManager;
     .RMContainerTokenSecretManager;
 import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -90,11 +90,11 @@ import static org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager
     .NO_LABEL;
     .NO_LABEL;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -119,7 +119,8 @@ public class TestCapacitySchedulerAutoQueueCreation
       4);
       4);
 
 
 
 
-  @Test(timeout = 20000)
+  @Test
+  @Timeout(value = 20)
   public void testAutoCreateLeafQueueCreation() throws Exception {
   public void testAutoCreateLeafQueueCreation() throws Exception {
 
 
     try {
     try {
@@ -176,7 +177,8 @@ public class TestCapacitySchedulerAutoQueueCreation
     }
     }
   }
   }
 
 
-  @Test(timeout = 20000)
+  @Test
+  @Timeout(value = 20)
   public void testAutoCreateLeafQueueCreationSchedulerMaximumAllocation()
   public void testAutoCreateLeafQueueCreationSchedulerMaximumAllocation()
       throws Exception {
       throws Exception {
     try {
     try {
@@ -205,7 +207,8 @@ public class TestCapacitySchedulerAutoQueueCreation
     }
     }
   }
   }
 
 
-  @Test(timeout = 20000)
+  @Test
+  @Timeout(value = 20)
   public void testAutoCreateLeafQueueCreationUsingFullParentPath()
   public void testAutoCreateLeafQueueCreationUsingFullParentPath()
       throws Exception {
       throws Exception {
 
 
@@ -429,7 +432,8 @@ public class TestCapacitySchedulerAutoQueueCreation
     }
     }
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testAutoCreateLeafQueueFailsWithNoQueueMapping()
   public void testAutoCreateLeafQueueFailsWithNoQueueMapping()
       throws Exception {
       throws Exception {
 
 
@@ -450,7 +454,8 @@ public class TestCapacitySchedulerAutoQueueCreation
     assertEquals(RMAppState.FAILED, app.getState());
     assertEquals(RMAppState.FAILED, app.getState());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testQueueMappingValidationFailsWithInvalidParentQueueInMapping()
   public void testQueueMappingValidationFailsWithInvalidParentQueueInMapping()
       throws Exception {
       throws Exception {
 
 
@@ -497,7 +502,8 @@ public class TestCapacitySchedulerAutoQueueCreation
     }
     }
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testQueueMappingUpdatesFailsOnRemovalOfParentQueueInMapping()
   public void testQueueMappingUpdatesFailsOnRemovalOfParentQueueInMapping()
       throws Exception {
       throws Exception {
 
 
@@ -654,18 +660,17 @@ public class TestCapacitySchedulerAutoQueueCreation
               .build();
               .build();
     RMApp app1 = MockRMAppSubmitter.submit(newMockRM, app);
     RMApp app1 = MockRMAppSubmitter.submit(newMockRM, app);
 
 
-    Assert.assertEquals(newCS.getMaximumApplicationLifetime("root.test.user"), 20L);
+    assertEquals(newCS.getMaximumApplicationLifetime("root.test.user"), 20L);
 
 
     try {
     try {
       newMockRM.waitForState(app1.getApplicationId(), RMAppState.KILLED);
       newMockRM.waitForState(app1.getApplicationId(), RMAppState.KILLED);
       long totalTimeRun = app1.getFinishTime() - app1.getSubmitTime();
       long totalTimeRun = app1.getFinishTime() - app1.getSubmitTime();
 
 
-      Assert.assertEquals(RMAppState.KILLED, app1.getState());
-      Assert.assertTrue("Application killed before default lifetime value",
-          totalTimeRun > (defaultRootLifetime * 1000));
-      Assert.assertTrue(
-          "Application killed after max lifetime value " + totalTimeRun,
-          totalTimeRun < (maxRootLifetime * 1000));
+      assertEquals(RMAppState.KILLED, app1.getState());
+      assertTrue(totalTimeRun > (defaultRootLifetime * 1000),
+          "Application killed before default lifetime value");
+      assertTrue(totalTimeRun < (maxRootLifetime * 1000),
+          "Application killed after max lifetime value " + totalTimeRun);
     } finally {
     } finally {
       ((CapacityScheduler) newMockRM.getResourceScheduler()).stop();
       ((CapacityScheduler) newMockRM.getResourceScheduler()).stop();
       newMockRM.stop();
       newMockRM.stop();
@@ -912,28 +917,23 @@ public class TestCapacitySchedulerAutoQueueCreation
 
 
       Resource MIN_RES = Resources.createResource(14438, 6);
       Resource MIN_RES = Resources.createResource(14438, 6);
 
 
-      Assert.assertEquals("Effective Min resource for USER3 is not correct",
-          Resources.none(), user3LeafQueue.getQueueResourceQuotas()
-              .getEffectiveMinResource());
-      Assert.assertEquals("Effective Max resource for USER3 is not correct",
-          MAX_RES, user3LeafQueue
-              .getQueueResourceQuotas()
-              .getEffectiveMaxResource());
+      assertEquals(Resources.none(), user3LeafQueue.getQueueResourceQuotas()
+          .getEffectiveMinResource(), "Effective Min resource for USER3 is not correct");
+      assertEquals(MAX_RES, user3LeafQueue
+          .getQueueResourceQuotas()
+          .getEffectiveMaxResource(), "Effective Max resource for USER3 is not correct");
 
 
       CSQueue user1LeafQueue = newCS.getQueue(USER1);
       CSQueue user1LeafQueue = newCS.getQueue(USER1);
       CSQueue user2LeafQueue = newCS.getQueue(USER2);
       CSQueue user2LeafQueue = newCS.getQueue(USER2);
-      Assert.assertEquals("Effective Min resource for USER2 is not correct",
-          MIN_RES, user1LeafQueue.getQueueResourceQuotas()
-              .getEffectiveMinResource());
-      Assert.assertEquals("Effective Max resource for USER2 is not correct",
-          MAX_RES, user1LeafQueue.getQueueResourceQuotas().getEffectiveMaxResource());
-
-      Assert.assertEquals("Effective Min resource for USER1 is not correct",
-          MIN_RES, user2LeafQueue.getQueueResourceQuotas()
-              .getEffectiveMinResource());
-      Assert.assertEquals("Effective Max resource for USER1 is not correct",
-          MAX_RES, user2LeafQueue.getQueueResourceQuotas()
-              .getEffectiveMaxResource());
+      assertEquals(MIN_RES, user1LeafQueue.getQueueResourceQuotas()
+          .getEffectiveMinResource(), "Effective Min resource for USER2 is not correct");
+      assertEquals(MAX_RES, user1LeafQueue.getQueueResourceQuotas().getEffectiveMaxResource(),
+          "Effective Max resource for USER2 is not correct");
+
+      assertEquals(MIN_RES, user2LeafQueue.getQueueResourceQuotas()
+          .getEffectiveMinResource(), "Effective Min resource for USER1 is not correct");
+      assertEquals(MAX_RES, user2LeafQueue.getQueueResourceQuotas()
+          .getEffectiveMaxResource(), "Effective Max resource for USER1 is not correct");
 
 
       // unregister one NM.
       // unregister one NM.
       newMockRM.unRegisterNode(nm3);
       newMockRM.unRegisterNode(nm3);
@@ -941,12 +941,11 @@ public class TestCapacitySchedulerAutoQueueCreation
       Resource MAX_RES_UPDATED = Resources.createResource(128000, 20);
       Resource MAX_RES_UPDATED = Resources.createResource(128000, 20);
 
 
       // After loosing one NM, resources will reduce
       // After loosing one NM, resources will reduce
-      Assert.assertEquals("Effective Min resource for USER2 is not correct",
-          MIN_RES_UPDATED, user1LeafQueue.getQueueResourceQuotas().getEffectiveMinResource
-              ());
-      Assert.assertEquals("Effective Max resource for USER2 is not correct",
-          MAX_RES_UPDATED, user2LeafQueue.getQueueResourceQuotas()
-              .getEffectiveMaxResource());
+      assertEquals(MIN_RES_UPDATED,
+          user1LeafQueue.getQueueResourceQuotas().getEffectiveMinResource(),
+          "Effective Min resource for USER2 is not correct");
+      assertEquals(MAX_RES_UPDATED, user2LeafQueue.getQueueResourceQuotas()
+          .getEffectiveMaxResource(), "Effective Max resource for USER2 is not correct");
 
 
     } finally {
     } finally {
       cleanupQueue(USER1);
       cleanupQueue(USER1);
@@ -1099,9 +1098,8 @@ public class TestCapacitySchedulerAutoQueueCreation
 
 
       CapacityScheduler cs = (CapacityScheduler) mockRM.getResourceScheduler();
       CapacityScheduler cs = (CapacityScheduler) mockRM.getResourceScheduler();
       CSQueue queue = cs.getQueue("root.a.testuser");
       CSQueue queue = cs.getQueue("root.a.testuser");
-      assertNotNull("Leaf queue has not been auto-created", queue);
-      assertEquals("Number of running applications", 1,
-          queue.getNumApplications());
+      assertNotNull(queue, "Leaf queue has not been auto-created");
+      assertEquals(1, queue.getNumApplications(), "Number of running applications");
     } finally {
     } finally {
       if (mockRM != null) {
       if (mockRM != null) {
         mockRM.close();
         mockRM.close();
@@ -1109,7 +1107,8 @@ public class TestCapacitySchedulerAutoQueueCreation
     }
     }
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testAutoCreateLeafQueueFailsWithSpecifiedEmptyStringLeafQueue()
   public void testAutoCreateLeafQueueFailsWithSpecifiedEmptyStringLeafQueue()
           throws Exception {
           throws Exception {
 
 

+ 115 - 109
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerConfigValidator.java

@@ -40,16 +40,23 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler
 import org.apache.hadoop.yarn.util.YarnVersionInfo;
 import org.apache.hadoop.yarn.util.YarnVersionInfo;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.mockito.Mockito;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.GPU_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.GPU_URI;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 
 public class TestCapacitySchedulerConfigValidator {
 public class TestCapacitySchedulerConfigValidator {
   public static final int NODE_MEMORY = 16;
   public static final int NODE_MEMORY = 16;
@@ -117,32 +124,35 @@ public class TestCapacitySchedulerConfigValidator {
   /**
   /**
    * Test for the case when the scheduler.minimum-allocation-mb == 0.
    * Test for the case when the scheduler.minimum-allocation-mb == 0.
    */
    */
-  @Test (expected = YarnRuntimeException.class)
+  @Test
   public void testValidateMemoryAllocationInvalidMinMem() {
   public void testValidateMemoryAllocationInvalidMinMem() {
-    Map<String, String> configs = new HashMap();
-    configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, "0");
-    Configuration config = CapacitySchedulerConfigGeneratorForTest
-            .createConfiguration(configs);
-    CapacitySchedulerConfigValidator.validateMemoryAllocation(config);
-    fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB +
-            " should be > 0");
+    assertThrows(YarnRuntimeException.class, () -> {
+      Map<String, String> configs = new HashMap();
+      configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, "0");
+      Configuration config = CapacitySchedulerConfigGeneratorForTest
+          .createConfiguration(configs);
+      CapacitySchedulerConfigValidator.validateMemoryAllocation(config);
+      fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB +
+          " should be > 0");
+    });
   }
   }
 
 
   /**
   /**
    * Test for the case when the scheduler.minimum-allocation-mb is greater than
    * Test for the case when the scheduler.minimum-allocation-mb is greater than
    * scheduler.maximum-allocation-mb.
    * scheduler.maximum-allocation-mb.
    */
    */
-  @Test (expected = YarnRuntimeException.class)
+  @Test
   public void testValidateMemoryAllocationHIgherMinThanMaxMem() {
   public void testValidateMemoryAllocationHIgherMinThanMaxMem() {
-    Map<String, String> configs = new HashMap();
-    configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, "8192");
-    configs.put(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, "1024");
-    Configuration config = CapacitySchedulerConfigGeneratorForTest
-            .createConfiguration(configs);
-    CapacitySchedulerConfigValidator.validateMemoryAllocation(config);
-    fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB + " should be > "
-            + YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB);
-
+    assertThrows(YarnRuntimeException.class, () -> {
+      Map<String, String> configs = new HashMap();
+      configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, "8192");
+      configs.put(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, "1024");
+      Configuration config = CapacitySchedulerConfigGeneratorForTest
+          .createConfiguration(configs);
+      CapacitySchedulerConfigValidator.validateMemoryAllocation(config);
+      fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB + " should be > "
+          + YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB);
+    });
   }
   }
 
 
   @Test
   @Test
@@ -161,33 +171,36 @@ public class TestCapacitySchedulerConfigValidator {
   /**
   /**
    * Test for the case when the scheduler.minimum-allocation-vcores == 0.
    * Test for the case when the scheduler.minimum-allocation-vcores == 0.
    */
    */
-  @Test (expected = YarnRuntimeException.class)
+  @Test
   public void testValidateVCoresInvalidMinVCore() {
   public void testValidateVCoresInvalidMinVCore() {
-    Map<String, String> configs = new HashMap();
-    configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, "0");
-    Configuration config = CapacitySchedulerConfigGeneratorForTest
-            .createConfiguration(configs);
-    CapacitySchedulerConfigValidator.validateVCores(config);
-    fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES
-            + " should be > 0");
+    assertThrows(YarnRuntimeException.class, () -> {
+      Map<String, String> configs = new HashMap();
+      configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, "0");
+      Configuration config = CapacitySchedulerConfigGeneratorForTest
+          .createConfiguration(configs);
+      CapacitySchedulerConfigValidator.validateVCores(config);
+      fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES
+          + " should be > 0");
+    });
   }
   }
 
 
   /**
   /**
    * Test for the case when the scheduler.minimum-allocation-vcores is greater
    * Test for the case when the scheduler.minimum-allocation-vcores is greater
    * than scheduler.maximum-allocation-vcores.
    * than scheduler.maximum-allocation-vcores.
    */
    */
-  @Test (expected = YarnRuntimeException.class)
+  @Test
   public void testValidateVCoresHigherMinThanMaxVCore() {
   public void testValidateVCoresHigherMinThanMaxVCore() {
-    Map<String, String> configs = new HashMap();
-    configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, "4");
-    configs.put(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, "1");
-    Configuration config = CapacitySchedulerConfigGeneratorForTest
-            .createConfiguration(configs);
-    CapacitySchedulerConfigValidator.validateVCores(config);
-    fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES +
-            " should be > "
-            + YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB);
-
+    assertThrows(YarnRuntimeException.class, () -> {
+      Map<String, String> configs = new HashMap();
+      configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, "4");
+      configs.put(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, "1");
+      Configuration config = CapacitySchedulerConfigGeneratorForTest
+          .createConfiguration(configs);
+      CapacitySchedulerConfigValidator.validateVCores(config);
+      fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES +
+          " should be > "
+          + YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB);
+    });
   }
   }
 
 
   @Test
   @Test
@@ -216,8 +229,7 @@ public class TestCapacitySchedulerConfigValidator {
               .validateCSConfiguration(oldConfig, newConfig, rmContext);
               .validateCSConfiguration(oldConfig, newConfig, rmContext);
       fail("Invalid capacity");
       fail("Invalid capacity");
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e.getCause().getMessage()
-              .startsWith("Illegal capacity"));
+      assertTrue(e.getCause().getMessage().startsWith("Illegal capacity"));
     }
     }
   }
   }
 
 
@@ -236,7 +248,7 @@ public class TestCapacitySchedulerConfigValidator {
           .validateCSConfiguration(oldConfiguration, newConfiguration, rmContext);
           .validateCSConfiguration(oldConfiguration, newConfiguration, rmContext);
       fail("Parent maximum capacity exceeded");
       fail("Parent maximum capacity exceeded");
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e.getCause().getMessage()
+      assertTrue(e.getCause().getMessage()
           .startsWith("Max resource configuration"));
           .startsWith("Max resource configuration"));
     } finally {
     } finally {
       mockRM.stop();
       mockRM.stop();
@@ -277,7 +289,7 @@ public class TestCapacitySchedulerConfigValidator {
           .validateCSConfiguration(oldConfiguration, newConfiguration, rmContext);
           .validateCSConfiguration(oldConfiguration, newConfiguration, rmContext);
       fail("Parent maximum capacity exceeded");
       fail("Parent maximum capacity exceeded");
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e.getCause().getMessage()
+      assertTrue(e.getCause().getMessage()
           .startsWith("Max resource configuration"));
           .startsWith("Max resource configuration"));
     } finally {
     } finally {
       mockRM.stop();
       mockRM.stop();
@@ -298,7 +310,7 @@ public class TestCapacitySchedulerConfigValidator {
           .validateCSConfiguration(oldConfiguration, newConfiguration, rmContext);
           .validateCSConfiguration(oldConfiguration, newConfiguration, rmContext);
       fail("Parent maximum capacity exceeded");
       fail("Parent maximum capacity exceeded");
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e.getCause().getMessage()
+      assertTrue(e.getCause().getMessage()
           .startsWith("Max resource configuration"));
           .startsWith("Max resource configuration"));
     } finally {
     } finally {
       mockRM.stop();
       mockRM.stop();
@@ -319,7 +331,7 @@ public class TestCapacitySchedulerConfigValidator {
           .validateCSConfiguration(oldConfiguration, newConfiguration, rmContext);
           .validateCSConfiguration(oldConfiguration, newConfiguration, rmContext);
       fail("Parent maximum capacity exceeded");
       fail("Parent maximum capacity exceeded");
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e.getCause().getMessage()
+      assertTrue(e.getCause().getMessage()
           .startsWith("Max resource configuration"));
           .startsWith("Max resource configuration"));
     } finally {
     } finally {
       mockRM.stop();
       mockRM.stop();
@@ -336,7 +348,7 @@ public class TestCapacitySchedulerConfigValidator {
     RMContext rmContext = prepareRMContext();
     RMContext rmContext = prepareRMContext();
     boolean isValidConfig = CapacitySchedulerConfigValidator
     boolean isValidConfig = CapacitySchedulerConfigValidator
             .validateCSConfiguration(oldConfig, newConfig, rmContext);
             .validateCSConfiguration(oldConfig, newConfig, rmContext);
-    Assert.assertTrue(isValidConfig);
+    assertTrue(isValidConfig);
   }
   }
 
 
   /**
   /**
@@ -355,7 +367,7 @@ public class TestCapacitySchedulerConfigValidator {
               .validateCSConfiguration(oldConfig, newConfig, rmContext);
               .validateCSConfiguration(oldConfig, newConfig, rmContext);
       fail("There are child queues in running state");
       fail("There are child queues in running state");
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e.getCause().getMessage()
+      assertTrue(e.getCause().getMessage()
               .contains("The parent queue:root cannot be STOPPED"));
               .contains("The parent queue:root cannot be STOPPED"));
     }
     }
   }
   }
@@ -374,7 +386,7 @@ public class TestCapacitySchedulerConfigValidator {
     RMContext rmContext = prepareRMContext();
     RMContext rmContext = prepareRMContext();
     Boolean isValidConfig = CapacitySchedulerConfigValidator
     Boolean isValidConfig = CapacitySchedulerConfigValidator
             .validateCSConfiguration(oldConfig, newConfig, rmContext);
             .validateCSConfiguration(oldConfig, newConfig, rmContext);
-    Assert.assertTrue(isValidConfig);
+    assertTrue(isValidConfig);
 
 
   }
   }
 
 
@@ -402,7 +414,7 @@ public class TestCapacitySchedulerConfigValidator {
         fail("Invalid capacity for children of queue root");
         fail("Invalid capacity for children of queue root");
       }
       }
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e.getCause().getMessage()
+      assertTrue(e.getCause().getMessage()
               .startsWith("Illegal capacity"));
               .startsWith("Illegal capacity"));
     }
     }
   }
   }
@@ -428,7 +440,7 @@ public class TestCapacitySchedulerConfigValidator {
     RMContext rmContext = prepareRMContext();
     RMContext rmContext = prepareRMContext();
     Boolean isValidConfig = CapacitySchedulerConfigValidator
     Boolean isValidConfig = CapacitySchedulerConfigValidator
             .validateCSConfiguration(oldConfig, newConfig, rmContext);
             .validateCSConfiguration(oldConfig, newConfig, rmContext);
-    Assert.assertTrue(isValidConfig);
+    assertTrue(isValidConfig);
   }
   }
 
 
   @Test
   @Test
@@ -451,33 +463,33 @@ public class TestCapacitySchedulerConfigValidator {
 
 
       QueueMetrics origQM1 = cache.get("root.test1");
       QueueMetrics origQM1 = cache.get("root.test1");
       QueueMetrics origQM2 = cache.get("root.test2");
       QueueMetrics origQM2 = cache.get("root.test2");
-      Assert.assertNotNull("Original queues should be found in the cache", origQM1);
-      Assert.assertNotNull("Original queues should be found in the cache", origQM2);
+      assertNotNull(origQM1, "Original queues should be found in the cache");
+      assertNotNull(origQM2, "Original queues should be found in the cache");
 
 
       QueueMetrics origPQM1 = cache.get("default.root.test1");
       QueueMetrics origPQM1 = cache.get("default.root.test1");
       QueueMetrics origPQM2 = cache.get("default.root.test2");
       QueueMetrics origPQM2 = cache.get("default.root.test2");
-      Assert.assertNotNull("Original queues should be found in the cache (PartitionQueueMetrics)",
-          origPQM1);
-      Assert.assertNotNull("Original queues should be found in the cache (PartitionQueueMetrics)",
-          origPQM2);
+      assertNotNull(origPQM1,
+          "Original queues should be found in the cache (PartitionQueueMetrics)");
+      assertNotNull(origPQM2,
+          "Original queues should be found in the cache (PartitionQueueMetrics)");
 
 
       MetricsSource origMS1 =
       MetricsSource origMS1 =
           ms.getSource("QueueMetrics,q0=root,q1=test1");
           ms.getSource("QueueMetrics,q0=root,q1=test1");
       MetricsSource origMS2 =
       MetricsSource origMS2 =
           ms.getSource("QueueMetrics,q0=root,q1=test2");
           ms.getSource("QueueMetrics,q0=root,q1=test2");
-      Assert.assertNotNull("Original queues should be found in the Metrics System",
-          origMS1);
-      Assert.assertNotNull("Original queues should be found in the Metrics System",
-          origMS2);
+      assertNotNull(origMS1,
+          "Original queues should be found in the Metrics System");
+      assertNotNull(origMS2,
+          "Original queues should be found in the Metrics System");
 
 
       MetricsSource origPMS1 = ms
       MetricsSource origPMS1 = ms
           .getSource("PartitionQueueMetrics,partition=,q0=root,q1=test1");
           .getSource("PartitionQueueMetrics,partition=,q0=root,q1=test1");
       MetricsSource origPMS2 = ms
       MetricsSource origPMS2 = ms
           .getSource("PartitionQueueMetrics,partition=,q0=root,q1=test2");
           .getSource("PartitionQueueMetrics,partition=,q0=root,q1=test2");
-      Assert.assertNotNull(
-          "Original queues should be found in Metrics System (PartitionQueueMetrics)", origPMS1);
-      Assert.assertNotNull(
-          "Original queues should be found in Metrics System (PartitionQueueMetrics)", origPMS2);
+      assertNotNull(origPMS1,
+          "Original queues should be found in Metrics System (PartitionQueueMetrics)");
+      assertNotNull(origPMS2,
+          "Original queues should be found in Metrics System (PartitionQueueMetrics)");
 
 
       Configuration newConfig = new Configuration(oldConfig);
       Configuration newConfig = new Configuration(oldConfig);
       newConfig
       newConfig
@@ -491,32 +503,30 @@ public class TestCapacitySchedulerConfigValidator {
 
 
       boolean isValidConfig = CapacitySchedulerConfigValidator
       boolean isValidConfig = CapacitySchedulerConfigValidator
           .validateCSConfiguration(oldConfig, newConfig, rmContext);
           .validateCSConfiguration(oldConfig, newConfig, rmContext);
-      Assert.assertTrue(isValidConfig);
-
-      Assert.assertFalse("Validated new queue should not be in the cache",
-          cache.containsKey("root.test3"));
-      Assert.assertFalse("Validated new queue should not be in the cache (PartitionQueueMetrics)",
-          cache.containsKey("default.root.test3"));
-      Assert.assertNull("Validated new queue should not be in the Metrics System",
-          ms.getSource("QueueMetrics,q0=root,q1=test3"));
-      Assert.assertNull(
-          "Validated new queue should not be in Metrics System (PartitionQueueMetrics)",
-          ms
-              .getSource("PartitionQueueMetrics,partition=,q0=root,q1=test3"));
+      assertTrue(isValidConfig);
+
+      assertFalse(cache.containsKey("root.test3"),
+          "Validated new queue should not be in the cache");
+      assertFalse(cache.containsKey("default.root.test3"),
+          "Validated new queue should not be in the cache (PartitionQueueMetrics)");
+      assertNull(ms.getSource("QueueMetrics,q0=root,q1=test3"),
+          "Validated new queue should not be in the Metrics System");
+      assertNull(ms.getSource("PartitionQueueMetrics,partition=,q0=root,q1=test3"),
+          "Validated new queue should not be in Metrics System (PartitionQueueMetrics)");
 
 
       // Config validation should not change the existing
       // Config validation should not change the existing
       // objects in the cache and the metrics system
       // objects in the cache and the metrics system
-      Assert.assertEquals(origQM1, cache.get("root.test1"));
-      Assert.assertEquals(origQM2, cache.get("root.test2"));
-      Assert.assertEquals(origPQM1, cache.get("default.root.test1"));
-      Assert.assertEquals(origPQM1, cache.get("default.root.test1"));
-      Assert.assertEquals(origMS1,
+      assertEquals(origQM1, cache.get("root.test1"));
+      assertEquals(origQM2, cache.get("root.test2"));
+      assertEquals(origPQM1, cache.get("default.root.test1"));
+      assertEquals(origPQM1, cache.get("default.root.test1"));
+      assertEquals(origMS1,
           ms.getSource("QueueMetrics,q0=root,q1=test1"));
           ms.getSource("QueueMetrics,q0=root,q1=test1"));
-      Assert.assertEquals(origMS2,
+      assertEquals(origMS2,
           ms.getSource("QueueMetrics,q0=root,q1=test2"));
           ms.getSource("QueueMetrics,q0=root,q1=test2"));
-      Assert.assertEquals(origPMS1,
+      assertEquals(origPMS1,
           ms.getSource("PartitionQueueMetrics,partition=,q0=root,q1=test1"));
           ms.getSource("PartitionQueueMetrics,partition=,q0=root,q1=test1"));
-      Assert.assertEquals(origPMS2,
+      assertEquals(origPMS2,
           ms.getSource("PartitionQueueMetrics,partition=,q0=root,q1=test2"));
           ms.getSource("PartitionQueueMetrics,partition=,q0=root,q1=test2"));
     } finally {
     } finally {
       mockRM.stop();
       mockRM.stop();
@@ -543,9 +553,9 @@ public class TestCapacitySchedulerConfigValidator {
               .validateCSConfiguration(oldConfig, newConfig, rmContext);
               .validateCSConfiguration(oldConfig, newConfig, rmContext);
       fail("Invalid capacity for children of queue root");
       fail("Invalid capacity for children of queue root");
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e.getCause().getMessage()
+      assertTrue(e.getCause().getMessage()
               .contains("root.test2 cannot be deleted"));
               .contains("root.test2 cannot be deleted"));
-      Assert.assertTrue(e.getCause().getMessage()
+      assertTrue(e.getCause().getMessage()
               .contains("the queue is not yet in stopped state"));
               .contains("the queue is not yet in stopped state"));
     }
     }
   }
   }
@@ -572,7 +582,7 @@ public class TestCapacitySchedulerConfigValidator {
         fail("Invalid capacity for children of queue root");
         fail("Invalid capacity for children of queue root");
       }
       }
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.assertTrue(e.getCause().getMessage()
+      assertTrue(e.getCause().getMessage()
               .contains("Illegal capacity"));
               .contains("Illegal capacity"));
     }
     }
   }
   }
@@ -595,7 +605,7 @@ public class TestCapacitySchedulerConfigValidator {
     RMContext rmContext = prepareRMContext();
     RMContext rmContext = prepareRMContext();
     boolean isValidConfig = CapacitySchedulerConfigValidator
     boolean isValidConfig = CapacitySchedulerConfigValidator
               .validateCSConfiguration(oldConfig, newConfig, rmContext);
               .validateCSConfiguration(oldConfig, newConfig, rmContext);
-    Assert.assertTrue(isValidConfig);
+    assertTrue(isValidConfig);
 
 
   }
   }
 
 
@@ -613,30 +623,26 @@ public class TestCapacitySchedulerConfigValidator {
     RMContext rmContext = prepareRMContext();
     RMContext rmContext = prepareRMContext();
     boolean isValidConfig = CapacitySchedulerConfigValidator
     boolean isValidConfig = CapacitySchedulerConfigValidator
             .validateCSConfiguration(oldConfig, newConfig, rmContext);
             .validateCSConfiguration(oldConfig, newConfig, rmContext);
-    Assert.assertTrue(isValidConfig);
+    assertTrue(isValidConfig);
   }
   }
 
 
   public static RMContext prepareRMContext() {
   public static RMContext prepareRMContext() {
     setupResources(false);
     setupResources(false);
-    RMContext rmContext = Mockito.mock(RMContext.class);
-    CapacityScheduler mockCs = Mockito.mock(CapacityScheduler.class);
-    Mockito.when(rmContext.getScheduler()).thenReturn(mockCs);
-    LocalConfigurationProvider configProvider = Mockito
-            .mock(LocalConfigurationProvider.class);
-    Mockito.when(rmContext.getConfigurationProvider())
+    RMContext rmContext = mock(RMContext.class);
+    CapacityScheduler mockCs = mock(CapacityScheduler.class);
+    when(rmContext.getScheduler()).thenReturn(mockCs);
+    LocalConfigurationProvider configProvider = mock(LocalConfigurationProvider.class);
+    when(rmContext.getConfigurationProvider())
             .thenReturn(configProvider);
             .thenReturn(configProvider);
-    RMNodeLabelsManager nodeLabelsManager = Mockito
-            .mock(RMNodeLabelsManager.class);
-    Mockito.when(rmContext.getNodeLabelManager()).thenReturn(nodeLabelsManager);
-    LightWeightResource partitionResource = Mockito
-            .mock(LightWeightResource.class);
-    Mockito.when(nodeLabelsManager
-            .getResourceByLabel(Mockito.any(), Mockito.any()))
-            .thenReturn(partitionResource);
-    PlacementManager queuePlacementManager = Mockito
-            .mock(PlacementManager.class);
-    Mockito.when(rmContext.getQueuePlacementManager())
-            .thenReturn(queuePlacementManager);
+    RMNodeLabelsManager nodeLabelsManager = mock(RMNodeLabelsManager.class);
+    when(rmContext.getNodeLabelManager()).thenReturn(nodeLabelsManager);
+    LightWeightResource partitionResource = mock(LightWeightResource.class);
+    when(nodeLabelsManager
+        .getResourceByLabel(any(), any()))
+        .thenReturn(partitionResource);
+    PlacementManager queuePlacementManager = mock(PlacementManager.class);
+    when(rmContext.getQueuePlacementManager())
+        .thenReturn(queuePlacementManager);
     return rmContext;
     return rmContext;
   }
   }
 
 

+ 4 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerConfiguration.java

@@ -20,13 +20,13 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.security.authorize.AccessControlList;
 import org.apache.hadoop.security.authorize.AccessControlList;
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.yarn.api.records.QueueACL;
 import org.apache.hadoop.yarn.api.records.QueueACL;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.Set;
 import java.util.Set;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestCapacitySchedulerConfiguration {
 public class TestCapacitySchedulerConfiguration {
 
 

+ 10 - 12
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerDynamicBehavior.java

@@ -34,13 +34,11 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.C
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.ROOT;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.ROOT;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.checkQueueStructureCapacities;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.checkQueueStructureCapacities;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.getDefaultCapacities;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.getDefaultCapacities;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import java.util.List;
 import java.util.List;
 
 
-import org.junit.After;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
@@ -54,9 +52,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.QueueEntitlement;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.QueueEntitlement;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 public class TestCapacitySchedulerDynamicBehavior {
 public class TestCapacitySchedulerDynamicBehavior {
   private static final Logger LOG = LoggerFactory
   private static final Logger LOG = LoggerFactory
@@ -66,7 +64,7 @@ public class TestCapacitySchedulerDynamicBehavior {
 
 
   private MockRM rm;
   private MockRM rm;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
     CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
     setupPlanQueueConfiguration(conf);
     setupPlanQueueConfiguration(conf);
@@ -78,7 +76,7 @@ public class TestCapacitySchedulerDynamicBehavior {
     rm.registerNode("n1:1234", 64 * GB, 64);
     rm.registerNode("n1:1234", 64 * GB, 64);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (rm != null) {
     if (rm != null) {
       rm.stop();
       rm.stop();
@@ -249,7 +247,7 @@ public class TestCapacitySchedulerDynamicBehavior {
     String queue =
     String queue =
         scheduler.getApplicationAttempt(appsInB1.get(0)).getQueue()
         scheduler.getApplicationAttempt(appsInB1.get(0)).getQueue()
             .getQueueName();
             .getQueueName();
-    Assert.assertEquals("b1", queue);
+    assertEquals("b1", queue);
 
 
     List<ApplicationAttemptId> appsInRoot = scheduler.getAppsInQueue("root");
     List<ApplicationAttemptId> appsInRoot = scheduler.getAppsInQueue("root");
     assertTrue(appsInRoot.contains(appAttemptId));
     assertTrue(appsInRoot.contains(appAttemptId));
@@ -275,7 +273,7 @@ public class TestCapacitySchedulerDynamicBehavior {
     queue =
     queue =
         scheduler.getApplicationAttempt(appsInDefQ.get(0)).getQueue()
         scheduler.getApplicationAttempt(appsInDefQ.get(0)).getQueue()
             .getQueueName();
             .getQueueName();
-    Assert.assertTrue(queue.equals(defQName));
+    assertTrue(queue.equals(defQName));
 
 
     appsInA = scheduler.getAppsInQueue("a");
     appsInA = scheduler.getAppsInQueue("a");
     assertTrue(appsInA.contains(appAttemptId));
     assertTrue(appsInA.contains(appAttemptId));

+ 66 - 59
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerLazyPreemption.java

@@ -18,6 +18,9 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.api.records.Priority;
@@ -38,10 +41,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preempti
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
@@ -52,14 +55,15 @@ import java.util.Set;
 public class TestCapacitySchedulerLazyPreemption
 public class TestCapacitySchedulerLazyPreemption
     extends CapacitySchedulerPreemptionTestBase {
     extends CapacitySchedulerPreemptionTestBase {
   @Override
   @Override
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     super.setUp();
     super.setUp();
     conf.setBoolean(CapacitySchedulerConfiguration.LAZY_PREEMPTION_ENABLED,
     conf.setBoolean(CapacitySchedulerConfiguration.LAZY_PREEMPTION_ENABLED,
         true);
         true);
   }
   }
 
 
-  @Test (timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testSimplePreemption() throws Exception {
   public void testSimplePreemption() throws Exception {
     /**
     /**
      * Test case: Submit two application (app1/app2) to different queues, queue
      * Test case: Submit two application (app1/app2) to different queues, queue
@@ -117,7 +121,7 @@ public class TestCapacitySchedulerLazyPreemption
     // App1 should have 7 containers now, and no available resource for cluster
     // App1 should have 7 containers now, and no available resource for cluster
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
 
 
     // Submit app2 to queue-c and asks for a 1G container for AM
     // Submit app2 to queue-c and asks for a 1G container for AM
     MockRMAppSubmissionData data =
     MockRMAppSubmissionData data =
@@ -132,9 +136,9 @@ public class TestCapacitySchedulerLazyPreemption
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm2);
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm2);
 
 
     // NM1/NM2 has available resource = 0G
     // NM1/NM2 has available resource = 0G
-    Assert.assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getNode(nm2.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm2.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
 
 
     // AM asks for a 1 * GB container
     // AM asks for a 1 * GB container
@@ -158,8 +162,8 @@ public class TestCapacitySchedulerLazyPreemption
     Map<ContainerId, RMContainer> killableContainers =
     Map<ContainerId, RMContainer> killableContainers =
         waitKillableContainersSize(
         waitKillableContainersSize(
             pm, "root.a", RMNodeLabelsManager.NO_LABEL, 1);
             pm, "root.a", RMNodeLabelsManager.NO_LABEL, 1);
-    Assert.assertEquals(1, killableContainers.size());
-    Assert.assertEquals(killableContainers.entrySet().iterator().next().getKey()
+    assertEquals(1, killableContainers.size());
+    assertEquals(killableContainers.entrySet().iterator().next().getKey()
         .getApplicationAttemptId(), am1.getApplicationAttemptId());
         .getApplicationAttemptId(), am1.getApplicationAttemptId());
 
 
     // Call CS.handle once to see if container preempted
     // Call CS.handle once to see if container preempted
@@ -169,21 +173,20 @@ public class TestCapacitySchedulerLazyPreemption
         am2.getApplicationAttemptId());
         am2.getApplicationAttemptId());
 
 
     // App1 has 6 containers, and app2 has 2 containers
     // App1 has 6 containers, and app2 has 2 containers
-    Assert.assertEquals(6, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(2, schedulerApp2.getLiveContainers().size());
+    assertEquals(6, schedulerApp1.getLiveContainers().size());
+    assertEquals(2, schedulerApp2.getLiveContainers().size());
 
 
     // Ensure preemption metrics were recored.
     // Ensure preemption metrics were recored.
-    Assert.assertEquals(
-        "Number of preempted containers incorrectly recorded:", 1,
-        cs.getQueue("a").getMetrics().getAggregatePreemptedContainers());
-    Assert.assertEquals(
-        "Number of preempted containers incorrectly recorded:", 1,
-        cs.getRootQueue().getMetrics().getAggregatePreemptedContainers());
+    assertEquals(1, cs.getQueue("a").getMetrics().getAggregatePreemptedContainers(),
+        "Number of preempted containers incorrectly recorded:");
+    assertEquals(1, cs.getRootQueue().getMetrics().getAggregatePreemptedContainers(),
+        "Number of preempted containers incorrectly recorded:");
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test (timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testPreemptionConsidersNodeLocalityDelay()
   public void testPreemptionConsidersNodeLocalityDelay()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -225,7 +228,7 @@ public class TestCapacitySchedulerLazyPreemption
     // App1 should have 7 containers now, and no available resource for cluster
     // App1 should have 7 containers now, and no available resource for cluster
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
 
 
     // Submit app2 to queue-c and asks for a 1G container for AM
     // Submit app2 to queue-c and asks for a 1G container for AM
     MockRMAppSubmissionData data =
     MockRMAppSubmissionData data =
@@ -240,9 +243,9 @@ public class TestCapacitySchedulerLazyPreemption
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm2);
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm2);
 
 
     // NM1/NM2 has available resource = 0G
     // NM1/NM2 has available resource = 0G
-    Assert.assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getNode(nm2.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm2.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
 
 
     // AM asks for a 1 * GB container with unknown host and unknown rack
     // AM asks for a 1 * GB container with unknown host and unknown rack
@@ -270,7 +273,7 @@ public class TestCapacitySchedulerLazyPreemption
     Map<ContainerId, RMContainer> killableContainers =
     Map<ContainerId, RMContainer> killableContainers =
         waitKillableContainersSize(
         waitKillableContainersSize(
             pm, "root.a", RMNodeLabelsManager.NO_LABEL, 1);
             pm, "root.a", RMNodeLabelsManager.NO_LABEL, 1);
-    Assert.assertEquals(killableContainers.entrySet().iterator().next().getKey()
+    assertEquals(killableContainers.entrySet().iterator().next().getKey()
         .getApplicationAttemptId(), am1.getApplicationAttemptId());
         .getApplicationAttemptId(), am1.getApplicationAttemptId());
 
 
     // Call CS.handle once to see if container preempted
     // Call CS.handle once to see if container preempted
@@ -280,20 +283,21 @@ public class TestCapacitySchedulerLazyPreemption
         am2.getApplicationAttemptId());
         am2.getApplicationAttemptId());
 
 
     // App1 has 7 containers, and app2 has 1 containers (no container preempted)
     // App1 has 7 containers, and app2 has 1 containers (no container preempted)
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
 
 
     // Do allocation again, one container will be preempted
     // Do allocation again, one container will be preempted
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
 
 
     // App1 has 6 containers, and app2 has 2 containers (new container allocated)
     // App1 has 6 containers, and app2 has 2 containers (new container allocated)
-    Assert.assertEquals(6, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(2, schedulerApp2.getLiveContainers().size());
+    assertEquals(6, schedulerApp1.getLiveContainers().size());
+    assertEquals(2, schedulerApp2.getLiveContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test (timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testPreemptionConsidersHardNodeLocality()
   public void testPreemptionConsidersHardNodeLocality()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -337,7 +341,7 @@ public class TestCapacitySchedulerLazyPreemption
     // App1 should have 7 containers now, and no available resource for cluster
     // App1 should have 7 containers now, and no available resource for cluster
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
 
 
     // Submit app2 to queue-c and asks for a 1G container for AM
     // Submit app2 to queue-c and asks for a 1G container for AM
     MockRMAppSubmissionData data =
     MockRMAppSubmissionData data =
@@ -352,9 +356,9 @@ public class TestCapacitySchedulerLazyPreemption
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm2);
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm2);
 
 
     // NM1/NM2 has available resource = 0G
     // NM1/NM2 has available resource = 0G
-    Assert.assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getNode(nm2.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm2.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
 
 
     // AM asks for a 1 * GB container for h3 with hard locality,
     // AM asks for a 1 * GB container for h3 with hard locality,
@@ -383,7 +387,7 @@ public class TestCapacitySchedulerLazyPreemption
     Map<ContainerId, RMContainer> killableContainers =
     Map<ContainerId, RMContainer> killableContainers =
         waitKillableContainersSize(
         waitKillableContainersSize(
             pm, "root.a", RMNodeLabelsManager.NO_LABEL, 1);
             pm, "root.a", RMNodeLabelsManager.NO_LABEL, 1);
-    Assert.assertEquals(killableContainers.entrySet().iterator().next().getKey()
+    assertEquals(killableContainers.entrySet().iterator().next().getKey()
         .getApplicationAttemptId(), am1.getApplicationAttemptId());
         .getApplicationAttemptId(), am1.getApplicationAttemptId());
 
 
     // Call CS.handle once to see if container preempted
     // Call CS.handle once to see if container preempted
@@ -393,20 +397,21 @@ public class TestCapacitySchedulerLazyPreemption
         am2.getApplicationAttemptId());
         am2.getApplicationAttemptId());
 
 
     // App1 has 7 containers, and app2 has 1 containers (no container preempted)
     // App1 has 7 containers, and app2 has 1 containers (no container preempted)
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
 
 
     // Do allocation again, nothing will be preempted
     // Do allocation again, nothing will be preempted
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
 
 
     // App1 has 7 containers, and app2 has 1 containers (no container allocated)
     // App1 has 7 containers, and app2 has 1 containers (no container allocated)
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test (timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testPreemptionPolicyShouldRespectAlreadyMarkedKillableContainers()
   public void testPreemptionPolicyShouldRespectAlreadyMarkedKillableContainers()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -455,7 +460,7 @@ public class TestCapacitySchedulerLazyPreemption
     // App1 should have 7 containers now, and no available resource for cluster
     // App1 should have 7 containers now, and no available resource for cluster
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
 
 
     // Submit app2 to queue-c and asks for a 1G container for AM
     // Submit app2 to queue-c and asks for a 1G container for AM
     MockRMAppSubmissionData data =
     MockRMAppSubmissionData data =
@@ -470,7 +475,7 @@ public class TestCapacitySchedulerLazyPreemption
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1);
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1);
 
 
     // NM1 has available resource = 0G
     // NM1 has available resource = 0G
-    Assert.assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
     am2.allocate("*", 1 * GB, 1, new ArrayList<ContainerId>());
     am2.allocate("*", 1 * GB, 1, new ArrayList<ContainerId>());
 
 
@@ -490,11 +495,11 @@ public class TestCapacitySchedulerLazyPreemption
     waitKillableContainersSize(pm, "root.a", RMNodeLabelsManager.NO_LABEL, 1);
     waitKillableContainersSize(pm, "root.a", RMNodeLabelsManager.NO_LABEL, 1);
 
 
     // Check killable containers and to-be-preempted containers in edit policy
     // Check killable containers and to-be-preempted containers in edit policy
-    Assert.assertEquals(0, editPolicy.getToPreemptContainers().size());
+    assertEquals(0, editPolicy.getToPreemptContainers().size());
 
 
     // Run edit schedule again, confirm status doesn't changed
     // Run edit schedule again, confirm status doesn't changed
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(0, editPolicy.getToPreemptContainers().size());
+    assertEquals(0, editPolicy.getToPreemptContainers().size());
 
 
     // Save current to kill containers
     // Save current to kill containers
     Set<ContainerId> previousKillableContainers = new HashSet<>(
     Set<ContainerId> previousKillableContainers = new HashSet<>(
@@ -508,17 +513,17 @@ public class TestCapacitySchedulerLazyPreemption
     // Call editPolicy.editSchedule() once, we should have 1 container in to-preempt map
     // Call editPolicy.editSchedule() once, we should have 1 container in to-preempt map
     // and 1 container in killable map
     // and 1 container in killable map
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(1, editPolicy.getToPreemptContainers().size());
+    assertEquals(1, editPolicy.getToPreemptContainers().size());
 
 
     // Call editPolicy.editSchedule() once more, we should have 2 containers killable map
     // Call editPolicy.editSchedule() once more, we should have 2 containers killable map
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(0, editPolicy.getToPreemptContainers().size());
+    assertEquals(0, editPolicy.getToPreemptContainers().size());
 
 
     // Check if previous killable containers included by new killable containers
     // Check if previous killable containers included by new killable containers
     Map<ContainerId, RMContainer> killableContainers =
     Map<ContainerId, RMContainer> killableContainers =
         waitKillableContainersSize(
         waitKillableContainersSize(
             pm, "root.a", RMNodeLabelsManager.NO_LABEL, 2);
             pm, "root.a", RMNodeLabelsManager.NO_LABEL, 2);
-    Assert.assertTrue(
+    assertTrue(
         Sets.difference(previousKillableContainers, killableContainers.keySet())
         Sets.difference(previousKillableContainers, killableContainers.keySet())
             .isEmpty());
             .isEmpty());
   }
   }
@@ -526,8 +531,9 @@ public class TestCapacitySchedulerLazyPreemption
   /*
   /*
    * Ignore this test now because it could be a premature optimization
    * Ignore this test now because it could be a premature optimization
    */
    */
-  @Ignore
-  @Test (timeout = 60000)
+  @Disabled
+  @Test
+  @Timeout(value = 60)
   public void testPreemptionPolicyCleanupKillableContainersWhenNoPreemptionNeeded()
   public void testPreemptionPolicyCleanupKillableContainersWhenNoPreemptionNeeded()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -575,7 +581,7 @@ public class TestCapacitySchedulerLazyPreemption
     // App1 should have 7 containers now, and no available resource for cluster
     // App1 should have 7 containers now, and no available resource for cluster
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
 
 
     // Submit app2 to queue-c and asks for a 1G container for AM
     // Submit app2 to queue-c and asks for a 1G container for AM
     MockRMAppSubmissionData data =
     MockRMAppSubmissionData data =
@@ -590,7 +596,7 @@ public class TestCapacitySchedulerLazyPreemption
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1);
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1);
 
 
     // NM1 has available resource = 0G
     // NM1 has available resource = 0G
-    Assert.assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
     am2.allocate("*", 3 * GB, 1, new ArrayList<ContainerId>());
     am2.allocate("*", 3 * GB, 1, new ArrayList<ContainerId>());
 
 
@@ -612,17 +618,18 @@ public class TestCapacitySchedulerLazyPreemption
     // Change reqeust from 3G to 2G, now we can preempt one less container. (3->2)
     // Change reqeust from 3G to 2G, now we can preempt one less container. (3->2)
     am2.allocate("*", 2 * GB, 1, new ArrayList<ContainerId>());
     am2.allocate("*", 2 * GB, 1, new ArrayList<ContainerId>());
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(0, editPolicy.getToPreemptContainers().size());
+    assertEquals(0, editPolicy.getToPreemptContainers().size());
     waitKillableContainersSize(pm, "a", RMNodeLabelsManager.NO_LABEL, 2);
     waitKillableContainersSize(pm, "a", RMNodeLabelsManager.NO_LABEL, 2);
 
 
     // Call editSchedule once more to make sure still nothing happens
     // Call editSchedule once more to make sure still nothing happens
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(0, editPolicy.getToPreemptContainers().size());
+    assertEquals(0, editPolicy.getToPreemptContainers().size());
     waitKillableContainersSize(pm, "a", RMNodeLabelsManager.NO_LABEL, 2);
     waitKillableContainersSize(pm, "a", RMNodeLabelsManager.NO_LABEL, 2);
     rm1.stop();
     rm1.stop();
   }
   }
 
 
-  @Test (timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testPreemptionConsidersUserLimit()
   public void testPreemptionConsidersUserLimit()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -685,7 +692,7 @@ public class TestCapacitySchedulerLazyPreemption
     // App1 should have 7 containers now, and no available resource for cluster
     // App1 should have 7 containers now, and no available resource for cluster
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
 
 
     // Submit app2 to queue-c and asks for a 1G container for AM
     // Submit app2 to queue-c and asks for a 1G container for AM
     MockRMAppSubmissionData data =
     MockRMAppSubmissionData data =
@@ -700,9 +707,9 @@ public class TestCapacitySchedulerLazyPreemption
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm2);
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm2);
 
 
     // NM1/NM2 has available resource = 0G
     // NM1/NM2 has available resource = 0G
-    Assert.assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getNode(nm2.getNodeId())
+    assertEquals(0 * GB, cs.getNode(nm2.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
 
 
     // AM asks for a 1 * GB container
     // AM asks for a 1 * GB container
@@ -726,7 +733,7 @@ public class TestCapacitySchedulerLazyPreemption
     PreemptionManager pm = cs.getPreemptionManager();
     PreemptionManager pm = cs.getPreemptionManager();
     Map<ContainerId, RMContainer> killableContainers =
     Map<ContainerId, RMContainer> killableContainers =
         waitKillableContainersSize(pm, "a", RMNodeLabelsManager.NO_LABEL, 0);
         waitKillableContainersSize(pm, "a", RMNodeLabelsManager.NO_LABEL, 0);
-    Assert.assertEquals(0, killableContainers.size());
+    assertEquals(0, killableContainers.size());
 
 
     // Call CS.handle once to see if container preempted
     // Call CS.handle once to see if container preempted
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
@@ -735,8 +742,8 @@ public class TestCapacitySchedulerLazyPreemption
         am2.getApplicationAttemptId());
         am2.getApplicationAttemptId());
 
 
     // App1 has 7 containers, and app2 has 1 containers (nothing preempted)
     // App1 has 7 containers, and app2 has 1 containers (nothing preempted)
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
@@ -755,7 +762,7 @@ public class TestCapacitySchedulerLazyPreemption
       wait++;
       wait++;
     }
     }
 
 
-    Assert.assertEquals(expectedSize, killableContainers.size());
+    assertEquals(expectedSize, killableContainers.size());
     return killableContainers;
     return killableContainers;
   }
   }
 }
 }

+ 28 - 21
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerMaxParallelApps.java

@@ -19,8 +19,8 @@
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.PREFIX;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.PREFIX;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.util.Collections;
 import java.util.Collections;
 import java.util.List;
 import java.util.List;
@@ -46,9 +46,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 public class TestCapacitySchedulerMaxParallelApps {
 public class TestCapacitySchedulerMaxParallelApps {
   private CapacitySchedulerConfiguration conf;
   private CapacitySchedulerConfiguration conf;
@@ -67,7 +68,7 @@ public class TestCapacitySchedulerMaxParallelApps {
   private ParentQueue rootQueue;
   private ParentQueue rootQueue;
   private LeafQueue defaultQueue;
   private LeafQueue defaultQueue;
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     CapacitySchedulerConfiguration config =
     CapacitySchedulerConfiguration config =
         new CapacitySchedulerConfiguration();
         new CapacitySchedulerConfiguration();
@@ -77,21 +78,23 @@ public class TestCapacitySchedulerMaxParallelApps {
     conf = new CapacitySchedulerConfiguration(config);
     conf = new CapacitySchedulerConfiguration(config);
   }
   }
 
 
-  @After
+  @AfterEach
   public void after() {
   public void after() {
     if (rm != null) {
     if (rm != null) {
       rm.stop();
       rm.stop();
     }
     }
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testMaxParallelAppsExceedsQueueSetting() throws Exception {
   public void testMaxParallelAppsExceedsQueueSetting() throws Exception {
     conf.setInt("yarn.scheduler.capacity.root.default.max-parallel-apps", 2);
     conf.setInt("yarn.scheduler.capacity.root.default.max-parallel-apps", 2);
     executeCommonStepsAndChecks();
     executeCommonStepsAndChecks();
     testWhenSettingsExceeded();
     testWhenSettingsExceeded();
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testMaxParallelAppsExceedsDefaultQueueSetting()
   public void testMaxParallelAppsExceedsDefaultQueueSetting()
       throws Exception {
       throws Exception {
     conf.setInt("yarn.scheduler.capacity.max-parallel-apps", 2);
     conf.setInt("yarn.scheduler.capacity.max-parallel-apps", 2);
@@ -99,21 +102,24 @@ public class TestCapacitySchedulerMaxParallelApps {
     testWhenSettingsExceeded();
     testWhenSettingsExceeded();
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testMaxParallelAppsExceedsUserSetting() throws Exception {
   public void testMaxParallelAppsExceedsUserSetting() throws Exception {
     conf.setInt("yarn.scheduler.capacity.user.testuser.max-parallel-apps", 2);
     conf.setInt("yarn.scheduler.capacity.user.testuser.max-parallel-apps", 2);
     executeCommonStepsAndChecks();
     executeCommonStepsAndChecks();
     testWhenSettingsExceeded();
     testWhenSettingsExceeded();
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testMaxParallelAppsExceedsDefaultUserSetting() throws Exception {
   public void testMaxParallelAppsExceedsDefaultUserSetting() throws Exception {
     conf.setInt("yarn.scheduler.capacity.user.max-parallel-apps", 2);
     conf.setInt("yarn.scheduler.capacity.user.max-parallel-apps", 2);
     executeCommonStepsAndChecks();
     executeCommonStepsAndChecks();
     testWhenSettingsExceeded();
     testWhenSettingsExceeded();
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testMaxParallelAppsWhenReloadingConfig() throws Exception {
   public void testMaxParallelAppsWhenReloadingConfig() throws Exception {
     conf.setInt("yarn.scheduler.capacity.root.default.max-parallel-apps", 2);
     conf.setInt("yarn.scheduler.capacity.root.default.max-parallel-apps", 2);
 
 
@@ -132,7 +138,8 @@ public class TestCapacitySchedulerMaxParallelApps {
     verifyRunningAndAcceptedApps(4, 0);
     verifyRunningAndAcceptedApps(4, 0);
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testMaxAppsReachedWithNonRunnableApps() throws Exception {
   public void testMaxAppsReachedWithNonRunnableApps() throws Exception {
     conf.setInt("yarn.scheduler.capacity.root.default.max-parallel-apps", 2);
     conf.setInt("yarn.scheduler.capacity.root.default.max-parallel-apps", 2);
     conf.setInt("yarn.scheduler.capacity.root.default.maximum-applications", 4);
     conf.setInt("yarn.scheduler.capacity.root.default.maximum-applications", 4);
@@ -245,20 +252,20 @@ public class TestCapacitySchedulerMaxParallelApps {
 
 
   private void verifyRunnableAppsInParent(ParentQueue queue,
   private void verifyRunnableAppsInParent(ParentQueue queue,
       int expectedRunnable) {
       int expectedRunnable) {
-    assertEquals("Num of runnable apps", expectedRunnable,
-        queue.getNumRunnableApps());
+    assertEquals(expectedRunnable, queue.getNumRunnableApps(),
+        "Num of runnable apps");
   }
   }
 
 
   private void verifyRunnableAppsInLeaf(LeafQueue queue, int expectedRunnable,
   private void verifyRunnableAppsInLeaf(LeafQueue queue, int expectedRunnable,
       Set<ApplicationAttemptId> nonRunnableIds) {
       Set<ApplicationAttemptId> nonRunnableIds) {
-    assertEquals("Num of runnable apps", expectedRunnable,
-        queue.getNumRunnableApps());
+    assertEquals(expectedRunnable, queue.getNumRunnableApps(),
+        "Num of runnable apps");
 
 
     queue.getCopyOfNonRunnableAppSchedulables()
     queue.getCopyOfNonRunnableAppSchedulables()
         .stream()
         .stream()
         .map(fca -> fca.getApplicationAttemptId())
         .map(fca -> fca.getApplicationAttemptId())
-        .forEach(id -> assertTrue(id + " not found as non-runnable",
-          nonRunnableIds.contains(id)));
+        .forEach(id -> assertTrue(nonRunnableIds.contains(id),
+        id + " not found as non-runnable"));
   }
   }
 
 
   private void verifyRunningAndAcceptedApps(int expectedRunning,
   private void verifyRunningAndAcceptedApps(int expectedRunning,
@@ -282,8 +289,8 @@ public class TestCapacitySchedulerMaxParallelApps {
           report.getYarnApplicationState() == YarnApplicationState.ACCEPTED)
           report.getYarnApplicationState() == YarnApplicationState.ACCEPTED)
         .count();
         .count();
 
 
-    assertEquals("Running apps count", expectedRunning, runningCount);
-    assertEquals("Accepted apps count", expectedAccepted, acceptedCount);
+    assertEquals(expectedRunning, runningCount, "Running apps count");
+    assertEquals(expectedAccepted, acceptedCount, "Accepted apps count");
   }
   }
 
 
   private void unregisterAMandWaitForFinish(RMApp app, MockAM am, MockNM nm)
   private void unregisterAMandWaitForFinish(RMApp app, MockAM am, MockNM nm)

+ 59 - 51
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerMultiNodes.java

@@ -20,6 +20,10 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.waitforNMRegistered;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.waitforNMRegistered;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.HashSet;
@@ -53,9 +57,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeRepo
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.MultiNodeSorter;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.MultiNodeSorter;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.MultiNodeSortingManager;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.MultiNodeSortingManager;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 /**
 /**
  * Test class for Multi Node scheduling related tests.
  * Test class for Multi Node scheduling related tests.
@@ -69,7 +73,7 @@ public class TestCapacitySchedulerMultiNodes {
   private static final String POLICY_CLASS_NAME =
   private static final String POLICY_CLASS_NAME =
       "org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.ResourceUsageMultiNodeLookupPolicy";
       "org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.ResourceUsageMultiNodeLookupPolicy";
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     CapacitySchedulerConfiguration config =
     CapacitySchedulerConfiguration config =
         new CapacitySchedulerConfiguration();
         new CapacitySchedulerConfiguration();
@@ -109,7 +113,7 @@ public class TestCapacitySchedulerMultiNodes {
     sorter.reSortClusterNodes();
     sorter.reSortClusterNodes();
     Set<SchedulerNode> nodes = sorter.getMultiNodeLookupPolicy()
     Set<SchedulerNode> nodes = sorter.getMultiNodeLookupPolicy()
         .getNodesPerPartition("");
         .getNodesPerPartition("");
-    Assert.assertEquals(4, nodes.size());
+    assertEquals(4, nodes.size());
     rm.stop();
     rm.stop();
   }
   }
 
 
@@ -132,7 +136,7 @@ public class TestCapacitySchedulerMultiNodes {
 
 
     Set<SchedulerNode> nodes = sorter.getMultiNodeLookupPolicy()
     Set<SchedulerNode> nodes = sorter.getMultiNodeLookupPolicy()
         .getNodesPerPartition("");
         .getNodesPerPartition("");
-    Assert.assertEquals(4, nodes.size());
+    assertEquals(4, nodes.size());
 
 
     MockRMAppSubmissionData data1 =
     MockRMAppSubmissionData data1 =
         MockRMAppSubmissionData.Builder.createWithMemory(2048, rm)
         MockRMAppSubmissionData.Builder.createWithMemory(2048, rm)
@@ -148,8 +152,8 @@ public class TestCapacitySchedulerMultiNodes {
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
 
 
     // check node report
     // check node report
-    Assert.assertEquals(2 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(8 * GB,
+    assertEquals(2 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(8 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
 
 
     // Ideally thread will invoke this, but thread operates every 1sec.
     // Ideally thread will invoke this, but thread operates every 1sec.
@@ -170,8 +174,8 @@ public class TestCapacitySchedulerMultiNodes {
         rm.getResourceScheduler().getNodeReport(nm2.getNodeId());
         rm.getResourceScheduler().getNodeReport(nm2.getNodeId());
 
 
     // check node report
     // check node report
-    Assert.assertEquals(1 * GB, reportNm2.getUsedResource().getMemorySize());
-    Assert.assertEquals(9 * GB,
+    assertEquals(1 * GB, reportNm2.getUsedResource().getMemorySize());
+    assertEquals(9 * GB,
         reportNm2.getAvailableResource().getMemorySize());
         reportNm2.getAvailableResource().getMemorySize());
 
 
     // Ideally thread will invoke this, but thread operates every 1sec.
     // Ideally thread will invoke this, but thread operates every 1sec.
@@ -192,12 +196,13 @@ public class TestCapacitySchedulerMultiNodes {
     int i = 0;
     int i = 0;
     while (it.hasNext()) {
     while (it.hasNext()) {
       current = it.next();
       current = it.next();
-      Assert.assertEquals(current.getNodeID(), currentNodes.get(i++));
+      assertEquals(current.getNodeID(), currentNodes.get(i++));
     }
     }
     rm.stop();
     rm.stop();
   }
   }
 
 
-  @Test (timeout=30000)
+  @Test
+  @Timeout(value = 30)
   public void testExcessReservationWillBeUnreserved() throws Exception {
   public void testExcessReservationWillBeUnreserved() throws Exception {
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
         new CapacitySchedulerConfiguration(conf);
         new CapacitySchedulerConfiguration(conf);
@@ -253,10 +258,10 @@ public class TestCapacitySchedulerMultiNodes {
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
 
 
     // Check containers of app1 and app2.
     // Check containers of app1 and app2.
-    Assert.assertNotNull(cs.getNode(nm2.getNodeId()).getReservedContainer());
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp1.getReservedContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertNotNull(cs.getNode(nm2.getNodeId()).getReservedContainer());
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp1.getReservedContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
 
 
     // Cancel ask of the reserved container.
     // Cancel ask of the reserved container.
     am1.allocate("*", 6 * GB, 0, new ArrayList<>());
     am1.allocate("*", 6 * GB, 0, new ArrayList<>());
@@ -266,24 +271,25 @@ public class TestCapacitySchedulerMultiNodes {
     // Trigger scheduling to release reserved container
     // Trigger scheduling to release reserved container
     // whose ask has been cancelled.
     // whose ask has been cancelled.
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(0, schedulerApp1.getReservedContainers().size());
-    Assert.assertEquals(2, schedulerApp2.getLiveContainers().size());
-    Assert.assertEquals(7 * GB,
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertEquals(0, schedulerApp1.getReservedContainers().size());
+    assertEquals(2, schedulerApp2.getLiveContainers().size());
+    assertEquals(7 * GB,
         cs.getNode(nm1.getNodeId()).getAllocatedResource().getMemorySize());
         cs.getNode(nm1.getNodeId()).getAllocatedResource().getMemorySize());
-    Assert.assertEquals(12 * GB,
+    assertEquals(12 * GB,
         cs.getRootQueue().getQueueResourceUsage().getUsed().getMemorySize());
         cs.getRootQueue().getQueueResourceUsage().getUsed().getMemorySize());
-    Assert.assertEquals(0,
+    assertEquals(0,
         cs.getRootQueue().getQueueResourceUsage().getReserved()
         cs.getRootQueue().getQueueResourceUsage().getReserved()
             .getMemorySize());
             .getMemorySize());
-    Assert.assertEquals(0,
+    assertEquals(0,
         leafQueue.getQueueResourceUsage().getReserved().getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved().getMemorySize());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout=30000)
+  @Test
+  @Timeout(value = 30)
   public void testAllocateForReservedContainer() throws Exception {
   public void testAllocateForReservedContainer() throws Exception {
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
         new CapacitySchedulerConfiguration(conf);
         new CapacitySchedulerConfiguration(conf);
@@ -337,23 +343,24 @@ public class TestCapacitySchedulerMultiNodes {
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
 
 
     // Check containers of app1 and app2.
     // Check containers of app1 and app2.
-    Assert.assertNotNull(cs.getNode(nm2.getNodeId()).getReservedContainer());
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getReservedContainers().size());
+    assertNotNull(cs.getNode(nm2.getNodeId()).getReservedContainer());
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getReservedContainers().size());
 
 
     // Kill app1 to release resource on nm1.
     // Kill app1 to release resource on nm1.
     rm1.killApp(app1.getApplicationId());
     rm1.killApp(app1.getApplicationId());
 
 
     // Trigger scheduling to allocate for reserved container on nm1.
     // Trigger scheduling to allocate for reserved container on nm1.
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
-    Assert.assertEquals(2, schedulerApp2.getLiveContainers().size());
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertEquals(2, schedulerApp2.getLiveContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout=30000)
+  @Test
+  @Timeout(value = 30)
   public void testAllocateOfReservedContainerFromAnotherNode()
   public void testAllocateOfReservedContainerFromAnotherNode()
       throws Exception {
       throws Exception {
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
@@ -410,7 +417,7 @@ public class TestCapacitySchedulerMultiNodes {
           MockAM am3 = MockRM.launchAndRegisterAM(app3, rm1, nm1);
           MockAM am3 = MockRM.launchAndRegisterAM(app3, rm1, nm1);
           result.set(true);
           result.set(true);
         } catch (Exception e) {
         } catch (Exception e) {
-          Assert.fail("Failed to allocate the reserved container");
+          fail("Failed to allocate the reserved container");
         }
         }
       }
       }
     };
     };
@@ -420,8 +427,8 @@ public class TestCapacitySchedulerMultiNodes {
     // Validate if app3 has got RESERVED container
     // Validate if app3 has got RESERVED container
     FiCaSchedulerApp schedulerApp =
     FiCaSchedulerApp schedulerApp =
         cs.getApplicationAttempt(app3.getCurrentAppAttempt().getAppAttemptId());
         cs.getApplicationAttempt(app3.getCurrentAppAttempt().getAppAttemptId());
-    Assert.assertEquals("App3 failed to get reserved container", 1,
-        schedulerApp.getReservedContainers().size());
+    assertEquals(1, schedulerApp.getReservedContainers().size(),
+        "App3 failed to get reserved container");
 
 
     // Free the Space on other node where Reservation has not happened
     // Free the Space on other node where Reservation has not happened
     if (cs.getNode(rmNode1.getNodeID()).getReservedContainer() != null) {
     if (cs.getNode(rmNode1.getNodeID()).getReservedContainer() != null) {
@@ -441,10 +448,10 @@ public class TestCapacitySchedulerMultiNodes {
     // Validate release of reserved containers
     // Validate release of reserved containers
     schedulerApp =
     schedulerApp =
         cs.getApplicationAttempt(app3.getCurrentAppAttempt().getAppAttemptId());
         cs.getApplicationAttempt(app3.getCurrentAppAttempt().getAppAttemptId());
-    Assert.assertEquals("App3 failed to release Reserved container", 0,
-        schedulerApp.getReservedContainers().size());
-    Assert.assertNull(cs.getNode(rmNode1.getNodeID()).getReservedContainer());
-    Assert.assertNull(cs.getNode(rmNode2.getNodeID()).getReservedContainer());
+    assertEquals(0, schedulerApp.getReservedContainers().size(),
+        "App3 failed to release Reserved container");
+    assertNull(cs.getNode(rmNode1.getNodeID()).getReservedContainer());
+    assertNull(cs.getNode(rmNode2.getNodeID()).getReservedContainer());
 
 
     rm1.close();
     rm1.close();
   }
   }
@@ -471,19 +478,20 @@ public class TestCapacitySchedulerMultiNodes {
 
 
     Iterator<SchedulerNode> nodeIterator = mns.getMultiNodeSortIterator(
     Iterator<SchedulerNode> nodeIterator = mns.getMultiNodeSortIterator(
         nodes, partition, POLICY_CLASS_NAME);
         nodes, partition, POLICY_CLASS_NAME);
-    Assert.assertEquals(4, Iterators.size(nodeIterator));
+    assertEquals(4, Iterators.size(nodeIterator));
 
 
     // Validate the count after missing 3 node heartbeats
     // Validate the count after missing 3 node heartbeats
     Thread.sleep(YarnConfiguration.DEFAULT_RM_NM_HEARTBEAT_INTERVAL_MS * 3);
     Thread.sleep(YarnConfiguration.DEFAULT_RM_NM_HEARTBEAT_INTERVAL_MS * 3);
 
 
     nodeIterator = mns.getMultiNodeSortIterator(
     nodeIterator = mns.getMultiNodeSortIterator(
         nodes, partition, POLICY_CLASS_NAME);
         nodes, partition, POLICY_CLASS_NAME);
-    Assert.assertEquals(0, Iterators.size(nodeIterator));
+    assertEquals(0, Iterators.size(nodeIterator));
 
 
     rm.stop();
     rm.stop();
   }
   }
 
 
-  @Test(timeout=30000)
+  @Test
+  @Timeout(value = 30)
   public void testSkipAllocationOnNodeReservedByAnotherApp() throws Exception {
   public void testSkipAllocationOnNodeReservedByAnotherApp() throws Exception {
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
         new CapacitySchedulerConfiguration(conf);
         new CapacitySchedulerConfiguration(conf);
@@ -533,7 +541,7 @@ public class TestCapacitySchedulerMultiNodes {
     // Check containers of app1 and app2.
     // Check containers of app1 and app2.
     Set<RMNode> reservedContainers = checkReservedContainers(cs,
     Set<RMNode> reservedContainers = checkReservedContainers(cs,
         rm1.getRMContext().getRMNodes(), 1);
         rm1.getRMContext().getRMNodes(), 1);
-    Assert.assertEquals(1, reservedContainers.size());
+    assertEquals(1, reservedContainers.size());
     RMNode nodeWithReservedContainer = reservedContainers.iterator().next();
     RMNode nodeWithReservedContainer = reservedContainers.iterator().next();
     LOG.debug("Reserved container on: {}", nodeWithReservedContainer);
     LOG.debug("Reserved container on: {}", nodeWithReservedContainer);
 
 
@@ -541,12 +549,12 @@ public class TestCapacitySchedulerMultiNodes {
     if (nodeWithReservedContainer.getNodeID().getHost().startsWith("127.0.0.2")) {
     if (nodeWithReservedContainer.getNodeID().getHost().startsWith("127.0.0.2")) {
       moveReservation(cs, rm1, nm1, nm2, am1);
       moveReservation(cs, rm1, nm1, nm2, am1);
     }
     }
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
-    Assert.assertNull(cs.getNode(nm2.getNodeId()).getReservedContainer());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertNull(cs.getNode(nm2.getNodeId()).getReservedContainer());
 
 
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp1.getReservedContainers().size());
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertEquals(1, schedulerApp1.getReservedContainers().size());
 
 
     //Make sure to have available headroom on the child queue,
     //Make sure to have available headroom on the child queue,
     // see: RegularContainerAllocator#checkHeadroom,
     // see: RegularContainerAllocator#checkHeadroom,
@@ -558,8 +566,8 @@ public class TestCapacitySchedulerMultiNodes {
     // nm1 has a reservation for another app
     // nm1 has a reservation for another app
     am2.allocate("*", 4 * GB, 1, new ArrayList<>());
     am2.allocate("*", 4 * GB, 1, new ArrayList<>());
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
-    Assert.assertNotNull(cs.getNode(nm2.getNodeId()).getReservedContainer());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertNotNull(cs.getNode(nm2.getNodeId()).getReservedContainer());
 
 
     rm1.close();
     rm1.close();
   }
   }
@@ -586,7 +594,7 @@ public class TestCapacitySchedulerMultiNodes {
       }
       }
     }
     }
 
 
-    Assert.assertEquals(expectedNumberOfContainers, result.size());
+    assertEquals(expectedNumberOfContainers, result.size());
     return result;
     return result;
   }
   }
 }
 }

+ 20 - 17
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerMultiNodesWithPreemption.java

@@ -19,8 +19,9 @@
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
@@ -44,9 +45,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.MultiNo
 import org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity.ProportionalCapacityPreemptionPolicy;
 import org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity.ProportionalCapacityPreemptionPolicy;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -62,7 +63,7 @@ public class TestCapacitySchedulerMultiNodesWithPreemption {
       "org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement."
       "org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement."
       + "ResourceUsageMultiNodeLookupPolicy";
       + "ResourceUsageMultiNodeLookupPolicy";
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     CapacitySchedulerConfiguration config =
     CapacitySchedulerConfiguration config =
         new CapacitySchedulerConfiguration();
         new CapacitySchedulerConfiguration();
@@ -114,7 +115,9 @@ public class TestCapacitySchedulerMultiNodesWithPreemption {
     conf.setLong(YarnConfiguration.RM_NM_HEARTBEAT_INTERVAL_MS, 60000);
     conf.setLong(YarnConfiguration.RM_NM_HEARTBEAT_INTERVAL_MS, 60000);
   }
   }
 
 
-  @Test(timeout=60000)
+  @Test
+  @Timeout(value = 60)
+  @SuppressWarnings("checkstyle:methodlength")
   public void testAllocateReservationFromOtherNode() throws Exception {
   public void testAllocateReservationFromOtherNode() throws Exception {
     MockRM rm = new MockRM(conf);
     MockRM rm = new MockRM(conf);
     rm.start();
     rm.start();
@@ -174,7 +177,7 @@ public class TestCapacitySchedulerMultiNodesWithPreemption {
           MockAM am2 = MockRM.launchAM(app2, rm, nm1);
           MockAM am2 = MockRM.launchAM(app2, rm, nm1);
           result.set(true);
           result.set(true);
         } catch (Exception e) {
         } catch (Exception e) {
-          Assert.fail("Failed to launch app-2");
+          fail("Failed to launch app-2");
         }
         }
       }
       }
     };
     };
@@ -226,13 +229,13 @@ public class TestCapacitySchedulerMultiNodesWithPreemption {
         .getAppAttemptId();
         .getAppAttemptId();
     FiCaSchedulerApp schedulerApp = cs.getApplicationAttempt(app2AttemptId);
     FiCaSchedulerApp schedulerApp = cs.getApplicationAttempt(app2AttemptId);
 
 
-    assertEquals("App2 failed to get reserved container", 1,
-        schedulerApp.getReservedContainers().size());
+    assertEquals(1, schedulerApp.getReservedContainers().size(),
+        "App2 failed to get reserved container");
     LOG.info("Reserved node is: " +
     LOG.info("Reserved node is: " +
         schedulerApp.getReservedContainers().get(0).getReservedNode());
         schedulerApp.getReservedContainers().get(0).getReservedNode());
-    assertNotEquals("Failed to reserve as per the Multi Node Itearor",
-        schedulerApp.getReservedContainers().get(0).getReservedNode(),
-        preemptedNode.get().getNodeId());
+    assertNotEquals(schedulerApp.getReservedContainers().get(0).getReservedNode(),
+        preemptedNode.get().getNodeId(),
+        "Failed to reserve as per the Multi Node Itearor");
 
 
 
 
     // Step 6: Okay, now preempted node is Node1 and reserved node is Node3
     // Step 6: Okay, now preempted node is Node1 and reserved node is Node3
@@ -262,10 +265,10 @@ public class TestCapacitySchedulerMultiNodesWithPreemption {
     // Step 8: Validate if app-2 has got 1 live container and
     // Step 8: Validate if app-2 has got 1 live container and
     // released the reserved container
     // released the reserved container
     schedulerApp = cs.getApplicationAttempt(app2AttemptId);
     schedulerApp = cs.getApplicationAttempt(app2AttemptId);
-    assertEquals("App2 failed to get Allocated", 1,
-        schedulerApp.getLiveContainers().size());
-    assertEquals("App2 failed to Unreserve", 0,
-        schedulerApp.getReservedContainers().size());
+    assertEquals(1, schedulerApp.getLiveContainers().size(),
+        "App2 failed to get Allocated");
+    assertEquals(0, schedulerApp.getReservedContainers().size(),
+        "App2 failed to Unreserve");
 
 
     rm.stop();
     rm.stop();
   }
   }

文件差异内容过多而无法显示
+ 236 - 232
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNewQueueAutoCreation.java


+ 51 - 50
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNewQueueAutoCreationWithCapacityVectors.java

@@ -18,6 +18,8 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
 import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
@@ -25,10 +27,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NullRMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NullRMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
@@ -55,7 +56,7 @@ public class TestCapacitySchedulerNewQueueAutoCreationWithCapacityVectors
     /
     /
   a1
   a1
    */
    */
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     csConf = new CapacitySchedulerConfiguration();
     csConf = new CapacitySchedulerConfiguration();
     csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     csConf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -63,7 +64,7 @@ public class TestCapacitySchedulerNewQueueAutoCreationWithCapacityVectors
     csConf.setLegacyQueueModeEnabled(false);
     csConf.setLegacyQueueModeEnabled(false);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (mockRM != null) {
     if (mockRM != null) {
       mockRM.stop();
       mockRM.stop();
@@ -186,36 +187,36 @@ public class TestCapacitySchedulerNewQueueAutoCreationWithCapacityVectors
 
 
   private void validateBasicConfiguration() throws Exception {
   private void validateBasicConfiguration() throws Exception {
     CSQueue a = cs.getQueue(A_PATH);
     CSQueue a = cs.getQueue(A_PATH);
-    Assert.assertEquals(8 / 32f, a.getAbsoluteCapacity(), EPSILON);
-    Assert.assertEquals(-1f, a.getQueueCapacities().getWeight(), EPSILON);
-    Assert.assertEquals(8000,
+    assertEquals(8 / 32f, a.getAbsoluteCapacity(), EPSILON);
+    assertEquals(-1f, a.getQueueCapacities().getWeight(), EPSILON);
+    assertEquals(8000,
             a.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             a.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(8,
+    assertEquals(8,
             a.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             a.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
 
 
     createQueue("root.b-auto");
     createQueue("root.b-auto");
 
 
     CSQueue bAuto = cs.getQueue("root.b-auto");
     CSQueue bAuto = cs.getQueue("root.b-auto");
-    Assert.assertEquals(2 / 32f, bAuto.getAbsoluteCapacity(), EPSILON);
-    Assert.assertEquals(-1f, bAuto.getQueueCapacities().getWeight(), EPSILON);
-    Assert.assertEquals(2000,
+    assertEquals(2 / 32f, bAuto.getAbsoluteCapacity(), EPSILON);
+    assertEquals(-1f, bAuto.getQueueCapacities().getWeight(), EPSILON);
+    assertEquals(2000,
             bAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             bAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(2,
+    assertEquals(2,
             bAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             bAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
-    Assert.assertEquals(((LeafQueue) bAuto).getUserLimitFactor(), -1, EPSILON);
-    Assert.assertEquals(((LeafQueue) bAuto).getMaxAMResourcePerQueuePercent(), 1, EPSILON);
+    assertEquals(((LeafQueue) bAuto).getUserLimitFactor(), -1, EPSILON);
+    assertEquals(((LeafQueue) bAuto).getMaxAMResourcePerQueuePercent(), 1, EPSILON);
 
 
     createQueue("root.a.a1-auto");
     createQueue("root.a.a1-auto");
 
 
     CSQueue a1Auto = cs.getQueue("root.a.a1-auto");
     CSQueue a1Auto = cs.getQueue("root.a.a1-auto");
-    Assert.assertEquals(2 / 32f, a1Auto.getAbsoluteCapacity(), EPSILON);
-    Assert.assertEquals(-1f, a1Auto.getQueueCapacities().getWeight(), EPSILON);
-    Assert.assertEquals(2000,
+    assertEquals(2 / 32f, a1Auto.getAbsoluteCapacity(), EPSILON);
+    assertEquals(-1f, a1Auto.getQueueCapacities().getWeight(), EPSILON);
+    assertEquals(2000,
             a1Auto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             a1Auto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(4,
+    assertEquals(4,
             a1Auto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             a1Auto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
-    Assert.assertEquals(((LeafQueue) a1Auto).getUserLimitFactor(), -1, EPSILON);
-    Assert.assertEquals(((LeafQueue) a1Auto).getMaxAMResourcePerQueuePercent(), 1, EPSILON);
+    assertEquals(((LeafQueue) a1Auto).getUserLimitFactor(), -1, EPSILON);
+    assertEquals(((LeafQueue) a1Auto).getMaxAMResourcePerQueuePercent(), 1, EPSILON);
   }
   }
 
 
   /*
   /*
@@ -241,14 +242,14 @@ public class TestCapacitySchedulerNewQueueAutoCreationWithCapacityVectors
     // b takes 2000 MB from the cluster, a and d take up 10 + 10 = 20% (6000 MB, 6 vcore),
     // b takes 2000 MB from the cluster, a and d take up 10 + 10 = 20% (6000 MB, 6 vcore),
     // so c-auto should get the rest (24000 MB, 24 vcore) because it's the only one
     // so c-auto should get the rest (24000 MB, 24 vcore) because it's the only one
     // with configured weights
     // with configured weights
-    Assert.assertEquals(24 / 32f, cAuto.getAbsoluteCapacity(), EPSILON);
-    Assert.assertEquals(-1f, cAuto.getQueueCapacities().getWeight(), EPSILON);
-    Assert.assertEquals(24000,
+    assertEquals(24 / 32f, cAuto.getAbsoluteCapacity(), EPSILON);
+    assertEquals(-1f, cAuto.getQueueCapacities().getWeight(), EPSILON);
+    assertEquals(24000,
             cAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             cAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(24,
+    assertEquals(24,
             cAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             cAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
-    Assert.assertEquals(((LeafQueue) cAuto).getUserLimitFactor(), -1, EPSILON);
-    Assert.assertEquals(((LeafQueue) cAuto).getMaxAMResourcePerQueuePercent(), 1, EPSILON);
+    assertEquals(((LeafQueue) cAuto).getUserLimitFactor(), -1, EPSILON);
+    assertEquals(((LeafQueue) cAuto).getMaxAMResourcePerQueuePercent(), 1, EPSILON);
 
 
     // Now add another queue-d, in the same hierarchy
     // Now add another queue-d, in the same hierarchy
     createQueue("root.d.d1-auto");
     createQueue("root.d.d1-auto");
@@ -257,57 +258,57 @@ public class TestCapacitySchedulerNewQueueAutoCreationWithCapacityVectors
     // become 1/4
     // become 1/4
     CSQueue dAuto = cs.getQueue("root.d.d1-auto");
     CSQueue dAuto = cs.getQueue("root.d.d1-auto");
     // d1-auto should get 1000 MB, 1 vcore
     // d1-auto should get 1000 MB, 1 vcore
-    Assert.assertEquals(1 / 32f, dAuto.getAbsoluteCapacity(), EPSILON);
-    Assert.assertEquals(-1f, dAuto.getQueueCapacities().getWeight(), EPSILON);
-    Assert.assertEquals(1000,
+    assertEquals(1 / 32f, dAuto.getAbsoluteCapacity(), EPSILON);
+    assertEquals(-1f, dAuto.getQueueCapacities().getWeight(), EPSILON);
+    assertEquals(1000,
             dAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             dAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(1,
+    assertEquals(1,
             dAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             dAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
 
 
     createQueue("root.a.a2-auto");
     createQueue("root.a.a2-auto");
 
 
     CSQueue a2Auto = cs.getQueue("root.a.a2-auto");
     CSQueue a2Auto = cs.getQueue("root.a.a2-auto");
-    Assert.assertEquals(2 / 32f, a2Auto.getAbsoluteCapacity(), EPSILON);
-    Assert.assertEquals(-1f, a2Auto.getQueueCapacities().getWeight(), EPSILON);
-    Assert.assertEquals(2000,
+    assertEquals(2 / 32f, a2Auto.getAbsoluteCapacity(), EPSILON);
+    assertEquals(-1f, a2Auto.getQueueCapacities().getWeight(), EPSILON);
+    assertEquals(2000,
             a2Auto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             a2Auto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(2,
+    assertEquals(2,
             a2Auto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             a2Auto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
 
 
     // Absolute requests take precedence over percentage and weight,
     // Absolute requests take precedence over percentage and weight,
     // hence a1 should have 1000 MB, 0 vcore
     // hence a1 should have 1000 MB, 0 vcore
     CSQueue a1 = cs.getQueue("root.a.a1");
     CSQueue a1 = cs.getQueue("root.a.a1");
-    Assert.assertEquals(1000,
+    assertEquals(1000,
             a1.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             a1.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(0,
+    assertEquals(0,
             a1.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             a1.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
 
 
     createQueue("root.e-auto.e1-auto");
     createQueue("root.e-auto.e1-auto");
 
 
     // e-auto has weights configured, so it will share the remaining resources with c-auto
     // e-auto has weights configured, so it will share the remaining resources with c-auto
     CSQueue eAuto = cs.getQueue("root.e-auto");
     CSQueue eAuto = cs.getQueue("root.e-auto");
-    Assert.assertEquals(12 / 32f, eAuto.getAbsoluteCapacity(), EPSILON);
-    Assert.assertEquals(-1f, eAuto.getQueueCapacities().getWeight(), EPSILON);
-    Assert.assertEquals(12000,
+    assertEquals(12 / 32f, eAuto.getAbsoluteCapacity(), EPSILON);
+    assertEquals(-1f, eAuto.getQueueCapacities().getWeight(), EPSILON);
+    assertEquals(12000,
             eAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             eAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(10,
+    assertEquals(10,
             eAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             eAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
 
 
     // Now we check queue c-auto again, it should have shared its resources with e-auto
     // Now we check queue c-auto again, it should have shared its resources with e-auto
-    Assert.assertEquals(12 / 32f, cAuto.getAbsoluteCapacity(), EPSILON);
-    Assert.assertEquals(-1f, cAuto.getQueueCapacities().getWeight(), EPSILON);
-    Assert.assertEquals(12000,
+    assertEquals(12 / 32f, cAuto.getAbsoluteCapacity(), EPSILON);
+    assertEquals(-1f, cAuto.getQueueCapacities().getWeight(), EPSILON);
+    assertEquals(12000,
             cAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             cAuto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(16,
+    assertEquals(16,
             cAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             cAuto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
 
 
     // Under e, there's only one queue, so e1 should have what it's asking for
     // Under e, there's only one queue, so e1 should have what it's asking for
     CSQueue e1Auto = cs.getQueue("root.e-auto.e1-auto");
     CSQueue e1Auto = cs.getQueue("root.e-auto.e1-auto");
-    Assert.assertEquals(2 / 32f, e1Auto.getAbsoluteCapacity(), EPSILON);
-    Assert.assertEquals(-1f, e1Auto.getQueueCapacities().getWeight(), EPSILON);
-    Assert.assertEquals(2000,
+    assertEquals(2 / 32f, e1Auto.getAbsoluteCapacity(), EPSILON);
+    assertEquals(-1f, e1Auto.getQueueCapacities().getWeight(), EPSILON);
+    assertEquals(2000,
             e1Auto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
             e1Auto.getQueueResourceQuotas().getEffectiveMinResource().getMemorySize());
-    Assert.assertEquals(2,
+    assertEquals(2,
             e1Auto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
             e1Auto.getQueueResourceQuotas().getEffectiveMinResource().getVirtualCores());
   }
   }
 
 

+ 69 - 62
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNodeLabelUpdate.java

@@ -18,7 +18,9 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.HashSet;
@@ -51,9 +53,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeLabelsUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeLabelsUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo;
 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
@@ -66,7 +68,7 @@ public class TestCapacitySchedulerNodeLabelUpdate {
   
   
   RMNodeLabelsManager mgr;
   RMNodeLabelsManager mgr;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -173,7 +175,7 @@ public class TestCapacitySchedulerNodeLabelUpdate {
       String label) {
       String label) {
     CapacityScheduler scheduler = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler scheduler = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = scheduler.getQueue(queueName);
     CSQueue queue = scheduler.getQueue(queueName);
-    Assert.assertEquals(memory, queue.getQueueResourceUsage().getUsed(label)
+    assertEquals(memory, queue.getQueueResourceUsage().getUsed(label)
         .getMemorySize());
         .getMemorySize());
   }
   }
 
 
@@ -182,7 +184,7 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     float epsillon = 0.0001f;
     float epsillon = 0.0001f;
     CapacityScheduler scheduler = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler scheduler = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = scheduler.getQueue(queueName);
     CSQueue queue = scheduler.getQueue(queueName);
-    Assert.assertEquals((float)capacity/total,
+    assertEquals((float)capacity/total,
         queue.getQueueCapacities().getUsedCapacity(label), epsillon);
         queue.getQueueCapacities().getUsedCapacity(label), epsillon);
   }
   }
 
 
@@ -190,7 +192,7 @@ public class TestCapacitySchedulerNodeLabelUpdate {
       String label) {
       String label) {
     CapacityScheduler scheduler = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler scheduler = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = scheduler.getQueue(queueName);
     CSQueue queue = scheduler.getQueue(queueName);
-    Assert.assertEquals(memory, queue.getQueueResourceUsage().getAMUsed(label)
+    assertEquals(memory, queue.getQueueResourceUsage().getAMUsed(label)
         .getMemorySize());
         .getMemorySize());
   }
   }
 
 
@@ -199,11 +201,12 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     CapacityScheduler scheduler = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler scheduler = (CapacityScheduler) rm.getResourceScheduler();
     LeafQueue queue = (LeafQueue) scheduler.getQueue(queueName);
     LeafQueue queue = (LeafQueue) scheduler.getQueue(queueName);
     UsersManager.User user = queue.getUser(userName);
     UsersManager.User user = queue.getUser(userName);
-    Assert.assertEquals(memory,
+    assertEquals(memory,
         user.getResourceUsage().getUsed(partition).getMemorySize());
         user.getResourceUsage().getUsed(partition).getMemorySize());
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testRequestContainerAfterNodePartitionUpdated()
   public void testRequestContainerAfterNodePartitionUpdated()
       throws Exception {
       throws Exception {
     // set node -> label
     // set node -> label
@@ -245,9 +248,9 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     ApplicationResourceUsageReport appResourceUsageReport =
     ApplicationResourceUsageReport appResourceUsageReport =
         rm.getResourceScheduler().getAppResourceUsageReport(
         rm.getResourceScheduler().getAppResourceUsageReport(
             am1.getApplicationAttemptId());
             am1.getApplicationAttemptId());
-    Assert.assertEquals(1024, appResourceUsageReport.getUsedResources()
+    assertEquals(1024, appResourceUsageReport.getUsedResources()
         .getMemorySize());
         .getMemorySize());
-    Assert.assertEquals(1, appResourceUsageReport.getUsedResources()
+    assertEquals(1, appResourceUsageReport.getUsedResources()
         .getVirtualCores());
         .getVirtualCores());
     // request a container.
     // request a container.
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>(), "x");
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>(), "x");
@@ -256,9 +259,9 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     appResourceUsageReport =
     appResourceUsageReport =
         rm.getResourceScheduler().getAppResourceUsageReport(
         rm.getResourceScheduler().getAppResourceUsageReport(
             am1.getApplicationAttemptId());
             am1.getApplicationAttemptId());
-    Assert.assertEquals(2048, appResourceUsageReport.getUsedResources()
+    assertEquals(2048, appResourceUsageReport.getUsedResources()
         .getMemorySize());
         .getMemorySize());
-    Assert.assertEquals(2, appResourceUsageReport.getUsedResources()
+    assertEquals(2, appResourceUsageReport.getUsedResources()
         .getVirtualCores());
         .getVirtualCores());
     LeafQueue queue =
     LeafQueue queue =
         (LeafQueue) ((CapacityScheduler) rm.getResourceScheduler())
         (LeafQueue) ((CapacityScheduler) rm.getResourceScheduler())
@@ -267,8 +270,8 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     for (UserInfo userInfo : users) {
     for (UserInfo userInfo : users) {
       if (userInfo.getUsername().equals("user")) {
       if (userInfo.getUsername().equals("user")) {
         ResourceInfo resourcesUsed = userInfo.getResourcesUsed();
         ResourceInfo resourcesUsed = userInfo.getResourcesUsed();
-        Assert.assertEquals(2048, resourcesUsed.getMemorySize());
-        Assert.assertEquals(2, resourcesUsed.getvCores());
+        assertEquals(2048, resourcesUsed.getMemorySize());
+        assertEquals(2, resourcesUsed.getvCores());
       }
       }
     }
     }
     rm.stop();
     rm.stop();
@@ -320,7 +323,7 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>(), "x");
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>(), "x");
     containerId1 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 1);
     containerId1 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 1);
     containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
     containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm.waitForState(nm1, containerId2,
+    assertTrue(rm.waitForState(nm1, containerId2,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     
     
     // check used resource:
     // check used resource:
@@ -349,9 +352,9 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     checkUsedResource(rm, "root", 1024);
     checkUsedResource(rm, "root", 1024);
     checkUserUsedResource(rm, "a", "user", "x", 0);
     checkUserUsedResource(rm, "a", "user", "x", 0);
     checkUserUsedResource(rm, "a", "user", "z", 1024);
     checkUserUsedResource(rm, "a", "user", "z", 1024);
-    Assert.assertEquals(0,
+    assertEquals(0,
         app.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
         app.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(1024,
+    assertEquals(1024,
         app.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
         app.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
     
     
     // change h1's label to y
     // change h1's label to y
@@ -374,11 +377,11 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     checkUserUsedResource(rm, "a", "user", "x", 0);
     checkUserUsedResource(rm, "a", "user", "x", 0);
     checkUserUsedResource(rm, "a", "user", "y", 1024);
     checkUserUsedResource(rm, "a", "user", "y", 1024);
     checkUserUsedResource(rm, "a", "user", "z", 0);
     checkUserUsedResource(rm, "a", "user", "z", 0);
-    Assert.assertEquals(0,
+    assertEquals(0,
         app.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
         app.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(1024,
+    assertEquals(1024,
         app.getAppAttemptResourceUsage().getUsed("y").getMemorySize());
         app.getAppAttemptResourceUsage().getUsed("y").getMemorySize());
-    Assert.assertEquals(0,
+    assertEquals(0,
         app.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
         app.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
     
     
     // change h1's label to no label
     // change h1's label to no label
@@ -404,13 +407,13 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     checkUserUsedResource(rm, "a", "user", "y", 0);
     checkUserUsedResource(rm, "a", "user", "y", 0);
     checkUserUsedResource(rm, "a", "user", "z", 0);
     checkUserUsedResource(rm, "a", "user", "z", 0);
     checkUserUsedResource(rm, "a", "user", "", 2048);
     checkUserUsedResource(rm, "a", "user", "", 2048);
-    Assert.assertEquals(0,
+    assertEquals(0,
         app.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
         app.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(0,
+    assertEquals(0,
         app.getAppAttemptResourceUsage().getUsed("y").getMemorySize());
         app.getAppAttemptResourceUsage().getUsed("y").getMemorySize());
-    Assert.assertEquals(0,
+    assertEquals(0,
         app.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
         app.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
-    Assert.assertEquals(2048,
+    assertEquals(2048,
         app.getAppAttemptResourceUsage().getUsed("").getMemorySize());
         app.getAppAttemptResourceUsage().getUsed("").getMemorySize());
 
 
     // Finish the two containers, we should see used resource becomes 0
     // Finish the two containers, we should see used resource becomes 0
@@ -443,7 +446,8 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     rm.close();
     rm.close();
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testMoveApplicationWithLabel() throws Exception {
   public void testMoveApplicationWithLabel() throws Exception {
     // set node -> label
     // set node -> label
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(
@@ -500,9 +504,9 @@ public class TestCapacitySchedulerNodeLabelUpdate {
       fail("Should throw exception since target queue doesnt have "
       fail("Should throw exception since target queue doesnt have "
           + "required labels");
           + "required labels");
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.assertTrue("Yarn Exception should be thrown",
-          e instanceof YarnException);
-      Assert.assertEquals("Specified queue=root.a.a2 can't satisfy "
+      assertTrue(e instanceof YarnException,
+          "Yarn Exception should be thrown");
+      assertEquals("Specified queue=root.a.a2 can't satisfy "
           + "following apps label expressions =[x] accessible "
           + "following apps label expressions =[x] accessible "
           + "node labels =[y]", e.getMessage());
           + "node labels =[y]", e.getMessage());
     }
     }
@@ -518,7 +522,8 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     rm.stop();
     rm.stop();
   }
   }
 
 
-  @Test (timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testComplexResourceUsageWhenNodeUpdatesPartition()
   public void testComplexResourceUsageWhenNodeUpdatesPartition()
       throws Exception {
       throws Exception {
     /*
     /*
@@ -575,12 +580,12 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>(), "x");
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>(), "x");
     ContainerId containerId =
     ContainerId containerId =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm.waitForState(nm1, containerId,
+    assertTrue(rm.waitForState(nm1, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>());
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>());
     containerId =
     containerId =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 3);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 3);
-    Assert.assertTrue(rm.waitForState(nm2, containerId,
+    assertTrue(rm.waitForState(nm2, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     
     
     // app2
     // app2
@@ -599,7 +604,7 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     am2.allocate("*", GB, 2, new ArrayList<ContainerId>(), "x");
     am2.allocate("*", GB, 2, new ArrayList<ContainerId>(), "x");
     containerId =
     containerId =
         ContainerId.newContainerId(am2.getApplicationAttemptId(), 3);
         ContainerId.newContainerId(am2.getApplicationAttemptId(), 3);
-    Assert.assertTrue(rm.waitForState(nm1, containerId,
+    assertTrue(rm.waitForState(nm1, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     
     
     // check used resource:
     // check used resource:
@@ -628,17 +633,17 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     checkUserUsedResource(rm, "a", "u2", "x", 0 * GB);
     checkUserUsedResource(rm, "a", "u2", "x", 0 * GB);
     checkUserUsedResource(rm, "a", "u2", "z", 2 * GB);
     checkUserUsedResource(rm, "a", "u2", "z", 2 * GB);
     checkUserUsedResource(rm, "a", "u2", "", 1 * GB);
     checkUserUsedResource(rm, "a", "u2", "", 1 * GB);
-    Assert.assertEquals(0,
+    assertEquals(0,
         application1.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
         application1.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(1 * GB,
+    assertEquals(1 * GB,
         application1.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
         application1.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
-    Assert.assertEquals(2 * GB,
+    assertEquals(2 * GB,
         application1.getAppAttemptResourceUsage().getUsed("").getMemorySize());
         application1.getAppAttemptResourceUsage().getUsed("").getMemorySize());
-    Assert.assertEquals(0,
+    assertEquals(0,
         application2.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
         application2.getAppAttemptResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(2 * GB,
+    assertEquals(2 * GB,
         application2.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
         application2.getAppAttemptResourceUsage().getUsed("z").getMemorySize());
-    Assert.assertEquals(1 * GB,
+    assertEquals(1 * GB,
         application2.getAppAttemptResourceUsage().getUsed("").getMemorySize());
         application2.getAppAttemptResourceUsage().getUsed("").getMemorySize());
 
 
     rm.close();
     rm.close();
@@ -687,7 +692,8 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     rm.stop();
     rm.stop();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testAMResourceUsageWhenNodeUpdatesPartition()
   public void testAMResourceUsageWhenNodeUpdatesPartition()
       throws Exception {
       throws Exception {
     // set node -> label
     // set node -> label
@@ -732,7 +738,7 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>(), "x");
     am1.allocate("*", GB, 1, new ArrayList<ContainerId>(), "x");
     ContainerId.newContainerId(am1.getApplicationAttemptId(), 1);
     ContainerId.newContainerId(am1.getApplicationAttemptId(), 1);
     containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
     containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm.waitForState(nm1, containerId2,
+    assertTrue(rm.waitForState(nm1, containerId2,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
 
 
     // check used resource:
     // check used resource:
@@ -755,9 +761,9 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     checkAMUsedResource(rm, "a", 1024, "z");
     checkAMUsedResource(rm, "a", 1024, "z");
     checkUserUsedResource(rm, "a", "user", "x", 0);
     checkUserUsedResource(rm, "a", "user", "x", 0);
     checkUserUsedResource(rm, "a", "user", "z", 2048);
     checkUserUsedResource(rm, "a", "user", "z", 2048);
-    Assert.assertEquals(0,
+    assertEquals(0,
         app.getAppAttemptResourceUsage().getAMUsed("x").getMemorySize());
         app.getAppAttemptResourceUsage().getAMUsed("x").getMemorySize());
-    Assert.assertEquals(1024,
+    assertEquals(1024,
         app.getAppAttemptResourceUsage().getAMUsed("z").getMemorySize());
         app.getAppAttemptResourceUsage().getAMUsed("z").getMemorySize());
 
 
     // change h1's label to no label
     // change h1's label to no label
@@ -774,17 +780,18 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     checkUserUsedResource(rm, "a", "user", "x", 0);
     checkUserUsedResource(rm, "a", "user", "x", 0);
     checkUserUsedResource(rm, "a", "user", "z", 0);
     checkUserUsedResource(rm, "a", "user", "z", 0);
     checkUserUsedResource(rm, "a", "user", "", 2048);
     checkUserUsedResource(rm, "a", "user", "", 2048);
-    Assert.assertEquals(0,
+    assertEquals(0,
         app.getAppAttemptResourceUsage().getAMUsed("x").getMemorySize());
         app.getAppAttemptResourceUsage().getAMUsed("x").getMemorySize());
-    Assert.assertEquals(0,
+    assertEquals(0,
         app.getAppAttemptResourceUsage().getAMUsed("z").getMemorySize());
         app.getAppAttemptResourceUsage().getAMUsed("z").getMemorySize());
-    Assert.assertEquals(1024,
+    assertEquals(1024,
         app.getAppAttemptResourceUsage().getAMUsed("").getMemorySize());
         app.getAppAttemptResourceUsage().getAMUsed("").getMemorySize());
 
 
     rm.close();
     rm.close();
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testBlacklistAMDisableLabel() throws Exception {
   public void testBlacklistAMDisableLabel() throws Exception {
     conf.setBoolean(YarnConfiguration.AM_SCHEDULING_NODE_BLACKLISTING_ENABLED,
     conf.setBoolean(YarnConfiguration.AM_SCHEDULING_NODE_BLACKLISTING_ENABLED,
         true);
         true);
@@ -836,13 +843,13 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     appAttempt.getAMBlacklistManager().addNode("h1");
     appAttempt.getAMBlacklistManager().addNode("h1");
     ResourceBlacklistRequest blacklistUpdates =
     ResourceBlacklistRequest blacklistUpdates =
         appAttempt.getAMBlacklistManager().getBlacklistUpdates();
         appAttempt.getAMBlacklistManager().getBlacklistUpdates();
-    Assert.assertEquals(1, blacklistUpdates.getBlacklistAdditions().size());
-    Assert.assertEquals(0, blacklistUpdates.getBlacklistRemovals().size());
+    assertEquals(1, blacklistUpdates.getBlacklistAdditions().size());
+    assertEquals(0, blacklistUpdates.getBlacklistRemovals().size());
     // Adding second node from default parition
     // Adding second node from default parition
     appAttempt.getAMBlacklistManager().addNode("h8");
     appAttempt.getAMBlacklistManager().addNode("h8");
     blacklistUpdates = appAttempt.getAMBlacklistManager().getBlacklistUpdates();
     blacklistUpdates = appAttempt.getAMBlacklistManager().getBlacklistUpdates();
-    Assert.assertEquals(0, blacklistUpdates.getBlacklistAdditions().size());
-    Assert.assertEquals(2, blacklistUpdates.getBlacklistRemovals().size());
+    assertEquals(0, blacklistUpdates.getBlacklistAdditions().size());
+    assertEquals(2, blacklistUpdates.getBlacklistRemovals().size());
 
 
     // Submission in label x
     // Submission in label x
     MockRMAppSubmissionData data1 =
     MockRMAppSubmissionData data1 =
@@ -859,21 +866,21 @@ public class TestCapacitySchedulerNodeLabelUpdate {
     appAttemptlabelx.getAMBlacklistManager().addNode("h2");
     appAttemptlabelx.getAMBlacklistManager().addNode("h2");
     ResourceBlacklistRequest blacklistUpdatesOnx =
     ResourceBlacklistRequest blacklistUpdatesOnx =
         appAttemptlabelx.getAMBlacklistManager().getBlacklistUpdates();
         appAttemptlabelx.getAMBlacklistManager().getBlacklistUpdates();
-    Assert.assertEquals(1, blacklistUpdatesOnx.getBlacklistAdditions().size());
-    Assert.assertEquals(0, blacklistUpdatesOnx.getBlacklistRemovals().size());
+    assertEquals(1, blacklistUpdatesOnx.getBlacklistAdditions().size());
+    assertEquals(0, blacklistUpdatesOnx.getBlacklistRemovals().size());
     // Adding second node from default parition
     // Adding second node from default parition
     appAttemptlabelx.getAMBlacklistManager().addNode("h3");
     appAttemptlabelx.getAMBlacklistManager().addNode("h3");
     blacklistUpdatesOnx =
     blacklistUpdatesOnx =
         appAttempt.getAMBlacklistManager().getBlacklistUpdates();
         appAttempt.getAMBlacklistManager().getBlacklistUpdates();
-    Assert.assertEquals(0, blacklistUpdatesOnx.getBlacklistAdditions().size());
-    Assert.assertEquals(2, blacklistUpdatesOnx.getBlacklistRemovals().size());
+    assertEquals(0, blacklistUpdatesOnx.getBlacklistAdditions().size());
+    assertEquals(2, blacklistUpdatesOnx.getBlacklistRemovals().size());
 
 
     rm.close();
     rm.close();
   }
   }
 
 
   private void checkAMResourceLimit(MockRM rm, String queuename, int memory,
   private void checkAMResourceLimit(MockRM rm, String queuename, int memory,
       String label) throws InterruptedException {
       String label) throws InterruptedException {
-    Assert.assertEquals(memory,
+    assertEquals(memory,
         waitForResourceUpdate(rm, queuename, memory, label, 3000L));
         waitForResourceUpdate(rm, queuename, memory, label, 3000L));
   }
   }
 
 
@@ -944,24 +951,24 @@ public class TestCapacitySchedulerNodeLabelUpdate {
 
 
     // Ensure that cluster node tracker is updated with correct set of node
     // Ensure that cluster node tracker is updated with correct set of node
     // after Node registration.
     // after Node registration.
-    Assert.assertEquals(2,
+    assertEquals(2,
         cs.getNodeTracker().getNodesPerPartition("x").size());
         cs.getNodeTracker().getNodesPerPartition("x").size());
-    Assert.assertEquals(1, cs.getNodeTracker().getNodesPerPartition("").size());
+    assertEquals(1, cs.getNodeTracker().getNodesPerPartition("").size());
 
 
     rm.unRegisterNode(nm1);
     rm.unRegisterNode(nm1);
     rm.registerNode("h4:1234", 8000);
     rm.registerNode("h4:1234", 8000);
 
 
     // Ensure that cluster node tracker is updated with correct set of node
     // Ensure that cluster node tracker is updated with correct set of node
     // after new Node registration and old node label change.
     // after new Node registration and old node label change.
-    Assert.assertEquals(1,
+    assertEquals(1,
         cs.getNodeTracker().getNodesPerPartition("x").size());
         cs.getNodeTracker().getNodesPerPartition("x").size());
-    Assert.assertEquals(2, cs.getNodeTracker().getNodesPerPartition("").size());
+    assertEquals(2, cs.getNodeTracker().getNodesPerPartition("").size());
 
 
     mgr.replaceLabelsOnNode(
     mgr.replaceLabelsOnNode(
         ImmutableMap.of(NodeId.newInstance("h2", 1234), toSet("")));
         ImmutableMap.of(NodeId.newInstance("h2", 1234), toSet("")));
 
 
     // Last node with label x is replaced by CLI or REST.
     // Last node with label x is replaced by CLI or REST.
-    Assert.assertEquals(0,
+    assertEquals(0,
         waitForNodeLabelSchedulerEventUpdate(rm, "x", 0, 3000L));
         waitForNodeLabelSchedulerEventUpdate(rm, "x", 0, 3000L));
     rm.stop();
     rm.stop();
   }
   }

+ 43 - 41
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNodes.java

@@ -61,11 +61,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.security.ClientToAMTokenSec
 import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM;
 import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM;
 import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager;
 import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.MockNM.createMockNodeStatus;
 import static org.apache.hadoop.yarn.server.resourcemanager.MockNM.createMockNodeStatus;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfiguration;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfiguration;
@@ -76,8 +74,12 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.C
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.registerNode;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.registerNode;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.stopResourceManager;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.stopResourceManager;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerAutoCreatedQueueBase.NULL_UPDATE_REQUESTS;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerAutoCreatedQueueBase.NULL_UPDATE_REQUESTS;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
@@ -86,12 +88,12 @@ public class TestCapacitySchedulerNodes {
 
 
   private ResourceManager resourceManager = null;
   private ResourceManager resourceManager = null;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     resourceManager = createResourceManager();
     resourceManager = createResourceManager();
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     stopResourceManager(resourceManager);
     stopResourceManager(resourceManager);
   }
   }
@@ -117,14 +119,14 @@ public class TestCapacitySchedulerNodes {
     cs.handle(new NodeAddedSchedulerEvent(n1));
     cs.handle(new NodeAddedSchedulerEvent(n1));
     cs.handle(new NodeAddedSchedulerEvent(n2));
     cs.handle(new NodeAddedSchedulerEvent(n2));
 
 
-    Assert.assertEquals(6 * GB, cs.getClusterResource().getMemorySize());
+    assertEquals(6 * GB, cs.getClusterResource().getMemorySize());
 
 
     // reconnect n1 with downgraded memory
     // reconnect n1 with downgraded memory
     n1 = MockNodes.newNodeInfo(0, MockNodes.newResource(2 * GB), 1);
     n1 = MockNodes.newNodeInfo(0, MockNodes.newResource(2 * GB), 1);
     cs.handle(new NodeRemovedSchedulerEvent(n1));
     cs.handle(new NodeRemovedSchedulerEvent(n1));
     cs.handle(new NodeAddedSchedulerEvent(n1));
     cs.handle(new NodeAddedSchedulerEvent(n1));
 
 
-    Assert.assertEquals(4 * GB, cs.getClusterResource().getMemorySize());
+    assertEquals(4 * GB, cs.getClusterResource().getMemorySize());
     cs.stop();
     cs.stop();
   }
   }
 
 
@@ -148,12 +150,12 @@ public class TestCapacitySchedulerNodes {
     cs.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(), null,
     cs.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(), null,
         Collections.<ContainerId>emptyList(),
         Collections.<ContainerId>emptyList(),
         Collections.singletonList(host), null, NULL_UPDATE_REQUESTS);
         Collections.singletonList(host), null, NULL_UPDATE_REQUESTS);
-    Assert.assertTrue(cs.getApplicationAttempt(appAttemptId)
+    assertTrue(cs.getApplicationAttempt(appAttemptId)
         .isPlaceBlacklisted(host));
         .isPlaceBlacklisted(host));
     cs.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(), null,
     cs.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(), null,
         Collections.<ContainerId>emptyList(), null,
         Collections.<ContainerId>emptyList(), null,
         Collections.singletonList(host), NULL_UPDATE_REQUESTS);
         Collections.singletonList(host), NULL_UPDATE_REQUESTS);
-    Assert.assertFalse(cs.getApplicationAttempt(appAttemptId)
+    assertFalse(cs.getApplicationAttempt(appAttemptId)
         .isPlaceBlacklisted(host));
         .isPlaceBlacklisted(host));
     rm.stop();
     rm.stop();
   }
   }
@@ -202,20 +204,20 @@ public class TestCapacitySchedulerNodes {
     cs.start();
     cs.start();
 
 
     QueueInfo queueInfoA = cs.getQueueInfo("a", true, false);
     QueueInfo queueInfoA = cs.getQueueInfo("a", true, false);
-    Assert.assertEquals("Queue Name should be a", "a",
-        queueInfoA.getQueueName());
-    Assert.assertEquals("Queue Path should be root.a", "root.a",
-        queueInfoA.getQueuePath());
-    Assert.assertEquals("Default Node Label Expression should be x", "x",
-        queueInfoA.getDefaultNodeLabelExpression());
+    assertEquals("a", queueInfoA.getQueueName(),
+        "Queue Name should be a");
+    assertEquals("root.a", queueInfoA.getQueuePath(),
+        "Queue Path should be root.a");
+    assertEquals("x", queueInfoA.getDefaultNodeLabelExpression(),
+        "Default Node Label Expression should be x");
 
 
     QueueInfo queueInfoB = cs.getQueueInfo("b", true, false);
     QueueInfo queueInfoB = cs.getQueueInfo("b", true, false);
-    Assert.assertEquals("Queue Name should be b", "b",
-        queueInfoB.getQueueName());
-    Assert.assertEquals("Queue Path should be root.b", "root.b",
-        queueInfoB.getQueuePath());
-    Assert.assertEquals("Default Node Label Expression should be y", "y",
-        queueInfoB.getDefaultNodeLabelExpression());
+    assertEquals("b", queueInfoB.getQueueName(),
+        "Queue Name should be b");
+    assertEquals("root.b", queueInfoB.getQueuePath(),
+        "Queue Path should be root.b");
+    assertEquals("y", queueInfoB.getDefaultNodeLabelExpression(),
+        "Default Node Label Expression should be y");
     cs.stop();
     cs.stop();
   }
   }
 
 
@@ -239,7 +241,7 @@ public class TestCapacitySchedulerNodes {
         removeNode(nm.getNodeId());
         removeNode(nm.getNodeId());
     // Kick off another heartbeat with the node state mocked to decommissioning
     // Kick off another heartbeat with the node state mocked to decommissioning
     RMNode spyNode =
     RMNode spyNode =
-        Mockito.spy(resourceManager.getRMContext().getRMNodes()
+        spy(resourceManager.getRMContext().getRMNodes()
             .get(nm.getNodeId()));
             .get(nm.getNodeId()));
     when(spyNode.getState()).thenReturn(NodeState.DECOMMISSIONING);
     when(spyNode.getState()).thenReturn(NodeState.DECOMMISSIONING);
     resourceManager.getResourceScheduler().handle(
     resourceManager.getResourceScheduler().handle(
@@ -250,7 +252,7 @@ public class TestCapacitySchedulerNodes {
   public void testResourceUpdateDecommissioningNode() throws Exception {
   public void testResourceUpdateDecommissioningNode() throws Exception {
     // Mock the RMNodeResourceUpdate event handler to update SchedulerNode
     // Mock the RMNodeResourceUpdate event handler to update SchedulerNode
     // to have 0 available resource
     // to have 0 available resource
-    RMContext spyContext = Mockito.spy(resourceManager.getRMContext());
+    RMContext spyContext = spy(resourceManager.getRMContext());
     Dispatcher mockDispatcher = mock(AsyncDispatcher.class);
     Dispatcher mockDispatcher = mock(AsyncDispatcher.class);
     when(mockDispatcher.getEventHandler()).thenReturn(new EventHandler<Event>() {
     when(mockDispatcher.getEventHandler()).thenReturn(new EventHandler<Event>() {
       @Override
       @Override
@@ -265,7 +267,7 @@ public class TestCapacitySchedulerNodes {
         }
         }
       }
       }
     });
     });
-    Mockito.doReturn(mockDispatcher).when(spyContext).getDispatcher();
+    doReturn(mockDispatcher).when(spyContext).getDispatcher();
     ((CapacityScheduler) resourceManager.getResourceScheduler())
     ((CapacityScheduler) resourceManager.getResourceScheduler())
         .setRMContext(spyContext);
         .setRMContext(spyContext);
     ((AsyncDispatcher) mockDispatcher).start();
     ((AsyncDispatcher) mockDispatcher).start();
@@ -301,7 +303,7 @@ public class TestCapacitySchedulerNodes {
     // Kick off another heartbeat with the node state mocked to decommissioning
     // Kick off another heartbeat with the node state mocked to decommissioning
     // This should update the schedulernodes to have 0 available resource
     // This should update the schedulernodes to have 0 available resource
     RMNode spyNode =
     RMNode spyNode =
-        Mockito.spy(resourceManager.getRMContext().getRMNodes()
+        spy(resourceManager.getRMContext().getRMNodes()
             .get(nm0.getNodeId()));
             .get(nm0.getNodeId()));
     when(spyNode.getState()).thenReturn(NodeState.DECOMMISSIONING);
     when(spyNode.getState()).thenReturn(NodeState.DECOMMISSIONING);
     resourceManager.getResourceScheduler().handle(
     resourceManager.getResourceScheduler().handle(
@@ -311,30 +313,30 @@ public class TestCapacitySchedulerNodes {
     application0.schedule();
     application0.schedule();
 
 
     // Check the used resource is 1 GB 1 core
     // Check the used resource is 1 GB 1 core
-    Assert.assertEquals(1 * GB, nm0.getUsed().getMemorySize());
+    assertEquals(1 * GB, nm0.getUsed().getMemorySize());
     Resource usedResource =
     Resource usedResource =
         resourceManager.getResourceScheduler()
         resourceManager.getResourceScheduler()
             .getSchedulerNode(nm0.getNodeId()).getAllocatedResource();
             .getSchedulerNode(nm0.getNodeId()).getAllocatedResource();
-    Assert.assertEquals("Used Resource Memory Size should be 1GB", 1 * GB,
-        usedResource.getMemorySize());
-    Assert.assertEquals("Used Resource Virtual Cores should be 1", 1,
-        usedResource.getVirtualCores());
+    assertEquals(1 * GB, usedResource.getMemorySize(),
+        "Used Resource Memory Size should be 1GB");
+    assertEquals(1, usedResource.getVirtualCores(),
+        "Used Resource Virtual Cores should be 1");
     // Check total resource of scheduler node is also changed to 1 GB 1 core
     // Check total resource of scheduler node is also changed to 1 GB 1 core
     Resource totalResource =
     Resource totalResource =
         resourceManager.getResourceScheduler()
         resourceManager.getResourceScheduler()
             .getSchedulerNode(nm0.getNodeId()).getTotalResource();
             .getSchedulerNode(nm0.getNodeId()).getTotalResource();
-    Assert.assertEquals("Total Resource Memory Size should be 1GB", 1 * GB,
-        totalResource.getMemorySize());
-    Assert.assertEquals("Total Resource Virtual Cores should be 1", 1,
-        totalResource.getVirtualCores());
+    assertEquals(1 * GB, totalResource.getMemorySize(),
+        "Total Resource Memory Size should be 1GB");
+    assertEquals(1, totalResource.getVirtualCores(),
+        "Total Resource Virtual Cores should be 1");
     // Check the available resource is 0/0
     // Check the available resource is 0/0
     Resource availableResource =
     Resource availableResource =
         resourceManager.getResourceScheduler()
         resourceManager.getResourceScheduler()
             .getSchedulerNode(nm0.getNodeId()).getUnallocatedResource();
             .getSchedulerNode(nm0.getNodeId()).getUnallocatedResource();
-    Assert.assertEquals("Available Resource Memory Size should be 0", 0,
-        availableResource.getMemorySize());
-    Assert.assertEquals("Available Resource Memory Size should be 0", 0,
-        availableResource.getVirtualCores());
+    assertEquals(0, availableResource.getMemorySize(),
+        "Available Resource Memory Size should be 0");
+    assertEquals(0, availableResource.getVirtualCores(),
+        "Available Resource Memory Size should be 0");
     // Kick off another heartbeat where the RMNodeResourceUpdateEvent would
     // Kick off another heartbeat where the RMNodeResourceUpdateEvent would
     // be skipped for DECOMMISSIONING state since the total resource is
     // be skipped for DECOMMISSIONING state since the total resource is
     // already equal to used resource from the previous heartbeat.
     // already equal to used resource from the previous heartbeat.

+ 17 - 11
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerPerf.java

@@ -52,8 +52,8 @@ import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.slf4j.event.Level;
 import org.slf4j.event.Level;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import java.util.Collections;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -62,9 +62,10 @@ import java.util.PriorityQueue;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicLong;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.resource.TestResourceProfiles.TEST_CONF_RESET_RESOURCE_TYPES;
 import static org.apache.hadoop.yarn.server.resourcemanager.resource.TestResourceProfiles.TEST_CONF_RESET_RESOURCE_TYPES;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -115,7 +116,7 @@ public class TestCapacitySchedulerPerf {
   private void testUserLimitThroughputWithNumberOfResourceTypes(
   private void testUserLimitThroughputWithNumberOfResourceTypes(
       int numOfResourceTypes, int numQueues, int pctActiveQueues, int appCount)
       int numOfResourceTypes, int numQueues, int pctActiveQueues, int appCount)
       throws Exception {
       throws Exception {
-    Assume.assumeTrue(Boolean.valueOf(
+    assumeTrue(Boolean.valueOf(
         System.getProperty("RunCapacitySchedulerPerfTests")));
         System.getProperty("RunCapacitySchedulerPerfTests")));
     int numThreads = Integer.valueOf(System.getProperty(
     int numThreads = Integer.valueOf(System.getProperty(
         "CapacitySchedulerPerfTestsNumThreads", "0"));
         "CapacitySchedulerPerfTestsNumThreads", "0"));
@@ -415,27 +416,32 @@ public class TestCapacitySchedulerPerf {
     rm.stop();
     rm.stop();
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testUserLimitThroughputForTwoResources() throws Exception {
   public void testUserLimitThroughputForTwoResources() throws Exception {
     testUserLimitThroughputWithNumberOfResourceTypes(2, 1, 100, 100);
     testUserLimitThroughputWithNumberOfResourceTypes(2, 1, 100, 100);
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testUserLimitThroughputForThreeResources() throws Exception {
   public void testUserLimitThroughputForThreeResources() throws Exception {
     testUserLimitThroughputWithNumberOfResourceTypes(3, 1, 100, 100);
     testUserLimitThroughputWithNumberOfResourceTypes(3, 1, 100, 100);
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testUserLimitThroughputForFourResources() throws Exception {
   public void testUserLimitThroughputForFourResources() throws Exception {
     testUserLimitThroughputWithNumberOfResourceTypes(4, 1, 100, 100);
     testUserLimitThroughputWithNumberOfResourceTypes(4, 1, 100, 100);
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testUserLimitThroughputForFiveResources() throws Exception {
   public void testUserLimitThroughputForFiveResources() throws Exception {
     testUserLimitThroughputWithNumberOfResourceTypes(5, 1, 100, 100);
     testUserLimitThroughputWithNumberOfResourceTypes(5, 1, 100, 100);
   }
   }
 
 
-  @Test(timeout = 1800000)
+  @Test
+  @Timeout(value = 1800)
   public void testUserLimitThroughputWithManyQueues() throws Exception {
   public void testUserLimitThroughputWithManyQueues() throws Exception {
 
 
     int numQueues = Integer.getInteger("NumberOfQueues", 40);
     int numQueues = Integer.getInteger("NumberOfQueues", 40);

+ 4 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerQueueACLs.java

@@ -17,7 +17,7 @@
 */
 */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
@@ -32,7 +32,7 @@ import org.apache.hadoop.security.authorize.AccessControlList;
 import org.apache.hadoop.yarn.api.records.QueueACL;
 import org.apache.hadoop.yarn.api.records.QueueACL;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.QueueACLsTestBase;
 import org.apache.hadoop.yarn.server.resourcemanager.QueueACLsTestBase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestCapacitySchedulerQueueACLs extends QueueACLsTestBase {
 public class TestCapacitySchedulerQueueACLs extends QueueACLsTestBase {
   @Override
   @Override
@@ -177,7 +177,7 @@ public class TestCapacitySchedulerQueueACLs extends QueueACLsTestBase {
         (CapacityScheduler) resourceManager.getResourceScheduler();
         (CapacityScheduler) resourceManager.getResourceScheduler();
     cs.setQueueManager(qm);
     cs.setQueueManager(qm);
 
 
-    assertEquals("checkAccess() failed", expectedResult,
-        cs.checkAccess(mockUGI, QueueACL.ADMINISTER_QUEUE, queueName));
+    assertEquals(expectedResult,
+        cs.checkAccess(mockUGI, QueueACL.ADMINISTER_QUEUE, queueName), "checkAccess() failed");
   }
   }
 }
 }

+ 18 - 18
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerQueueMappingFactory.java

@@ -33,15 +33,16 @@ import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping.Queu
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.SimpleGroupsMapping;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.SimpleGroupsMapping;
 import org.apache.hadoop.yarn.util.Records;
 import org.apache.hadoop.yarn.util.Records;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerAutoCreatedQueueBase.getQueueMapping;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerAutoCreatedQueueBase.getQueueMapping;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerAutoCreatedQueueBase.setupQueueConfiguration;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerAutoCreatedQueueBase.setupQueueConfiguration;
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestCapacitySchedulerQueueMappingFactory {
 public class TestCapacitySchedulerQueueMappingFactory {
 
 
@@ -131,7 +132,7 @@ public class TestCapacitySchedulerQueueMappingFactory {
       }
       }
 
 
       // verify both placement rules were added successfully
       // verify both placement rules were added successfully
-      assertThat(placementRuleNames, hasItems(QUEUE_MAPPING_RULE));
+      assertThat(placementRuleNames).contains(QUEUE_MAPPING_RULE);
     } finally {
     } finally {
       if(mockRM != null) {
       if(mockRM != null) {
         mockRM.close();
         mockRM.close();
@@ -200,11 +201,11 @@ public class TestCapacitySchedulerQueueMappingFactory {
           (CSMappingPlacementRule) rules.get(0);
           (CSMappingPlacementRule) rules.get(0);
 
 
       ApplicationPlacementContext ctx = r.getPlacementForApp(asc, "user1");
       ApplicationPlacementContext ctx = r.getPlacementForApp(asc, "user1");
-      assertEquals("Queue", "b1", ctx.getQueue());
+      assertEquals("b1", ctx.getQueue(), "Queue");
 
 
       ApplicationPlacementContext ctx2 = r.getPlacementForApp(asc, "user2");
       ApplicationPlacementContext ctx2 = r.getPlacementForApp(asc, "user2");
-      assertEquals("Queue", "user2", ctx2.getQueue());
-      assertEquals("Queue", "root.c", ctx2.getParentQueue());
+      assertEquals("user2", ctx2.getQueue(), "Queue");
+      assertEquals("root.c", ctx2.getParentQueue(), "Queue");
     } finally {
     } finally {
       if(mockRM != null) {
       if(mockRM != null) {
         mockRM.close();
         mockRM.close();
@@ -352,14 +353,13 @@ public class TestCapacitySchedulerQueueMappingFactory {
       CSMappingPlacementRule r =
       CSMappingPlacementRule r =
           (CSMappingPlacementRule) rules.get(0);
           (CSMappingPlacementRule) rules.get(0);
       ApplicationPlacementContext ctx = r.getPlacementForApp(asc, user);
       ApplicationPlacementContext ctx = r.getPlacementForApp(asc, user);
-      assertEquals("Queue", user, ctx.getQueue());
+      assertEquals(user, ctx.getQueue(), "Queue");
 
 
       if (primary) {
       if (primary) {
-        assertEquals(
-            "Primary Group", "root." + user + "group", ctx.getParentQueue());
+        assertEquals("root." + user + "group", ctx.getParentQueue(), "Primary Group");
       } else {
       } else {
-        assertEquals("Secondary Group", "root." + user + "subgroup1",
-            ctx.getParentQueue());
+        assertEquals("root." + user + "subgroup1",
+            ctx.getParentQueue(), "Secondary Group");
       }
       }
     } finally {
     } finally {
       if (mockRM != null) {
       if (mockRM != null) {
@@ -426,10 +426,10 @@ public class TestCapacitySchedulerQueueMappingFactory {
           (CSMappingPlacementRule) rules.get(0);
           (CSMappingPlacementRule) rules.get(0);
 
 
       ApplicationPlacementContext ctx = r.getPlacementForApp(asc, "user1");
       ApplicationPlacementContext ctx = r.getPlacementForApp(asc, "user1");
-      assertEquals("Queue", "b1", ctx.getQueue());
+      assertEquals("b1", ctx.getQueue(), "Queue");
 
 
       ApplicationPlacementContext ctx1 = r.getPlacementForApp(asc, "a1");
       ApplicationPlacementContext ctx1 = r.getPlacementForApp(asc, "a1");
-      assertEquals("Queue", "a1group", ctx1.getQueue());
+      assertEquals("a1group", ctx1.getQueue(), "Queue");
     } finally {
     } finally {
       if (mockRM != null) {
       if (mockRM != null) {
         mockRM.close();
         mockRM.close();
@@ -503,14 +503,14 @@ public class TestCapacitySchedulerQueueMappingFactory {
           (CSMappingPlacementRule) rules.get(0);
           (CSMappingPlacementRule) rules.get(0);
 
 
       ApplicationPlacementContext ctx = r.getPlacementForApp(asc, "user1");
       ApplicationPlacementContext ctx = r.getPlacementForApp(asc, "user1");
-      assertEquals("Queue", "b1", ctx.getQueue());
+      assertEquals("b1", ctx.getQueue(), "Queue");
 
 
       ApplicationPlacementContext ctx1 = r.getPlacementForApp(asc, "a1");
       ApplicationPlacementContext ctx1 = r.getPlacementForApp(asc, "a1");
-      assertEquals("Queue", "a1group", ctx1.getQueue());
+      assertEquals("a1group", ctx1.getQueue(), "Queue");
 
 
       ApplicationPlacementContext ctx2 = r.getPlacementForApp(asc, "b4");
       ApplicationPlacementContext ctx2 = r.getPlacementForApp(asc, "b4");
-      assertEquals("Queue", "b4subgroup1", ctx2.getQueue());
-      assertEquals("Queue", "root.b", ctx2.getParentQueue());
+      assertEquals("b4subgroup1", ctx2.getQueue(), "Queue");
+      assertEquals("root.b", ctx2.getParentQueue(), "Queue");
     } finally {
     } finally {
       if (mockRM != null) {
       if (mockRM != null) {
         mockRM.close();
         mockRM.close();

+ 216 - 224
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerQueues.java

@@ -35,11 +35,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManag
 import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager;
 import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -69,11 +68,14 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.C
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfigurationWithoutB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfigurationWithoutB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfigurationWithoutB1;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfigurationWithoutB1;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
 public class TestCapacitySchedulerQueues {
 public class TestCapacitySchedulerQueues {
@@ -84,7 +86,7 @@ public class TestCapacitySchedulerQueues {
   private NullRMNodeLabelsManager mgr;
   private NullRMNodeLabelsManager mgr;
   private CapacitySchedulerConfiguration conf;
   private CapacitySchedulerConfiguration conf;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new CapacitySchedulerConfiguration();
     conf = new CapacitySchedulerConfiguration();
     setupQueueConfiguration(conf);
     setupQueueConfiguration(conf);
@@ -107,7 +109,7 @@ public class TestCapacitySchedulerQueues {
         new ResourceLimits(clusterResource));
         new ResourceLimits(clusterResource));
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     if (rm != null) {
     if (rm != null) {
       rm.stop();
       rm.stop();
@@ -123,23 +125,25 @@ public class TestCapacitySchedulerQueues {
    *
    *
    * @throws IOException
    * @throws IOException
    */
    */
-  @Test(expected = IOException.class)
+  @Test
   public void testParseQueue() throws IOException {
   public void testParseQueue() throws IOException {
-    CapacityScheduler cs = new CapacityScheduler();
-    cs.setConf(new YarnConfiguration());
-    cs.setRMContext(rm.getRMContext());
-    cs.init(conf);
-    cs.start();
-
-    conf.setQueues(A1, new String[]{"b1"});
-    conf.setCapacity(A1_B1, 100.0f);
-    conf.setUserLimitFactor(A1_B1, 100.0f);
-
-    cs.reinitialize(conf, new RMContextImpl(null, null, null, null, null,
-        null, new RMContainerTokenSecretManager(conf),
-        new NMTokenSecretManagerInRM(conf),
-        new ClientToAMTokenSecretManagerInRM(), null));
-    cs.stop();
+    assertThrows(IOException.class, () -> {
+      CapacityScheduler cs = new CapacityScheduler();
+      cs.setConf(new YarnConfiguration());
+      cs.setRMContext(rm.getRMContext());
+      cs.init(conf);
+      cs.start();
+
+      conf.setQueues(A1, new String[]{"b1"});
+      conf.setCapacity(A1_B1, 100.0f);
+      conf.setUserLimitFactor(A1_B1, 100.0f);
+
+      cs.reinitialize(conf, new RMContextImpl(null, null, null, null, null,
+              null, new RMContainerTokenSecretManager(conf),
+              new NMTokenSecretManagerInRM(conf),
+              new ClientToAMTokenSecretManagerInRM(), null));
+      cs.stop();
+    });
   }
   }
 
 
   @Test
   @Test
@@ -218,21 +222,19 @@ public class TestCapacitySchedulerQueues {
     cs.reinitialize(conf, rm.getRMContext());
     cs.reinitialize(conf, rm.getRMContext());
     checkQueueStructureCapacities(cs);
     checkQueueStructureCapacities(cs);
 
 
-    assertEquals("max allocation in CS",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        cs.getMaximumResourceCapability().getMemorySize());
-    assertEquals("max allocation for A1",
-        Resources.none(),
-        conf.getQueueMaximumAllocation(A1));
-    assertEquals("max allocation",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getMemorySize());
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        cs.getMaximumResourceCapability().getMemorySize(), "max allocation in CS");
+    assertEquals(Resources.none(),
+        conf.getQueueMaximumAllocation(A1), "max allocation for A1");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getMemorySize(),
+        "max allocation");
 
 
     CSQueue rootQueue = cs.getRootQueue();
     CSQueue rootQueue = cs.getRootQueue();
     CSQueue queueA = findQueue(rootQueue, A.getFullPath());
     CSQueue queueA = findQueue(rootQueue, A.getFullPath());
     CSQueue queueA1 = findQueue(queueA, A1.getFullPath());
     CSQueue queueA1 = findQueue(queueA, A1.getFullPath());
-    assertEquals("queue max allocation", ((LeafQueue) queueA1)
-        .getMaximumAllocation().getMemorySize(), 8192);
+    assertEquals(((LeafQueue) queueA1)
+        .getMaximumAllocation().getMemorySize(), 8192, "queue max allocation");
 
 
     setMaxAllocMb(conf, A1, 4096);
     setMaxAllocMb(conf, A1, 4096);
 
 
@@ -240,8 +242,8 @@ public class TestCapacitySchedulerQueues {
       cs.reinitialize(conf, rm.getRMContext());
       cs.reinitialize(conf, rm.getRMContext());
       fail("should have thrown exception");
       fail("should have thrown exception");
     } catch (IOException e) {
     } catch (IOException e) {
-      assertTrue("max allocation exception",
-          e.getCause().toString().contains("not be decreased"));
+      assertTrue(e.getCause().toString().contains("not be decreased"),
+          "max allocation exception");
     }
     }
 
 
     setMaxAllocMb(conf, A1, 8192);
     setMaxAllocMb(conf, A1, 8192);
@@ -253,8 +255,8 @@ public class TestCapacitySchedulerQueues {
       cs.reinitialize(conf, rm.getRMContext());
       cs.reinitialize(conf, rm.getRMContext());
       fail("should have thrown exception");
       fail("should have thrown exception");
     } catch (IOException e) {
     } catch (IOException e) {
-      assertTrue("max allocation exception",
-          e.getCause().toString().contains("not be decreased"));
+      assertTrue(e.getCause().toString().contains("not be decreased"),
+          "max allocation exception");
     }
     }
     cs.stop();
     cs.stop();
   }
   }
@@ -274,8 +276,8 @@ public class TestCapacitySchedulerQueues {
       cs.reinitialize(conf, rm.getRMContext());
       cs.reinitialize(conf, rm.getRMContext());
       fail("should have thrown exception");
       fail("should have thrown exception");
     } catch (IOException e) {
     } catch (IOException e) {
-      assertTrue("maximum allocation exception",
-          e.getCause().getMessage().contains("maximum allocation"));
+      assertTrue(e.getCause().getMessage().contains("maximum allocation"),
+          "maximum allocation exception");
     }
     }
 
 
     setMaxAllocMb(conf, B3,
     setMaxAllocMb(conf, B3,
@@ -288,8 +290,8 @@ public class TestCapacitySchedulerQueues {
       cs.reinitialize(conf, rm.getRMContext());
       cs.reinitialize(conf, rm.getRMContext());
       fail("should have thrown exception");
       fail("should have thrown exception");
     } catch (IOException e) {
     } catch (IOException e) {
-      assertTrue("maximum allocation exception",
-          e.getCause().getMessage().contains("maximum allocation"));
+      assertTrue(e.getCause().getMessage().contains("maximum allocation"),
+          "maximum allocation exception");
     }
     }
     cs.stop();
     cs.stop();
   }
   }
@@ -315,53 +317,51 @@ public class TestCapacitySchedulerQueues {
     CSQueue queueA = findQueue(rootQueue, A.getFullPath());
     CSQueue queueA = findQueue(rootQueue, A.getFullPath());
     CSQueue queueA1 = findQueue(queueA, A1.getFullPath());
     CSQueue queueA1 = findQueue(queueA, A1.getFullPath());
 
 
-    assertEquals("max capability MB in CS",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        cs.getMaximumResourceCapability().getMemorySize());
-    assertEquals("max capability vcores in CS",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
-        cs.getMaximumResourceCapability().getVirtualCores());
-    assertEquals("max allocation MB A1",
-        4096,
-        queueA1.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation vcores A1",
-        2,
-        queueA1.getMaximumAllocation().getVirtualCores());
-    assertEquals("cluster max allocation MB",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getMemorySize());
-    assertEquals("cluster max allocation vcores",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
-        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getVirtualCores());
-
-    assertEquals("queue max allocation", 4096,
-        queueA1.getMaximumAllocation().getMemorySize());
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        cs.getMaximumResourceCapability().getMemorySize(),
+        "max capability MB in CS");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
+        cs.getMaximumResourceCapability().getVirtualCores(),
+        "max capability vcores in CS");
+    assertEquals(4096, queueA1.getMaximumAllocation().getMemorySize(),
+        "max allocation MB A1");
+    assertEquals(2, queueA1.getMaximumAllocation().getVirtualCores(),
+        "max allocation vcores A1");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getMemorySize(),
+        "cluster max allocation MB");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
+        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getVirtualCores(),
+        "cluster max allocation vcores");
+
+    assertEquals(4096, queueA1.getMaximumAllocation().getMemorySize(),
+        "queue max allocation");
 
 
     setMaxAllocMb(conf, A1, 6144);
     setMaxAllocMb(conf, A1, 6144);
     setMaxAllocVcores(conf, A1, 3);
     setMaxAllocVcores(conf, A1, 3);
     cs.reinitialize(conf, null);
     cs.reinitialize(conf, null);
     // conf will have changed but we shouldn't be able to change max allocation
     // conf will have changed but we shouldn't be able to change max allocation
     // for the actual queue
     // for the actual queue
-    assertEquals("max allocation MB A1", 6144,
-        queueA1.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation vcores A1", 3,
-        queueA1.getMaximumAllocation().getVirtualCores());
-    assertEquals("max allocation MB cluster",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getMemorySize());
-    assertEquals("max allocation vcores cluster",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
-        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getVirtualCores());
-    assertEquals("queue max allocation MB", 6144,
-        queueA1.getMaximumAllocation().getMemorySize());
-    assertEquals("queue max allocation vcores", 3,
-        queueA1.getMaximumAllocation().getVirtualCores());
-    assertEquals("max capability MB cluster",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        cs.getMaximumResourceCapability().getMemorySize());
-    assertEquals("cluster max capability vcores",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
-        cs.getMaximumResourceCapability().getVirtualCores());
+    assertEquals(6144, queueA1.getMaximumAllocation().getMemorySize(),
+        "max allocation MB A1");
+    assertEquals(3, queueA1.getMaximumAllocation().getVirtualCores(),
+        "max allocation vcores A1");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getMemorySize(),
+        "max allocation MB cluster");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
+        ResourceUtils.fetchMaximumAllocationFromConfig(conf).getVirtualCores(),
+        "max allocation vcores cluster");
+    assertEquals(6144, queueA1.getMaximumAllocation().getMemorySize(),
+        "queue max allocation MB");
+    assertEquals(3, queueA1.getMaximumAllocation().getVirtualCores(),
+        "queue max allocation vcores");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        cs.getMaximumResourceCapability().getMemorySize(),
+        "max capability MB cluster");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
+        cs.getMaximumResourceCapability().getVirtualCores(),
+        "cluster max capability vcores");
     cs.stop();
     cs.stop();
   }
   }
 
 
@@ -382,18 +382,18 @@ public class TestCapacitySchedulerQueues {
 
 
     checkQueueStructureCapacities(cs);
     checkQueueStructureCapacities(cs);
 
 
-    assertEquals("max allocation MB in CS", 10240,
-        cs.getMaximumResourceCapability().getMemorySize());
-    assertEquals("max allocation vcores in CS", 10,
-        cs.getMaximumResourceCapability().getVirtualCores());
+    assertEquals(10240, cs.getMaximumResourceCapability().getMemorySize(),
+        "max allocation MB in CS");
+    assertEquals(10, cs.getMaximumResourceCapability().getVirtualCores(),
+        "max allocation vcores in CS");
 
 
     setMaxAllocMb(conf, 6144);
     setMaxAllocMb(conf, 6144);
     try {
     try {
       cs.reinitialize(conf, rm.getRMContext());
       cs.reinitialize(conf, rm.getRMContext());
       fail("should have thrown exception");
       fail("should have thrown exception");
     } catch (IOException e) {
     } catch (IOException e) {
-      assertTrue("max allocation exception",
-          e.getCause().toString().contains("not be decreased"));
+      assertTrue(e.getCause().toString().contains("not be decreased"),
+          "max allocation exception");
     }
     }
 
 
     setMaxAllocMb(conf, 10240);
     setMaxAllocMb(conf, 10240);
@@ -404,8 +404,8 @@ public class TestCapacitySchedulerQueues {
       cs.reinitialize(conf, rm.getRMContext());
       cs.reinitialize(conf, rm.getRMContext());
       fail("should have thrown exception");
       fail("should have thrown exception");
     } catch (IOException e) {
     } catch (IOException e) {
-      assertTrue("max allocation exception",
-          e.getCause().toString().contains("not be decreased"));
+      assertTrue(e.getCause().toString().contains("not be decreased"),
+          "max allocation exception");
     }
     }
     cs.stop();
     cs.stop();
   }
   }
@@ -427,10 +427,10 @@ public class TestCapacitySchedulerQueues {
     cs.reinitialize(conf, rm.getRMContext());
     cs.reinitialize(conf, rm.getRMContext());
     checkQueueStructureCapacities(cs);
     checkQueueStructureCapacities(cs);
 
 
-    assertEquals("max allocation MB in CS", 10240,
-        cs.getMaximumResourceCapability().getMemorySize());
-    assertEquals("max allocation vcores in CS", 10,
-        cs.getMaximumResourceCapability().getVirtualCores());
+    assertEquals(10240, cs.getMaximumResourceCapability().getMemorySize(),
+        "max allocation MB in CS");
+    assertEquals(10, cs.getMaximumResourceCapability().getVirtualCores(),
+        "max allocation vcores in CS");
 
 
     CSQueue rootQueue = cs.getRootQueue();
     CSQueue rootQueue = cs.getRootQueue();
     CSQueue queueA = findQueue(rootQueue, A.getFullPath());
     CSQueue queueA = findQueue(rootQueue, A.getFullPath());
@@ -439,40 +439,40 @@ public class TestCapacitySchedulerQueues {
     CSQueue queueA2 = findQueue(queueA, A2.getFullPath());
     CSQueue queueA2 = findQueue(queueA, A2.getFullPath());
     CSQueue queueB2 = findQueue(queueB, B2.getFullPath());
     CSQueue queueB2 = findQueue(queueB, B2.getFullPath());
 
 
-    assertEquals("queue A1 max allocation MB", 4096,
-        queueA1.getMaximumAllocation().getMemorySize());
-    assertEquals("queue A1 max allocation vcores", 4,
-        queueA1.getMaximumAllocation().getVirtualCores());
-    assertEquals("queue A2 max allocation MB", 10240,
-        queueA2.getMaximumAllocation().getMemorySize());
-    assertEquals("queue A2 max allocation vcores", 10,
-        queueA2.getMaximumAllocation().getVirtualCores());
-    assertEquals("queue B2 max allocation MB", 10240,
-        queueB2.getMaximumAllocation().getMemorySize());
-    assertEquals("queue B2 max allocation vcores", 10,
-        queueB2.getMaximumAllocation().getVirtualCores());
+    assertEquals(4096, queueA1.getMaximumAllocation().getMemorySize(),
+        "queue A1 max allocation MB");
+    assertEquals(4, queueA1.getMaximumAllocation().getVirtualCores(),
+        "queue A1 max allocation vcores");
+    assertEquals(10240, queueA2.getMaximumAllocation().getMemorySize(),
+        "queue A2 max allocation MB");
+    assertEquals(10, queueA2.getMaximumAllocation().getVirtualCores(),
+        "queue A2 max allocation vcores");
+    assertEquals(10240, queueB2.getMaximumAllocation().getMemorySize(),
+        "queue B2 max allocation MB");
+    assertEquals(10, queueB2.getMaximumAllocation().getVirtualCores(),
+        "queue B2 max allocation vcores");
 
 
     setMaxAllocMb(conf, 12288);
     setMaxAllocMb(conf, 12288);
     setMaxAllocVcores(conf, 12);
     setMaxAllocVcores(conf, 12);
     cs.reinitialize(conf, null);
     cs.reinitialize(conf, null);
     // cluster level setting should change and any queues without
     // cluster level setting should change and any queues without
     // per queue setting
     // per queue setting
-    assertEquals("max allocation MB in CS", 12288,
-        cs.getMaximumResourceCapability().getMemorySize());
-    assertEquals("max allocation vcores in CS", 12,
-        cs.getMaximumResourceCapability().getVirtualCores());
-    assertEquals("queue A1 max MB allocation", 4096,
-        queueA1.getMaximumAllocation().getMemorySize());
-    assertEquals("queue A1 max vcores allocation", 4,
-        queueA1.getMaximumAllocation().getVirtualCores());
-    assertEquals("queue A2 max MB allocation", 12288,
-        queueA2.getMaximumAllocation().getMemorySize());
-    assertEquals("queue A2 max vcores allocation", 12,
-        queueA2.getMaximumAllocation().getVirtualCores());
-    assertEquals("queue B2 max MB allocation", 12288,
-        queueB2.getMaximumAllocation().getMemorySize());
-    assertEquals("queue B2 max vcores allocation", 12,
-        queueB2.getMaximumAllocation().getVirtualCores());
+    assertEquals(12288, cs.getMaximumResourceCapability().getMemorySize(),
+        "max allocation MB in CS");
+    assertEquals(12, cs.getMaximumResourceCapability().getVirtualCores(),
+        "max allocation vcores in CS");
+    assertEquals(4096, queueA1.getMaximumAllocation().getMemorySize(),
+        "queue A1 max MB allocation");
+    assertEquals(4, queueA1.getMaximumAllocation().getVirtualCores(),
+        "queue A1 max vcores allocation");
+    assertEquals(12288, queueA2.getMaximumAllocation().getMemorySize(),
+        "queue A2 max MB allocation");
+    assertEquals(12, queueA2.getMaximumAllocation().getVirtualCores(),
+        "queue A2 max vcores allocation");
+    assertEquals(12288, queueB2.getMaximumAllocation().getMemorySize(),
+        "queue B2 max MB allocation");
+    assertEquals(12, queueB2.getMaximumAllocation().getVirtualCores(),
+        "queue B2 max vcores allocation");
     cs.stop();
     cs.stop();
   }
   }
 
 
@@ -495,7 +495,7 @@ public class TestCapacitySchedulerQueues {
     Map<String, CSQueue> queues =
     Map<String, CSQueue> queues =
         cs.getCapacitySchedulerQueueManager().getShortNameQueues();
         cs.getCapacitySchedulerQueueManager().getShortNameQueues();
     String b1QTobeDeleted = "b1";
     String b1QTobeDeleted = "b1";
-    LeafQueue csB1Queue = Mockito.spy((LeafQueue) queues.get(b1QTobeDeleted));
+    LeafQueue csB1Queue = spy((LeafQueue) queues.get(b1QTobeDeleted));
     when(csB1Queue.getState()).thenReturn(QueueState.DRAINING)
     when(csB1Queue.getState()).thenReturn(QueueState.DRAINING)
         .thenReturn(QueueState.STOPPED);
         .thenReturn(QueueState.STOPPED);
     cs.getCapacitySchedulerQueueManager().addQueue(b1QTobeDeleted, csB1Queue);
     cs.getCapacitySchedulerQueueManager().addQueue(b1QTobeDeleted, csB1Queue);
@@ -525,7 +525,7 @@ public class TestCapacitySchedulerQueues {
     CSQueue rootQueue = cs.getRootQueue();
     CSQueue rootQueue = cs.getRootQueue();
     CSQueue queueB = findQueue(rootQueue, B.getFullPath());
     CSQueue queueB = findQueue(rootQueue, B.getFullPath());
     CSQueue queueB3 = findQueue(queueB, B1.getFullPath());
     CSQueue queueB3 = findQueue(queueB, B1.getFullPath());
-    assertNull("Refresh needs to support delete of leaf queue ", queueB3);
+    assertNull(queueB3, "Refresh needs to support delete of leaf queue ");
 
 
     // reset back to default configuration for testing parent queue delete
     // reset back to default configuration for testing parent queue delete
     conf = new CapacitySchedulerConfiguration();
     conf = new CapacitySchedulerConfiguration();
@@ -536,20 +536,20 @@ public class TestCapacitySchedulerQueues {
     // set the configurations such that it fails once but should be successfull
     // set the configurations such that it fails once but should be successfull
     // next time
     // next time
     queues = cs.getCapacitySchedulerQueueManager().getShortNameQueues();
     queues = cs.getCapacitySchedulerQueueManager().getShortNameQueues();
-    CSQueue bQueue = Mockito.spy((ParentQueue) queues.get("b"));
+    CSQueue bQueue = spy((ParentQueue) queues.get("b"));
     when(bQueue.getState()).thenReturn(QueueState.DRAINING)
     when(bQueue.getState()).thenReturn(QueueState.DRAINING)
         .thenReturn(QueueState.STOPPED);
         .thenReturn(QueueState.STOPPED);
     cs.getCapacitySchedulerQueueManager().addQueue("b", bQueue);
     cs.getCapacitySchedulerQueueManager().addQueue("b", bQueue);
 
 
-    bQueue = Mockito.spy((LeafQueue) queues.get("b1"));
+    bQueue = spy((LeafQueue) queues.get("b1"));
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     cs.getCapacitySchedulerQueueManager().addQueue("b1", bQueue);
     cs.getCapacitySchedulerQueueManager().addQueue("b1", bQueue);
 
 
-    bQueue = Mockito.spy((LeafQueue) queues.get("b2"));
+    bQueue = spy((LeafQueue) queues.get("b2"));
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     cs.getCapacitySchedulerQueueManager().addQueue("b2", bQueue);
     cs.getCapacitySchedulerQueueManager().addQueue("b2", bQueue);
 
 
-    bQueue = Mockito.spy((LeafQueue) queues.get("b3"));
+    bQueue = spy((LeafQueue) queues.get("b3"));
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     cs.getCapacitySchedulerQueueManager().addQueue("b3", bQueue);
     cs.getCapacitySchedulerQueueManager().addQueue("b3", bQueue);
 
 
@@ -577,13 +577,13 @@ public class TestCapacitySchedulerQueues {
     queueB = findQueue(rootQueue, B.getFullPath());
     queueB = findQueue(rootQueue, B.getFullPath());
     String message =
     String message =
         "Refresh needs to support delete of Parent queue and its children.";
         "Refresh needs to support delete of Parent queue and its children.";
-    assertNull(message, queueB);
-    assertNull(message,
-        cs.getCapacitySchedulerQueueManager().getQueues().get("b"));
-    assertNull(message,
-        cs.getCapacitySchedulerQueueManager().getQueues().get("b1"));
-    assertNull(message,
-        cs.getCapacitySchedulerQueueManager().getQueues().get("b2"));
+    assertNull(queueB, message);
+    assertNull(cs.getCapacitySchedulerQueueManager().getQueues().get("b"),
+        message);
+    assertNull(cs.getCapacitySchedulerQueueManager().getQueues().get("b1"),
+        message);
+    assertNull(cs.getCapacitySchedulerQueueManager().getQueues().get("b2"),
+        message);
 
 
     cs.stop();
     cs.stop();
   }
   }
@@ -607,16 +607,16 @@ public class TestCapacitySchedulerQueues {
     Map<String, CSQueue> queues =
     Map<String, CSQueue> queues =
         cs.getCapacitySchedulerQueueManager().getShortNameQueues();
         cs.getCapacitySchedulerQueueManager().getShortNameQueues();
 
 
-    CSQueue bQueue = Mockito.spy((LeafQueue) queues.get("b1"));
+    CSQueue bQueue = spy((LeafQueue) queues.get("b1"));
     when(bQueue.getState()).thenReturn(QueueState.RUNNING)
     when(bQueue.getState()).thenReturn(QueueState.RUNNING)
         .thenReturn(QueueState.STOPPED);
         .thenReturn(QueueState.STOPPED);
     cs.getCapacitySchedulerQueueManager().addQueue("b1", bQueue);
     cs.getCapacitySchedulerQueueManager().addQueue("b1", bQueue);
 
 
-    bQueue = Mockito.spy((LeafQueue) queues.get("b2"));
+    bQueue = spy((LeafQueue) queues.get("b2"));
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     cs.getCapacitySchedulerQueueManager().addQueue("b2", bQueue);
     cs.getCapacitySchedulerQueueManager().addQueue("b2", bQueue);
 
 
-    bQueue = Mockito.spy((LeafQueue) queues.get("b3"));
+    bQueue = spy((LeafQueue) queues.get("b3"));
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     when(bQueue.getState()).thenReturn(QueueState.STOPPED);
     cs.getCapacitySchedulerQueueManager().addQueue("b3", bQueue);
     cs.getCapacitySchedulerQueueManager().addQueue("b3", bQueue);
 
 
@@ -644,18 +644,18 @@ public class TestCapacitySchedulerQueues {
     }
     }
     CSQueue rootQueue = cs.getRootQueue();
     CSQueue rootQueue = cs.getRootQueue();
     CSQueue queueB = findQueue(rootQueue, B.getFullPath());
     CSQueue queueB = findQueue(rootQueue, B.getFullPath());
-    assertNotNull("Parent Queue B should not be deleted", queueB);
-    Assert.assertTrue("As Queue'B children are not deleted",
-        queueB instanceof LeafQueue);
+    assertNotNull(queueB, "Parent Queue B should not be deleted");
+    assertTrue(queueB instanceof LeafQueue,
+        "As Queue'B children are not deleted");
 
 
     String message =
     String message =
         "Refresh needs to support delete of all children of Parent queue.";
         "Refresh needs to support delete of all children of Parent queue.";
-    assertNull(message,
-        cs.getCapacitySchedulerQueueManager().getQueues().get("b3"));
-    assertNull(message,
-        cs.getCapacitySchedulerQueueManager().getQueues().get("b1"));
-    assertNull(message,
-        cs.getCapacitySchedulerQueueManager().getQueues().get("b2"));
+    assertNull(cs.getCapacitySchedulerQueueManager().getQueues().get("b3"),
+        message);
+    assertNull(cs.getCapacitySchedulerQueueManager().getQueues().get("b1"),
+        message);
+    assertNull(cs.getCapacitySchedulerQueueManager().getQueues().get("b2"),
+        message);
 
 
     cs.stop();
     cs.stop();
   }
   }
@@ -665,7 +665,8 @@ public class TestCapacitySchedulerQueues {
    *
    *
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testConvertLeafQueueToParentQueue() throws Exception {
   public void testConvertLeafQueueToParentQueue() throws Exception {
     CapacityScheduler cs = new CapacityScheduler();
     CapacityScheduler cs = new CapacityScheduler();
     cs.setConf(new YarnConfiguration());
     cs.setConf(new YarnConfiguration());
@@ -677,7 +678,7 @@ public class TestCapacitySchedulerQueues {
 
 
     String targetQueue = "b1";
     String targetQueue = "b1";
     CSQueue b1 = cs.getQueue(targetQueue);
     CSQueue b1 = cs.getQueue(targetQueue);
-    Assert.assertEquals(QueueState.RUNNING, b1.getState());
+    assertEquals(QueueState.RUNNING, b1.getState());
 
 
     // test if we can convert a leaf queue which is in RUNNING state
     // test if we can convert a leaf queue which is in RUNNING state
     conf = new CapacitySchedulerConfiguration();
     conf = new CapacitySchedulerConfiguration();
@@ -695,7 +696,7 @@ public class TestCapacitySchedulerQueues {
     setupQueueConfiguration(conf);
     setupQueueConfiguration(conf);
     conf.set("yarn.scheduler.capacity.root.b.b1.state", "STOPPED");
     conf.set("yarn.scheduler.capacity.root.b.b1.state", "STOPPED");
     cs.reinitialize(conf, rm.getRMContext());
     cs.reinitialize(conf, rm.getRMContext());
-    Assert.assertEquals(QueueState.STOPPED, b1.getState());
+    assertEquals(QueueState.STOPPED, b1.getState());
 
 
     // test if we can convert a leaf queue which is in STOPPED state
     // test if we can convert a leaf queue which is in STOPPED state
     conf = new CapacitySchedulerConfiguration();
     conf = new CapacitySchedulerConfiguration();
@@ -707,9 +708,9 @@ public class TestCapacitySchedulerQueues {
           + " to convert a leaf queue WITHOUT running apps");
           + " to convert a leaf queue WITHOUT running apps");
     }
     }
     b1 = cs.getQueue(targetQueue);
     b1 = cs.getQueue(targetQueue);
-    Assert.assertTrue(b1 instanceof AbstractParentQueue);
-    Assert.assertEquals(QueueState.RUNNING, b1.getState());
-    Assert.assertTrue(!b1.getChildQueues().isEmpty());
+    assertTrue(b1 instanceof AbstractParentQueue);
+    assertEquals(QueueState.RUNNING, b1.getState());
+    assertTrue(!b1.getChildQueues().isEmpty());
     cs.stop();
     cs.stop();
   }
   }
 
 
@@ -746,29 +747,26 @@ public class TestCapacitySchedulerQueues {
     CSQueue queueB1 = findQueue(queueB, B1.getFullPath());
     CSQueue queueB1 = findQueue(queueB, B1.getFullPath());
     CSQueue queueB2 = findQueue(queueB, B2.getFullPath());
     CSQueue queueB2 = findQueue(queueB, B2.getFullPath());
 
 
-    assertEquals("max capability MB in CS",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        cs.getMaximumResourceCapability().getMemorySize());
-    assertEquals("max capability vcores in CS",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
-        cs.getMaximumResourceCapability().getVirtualCores());
-    assertEquals("max allocation MB A1",
-        6144,
-        queueA1.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation vcores A1",
-        2,
-        queueA1.getMaximumAllocation().getVirtualCores());
-    assertEquals("max allocation MB A2", 4096,
-        queueA2.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation vcores A2",
-        2,
-        queueA2.getMaximumAllocation().getVirtualCores());
-    assertEquals("max allocation MB B", 5120,
-        queueB.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation MB B1", 5120,
-        queueB1.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation MB B2", 1024,
-        queueB2.getMaximumAllocation().getMemorySize());
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        cs.getMaximumResourceCapability().getMemorySize(),
+        "max capability MB in CS");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
+        cs.getMaximumResourceCapability().getVirtualCores(),
+        "max capability vcores in CS");
+    assertEquals(6144, queueA1.getMaximumAllocation().getMemorySize(),
+        "max allocation MB A1");
+    assertEquals(2, queueA1.getMaximumAllocation().getVirtualCores(),
+        "max allocation vcores A1");
+    assertEquals(4096, queueA2.getMaximumAllocation().getMemorySize(),
+        "max allocation MB A2");
+    assertEquals(2, queueA2.getMaximumAllocation().getVirtualCores(),
+        "max allocation vcores A2");
+    assertEquals(5120, queueB.getMaximumAllocation().getMemorySize(),
+        "max allocation MB B");
+    assertEquals(5120, queueB1.getMaximumAllocation().getMemorySize(),
+        "max allocation MB B1");
+    assertEquals(1024, queueB2.getMaximumAllocation().getMemorySize(),
+        "max allocation MB B2");
 
 
     // Test get the max-allocation from different parent
     // Test get the max-allocation from different parent
     unsetMaxAllocation(conf, A1);
     unsetMaxAllocation(conf, A1);
@@ -780,24 +778,20 @@ public class TestCapacitySchedulerQueues {
 
 
     cs.reinitialize(conf, rm.getRMContext());
     cs.reinitialize(conf, rm.getRMContext());
 
 
-    assertEquals("max capability MB in CS",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        cs.getMaximumResourceCapability().getMemorySize());
-    assertEquals("max capability vcores in CS",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
-        cs.getMaximumResourceCapability().getVirtualCores());
-    assertEquals("max allocation MB A1",
-        8192,
-        queueA1.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation vcores A1",
-        2,
-        queueA1.getMaximumAllocation().getVirtualCores());
-    assertEquals("max allocation MB B1",
-        6144,
-        queueB1.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation vcores B1",
-        2,
-        queueB1.getMaximumAllocation().getVirtualCores());
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        cs.getMaximumResourceCapability().getMemorySize(),
+        "max capability MB in CS");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
+        cs.getMaximumResourceCapability().getVirtualCores(),
+        "max capability vcores in CS");
+    assertEquals(8192, queueA1.getMaximumAllocation().getMemorySize(),
+        "max allocation MB A1");
+    assertEquals(2, queueA1.getMaximumAllocation().getVirtualCores(),
+        "max allocation vcores A1");
+    assertEquals(6144, queueB1.getMaximumAllocation().getMemorySize(),
+        "max allocation MB B1");
+    assertEquals(2, queueB1.getMaximumAllocation().getVirtualCores(),
+        "max allocation vcores B1");
 
 
     // Test the default
     // Test the default
     unsetMaxAllocation(conf, ROOT);
     unsetMaxAllocation(conf, ROOT);
@@ -805,24 +799,22 @@ public class TestCapacitySchedulerQueues {
     unsetMaxAllocation(conf, A1);
     unsetMaxAllocation(conf, A1);
     cs.reinitialize(conf, rm.getRMContext());
     cs.reinitialize(conf, rm.getRMContext());
 
 
-    assertEquals("max capability MB in CS",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        cs.getMaximumResourceCapability().getMemorySize());
-    assertEquals("max capability vcores in CS",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
-        cs.getMaximumResourceCapability().getVirtualCores());
-    assertEquals("max allocation MB A1",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        queueA1.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation vcores A1",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
-        queueA1.getMaximumAllocation().getVirtualCores());
-    assertEquals("max allocation MB A2",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
-        queueA2.getMaximumAllocation().getMemorySize());
-    assertEquals("max allocation vcores A2",
-        YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
-        queueA2.getMaximumAllocation().getVirtualCores());
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        cs.getMaximumResourceCapability().getMemorySize(),
+        "max capability MB in CS");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
+        cs.getMaximumResourceCapability().getVirtualCores(),
+        "max capability vcores in CS");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        queueA1.getMaximumAllocation().getMemorySize(), "max allocation MB A1");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
+        queueA1.getMaximumAllocation().getVirtualCores(),
+        "max allocation vcores A1");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
+        queueA2.getMaximumAllocation().getMemorySize(), "max allocation MB A2");
+    assertEquals(YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
+        queueA2.getMaximumAllocation().getVirtualCores(),
+        "max allocation vcores A2");
     cs.stop();
     cs.stop();
   }
   }
 
 
@@ -854,8 +846,8 @@ public class TestCapacitySchedulerQueues {
       cs.reinitialize(conf, rm.getRMContext());
       cs.reinitialize(conf, rm.getRMContext());
       fail("Queue Root maximum allocation can't exceed the cluster setting");
       fail("Queue Root maximum allocation can't exceed the cluster setting");
     } catch (Exception e) {
     } catch (Exception e) {
-      assertTrue("maximum allocation exception",
-          e.getCause().getMessage().contains("maximum allocation"));
+      assertTrue(e.getCause().getMessage().contains("maximum allocation"),
+          "maximum allocation exception");
     }
     }
 
 
     setMaxAllocation(conf, ROOT,
     setMaxAllocation(conf, ROOT,
@@ -866,16 +858,16 @@ public class TestCapacitySchedulerQueues {
       cs.reinitialize(conf, rm.getRMContext());
       cs.reinitialize(conf, rm.getRMContext());
       fail("Queue A1 maximum allocation can't exceed the cluster setting");
       fail("Queue A1 maximum allocation can't exceed the cluster setting");
     } catch (Exception e) {
     } catch (Exception e) {
-      assertTrue("maximum allocation exception",
-          e.getCause().getMessage().contains("maximum allocation"));
+      assertTrue(e.getCause().getMessage().contains("maximum allocation"),
+          "maximum allocation exception");
     }
     }
     setMaxAllocation(conf, A1, "memory-mb=8192" + ",vcores=" + largerVcores);
     setMaxAllocation(conf, A1, "memory-mb=8192" + ",vcores=" + largerVcores);
     try {
     try {
       cs.reinitialize(conf, rm.getRMContext());
       cs.reinitialize(conf, rm.getRMContext());
       fail("Queue A1 maximum allocation can't exceed the cluster setting");
       fail("Queue A1 maximum allocation can't exceed the cluster setting");
     } catch (Exception e) {
     } catch (Exception e) {
-      assertTrue("maximum allocation exception",
-          e.getCause().getMessage().contains("maximum allocation"));
+      assertTrue(e.getCause().getMessage().contains("maximum allocation"),
+          "maximum allocation exception");
     }
     }
     cs.stop();
     cs.stop();
   }
   }

+ 1 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerSchedulingRequestUpdate.java

@@ -42,7 +42,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptRemovedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptRemovedSchedulerEvent;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 
 

+ 73 - 66
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerSurgicalPreemption.java

@@ -44,10 +44,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -56,7 +55,10 @@ import java.util.List;
 import java.util.Set;
 import java.util.Set;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.PREFIX;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.PREFIX;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 public class TestCapacitySchedulerSurgicalPreemption
 public class TestCapacitySchedulerSurgicalPreemption
     extends CapacitySchedulerPreemptionTestBase {
     extends CapacitySchedulerPreemptionTestBase {
@@ -74,7 +76,7 @@ public class TestCapacitySchedulerSurgicalPreemption
       ".d");
       ".d");
 
 
   @Override
   @Override
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     super.setUp();
     super.setUp();
     conf.setBoolean(
     conf.setBoolean(
@@ -82,7 +84,8 @@ public class TestCapacitySchedulerSurgicalPreemption
         true);
         true);
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testSimpleSurgicalPreemption()
   public void testSimpleSurgicalPreemption()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -156,7 +159,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     // App1 should have 33 containers now
     // App1 should have 33 containers now
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(33, schedulerApp1.getLiveContainers().size());
+    assertEquals(33, schedulerApp1.getLiveContainers().size());
     // 17 from n1 and 16 from n2
     // 17 from n1 and 16 from n2
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
         am1.getApplicationAttemptId(), 17);
         am1.getApplicationAttemptId(), 17);
@@ -177,9 +180,9 @@ public class TestCapacitySchedulerSurgicalPreemption
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1);
     MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1);
 
 
     // NM1/NM2 has available resource = 2G/4G
     // NM1/NM2 has available resource = 2G/4G
-    Assert.assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertEquals(4 * GB, cs.getNode(nm2.getNodeId())
+    assertEquals(4 * GB, cs.getNode(nm2.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
 
 
     // AM asks for a 1 * GB container
     // AM asks for a 1 * GB container
@@ -189,7 +192,7 @@ public class TestCapacitySchedulerSurgicalPreemption
 
 
     // Call allocation once on n1, we should expect the container reserved on n1
     // Call allocation once on n1, we should expect the container reserved on n1
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
 
 
     // Get edit policy and do one update
     // Get edit policy and do one update
     SchedulingMonitorManager smm = ((CapacityScheduler) rm1.
     SchedulingMonitorManager smm = ((CapacityScheduler) rm1.
@@ -211,20 +214,20 @@ public class TestCapacitySchedulerSurgicalPreemption
         am1.getApplicationAttemptId(), 16);
         am1.getApplicationAttemptId(), 16);
 
 
     // Ensure preemption metrics were recored.
     // Ensure preemption metrics were recored.
-    Assert.assertEquals("Number of preempted containers incorrectly recorded:",
-        4, cs.getQueue("root").getMetrics().getAggregatePreemptedContainers());
+    assertEquals(4, cs.getQueue("root").getMetrics().getAggregatePreemptedContainers(),
+        "Number of preempted containers incorrectly recorded:");
 
 
-    Assert.assertEquals("Amount of preempted memory incorrectly recorded:",
-        4 * GB,
-        cs.getQueue("root").getMetrics().getAggregateMemoryMBPreempted());
+    assertEquals(4 * GB, cs.getQueue("root").getMetrics().getAggregateMemoryMBPreempted(),
+        "Amount of preempted memory incorrectly recorded:");
 
 
-    Assert.assertEquals("Number of preempted vcores incorrectly recorded:", 4,
-        cs.getQueue("root").getMetrics().getAggregateVcoresPreempted());
+    assertEquals(4, cs.getQueue("root").getMetrics().getAggregateVcoresPreempted(),
+        "Number of preempted vcores incorrectly recorded:");
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testSurgicalPreemptionWithAvailableResource()
   public void testSurgicalPreemptionWithAvailableResource()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -280,7 +283,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     // App1 should have 31 containers now
     // App1 should have 31 containers now
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(39, schedulerApp1.getLiveContainers().size());
+    assertEquals(39, schedulerApp1.getLiveContainers().size());
     // 17 from n1 and 16 from n2
     // 17 from n1 and 16 from n2
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
         am1.getApplicationAttemptId(), 20);
         am1.getApplicationAttemptId(), 20);
@@ -308,7 +311,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     ProportionalCapacityPreemptionPolicy editPolicy =
     ProportionalCapacityPreemptionPolicy editPolicy =
         (ProportionalCapacityPreemptionPolicy) smon.getSchedulingEditPolicy();
         (ProportionalCapacityPreemptionPolicy) smon.getSchedulingEditPolicy();
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(3, editPolicy.getToPreemptContainers().size());
+    assertEquals(3, editPolicy.getToPreemptContainers().size());
 
 
     // Call editSchedule again: selected containers are killed
     // Call editSchedule again: selected containers are killed
     editPolicy.editSchedule();
     editPolicy.editSchedule();
@@ -335,7 +338,8 @@ public class TestCapacitySchedulerSurgicalPreemption
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testPriorityPreemptionWhenAllQueuesAreBelowGuaranteedCapacities()
   public void testPriorityPreemptionWhenAllQueuesAreBelowGuaranteedCapacities()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -401,7 +405,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     // 7 / 40 = 17.5% < 20% (guaranteed)
     // 7 / 40 = 17.5% < 20% (guaranteed)
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(7, schedulerApp1.getLiveContainers().size());
+    assertEquals(7, schedulerApp1.getLiveContainers().size());
     // 4 from n1 and 3 from n2
     // 4 from n1 and 3 from n2
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
         am1.getApplicationAttemptId(), 4);
         am1.getApplicationAttemptId(), 4);
@@ -433,12 +437,12 @@ public class TestCapacitySchedulerSurgicalPreemption
     ProportionalCapacityPreemptionPolicy editPolicy =
     ProportionalCapacityPreemptionPolicy editPolicy =
         (ProportionalCapacityPreemptionPolicy) smon.getSchedulingEditPolicy();
         (ProportionalCapacityPreemptionPolicy) smon.getSchedulingEditPolicy();
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(0, editPolicy.getToPreemptContainers().size());
+    assertEquals(0, editPolicy.getToPreemptContainers().size());
 
 
     // Sleep the timeout interval, we should be able to see containers selected
     // Sleep the timeout interval, we should be able to see containers selected
     Thread.sleep(1000);
     Thread.sleep(1000);
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(2, editPolicy.getToPreemptContainers().size());
+    assertEquals(2, editPolicy.getToPreemptContainers().size());
 
 
     // Call editSchedule again: selected containers are killed, and new AM
     // Call editSchedule again: selected containers are killed, and new AM
     // container launched
     // container launched
@@ -455,7 +459,8 @@ public class TestCapacitySchedulerSurgicalPreemption
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testPriorityPreemptionRequiresMoveReservation()
   public void testPriorityPreemptionRequiresMoveReservation()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -524,7 +529,7 @@ public class TestCapacitySchedulerSurgicalPreemption
 
 
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
 
 
     // 1 from n1 and 2 from n2
     // 1 from n1 and 2 from n2
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
@@ -553,7 +558,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     cs.handle(new NodeUpdateSchedulerEvent(rmNode3));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode3));
 
 
     // Make sure container reserved on node3
     // Make sure container reserved on node3
-    Assert.assertNotNull(
+    assertNotNull(
         cs.getNode(rmNode3.getNodeID()).getReservedContainer());
         cs.getNode(rmNode3.getNodeID()).getReservedContainer());
 
 
     // Call editSchedule immediately: nothing happens
     // Call editSchedule immediately: nothing happens
@@ -563,23 +568,23 @@ public class TestCapacitySchedulerSurgicalPreemption
     ProportionalCapacityPreemptionPolicy editPolicy =
     ProportionalCapacityPreemptionPolicy editPolicy =
         (ProportionalCapacityPreemptionPolicy) smon.getSchedulingEditPolicy();
         (ProportionalCapacityPreemptionPolicy) smon.getSchedulingEditPolicy();
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertNotNull(
+    assertNotNull(
         cs.getNode(rmNode3.getNodeID()).getReservedContainer());
         cs.getNode(rmNode3.getNodeID()).getReservedContainer());
 
 
     // Sleep the timeout interval, we should be able to see reserved container
     // Sleep the timeout interval, we should be able to see reserved container
     // moved to n2 (n1 occupied by AM)
     // moved to n2 (n1 occupied by AM)
     Thread.sleep(1000);
     Thread.sleep(1000);
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertNull(
+    assertNull(
         cs.getNode(rmNode3.getNodeID()).getReservedContainer());
         cs.getNode(rmNode3.getNodeID()).getReservedContainer());
-    Assert.assertNotNull(
+    assertNotNull(
         cs.getNode(rmNode2.getNodeID()).getReservedContainer());
         cs.getNode(rmNode2.getNodeID()).getReservedContainer());
-    Assert.assertEquals(am2.getApplicationAttemptId(), cs.getNode(
+    assertEquals(am2.getApplicationAttemptId(), cs.getNode(
         rmNode2.getNodeID()).getReservedContainer().getApplicationAttemptId());
         rmNode2.getNodeID()).getReservedContainer().getApplicationAttemptId());
 
 
     // Do it again, we should see containers marked to be preempt
     // Do it again, we should see containers marked to be preempt
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(2, editPolicy.getToPreemptContainers().size());
+    assertEquals(2, editPolicy.getToPreemptContainers().size());
 
 
     // Call editSchedule again: selected containers are killed
     // Call editSchedule again: selected containers are killed
     editPolicy.editSchedule();
     editPolicy.editSchedule();
@@ -595,7 +600,8 @@ public class TestCapacitySchedulerSurgicalPreemption
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testPriorityPreemptionOnlyTriggeredWhenDemandingQueueUnsatisfied()
   public void testPriorityPreemptionOnlyTriggeredWhenDemandingQueueUnsatisfied()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -665,7 +671,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     // App1 should have 9 containers now, so the abs-used-cap of b is 9%
     // App1 should have 9 containers now, so the abs-used-cap of b is 9%
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(9, schedulerApp1.getLiveContainers().size());
+    assertEquals(9, schedulerApp1.getLiveContainers().size());
     for (int i = 0; i < 9; i++) {
     for (int i = 0; i < 9; i++) {
       waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNodes[i].getNodeID()),
       waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNodes[i].getNodeID()),
           am1.getApplicationAttemptId(), 1);
           am1.getApplicationAttemptId(), 1);
@@ -696,8 +702,8 @@ public class TestCapacitySchedulerSurgicalPreemption
 
 
     // Check am2 reserved resource from nm1-nm9
     // Check am2 reserved resource from nm1-nm9
     for (int i = 1; i < 9; i++) {
     for (int i = 1; i < 9; i++) {
-      Assert.assertNotNull("Should reserve on nm-" + i,
-          cs.getNode(rmNodes[i].getNodeID()).getReservedContainer());
+      assertNotNull(cs.getNode(rmNodes[i].getNodeID()).getReservedContainer(),
+          "Should reserve on nm-" + i);
     }
     }
 
 
     // Sleep the timeout interval, we should be able to see 6 containers selected
     // Sleep the timeout interval, we should be able to see 6 containers selected
@@ -728,7 +734,8 @@ public class TestCapacitySchedulerSurgicalPreemption
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 600000)
+  @Test
+  @Timeout(value = 600)
   public void testPriorityPreemptionFromHighestPriorityQueueAndOldestContainer()
   public void testPriorityPreemptionFromHighestPriorityQueueAndOldestContainer()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -825,7 +832,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     // App1 should have 5 containers now, one for each node
     // App1 should have 5 containers now, one for each node
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(5, schedulerApp1.getLiveContainers().size());
+    assertEquals(5, schedulerApp1.getLiveContainers().size());
     for (int i = 0; i < 5; i++) {
     for (int i = 0; i < 5; i++) {
       waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNodes[i].getNodeID()),
       waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNodes[i].getNodeID()),
           am1.getApplicationAttemptId(), 1);
           am1.getApplicationAttemptId(), 1);
@@ -855,9 +862,9 @@ public class TestCapacitySchedulerSurgicalPreemption
 
 
     // Check am2 reserved resource from nm0-nm1
     // Check am2 reserved resource from nm0-nm1
     for (int i = 0; i < 2; i++) {
     for (int i = 0; i < 2; i++) {
-      Assert.assertNotNull("Should reserve on nm-" + i,
-          cs.getNode(rmNodes[i].getNodeID()).getReservedContainer());
-      Assert.assertEquals(cs.getNode(rmNodes[i].getNodeID())
+      assertNotNull(cs.getNode(rmNodes[i].getNodeID()).getReservedContainer(),
+          "Should reserve on nm-" + i);
+      assertEquals(cs.getNode(rmNodes[i].getNodeID())
           .getReservedContainer()
           .getReservedContainer()
           .getQueueName(), cs.normalizeQueueName(queues[0]));
           .getQueueName(), cs.normalizeQueueName(queues[0]));
     }
     }
@@ -886,9 +893,9 @@ public class TestCapacitySchedulerSurgicalPreemption
 
 
     // Check am2 reserved resource from nm2-nm3
     // Check am2 reserved resource from nm2-nm3
     for (int i = 2; i < 4; i++) {
     for (int i = 2; i < 4; i++) {
-      Assert.assertNotNull("Should reserve on nm-" + i,
-          cs.getNode(rmNodes[i].getNodeID()).getReservedContainer());
-      Assert.assertEquals(cs.getNode(rmNodes[i].getNodeID())
+      assertNotNull(cs.getNode(rmNodes[i].getNodeID()).getReservedContainer(),
+          "Should reserve on nm-" + i);
+      assertEquals(cs.getNode(rmNodes[i].getNodeID())
           .getReservedContainer()
           .getReservedContainer()
           .getQueueName(), cs.normalizeQueueName(queues[1]));
           .getQueueName(), cs.normalizeQueueName(queues[1]));
     }
     }
@@ -907,8 +914,8 @@ public class TestCapacitySchedulerSurgicalPreemption
     // We should have one to-preempt container, on node[2]
     // We should have one to-preempt container, on node[2]
     Set<RMContainer> selectedToPreempt =
     Set<RMContainer> selectedToPreempt =
         editPolicy.getToPreemptContainers().keySet();
         editPolicy.getToPreemptContainers().keySet();
-    Assert.assertEquals(1, selectedToPreempt.size());
-    Assert.assertEquals(mockNMs[2].getNodeId(),
+    assertEquals(1, selectedToPreempt.size());
+    assertEquals(mockNMs[2].getNodeId(),
         selectedToPreempt.iterator().next().getAllocatedNode());
         selectedToPreempt.iterator().next().getAllocatedNode());
 
 
     // Call editSchedule again: selected containers are killed
     // Call editSchedule again: selected containers are killed
@@ -930,8 +937,8 @@ public class TestCapacitySchedulerSurgicalPreemption
     // We should have one to-preempt container, on node[3]
     // We should have one to-preempt container, on node[3]
     selectedToPreempt =
     selectedToPreempt =
         editPolicy.getToPreemptContainers().keySet();
         editPolicy.getToPreemptContainers().keySet();
-    Assert.assertEquals(1, selectedToPreempt.size());
-    Assert.assertEquals(mockNMs[3].getNodeId(),
+    assertEquals(1, selectedToPreempt.size());
+    assertEquals(mockNMs[3].getNodeId(),
         selectedToPreempt.iterator().next().getAllocatedNode());
         selectedToPreempt.iterator().next().getAllocatedNode());
 
 
     // Call editSchedule again: selected containers are killed
     // Call editSchedule again: selected containers are killed
@@ -953,8 +960,8 @@ public class TestCapacitySchedulerSurgicalPreemption
     // We should have one to-preempt container, on node[0]
     // We should have one to-preempt container, on node[0]
     selectedToPreempt =
     selectedToPreempt =
         editPolicy.getToPreemptContainers().keySet();
         editPolicy.getToPreemptContainers().keySet();
-    Assert.assertEquals(1, selectedToPreempt.size());
-    Assert.assertEquals(mockNMs[0].getNodeId(),
+    assertEquals(1, selectedToPreempt.size());
+    assertEquals(mockNMs[0].getNodeId(),
         selectedToPreempt.iterator().next().getAllocatedNode());
         selectedToPreempt.iterator().next().getAllocatedNode());
 
 
     // Call editSchedule again: selected containers are killed
     // Call editSchedule again: selected containers are killed
@@ -976,8 +983,8 @@ public class TestCapacitySchedulerSurgicalPreemption
     // We should have one to-preempt container, on node[0]
     // We should have one to-preempt container, on node[0]
     selectedToPreempt =
     selectedToPreempt =
         editPolicy.getToPreemptContainers().keySet();
         editPolicy.getToPreemptContainers().keySet();
-    Assert.assertEquals(1, selectedToPreempt.size());
-    Assert.assertEquals(mockNMs[1].getNodeId(),
+    assertEquals(1, selectedToPreempt.size());
+    assertEquals(mockNMs[1].getNodeId(),
         selectedToPreempt.iterator().next().getAllocatedNode());
         selectedToPreempt.iterator().next().getAllocatedNode());
 
 
     // Call editSchedule again: selected containers are killed
     // Call editSchedule again: selected containers are killed
@@ -1085,7 +1092,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     // App1 should have 5 containers now, one for each node
     // App1 should have 5 containers now, one for each node
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(NUM_NM, schedulerApp1.getLiveContainers().size());
+    assertEquals(NUM_NM, schedulerApp1.getLiveContainers().size());
     for (int i = 0; i < NUM_NM; i++) {
     for (int i = 0; i < NUM_NM; i++) {
       waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(
       waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(
           rmNodes[i].getNodeID()), am1.getApplicationAttemptId(), 1);
           rmNodes[i].getNodeID()), am1.getApplicationAttemptId(), 1);
@@ -1151,19 +1158,18 @@ public class TestCapacitySchedulerSurgicalPreemption
     // We should only allow to preempt 2 containers, on node1 and node2
     // We should only allow to preempt 2 containers, on node1 and node2
     Set<RMContainer> selectedToPreempt =
     Set<RMContainer> selectedToPreempt =
         editPolicy.getToPreemptContainers().keySet();
         editPolicy.getToPreemptContainers().keySet();
-    Assert.assertEquals(2, selectedToPreempt.size());
+    assertEquals(2, selectedToPreempt.size());
     List<NodeId> selectedToPreemptNodeIds = new ArrayList<>();
     List<NodeId> selectedToPreemptNodeIds = new ArrayList<>();
     for (RMContainer rmc : selectedToPreempt) {
     for (RMContainer rmc : selectedToPreempt) {
       selectedToPreemptNodeIds.add(rmc.getAllocatedNode());
       selectedToPreemptNodeIds.add(rmc.getAllocatedNode());
     }
     }
-    assertThat(selectedToPreemptNodeIds, CoreMatchers.hasItems(
-        mockNMs[1].getNodeId(), mockNMs[2].getNodeId()));
-
+    assertThat(selectedToPreemptNodeIds).contains(mockNMs[1].getNodeId(), mockNMs[2].getNodeId());
     rm1.close();
     rm1.close();
 
 
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testPreemptionForFragmentatedCluster() throws Exception {
   public void testPreemptionForFragmentatedCluster() throws Exception {
     // Set additional_balance_queue_based_on_reserved_res to true to get
     // Set additional_balance_queue_based_on_reserved_res to true to get
     // additional preemptions.
     // additional preemptions.
@@ -1224,7 +1230,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     // App1 should have 5 containers now
     // App1 should have 5 containers now
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(5, schedulerApp1.getLiveContainers().size());
+    assertEquals(5, schedulerApp1.getLiveContainers().size());
 
 
     // launch an app to queue, AM container should be launched in nm1
     // launch an app to queue, AM container should be launched in nm1
     MockRMAppSubmissionData data =
     MockRMAppSubmissionData data =
@@ -1250,7 +1256,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     // App2 should have 2 containers now
     // App2 should have 2 containers now
     FiCaSchedulerApp schedulerApp2 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp2 = cs.getApplicationAttempt(
         am2.getApplicationAttemptId());
         am2.getApplicationAttemptId());
-    Assert.assertEquals(2, schedulerApp2.getLiveContainers().size());
+    assertEquals(2, schedulerApp2.getLiveContainers().size());
 
 
     waitNumberOfReservedContainersFromApp(schedulerApp2, 1);
     waitNumberOfReservedContainersFromApp(schedulerApp2, 1);
 
 
@@ -1274,12 +1280,13 @@ public class TestCapacitySchedulerSurgicalPreemption
       tick++;
       tick++;
       Thread.sleep(100);
       Thread.sleep(100);
     }
     }
-    Assert.assertEquals(3, schedulerApp2.getLiveContainers().size());
+    assertEquals(3, schedulerApp2.getLiveContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 600000)
+  @Test
+  @Timeout(value = 600)
   public void testPreemptionToBalanceWithCustomTimeout() throws Exception {
   public void testPreemptionToBalanceWithCustomTimeout() throws Exception {
     /**
     /**
      * Test case: Submit two application (app1/app2) to different queues, queue
      * Test case: Submit two application (app1/app2) to different queues, queue
@@ -1345,7 +1352,7 @@ public class TestCapacitySchedulerSurgicalPreemption
     // App1 should have 39 containers now
     // App1 should have 39 containers now
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(
         am1.getApplicationAttemptId());
         am1.getApplicationAttemptId());
-    Assert.assertEquals(39, schedulerApp1.getLiveContainers().size());
+    assertEquals(39, schedulerApp1.getLiveContainers().size());
     // 20 from n1 and 19 from n2
     // 20 from n1 and 19 from n2
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
     waitNumberOfLiveContainersOnNodeFromApp(cs.getNode(rmNode1.getNodeID()),
         am1.getApplicationAttemptId(), 20);
         am1.getApplicationAttemptId(), 20);
@@ -1373,10 +1380,10 @@ public class TestCapacitySchedulerSurgicalPreemption
     ProportionalCapacityPreemptionPolicy editPolicy =
     ProportionalCapacityPreemptionPolicy editPolicy =
         (ProportionalCapacityPreemptionPolicy) smon.getSchedulingEditPolicy();
         (ProportionalCapacityPreemptionPolicy) smon.getSchedulingEditPolicy();
     editPolicy.editSchedule();
     editPolicy.editSchedule();
-    Assert.assertEquals(4, editPolicy.getToPreemptContainers().size());
+    assertEquals(4, editPolicy.getToPreemptContainers().size());
 
 
     // check live containers immediately, nothing happen
     // check live containers immediately, nothing happen
-    Assert.assertEquals(39, schedulerApp1.getLiveContainers().size());
+    assertEquals(39, schedulerApp1.getLiveContainers().size());
 
 
     Thread.sleep(20*1000);
     Thread.sleep(20*1000);
     // Call editSchedule again: selected containers are killed
     // Call editSchedule again: selected containers are killed

+ 40 - 29
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerWeightMode.java

@@ -43,14 +43,20 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Set;
 import java.util.Set;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
 public class TestCapacitySchedulerWeightMode {
 public class TestCapacitySchedulerWeightMode {
   private static final String DEFAULT_PATH = CapacitySchedulerConfiguration.ROOT + ".default";
   private static final String DEFAULT_PATH = CapacitySchedulerConfiguration.ROOT + ".default";
   private static final String A_PATH = CapacitySchedulerConfiguration.ROOT + ".a";
   private static final String A_PATH = CapacitySchedulerConfiguration.ROOT + ".a";
@@ -70,7 +76,7 @@ public class TestCapacitySchedulerWeightMode {
 
 
   RMNodeLabelsManager mgr;
   RMNodeLabelsManager mgr;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -287,7 +293,8 @@ public class TestCapacitySchedulerWeightMode {
    * The only difference is, instead of using label, it uses weight mode
    * The only difference is, instead of using label, it uses weight mode
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testContainerAllocateWithComplexLabelsWeightOnly() throws Exception {
   public void testContainerAllocateWithComplexLabelsWeightOnly() throws Exception {
     internalTestContainerAllocationWithNodeLabel(
     internalTestContainerAllocationWithNodeLabel(
         getCSConfWithQueueLabelsWeightOnly(conf));
         getCSConfWithQueueLabelsWeightOnly(conf));
@@ -300,7 +307,8 @@ public class TestCapacitySchedulerWeightMode {
    * Parent uses weight, child uses percent
    * Parent uses weight, child uses percent
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testContainerAllocateWithComplexLabelsWeightAndPercentMixed1() throws Exception {
   public void testContainerAllocateWithComplexLabelsWeightAndPercentMixed1() throws Exception {
     internalTestContainerAllocationWithNodeLabel(
     internalTestContainerAllocationWithNodeLabel(
         getCSConfWithLabelsParentUseWeightChildUsePct(conf));
         getCSConfWithLabelsParentUseWeightChildUsePct(conf));
@@ -313,7 +321,8 @@ public class TestCapacitySchedulerWeightMode {
    * Parent uses percent, child uses weight
    * Parent uses percent, child uses weight
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testContainerAllocateWithComplexLabelsWeightAndPercentMixed2() throws Exception {
   public void testContainerAllocateWithComplexLabelsWeightAndPercentMixed2() throws Exception {
     internalTestContainerAllocationWithNodeLabel(
     internalTestContainerAllocationWithNodeLabel(
         getCSConfWithLabelsParentUsePctChildUseWeight(conf));
         getCSConfWithLabelsParentUsePctChildUseWeight(conf));
@@ -323,7 +332,8 @@ public class TestCapacitySchedulerWeightMode {
    * This checks whether the parent prints the correct log about the
    * This checks whether the parent prints the correct log about the
    * configured mode.
    * configured mode.
    */
    */
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testGetCapacityOrWeightStringUsingWeights() throws IOException {
   public void testGetCapacityOrWeightStringUsingWeights() throws IOException {
     try (MockRM rm = new MockRM(
     try (MockRM rm = new MockRM(
         getCSConfWithQueueLabelsWeightOnly(conf))) {
         getCSConfWithQueueLabelsWeightOnly(conf))) {
@@ -348,7 +358,8 @@ public class TestCapacitySchedulerWeightMode {
    * This checks whether the parent prints the correct log about the
    * This checks whether the parent prints the correct log about the
    * configured mode.
    * configured mode.
    */
    */
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testGetCapacityOrWeightStringParentPctLeafWeights()
   public void testGetCapacityOrWeightStringParentPctLeafWeights()
       throws IOException {
       throws IOException {
     try (MockRM rm = new MockRM(
     try (MockRM rm = new MockRM(
@@ -389,13 +400,13 @@ public class TestCapacitySchedulerWeightMode {
         (CapacityScheduler) rm.getRMContext().getScheduler();
         (CapacityScheduler) rm.getRMContext().getScheduler();
     LeafQueue b1 = (LeafQueue) cs.getQueue(B1.getFullPath());
     LeafQueue b1 = (LeafQueue) cs.getQueue(B1.getFullPath());
 
 
-    Assert.assertNotNull(b1);
-    Assert.assertTrue(b1.getAccessibleNodeLabels().isEmpty());
+    assertNotNull(b1);
+    assertTrue(b1.getAccessibleNodeLabels().isEmpty());
 
 
     Set<String> b1ExistingNodeLabels = ((CSQueue) b1).getQueueCapacities()
     Set<String> b1ExistingNodeLabels = ((CSQueue) b1).getQueueCapacities()
         .getExistingNodeLabels();
         .getExistingNodeLabels();
-    Assert.assertEquals(1, b1ExistingNodeLabels.size());
-    Assert.assertEquals("", b1ExistingNodeLabels.iterator().next());
+    assertEquals(1, b1ExistingNodeLabels.size());
+    assertEquals("", b1ExistingNodeLabels.iterator().next());
 
 
     rm.close();
     rm.close();
   }
   }
@@ -418,7 +429,7 @@ public class TestCapacitySchedulerWeightMode {
     try {
     try {
       cs.reinitialize(newConf, rm.getRMContext());
       cs.reinitialize(newConf, rm.getRMContext());
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.fail("Reinitialization failed with " + e);
+      fail("Reinitialization failed with " + e);
     }
     }
   }
   }
 
 
@@ -443,15 +454,15 @@ public class TestCapacitySchedulerWeightMode {
 
 
     LeafQueue a = (LeafQueue)
     LeafQueue a = (LeafQueue)
         cs.getQueue("root.a");
         cs.getQueue("root.a");
-    Assert.assertNotNull(a);
-    Assert.assertEquals(a.getQueueCapacities().getWeight(),
+    assertNotNull(a);
+    assertEquals(a.getQueueCapacities().getWeight(),
         a.getQueueInfo(false,
         a.getQueueInfo(false,
         false).getWeight(), 1e-6);
         false).getWeight(), 1e-6);
 
 
     LeafQueue b = (LeafQueue)
     LeafQueue b = (LeafQueue)
         cs.getQueue("root.b");
         cs.getQueue("root.b");
-    Assert.assertNotNull(b);
-    Assert.assertEquals(b.getQueueCapacities().getWeight(),
+    assertNotNull(b);
+    assertEquals(b.getQueueCapacities().getWeight(),
         b.getQueueInfo(false,
         b.getQueueInfo(false,
         false).getWeight(), 1e-6);
         false).getWeight(), 1e-6);
     rm.close();
     rm.close();
@@ -534,7 +545,7 @@ public class TestCapacitySchedulerWeightMode {
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     containerId =
     containerId =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2L);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2L);
-    Assert.assertTrue(rm1.waitForState(nm2, containerId,
+    assertTrue(rm1.waitForState(nm2, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
         "h2");
         "h2");
@@ -557,9 +568,9 @@ public class TestCapacitySchedulerWeightMode {
     // (Maximum capacity reached)
     // (Maximum capacity reached)
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm4, containerId,
+    assertFalse(rm1.waitForState(nm4, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertFalse(rm1.waitForState(nm5, containerId,
+    assertFalse(rm1.waitForState(nm5, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
 
 
     // launch an app to queue b2
     // launch an app to queue b2
@@ -578,9 +589,9 @@ public class TestCapacitySchedulerWeightMode {
     // y,z). Will successfully allocate on nm3
     // y,z). Will successfully allocate on nm3
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm1, containerId,
+    assertFalse(rm1.waitForState(nm1, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertTrue(rm1.waitForState(nm3, containerId,
+    assertTrue(rm1.waitForState(nm3, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
         "h3");
         "h3");
@@ -589,7 +600,7 @@ public class TestCapacitySchedulerWeightMode {
     // Will successfully allocate on nm4 only.
     // Will successfully allocate on nm4 only.
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "z");
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "z");
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 3L);
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 3L);
-    Assert.assertTrue(rm1.waitForState(nm4, containerId,
+    assertTrue(rm1.waitForState(nm4, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
         "h4");
         "h4");
@@ -602,21 +613,21 @@ public class TestCapacitySchedulerWeightMode {
     YarnScheduler scheduler = rm.getRMContext().getScheduler();
     YarnScheduler scheduler = rm.getRMContext().getScheduler();
     SchedulerAppReport appReport = scheduler.getSchedulerAppInfo(attemptId);
     SchedulerAppReport appReport = scheduler.getSchedulerAppInfo(attemptId);
 
 
-    Assert.assertTrue(appReport.getLiveContainers().size() > 0);
+    assertTrue(appReport.getLiveContainers().size() > 0);
     for (RMContainer c : appReport.getLiveContainers()) {
     for (RMContainer c : appReport.getLiveContainers()) {
       if (c.getContainerId().equals(containerId)) {
       if (c.getContainerId().equals(containerId)) {
-        Assert.assertEquals(host, c.getAllocatedNode().getHost());
+        assertEquals(host, c.getAllocatedNode().getHost());
       }
       }
     }
     }
   }
   }
 
 
   private void validateCapacityOrWeightString(String capacityOrWeightString,
   private void validateCapacityOrWeightString(String capacityOrWeightString,
       boolean shouldContainWeight) {
       boolean shouldContainWeight) {
-    Assert.assertEquals(shouldContainWeight,
+    assertEquals(shouldContainWeight,
         capacityOrWeightString.contains("weight"));
         capacityOrWeightString.contains("weight"));
-    Assert.assertEquals(shouldContainWeight,
+    assertEquals(shouldContainWeight,
         capacityOrWeightString.contains("normalizedWeight"));
         capacityOrWeightString.contains("normalizedWeight"));
-    Assert.assertEquals(!shouldContainWeight,
+    assertEquals(!shouldContainWeight,
         capacityOrWeightString.contains("capacity"));
         capacityOrWeightString.contains("capacity"));
 
 
   }
   }

+ 38 - 36
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerWithMultiResourceTypes.java

@@ -56,13 +56,14 @@ import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
-import org.junit.Assert;
 
 
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -142,23 +143,23 @@ public class TestCapacitySchedulerWithMultiResourceTypes {
     rm.start();
     rm.start();
 
 
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
-    Assert.assertEquals(3333L,
+    assertEquals(3333L,
         cs.getMaximumResourceCapability().getResourceValue(RESOURCE_1));
         cs.getMaximumResourceCapability().getResourceValue(RESOURCE_1));
-    Assert.assertEquals(3333L,
+    assertEquals(3333L,
         cs.getMaximumAllocation().getResourceValue(RESOURCE_1));
         cs.getMaximumAllocation().getResourceValue(RESOURCE_1));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         cs.getMaximumResourceCapability()
         cs.getMaximumResourceCapability()
             .getResourceValue(ResourceInformation.MEMORY_URI));
             .getResourceValue(ResourceInformation.MEMORY_URI));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         cs.getMaximumAllocation()
         cs.getMaximumAllocation()
             .getResourceValue(ResourceInformation.MEMORY_URI));
             .getResourceValue(ResourceInformation.MEMORY_URI));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         cs.getMaximumResourceCapability()
         cs.getMaximumResourceCapability()
             .getResourceValue(ResourceInformation.VCORES_URI));
             .getResourceValue(ResourceInformation.VCORES_URI));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         cs.getMaximumAllocation()
         cs.getMaximumAllocation()
             .getResourceValue(ResourceInformation.VCORES_URI));
             .getResourceValue(ResourceInformation.VCORES_URI));
@@ -175,26 +176,26 @@ public class TestCapacitySchedulerWithMultiResourceTypes {
       exception = true;
       exception = true;
     }
     }
 
 
-    Assert.assertTrue("Should have exception in CS", exception);
+    assertTrue(exception, "Should have exception in CS");
 
 
     // Maximum allocation won't be updated
     // Maximum allocation won't be updated
-    Assert.assertEquals(3333L,
+    assertEquals(3333L,
         cs.getMaximumResourceCapability().getResourceValue(RESOURCE_1));
         cs.getMaximumResourceCapability().getResourceValue(RESOURCE_1));
-    Assert.assertEquals(3333L,
+    assertEquals(3333L,
         cs.getMaximumAllocation().getResourceValue(RESOURCE_1));
         cs.getMaximumAllocation().getResourceValue(RESOURCE_1));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         cs.getMaximumResourceCapability()
         cs.getMaximumResourceCapability()
             .getResourceValue(ResourceInformation.MEMORY_URI));
             .getResourceValue(ResourceInformation.MEMORY_URI));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         cs.getMaximumAllocation()
         cs.getMaximumAllocation()
             .getResourceValue(ResourceInformation.MEMORY_URI));
             .getResourceValue(ResourceInformation.MEMORY_URI));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         cs.getMaximumResourceCapability()
         cs.getMaximumResourceCapability()
             .getResourceValue(ResourceInformation.VCORES_URI));
             .getResourceValue(ResourceInformation.VCORES_URI));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         cs.getMaximumAllocation()
         cs.getMaximumAllocation()
             .getResourceValue(ResourceInformation.VCORES_URI));
             .getResourceValue(ResourceInformation.VCORES_URI));
@@ -206,26 +207,26 @@ public class TestCapacitySchedulerWithMultiResourceTypes {
     cs.reinitialize(csconf, rm.getRMContext());
     cs.reinitialize(csconf, rm.getRMContext());
 
 
     // Maximum allocation will be updated
     // Maximum allocation will be updated
-    Assert.assertEquals(3334,
+    assertEquals(3334,
         cs.getMaximumResourceCapability().getResourceValue(RESOURCE_1));
         cs.getMaximumResourceCapability().getResourceValue(RESOURCE_1));
 
 
     // Since we haven't updated the real configuration of ResourceUtils,
     // Since we haven't updated the real configuration of ResourceUtils,
     // cs.getMaximumAllocation won't be updated.
     // cs.getMaximumAllocation won't be updated.
-    Assert.assertEquals(3333,
+    assertEquals(3333,
         cs.getMaximumAllocation().getResourceValue(RESOURCE_1));
         cs.getMaximumAllocation().getResourceValue(RESOURCE_1));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         cs.getMaximumResourceCapability()
         cs.getMaximumResourceCapability()
             .getResourceValue(ResourceInformation.MEMORY_URI));
             .getResourceValue(ResourceInformation.MEMORY_URI));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
         cs.getMaximumAllocation()
         cs.getMaximumAllocation()
             .getResourceValue(ResourceInformation.MEMORY_URI));
             .getResourceValue(ResourceInformation.MEMORY_URI));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         cs.getMaximumResourceCapability()
         cs.getMaximumResourceCapability()
             .getResourceValue(ResourceInformation.VCORES_URI));
             .getResourceValue(ResourceInformation.VCORES_URI));
-    Assert.assertEquals(
+    assertEquals(
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
         cs.getMaximumAllocation()
         cs.getMaximumAllocation()
             .getResourceValue(ResourceInformation.VCORES_URI));
             .getResourceValue(ResourceInformation.VCORES_URI));
@@ -265,7 +266,7 @@ public class TestCapacitySchedulerWithMultiResourceTypes {
       exception = true;
       exception = true;
     }
     }
 
 
-    Assert.assertTrue("Should have exception in CS", exception);
+    assertTrue(exception, "Should have exception in CS");
   }
   }
 
 
   @Test
   @Test
@@ -327,12 +328,12 @@ public class TestCapacitySchedulerWithMultiResourceTypes {
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
 
 
     // check node report
     // check node report
-    Assert.assertEquals(1 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(9 * GB,
+    assertEquals(1 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(9 * GB,
         report_nm1.getAvailableResource().getMemorySize());
         report_nm1.getAvailableResource().getMemorySize());
-    Assert.assertEquals(0, report_nm1.getUsedResource()
+    assertEquals(0, report_nm1.getUsedResource()
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
-    Assert.assertEquals(4, report_nm1.getAvailableResource()
+    assertEquals(4, report_nm1.getAvailableResource()
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
 
 
     nameToValues.put(ResourceInformation.GPU_URI, "4");
     nameToValues.put(ResourceInformation.GPU_URI, "4");
@@ -345,17 +346,17 @@ public class TestCapacitySchedulerWithMultiResourceTypes {
             Priority.newInstance(1), "*", containerGpuResource, 1)), null);
             Priority.newInstance(1), "*", containerGpuResource, 1)), null);
     ContainerId containerId2 =
     ContainerId containerId2 =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm.waitForState(nm1, containerId2,
+    assertTrue(rm.waitForState(nm1, containerId2,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     // Acquire this container
     // Acquire this container
     am1.allocate(null, null);
     am1.allocate(null, null);
 
 
     report_nm1 =
     report_nm1 =
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(2 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(4, report_nm1.getUsedResource()
+    assertEquals(2 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(4, report_nm1.getUsedResource()
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
-    Assert.assertEquals(0, report_nm1.getAvailableResource()
+    assertEquals(0, report_nm1.getAvailableResource()
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
 
 
     nameToValues.clear();
     nameToValues.clear();
@@ -367,20 +368,21 @@ public class TestCapacitySchedulerWithMultiResourceTypes {
             Priority.newInstance(1), "*", containerResource, 1)), null);
             Priority.newInstance(1), "*", containerResource, 1)), null);
     ContainerId containerId3 =
     ContainerId containerId3 =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 3);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 3);
-    Assert.assertTrue(rm.waitForState(nm1, containerId3,
+    assertTrue(rm.waitForState(nm1, containerId3,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
 
 
     report_nm1 =
     report_nm1 =
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
         rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(3 * GB, report_nm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(4, report_nm1.getUsedResource()
+    assertEquals(3 * GB, report_nm1.getUsedResource().getMemorySize());
+    assertEquals(4, report_nm1.getUsedResource()
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
-    Assert.assertEquals(0, report_nm1.getAvailableResource()
+    assertEquals(0, report_nm1.getAvailableResource()
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
         .getResourceInformation(ResourceInformation.GPU_URI).getValue());
   }
   }
 
 
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testConsumeAllExtendedResourcesWithSmallMinUserLimitPct()
   public void testConsumeAllExtendedResourcesWithSmallMinUserLimitPct()
       throws Exception {
       throws Exception {
     int GB = 1024;
     int GB = 1024;

+ 4 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerWorkflowPriorityMapping.java

@@ -34,7 +34,7 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.C
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.B_CAPACITY;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.B_CAPACITY;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.ROOT;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.ROOT;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
@@ -49,8 +49,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.MockRMAppSubmitter;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.WorkflowPriorityMappingsManager.WorkflowPriorityMapping;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.WorkflowPriorityMappingsManager.WorkflowPriorityMapping;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
@@ -58,7 +58,7 @@ import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 public class TestCapacitySchedulerWorkflowPriorityMapping {
 public class TestCapacitySchedulerWorkflowPriorityMapping {
   private MockRM mockRM = null;
   private MockRM mockRM = null;
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (mockRM != null) {
     if (mockRM != null) {
       mockRM.stop();
       mockRM.stop();

+ 6 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestChildQueueOrder.java

@@ -18,7 +18,7 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.eq;
@@ -58,9 +58,9 @@ import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.InOrder;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.mockito.stubbing.Answer;
@@ -82,7 +82,7 @@ public class TestChildQueueOrder {
   private final ResourceCalculator resourceComparator =
   private final ResourceCalculator resourceComparator =
     new DefaultResourceCalculator();
     new DefaultResourceCalculator();
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     rmContext = TestUtils.getMockRMContext();
     rmContext = TestUtils.getMockRMContext();
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
@@ -444,7 +444,7 @@ public class TestChildQueueOrder {
         ((ParentQueue)root).getChildQueuesToPrint());
         ((ParentQueue)root).getChildQueuesToPrint());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
   }
   }
 }
 }

+ 45 - 43
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestConfigurationProperties.java

@@ -18,17 +18,19 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 public class TestConfigurationProperties {
 public class TestConfigurationProperties {
   private static final Map<String, String> PROPERTIES = new HashMap<>();
   private static final Map<String, String> PROPERTIES = new HashMap<>();
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setUpClass() throws Exception {
   public static void setUpClass() throws Exception {
     PROPERTIES.put("root.1.2.3", "TEST_VALUE_1");
     PROPERTIES.put("root.1.2.3", "TEST_VALUE_1");
     PROPERTIES.put("root.1", "TEST_VALUE_2");
     PROPERTIES.put("root.1", "TEST_VALUE_2");
@@ -48,15 +50,15 @@ public class TestConfigurationProperties {
     Map<String, String> props = configurationProperties
     Map<String, String> props = configurationProperties
         .getPropertiesWithPrefix("root.1.2");
         .getPropertiesWithPrefix("root.1.2");
 
 
-    Assert.assertEquals(4, props.size());
-    Assert.assertTrue(props.containsKey(""));
-    Assert.assertEquals("TEST_VALUE_3", props.get(""));
-    Assert.assertTrue(props.containsKey("4"));
-    Assert.assertEquals("TEST_VALUE_3_1", props.get("4"));
-    Assert.assertTrue(props.containsKey("3"));
-    Assert.assertEquals("TEST_VALUE_1", props.get("3"));
-    Assert.assertTrue(props.containsKey("4.5"));
-    Assert.assertEquals("TEST_VALUE_3_2", props.get("4.5"));
+    assertEquals(4, props.size());
+    assertTrue(props.containsKey(""));
+    assertEquals("TEST_VALUE_3", props.get(""));
+    assertTrue(props.containsKey("4"));
+    assertEquals("TEST_VALUE_3_1", props.get("4"));
+    assertTrue(props.containsKey("3"));
+    assertEquals("TEST_VALUE_1", props.get("3"));
+    assertTrue(props.containsKey("4.5"));
+    assertEquals("TEST_VALUE_3_2", props.get("4.5"));
 
 
     // Test the scenario where the prefix has a dot appended to it
     // Test the scenario where the prefix has a dot appended to it
     // (see CapacitySchedulerConfiguration.getQueuePrefix(String queue)).
     // (see CapacitySchedulerConfiguration.getQueuePrefix(String queue)).
@@ -64,28 +66,28 @@ public class TestConfigurationProperties {
     props = configurationProperties
     props = configurationProperties
         .getPropertiesWithPrefix("root.1.2.4.");
         .getPropertiesWithPrefix("root.1.2.4.");
 
 
-    Assert.assertEquals(2, props.size());
-    Assert.assertTrue(props.containsKey(""));
-    Assert.assertEquals("TEST_VALUE_3_1", props.get(""));
-    Assert.assertTrue(props.containsKey("5"));
-    Assert.assertEquals("TEST_VALUE_3_2", props.get("5"));
+    assertEquals(2, props.size());
+    assertTrue(props.containsKey(""));
+    assertEquals("TEST_VALUE_3_1", props.get(""));
+    assertTrue(props.containsKey("5"));
+    assertEquals("TEST_VALUE_3_2", props.get("5"));
 
 
     Map<String, String> propsWithRootPrefix = configurationProperties
     Map<String, String> propsWithRootPrefix = configurationProperties
         .getPropertiesWithPrefix("root");
         .getPropertiesWithPrefix("root");
 
 
-    Assert.assertEquals(6, propsWithRootPrefix.size());
-    Assert.assertTrue(propsWithRootPrefix.containsKey(""));
-    Assert.assertEquals("TEST_VALUE_4", propsWithRootPrefix.get(""));
-    Assert.assertTrue(propsWithRootPrefix.containsKey("1.2.3"));
-    Assert.assertEquals("TEST_VALUE_1", propsWithRootPrefix.get("1.2.3"));
-    Assert.assertTrue(propsWithRootPrefix.containsKey("1"));
-    Assert.assertEquals("TEST_VALUE_2", propsWithRootPrefix.get("1"));
-    Assert.assertTrue(propsWithRootPrefix.containsKey("1.2"));
-    Assert.assertEquals("TEST_VALUE_3", propsWithRootPrefix.get("1.2"));
-    Assert.assertTrue(propsWithRootPrefix.containsKey("1.2.4"));
-    Assert.assertEquals("TEST_VALUE_3_1", propsWithRootPrefix.get("1.2.4"));
-    Assert.assertTrue(propsWithRootPrefix.containsKey("1.2.4.5"));
-    Assert.assertEquals("TEST_VALUE_3_2", propsWithRootPrefix.get("1.2.4.5"));
+    assertEquals(6, propsWithRootPrefix.size());
+    assertTrue(propsWithRootPrefix.containsKey(""));
+    assertEquals("TEST_VALUE_4", propsWithRootPrefix.get(""));
+    assertTrue(propsWithRootPrefix.containsKey("1.2.3"));
+    assertEquals("TEST_VALUE_1", propsWithRootPrefix.get("1.2.3"));
+    assertTrue(propsWithRootPrefix.containsKey("1"));
+    assertEquals("TEST_VALUE_2", propsWithRootPrefix.get("1"));
+    assertTrue(propsWithRootPrefix.containsKey("1.2"));
+    assertEquals("TEST_VALUE_3", propsWithRootPrefix.get("1.2"));
+    assertTrue(propsWithRootPrefix.containsKey("1.2.4"));
+    assertEquals("TEST_VALUE_3_1", propsWithRootPrefix.get("1.2.4"));
+    assertTrue(propsWithRootPrefix.containsKey("1.2.4.5"));
+    assertEquals("TEST_VALUE_3_2", propsWithRootPrefix.get("1.2.4.5"));
   }
   }
 
 
   @Test
   @Test
@@ -96,15 +98,15 @@ public class TestConfigurationProperties {
     Map<String, String> props = configurationProperties
     Map<String, String> props = configurationProperties
         .getPropertiesWithPrefix("root.1.2", true);
         .getPropertiesWithPrefix("root.1.2", true);
 
 
-    Assert.assertEquals(4, props.size());
-    Assert.assertTrue(props.containsKey("root.1.2.3"));
-    Assert.assertEquals("TEST_VALUE_1", props.get("root.1.2.3"));
-    Assert.assertTrue(props.containsKey("root.1.2"));
-    Assert.assertEquals("TEST_VALUE_3", props.get("root.1.2"));
-    Assert.assertTrue(props.containsKey("root.1.2.4.5"));
-    Assert.assertEquals("TEST_VALUE_3_2", props.get("root.1.2.4.5"));
-    Assert.assertTrue(props.containsKey("root.1.2.4"));
-    Assert.assertEquals("TEST_VALUE_3_1", props.get("root.1.2.4"));
+    assertEquals(4, props.size());
+    assertTrue(props.containsKey("root.1.2.3"));
+    assertEquals("TEST_VALUE_1", props.get("root.1.2.3"));
+    assertTrue(props.containsKey("root.1.2"));
+    assertEquals("TEST_VALUE_3", props.get("root.1.2"));
+    assertTrue(props.containsKey("root.1.2.4.5"));
+    assertEquals("TEST_VALUE_3_2", props.get("root.1.2.4.5"));
+    assertTrue(props.containsKey("root.1.2.4"));
+    assertEquals("TEST_VALUE_3_1", props.get("root.1.2.4"));
   }
   }
 
 
   @Test
   @Test
@@ -118,8 +120,8 @@ public class TestConfigurationProperties {
     Map<String, String> propsNonExistingRootPrefix = configurationProperties
     Map<String, String> propsNonExistingRootPrefix = configurationProperties
         .getPropertiesWithPrefix("3");
         .getPropertiesWithPrefix("3");
 
 
-    Assert.assertEquals(0, propsEmptyPrefix.size());
-    Assert.assertEquals(0, propsLongPrefix.size());
-    Assert.assertEquals(0, propsNonExistingRootPrefix.size());
+    assertEquals(0, propsEmptyPrefix.size());
+    assertEquals(0, propsLongPrefix.size());
+    assertEquals(0, propsNonExistingRootPrefix.size());
   }
   }
 }
 }

+ 142 - 126
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java

@@ -67,12 +67,17 @@ import org.apache.hadoop.yarn.util.resource.CustomResourceTypesConfigurationProv
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION_MB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION_MB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAX_ASSIGN_PER_HEARTBEAT;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAX_ASSIGN_PER_HEARTBEAT;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestContainerAllocation {
 public class TestContainerAllocation {
 
 
@@ -97,7 +102,7 @@ public class TestContainerAllocation {
   
   
   RMNodeLabelsManager mgr;
   RMNodeLabelsManager mgr;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -106,7 +111,8 @@ public class TestContainerAllocation {
     mgr.init(conf);
     mgr.init(conf);
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testExcessReservationThanNodeManagerCapacity() throws Exception {
   public void testExcessReservationThanNodeManagerCapacity() throws Exception {
     @SuppressWarnings("resource")
     @SuppressWarnings("resource")
     MockRM rm = new MockRM(conf);
     MockRM rm = new MockRM(conf);
@@ -127,7 +133,7 @@ public class TestContainerAllocation {
       LOG.info("Waiting for node managers to register : " + size);
       LOG.info("Waiting for node managers to register : " + size);
       Thread.sleep(100);
       Thread.sleep(100);
     }
     }
-    Assert.assertEquals(2, rm.getRMContext().getRMNodes().size());
+    assertEquals(2, rm.getRMContext().getRMNodes().size());
     // Submit an application
     // Submit an application
     RMApp app1 = MockRMAppSubmitter.submitWithMemory(128, rm);
     RMApp app1 = MockRMAppSubmitter.submitWithMemory(128, rm);
 
 
@@ -156,7 +162,7 @@ public class TestContainerAllocation {
 
 
     // No container should be allocated.
     // No container should be allocated.
     // Internally it should not been reserved.
     // Internally it should not been reserved.
-    Assert.assertTrue(alloc1Response.getAllocatedContainers().size() == 0);
+    assertTrue(alloc1Response.getAllocatedContainers().size() == 0);
 
 
     LOG.info("heartbeating nm2");
     LOG.info("heartbeating nm2");
     waitCounter = 20;
     waitCounter = 20;
@@ -169,7 +175,7 @@ public class TestContainerAllocation {
     }
     }
     LOG.info("received container : "
     LOG.info("received container : "
         + alloc1Response.getAllocatedContainers().size());
         + alloc1Response.getAllocatedContainers().size());
-    Assert.assertTrue(alloc1Response.getAllocatedContainers().size() == 1);
+    assertTrue(alloc1Response.getAllocatedContainers().size() == 1);
 
 
     rm.stop();
     rm.stop();
   }
   }
@@ -192,16 +198,16 @@ public class TestContainerAllocation {
     RMContainer container =
     RMContainer container =
         rm1.getResourceScheduler().getRMContainer(containerId2);
         rm1.getResourceScheduler().getRMContainer(containerId2);
     // no container token is generated.
     // no container token is generated.
-    Assert.assertEquals(containerId2, container.getContainerId());
-    Assert.assertNull(container.getContainer().getContainerToken());
+    assertEquals(containerId2, container.getContainerId());
+    assertNull(container.getContainer().getContainerToken());
 
 
     // acquire the container.
     // acquire the container.
     List<Container> containers =
     List<Container> containers =
         am1.allocate(new ArrayList<ResourceRequest>(),
         am1.allocate(new ArrayList<ResourceRequest>(),
           new ArrayList<ContainerId>()).getAllocatedContainers();
           new ArrayList<ContainerId>()).getAllocatedContainers();
-    Assert.assertEquals(containerId2, containers.get(0).getId());
+    assertEquals(containerId2, containers.get(0).getId());
     // container token is generated.
     // container token is generated.
-    Assert.assertNotNull(containers.get(0).getContainerToken());
+    assertNotNull(containers.get(0).getContainerToken());
     rm1.stop();
     rm1.stop();
   }
   }
 
 
@@ -227,7 +233,7 @@ public class TestContainerAllocation {
           am1.allocate(new ArrayList<ResourceRequest>(),
           am1.allocate(new ArrayList<ResourceRequest>(),
               new ArrayList<ContainerId>()).getAllocatedContainers();
               new ArrayList<ContainerId>()).getAllocatedContainers();
       // not able to fetch the container;
       // not able to fetch the container;
-      Assert.assertEquals(0, containers.size());
+      assertEquals(0, containers.size());
     } finally {
     } finally {
       SecurityUtilTestHelper.setTokenServiceUseIp(false);
       SecurityUtilTestHelper.setTokenServiceUseIp(false);
     }
     }
@@ -235,7 +241,7 @@ public class TestContainerAllocation {
         am1.allocate(new ArrayList<ResourceRequest>(),
         am1.allocate(new ArrayList<ResourceRequest>(),
           new ArrayList<ContainerId>()).getAllocatedContainers();
           new ArrayList<ContainerId>()).getAllocatedContainers();
     // should be able to fetch the container;
     // should be able to fetch the container;
-    Assert.assertEquals(1, containers.size());
+    assertEquals(1, containers.size());
     rm1.stop();
     rm1.stop();
   }
   }
 
 
@@ -249,8 +255,7 @@ public class TestContainerAllocation {
     MockNM nm1 = rm1.registerNode("127.0.0.1:1234", 8000);
     MockNM nm1 = rm1.registerNode("127.0.0.1:1234", 8000);
     MockNM nm2 = rm1.registerNode("127.0.0.1:2345", 8000);
     MockNM nm2 = rm1.registerNode("127.0.0.1:2345", 8000);
     // LogAggregationContext is set as null
     // LogAggregationContext is set as null
-    Assert
-      .assertNull(getLogAggregationContextFromContainerToken(rm1, nm1, null));
+    assertNull(getLogAggregationContextFromContainerToken(rm1, nm1, null));
 
 
     // create a not-null LogAggregationContext
     // create a not-null LogAggregationContext
     LogAggregationContext logAggregationContext =
     LogAggregationContext logAggregationContext =
@@ -263,15 +268,15 @@ public class TestContainerAllocation {
     LogAggregationContext returned =
     LogAggregationContext returned =
         getLogAggregationContextFromContainerToken(rm1, nm2,
         getLogAggregationContextFromContainerToken(rm1, nm2,
           logAggregationContext);
           logAggregationContext);
-    Assert.assertEquals("includePattern", returned.getIncludePattern());
-    Assert.assertEquals("excludePattern", returned.getExcludePattern());
-    Assert.assertEquals("rolledLogsIncludePattern",
+    assertEquals("includePattern", returned.getIncludePattern());
+    assertEquals("excludePattern", returned.getExcludePattern());
+    assertEquals("rolledLogsIncludePattern",
         returned.getRolledLogsIncludePattern());
         returned.getRolledLogsIncludePattern());
-    Assert.assertEquals("rolledLogsExcludePattern",
+    assertEquals("rolledLogsExcludePattern",
         returned.getRolledLogsExcludePattern());
         returned.getRolledLogsExcludePattern());
-    Assert.assertEquals("policyClass",
+    assertEquals("policyClass",
         returned.getLogAggregationPolicyClassName());
         returned.getLogAggregationPolicyClassName());
-    Assert.assertEquals("policyParameters",
+    assertEquals("policyParameters",
         returned.getLogAggregationPolicyParameters());
         returned.getLogAggregationPolicyParameters());
     rm1.stop();
     rm1.stop();
   }
   }
@@ -295,9 +300,9 @@ public class TestContainerAllocation {
     List<Container> containers =
     List<Container> containers =
         am2.allocate(new ArrayList<ResourceRequest>(),
         am2.allocate(new ArrayList<ResourceRequest>(),
           new ArrayList<ContainerId>()).getAllocatedContainers();
           new ArrayList<ContainerId>()).getAllocatedContainers();
-    Assert.assertEquals(containerId, containers.get(0).getId());
+    assertEquals(containerId, containers.get(0).getId());
     // container token is generated.
     // container token is generated.
-    Assert.assertNotNull(containers.get(0).getContainerToken());
+    assertNotNull(containers.get(0).getContainerToken());
     ContainerTokenIdentifier token =
     ContainerTokenIdentifier token =
         BuilderUtils.newContainerTokenIdentifier(containers.get(0)
         BuilderUtils.newContainerTokenIdentifier(containers.get(0)
           .getContainerToken());
           .getContainerToken());
@@ -336,7 +341,8 @@ public class TestContainerAllocation {
   // This is to test fetching AM container will be retried, if AM container is
   // This is to test fetching AM container will be retried, if AM container is
   // not fetchable since DNS is unavailable causing container token/NMtoken
   // not fetchable since DNS is unavailable causing container token/NMtoken
   // creation failure.
   // creation failure.
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testAMContainerAllocationWhenDNSUnavailable() throws Exception {
   public void testAMContainerAllocationWhenDNSUnavailable() throws Exception {
     MockRM rm1 = new MockRM(conf) {
     MockRM rm1 = new MockRM(conf) {
       @Override
       @Override
@@ -358,7 +364,7 @@ public class TestContainerAllocation {
       while (numRetries <= 5) {
       while (numRetries <= 5) {
         nm1.nodeHeartbeat(true);
         nm1.nodeHeartbeat(true);
         Thread.sleep(1000);
         Thread.sleep(1000);
-        Assert.assertEquals(RMAppAttemptState.SCHEDULED,
+        assertEquals(RMAppAttemptState.SCHEDULED,
             attempt.getAppAttemptState());
             attempt.getAppAttemptState());
         System.out.println("Waiting for am container to be allocated.");
         System.out.println("Waiting for am container to be allocated.");
       }
       }
@@ -369,7 +375,8 @@ public class TestContainerAllocation {
     rm1.stop();
     rm1.stop();
   }
   }
   
   
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testExcessReservationWillBeUnreserved() throws Exception {
   public void testExcessReservationWillBeUnreserved() throws Exception {
     /**
     /**
      * Test case: Submit two application (app1/app2) to a queue. And there's one
      * Test case: Submit two application (app1/app2) to a queue. And there's one
@@ -433,20 +440,20 @@ public class TestContainerAllocation {
         cs.getApplicationAttempt(am2.getApplicationAttemptId());
         cs.getApplicationAttempt(am2.getApplicationAttemptId());
 
 
     // Check if a 4G contaienr allocated for app1, and nothing allocated for app2
     // Check if a 4G contaienr allocated for app1, and nothing allocated for app2
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
-    Assert.assertTrue(schedulerApp2.getReservedContainers().size() > 0);
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertTrue(schedulerApp2.getReservedContainers().size() > 0);
     
     
     // NM1 has available resource = 2G (8G - 2 * 1G - 4G)
     // NM1 has available resource = 2G (8G - 2 * 1G - 4G)
-    Assert.assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Usage of queue = 4G + 2 * 1G + 4G (reserved)
     // Usage of queue = 4G + 2 * 1G + 4G (reserved)
-    Assert.assertEquals(10 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(10 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed().getMemorySize());
         .getUsed().getMemorySize());
-    Assert.assertEquals(4 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(4 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved().getMemorySize());
         .getReserved().getMemorySize());
-    Assert.assertEquals(4 * GB, leafQueue.getQueueResourceUsage().getReserved()
+    assertEquals(4 * GB, leafQueue.getQueueResourceUsage().getReserved()
         .getMemorySize());
         .getMemorySize());
 
 
     // Cancel asks of app2 and re-kick RM
     // Cancel asks of app2 and re-kick RM
@@ -454,21 +461,22 @@ public class TestContainerAllocation {
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     
     
     // App2's reservation will be cancelled
     // App2's reservation will be cancelled
-    Assert.assertTrue(schedulerApp2.getReservedContainers().size() == 0);
-    Assert.assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
+    assertTrue(schedulerApp2.getReservedContainers().size() == 0);
+    assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
-    Assert.assertEquals(6 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertEquals(6 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed().getMemorySize());
         .getUsed().getMemorySize());
-    Assert.assertEquals(0, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0, cs.getRootQueue().getQueueResourceUsage()
         .getReserved().getMemorySize());
         .getReserved().getMemorySize());
-    Assert.assertEquals(0, leafQueue.getQueueResourceUsage().getReserved()
+    assertEquals(0, leafQueue.getQueueResourceUsage().getReserved()
         .getMemorySize());
         .getMemorySize());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testAllocationForReservedContainer() throws Exception {
   public void testAllocationForReservedContainer() throws Exception {
     /**
     /**
      * Test case: Submit two application (app1/app2) to a queue. And there's one
      * Test case: Submit two application (app1/app2) to a queue. And there's one
@@ -532,20 +540,20 @@ public class TestContainerAllocation {
         cs.getApplicationAttempt(am2.getApplicationAttemptId());
         cs.getApplicationAttempt(am2.getApplicationAttemptId());
 
 
     // Check if a 4G container allocated for app1, and nothing allocated for app2
     // Check if a 4G container allocated for app1, and nothing allocated for app2
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
-    Assert.assertTrue(schedulerApp2.getReservedContainers().size() > 0);
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertTrue(schedulerApp2.getReservedContainers().size() > 0);
 
 
     // NM1 has available resource = 2G (8G - 2 * 1G - 4G)
     // NM1 has available resource = 2G (8G - 2 * 1G - 4G)
-    Assert.assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Usage of queue = 4G + 2 * 1G + 4G (reserved)
     // Usage of queue = 4G + 2 * 1G + 4G (reserved)
-    Assert.assertEquals(10 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(10 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed().getMemorySize());
         .getUsed().getMemorySize());
-    Assert.assertEquals(4 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(4 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved().getMemorySize());
         .getReserved().getMemorySize());
-    Assert.assertEquals(4 * GB, leafQueue.getQueueResourceUsage().getReserved()
+    assertEquals(4 * GB, leafQueue.getQueueResourceUsage().getReserved()
         .getMemorySize());
         .getMemorySize());
 
 
     // Mark one app1 container as killed/completed and re-kick RM
     // Mark one app1 container as killed/completed and re-kick RM
@@ -561,26 +569,27 @@ public class TestContainerAllocation {
 
 
     // Check 4G container cancelled for app1, and one container allocated for
     // Check 4G container cancelled for app1, and one container allocated for
     // app2
     // app2
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(2, schedulerApp2.getLiveContainers().size());
-    Assert.assertFalse(schedulerApp2.getReservedContainers().size() > 0);
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertEquals(2, schedulerApp2.getLiveContainers().size());
+    assertFalse(schedulerApp2.getReservedContainers().size() > 0);
 
 
     // NM1 has available resource = 2G (8G - 2 * 1G - 4G)
     // NM1 has available resource = 2G (8G - 2 * 1G - 4G)
-    Assert.assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Usage of queue = 4G + 2 * 1G
     // Usage of queue = 4G + 2 * 1G
-    Assert.assertEquals(6 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(6 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed().getMemorySize());
         .getUsed().getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved().getMemorySize());
         .getReserved().getMemorySize());
-    Assert.assertEquals(0 * GB, leafQueue.getQueueResourceUsage().getReserved()
+    assertEquals(0 * GB, leafQueue.getQueueResourceUsage().getReserved()
         .getMemorySize());
         .getMemorySize());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testReservedContainerMetricsOnDecommisionedNode() throws Exception {
   public void testReservedContainerMetricsOnDecommisionedNode() throws Exception {
     /**
     /**
      * Test case: Submit two application (app1/app2) to a queue. And there's one
      * Test case: Submit two application (app1/app2) to a queue. And there's one
@@ -644,42 +653,43 @@ public class TestContainerAllocation {
         cs.getApplicationAttempt(am2.getApplicationAttemptId());
         cs.getApplicationAttempt(am2.getApplicationAttemptId());
 
 
     // Check if a 4G container allocated for app1, and nothing allocated for app2
     // Check if a 4G container allocated for app1, and nothing allocated for app2
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
-    Assert.assertTrue(schedulerApp2.getReservedContainers().size() > 0);
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertTrue(schedulerApp2.getReservedContainers().size() > 0);
 
 
     // NM1 has available resource = 2G (8G - 2 * 1G - 4G)
     // NM1 has available resource = 2G (8G - 2 * 1G - 4G)
-    Assert.assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
+    assertEquals(2 * GB, cs.getNode(nm1.getNodeId())
         .getUnallocatedResource().getMemorySize());
         .getUnallocatedResource().getMemorySize());
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Usage of queue = 4G + 2 * 1G + 4G (reserved)
     // Usage of queue = 4G + 2 * 1G + 4G (reserved)
-    Assert.assertEquals(10 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(10 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed().getMemorySize());
         .getUsed().getMemorySize());
-    Assert.assertEquals(4 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(4 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved().getMemorySize());
         .getReserved().getMemorySize());
-    Assert.assertEquals(4 * GB, leafQueue.getQueueResourceUsage().getReserved()
+    assertEquals(4 * GB, leafQueue.getQueueResourceUsage().getReserved()
         .getMemorySize());
         .getMemorySize());
 
 
     // Remove the node
     // Remove the node
     cs.handle(new NodeRemovedSchedulerEvent(rmNode1));
     cs.handle(new NodeRemovedSchedulerEvent(rmNode1));
 
 
     // Check all container cancelled for app1 and app2
     // Check all container cancelled for app1 and app2
-    Assert.assertEquals(0, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(0, schedulerApp2.getLiveContainers().size());
-    Assert.assertFalse(schedulerApp2.getReservedContainers().size() > 0);
+    assertEquals(0, schedulerApp1.getLiveContainers().size());
+    assertEquals(0, schedulerApp2.getLiveContainers().size());
+    assertFalse(schedulerApp2.getReservedContainers().size() > 0);
 
 
     // Usage and Reserved capacity of queue is 0
     // Usage and Reserved capacity of queue is 0
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed().getMemorySize());
         .getUsed().getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved().getMemorySize());
         .getReserved().getMemorySize());
-    Assert.assertEquals(0 * GB, leafQueue.getQueueResourceUsage().getReserved()
+    assertEquals(0 * GB, leafQueue.getQueueResourceUsage().getReserved()
         .getMemorySize());
         .getMemorySize());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testAssignMultipleOffswitchContainers() throws Exception {
   public void testAssignMultipleOffswitchContainers() throws Exception {
     MockRM rm1 = new MockRM();
     MockRM rm1 = new MockRM();
 
 
@@ -711,7 +721,7 @@ public class TestContainerAllocation {
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
 
 
     // App1 will get one container allocated (plus AM container
     // App1 will get one container allocated (plus AM container
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
 
 
     // Set assign multiple off-switch containers to 3
     // Set assign multiple off-switch containers to 3
     CapacitySchedulerConfiguration newCSConf = new CapacitySchedulerConfiguration();
     CapacitySchedulerConfiguration newCSConf = new CapacitySchedulerConfiguration();
@@ -725,12 +735,13 @@ public class TestContainerAllocation {
 
 
     // App1 will get 3 new container allocated (plus 2 previously allocated
     // App1 will get 3 new container allocated (plus 2 previously allocated
     // container)
     // container)
-    Assert.assertEquals(5, schedulerApp1.getLiveContainers().size());
+    assertEquals(5, schedulerApp1.getLiveContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testContinuousReservationLookingWhenUsedEqualsMax() throws Exception {
   public void testContinuousReservationLookingWhenUsedEqualsMax() throws Exception {
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
         (CapacitySchedulerConfiguration) TestUtils
         (CapacitySchedulerConfiguration) TestUtils
@@ -784,14 +795,14 @@ public class TestContainerAllocation {
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
 
 
     // App1 will get 2 container allocated (plus AM container)
     // App1 will get 2 container allocated (plus AM container)
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp1.getReservedContainers().size());
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp1.getReservedContainers().size());
 
 
     // Do node heartbeats on nm2, we expect one container allocated on nm2 and
     // Do node heartbeats on nm2, we expect one container allocated on nm2 and
     // one unreserved on nm1
     // one unreserved on nm1
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(0, schedulerApp1.getReservedContainers().size());
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertEquals(0, schedulerApp1.getReservedContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
@@ -851,7 +862,7 @@ public class TestContainerAllocation {
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
 
 
     // App1 will get 1 container reserved
     // App1 will get 1 container reserved
-    Assert.assertEquals(1, schedulerApp1.getReservedContainers().size());
+    assertEquals(1, schedulerApp1.getReservedContainers().size());
 
 
     /*
     /*
      * Note that the behavior of appAttemptResourceUsage is different from queue's
      * Note that the behavior of appAttemptResourceUsage is different from queue's
@@ -861,23 +872,23 @@ public class TestContainerAllocation {
      * TODO (wangda): Need to make behaviors of queue/app's resource usage
      * TODO (wangda): Need to make behaviors of queue/app's resource usage
      * consistent
      * consistent
      */
      */
-    Assert.assertEquals(2 * GB,
+    assertEquals(2 * GB,
         schedulerApp1.getAppAttemptResourceUsage().getUsed().getMemorySize());
         schedulerApp1.getAppAttemptResourceUsage().getUsed().getMemorySize());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         schedulerApp1.getAppAttemptResourceUsage().getReserved()
         schedulerApp1.getAppAttemptResourceUsage().getReserved()
             .getMemorySize());
             .getMemorySize());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         schedulerApp1.getAppAttemptResourceUsage().getPending()
         schedulerApp1.getAppAttemptResourceUsage().getPending()
             .getMemorySize());
             .getMemorySize());
 
 
     FiCaSchedulerApp schedulerApp2 =
     FiCaSchedulerApp schedulerApp2 =
         cs.getApplicationAttempt(am2.getApplicationAttemptId());
         cs.getApplicationAttempt(am2.getApplicationAttemptId());
-    Assert.assertEquals(4 * GB,
+    assertEquals(4 * GB,
         schedulerApp2.getAppAttemptResourceUsage().getUsed().getMemorySize());
         schedulerApp2.getAppAttemptResourceUsage().getUsed().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         schedulerApp2.getAppAttemptResourceUsage().getReserved()
         schedulerApp2.getAppAttemptResourceUsage().getReserved()
             .getMemorySize());
             .getMemorySize());
-    Assert.assertEquals(5 * 4 * GB,
+    assertEquals(5 * 4 * GB,
         schedulerApp2.getAppAttemptResourceUsage().getPending()
         schedulerApp2.getAppAttemptResourceUsage().getPending()
             .getMemorySize());
             .getMemorySize());
 
 
@@ -887,15 +898,16 @@ public class TestContainerAllocation {
     //                           u2 = 8GB - 4GB = 4GB
     //                           u2 = 8GB - 4GB = 4GB
     // When not deduct reserved, total-pending = 3G (u1) + 4G (u2) = 7G
     // When not deduct reserved, total-pending = 3G (u1) + 4G (u2) = 7G
     //          deduct reserved, total-pending = 0G (u1) + 4G = 4G
     //          deduct reserved, total-pending = 0G (u1) + 4G = 4G
-    Assert.assertEquals(7 * GB, lq.getTotalPendingResourcesConsideringUserLimit(
+    assertEquals(7 * GB, lq.getTotalPendingResourcesConsideringUserLimit(
         Resources.createResource(20 * GB), "", false).getMemorySize());
         Resources.createResource(20 * GB), "", false).getMemorySize());
-    Assert.assertEquals(4 * GB, lq.getTotalPendingResourcesConsideringUserLimit(
+    assertEquals(4 * GB, lq.getTotalPendingResourcesConsideringUserLimit(
         Resources.createResource(20 * GB), "", true).getMemorySize());
         Resources.createResource(20 * GB), "", true).getMemorySize());
     rm1.close();
     rm1.close();
   }
   }
 
 
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testQueuePriorityOrdering() throws Exception {
   public void testQueuePriorityOrdering() throws Exception {
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
         (CapacitySchedulerConfiguration) TestUtils
         (CapacitySchedulerConfiguration) TestUtils
@@ -971,16 +983,16 @@ public class TestContainerAllocation {
     // container will be allocated to am1
     // container will be allocated to am1
     // App1 will get 2 container allocated (plus AM container)
     // App1 will get 2 container allocated (plus AM container)
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp3.getLiveContainers().size());
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertEquals(1, schedulerApp3.getLiveContainers().size());
 
 
     // container will be allocated to am1 again,
     // container will be allocated to am1 again,
     // App1 will get 3 container allocated (plus AM container)
     // App1 will get 3 container allocated (plus AM container)
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp2.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp3.getLiveContainers().size());
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp2.getLiveContainers().size());
+    assertEquals(1, schedulerApp3.getLiveContainers().size());
 
 
     // (Now usages of queues: a=12G (satisfied), b=2G, c=2G)
     // (Now usages of queues: a=12G (satisfied), b=2G, c=2G)
 
 
@@ -988,9 +1000,9 @@ public class TestContainerAllocation {
     // capacity)
     // capacity)
     // App2 will get 2 container allocated (plus AM container)
     // App2 will get 2 container allocated (plus AM container)
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(2, schedulerApp2.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp3.getLiveContainers().size());
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertEquals(2, schedulerApp2.getLiveContainers().size());
+    assertEquals(1, schedulerApp3.getLiveContainers().size());
 
 
     // Do this 3 times
     // Do this 3 times
     // container will be allocated to am2 (since app1 reaches its guaranteed
     // container will be allocated to am2 (since app1 reaches its guaranteed
@@ -999,9 +1011,9 @@ public class TestContainerAllocation {
     for (int i = 0; i < 3; i++) {
     for (int i = 0; i < 3; i++) {
       cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
       cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     }
     }
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(5, schedulerApp2.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp3.getLiveContainers().size());
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertEquals(5, schedulerApp2.getLiveContainers().size());
+    assertEquals(1, schedulerApp3.getLiveContainers().size());
 
 
     // (Now usages of queues: a=12G (satisfied), b=22G (satisfied), c=2G))
     // (Now usages of queues: a=12G (satisfied), b=22G (satisfied), c=2G))
 
 
@@ -1009,9 +1021,9 @@ public class TestContainerAllocation {
     for (int i = 0; i < 10; i++) {
     for (int i = 0; i < 10; i++) {
       cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
       cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     }
     }
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(5, schedulerApp2.getLiveContainers().size());
-    Assert.assertEquals(11, schedulerApp3.getLiveContainers().size());
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertEquals(5, schedulerApp2.getLiveContainers().size());
+    assertEquals(11, schedulerApp3.getLiveContainers().size());
 
 
     // (Now usages of queues: a=12G (satisfied), b=22G (satisfied),
     // (Now usages of queues: a=12G (satisfied), b=22G (satisfied),
     // c=52G (satisfied and no pending))
     // c=52G (satisfied and no pending))
@@ -1020,9 +1032,9 @@ public class TestContainerAllocation {
     for (int i = 0; i < 20; i++) {
     for (int i = 0; i < 20; i++) {
       cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
       cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     }
     }
-    Assert.assertEquals(4, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(6, schedulerApp2.getLiveContainers().size());
-    Assert.assertEquals(11, schedulerApp3.getLiveContainers().size());
+    assertEquals(4, schedulerApp1.getLiveContainers().size());
+    assertEquals(6, schedulerApp2.getLiveContainers().size());
+    assertEquals(11, schedulerApp3.getLiveContainers().size());
 
 
     // (Now usages of queues: a=17G (satisfied), b=27G (satisfied), c=52G))
     // (Now usages of queues: a=17G (satisfied), b=27G (satisfied), c=52G))
 
 
@@ -1031,7 +1043,8 @@ public class TestContainerAllocation {
 
 
 
 
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testUserLimitAllocationMultipleContainers() throws Exception {
   public void testUserLimitAllocationMultipleContainers() throws Exception {
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
         (CapacitySchedulerConfiguration) TestUtils
         (CapacitySchedulerConfiguration) TestUtils
@@ -1091,8 +1104,8 @@ public class TestContainerAllocation {
     // container will be allocated to am1
     // container will be allocated to am1
     // App1 will get 2 container allocated (plus AM container)
     // App1 will get 2 container allocated (plus AM container)
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertEquals(101, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(100, schedulerApp2.getLiveContainers().size());
+    assertEquals(101, schedulerApp1.getLiveContainers().size());
+    assertEquals(100, schedulerApp2.getLiveContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
@@ -1165,13 +1178,14 @@ public class TestContainerAllocation {
     LeafQueue lq = (LeafQueue) cs.getQueue("default");
     LeafQueue lq = (LeafQueue) cs.getQueue("default");
     UsersManager um = (UsersManager) lq.getAbstractUsersManager();
     UsersManager um = (UsersManager) lq.getAbstractUsersManager();
 
 
-    Assert.assertEquals(4, um.getNumActiveUsers());
-    Assert.assertEquals(2, um.getNumActiveUsersWithOnlyPendingApps());
-    Assert.assertEquals(2, lq.getMetrics().getAppsPending());
+    assertEquals(4, um.getNumActiveUsers());
+    assertEquals(2, um.getNumActiveUsersWithOnlyPendingApps());
+    assertEquals(2, lq.getMetrics().getAppsPending());
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testUnreserveWhenClusterResourceHasEmptyResourceType()
   public void testUnreserveWhenClusterResourceHasEmptyResourceType()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -1240,19 +1254,20 @@ public class TestContainerAllocation {
 
 
     // Do nm1 heartbeats 1 times, will reserve a container on nm1 for app1
     // Do nm1 heartbeats 1 times, will reserve a container on nm1 for app1
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp1.getReservedContainers().size());
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp1.getReservedContainers().size());
 
 
     // Do nm2 heartbeats 1 times, will unreserve a container on nm1
     // Do nm2 heartbeats 1 times, will unreserve a container on nm1
     // and allocate a container on nm2 for app1
     // and allocate a container on nm2 for app1
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(0, schedulerApp1.getReservedContainers().size());
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertEquals(0, schedulerApp1.getReservedContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testAllocationCannotBeBlockedWhenFormerQueueReachedItsLimit()
   public void testAllocationCannotBeBlockedWhenFormerQueueReachedItsLimit()
       throws Exception {
       throws Exception {
     /**
     /**
@@ -1340,13 +1355,14 @@ public class TestContainerAllocation {
     // Do nm1 heartbeats 1 times, will allocate a container on nm1 for app2
     // Do nm1 heartbeats 1 times, will allocate a container on nm1 for app2
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     rm1.drainEvents();
     rm1.drainEvents();
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(2, schedulerApp2.getLiveContainers().size());
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertEquals(2, schedulerApp2.getLiveContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testContainerRejectionWhenAskBeyondDynamicMax()
   public void testContainerRejectionWhenAskBeyondDynamicMax()
       throws Exception {
       throws Exception {
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
@@ -1379,7 +1395,7 @@ public class TestContainerAllocation {
     } catch (InvalidResourceRequestException e) {
     } catch (InvalidResourceRequestException e) {
       submitFailed = true;
       submitFailed = true;
     }
     }
-    Assert.assertTrue(submitFailed);
+    assertTrue(submitFailed);
 
 
     // Ask 4GB succeeded.
     // Ask 4GB succeeded.
     am1.allocate("*", 4 * GB, 1, null);
     am1.allocate("*", 4 * GB, 1, null);
@@ -1396,7 +1412,7 @@ public class TestContainerAllocation {
     } catch (InvalidResourceRequestException e) {
     } catch (InvalidResourceRequestException e) {
       submitFailed = true;
       submitFailed = true;
     }
     }
-    Assert.assertTrue(submitFailed);
+    assertTrue(submitFailed);
 
 
     // But ask 3 GB succeeded.
     // But ask 3 GB succeeded.
     am1.allocate("*", 3 * GB, 1, null);
     am1.allocate("*", 3 * GB, 1, null);

+ 113 - 106
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java

@@ -18,6 +18,13 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collection;
@@ -64,9 +71,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.CandidateNodeSet;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.CandidateNodeSet;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 public class TestContainerResizing {
 public class TestContainerResizing {
   private static final Logger LOG =
   private static final Logger LOG =
@@ -102,7 +109,7 @@ public class TestContainerResizing {
     }
     }
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -152,7 +159,7 @@ public class TestContainerResizing {
         rm1, app1.getApplicationId());
         rm1, app1.getApplicationId());
 
 
     checkPendingResource(rm1, "default", 2 * GB, null);
     checkPendingResource(rm1, "default", 2 * GB, null);
-    Assert.assertEquals(2 * GB,
+    assertEquals(2 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
 
 
     // NM1 do 1 heartbeats
     // NM1 do 1 heartbeats
@@ -162,7 +169,7 @@ public class TestContainerResizing {
 
 
     // Pending resource should be deducted
     // Pending resource should be deducted
     checkPendingResource(rm1, "default", 0 * GB, null);
     checkPendingResource(rm1, "default", 0 * GB, null);
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
 
 
     verifyContainerIncreased(am1.allocate(null, null), containerId1, 3 * GB);
     verifyContainerIncreased(am1.allocate(null, null), containerId1, 3 * GB);
@@ -207,7 +214,7 @@ public class TestContainerResizing {
         rm1, app1.getApplicationId());
         rm1, app1.getApplicationId());
 
 
     checkUsedResource(rm1, "default", 3 * GB, null);
     checkUsedResource(rm1, "default", 3 * GB, null);
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
 
 
     ContainerId containerId1 =
     ContainerId containerId1 =
@@ -227,7 +234,7 @@ public class TestContainerResizing {
     dispatcher.await();
     dispatcher.await();
 
 
     checkUsedResource(rm1, "default", 1 * GB, null);
     checkUsedResource(rm1, "default", 1 * GB, null);
-    Assert.assertEquals(1 * GB,
+    assertEquals(1 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
 
 
     // Check if decreased containers added to RMNode
     // Check if decreased containers added to RMNode
@@ -242,7 +249,7 @@ public class TestContainerResizing {
         rmNodeReceivedDecreaseContainer = true;
         rmNodeReceivedDecreaseContainer = true;
       }
       }
     }
     }
-    Assert.assertTrue(rmNodeReceivedDecreaseContainer);
+    assertTrue(rmNodeReceivedDecreaseContainer);
 
 
     rm1.close();
     rm1.close();
   }
   }
@@ -287,7 +294,7 @@ public class TestContainerResizing {
         null);
         null);
     ContainerId containerId2 =
     ContainerId containerId2 =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm1.waitForState(nm1, containerId2,
+    assertTrue(rm1.waitForState(nm1, containerId2,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     // Acquire them, and NM report RUNNING
     // Acquire them, and NM report RUNNING
     am1.allocate(null, null);
     am1.allocate(null, null);
@@ -306,7 +313,7 @@ public class TestContainerResizing {
                     Resources.createResource(7 * GB), null)));
                     Resources.createResource(7 * GB), null)));
 
 
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
 
 
     // NM1 do 1 heartbeats
     // NM1 do 1 heartbeats
@@ -316,19 +323,19 @@ public class TestContainerResizing {
     
     
     /* Check reservation statuses */
     /* Check reservation statuses */
     // Increase request should be reserved
     // Increase request should be reserved
-    Assert.assertFalse(app.getReservedContainers().isEmpty());
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertFalse(app.getReservedContainers().isEmpty());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will not be changed since it's not satisfied
     // Pending resource will not be changed since it's not satisfied
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 9 * GB, null);
     checkUsedResource(rm1, "default", 9 * GB, null);
-    Assert.assertEquals(9 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(9 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
 
 
     // Complete one container and do another allocation
     // Complete one container and do another allocation
@@ -340,19 +347,19 @@ public class TestContainerResizing {
     
     
     /* Check statuses after reservation satisfied */
     /* Check statuses after reservation satisfied */
     // Increase request should be unreserved
     // Increase request should be unreserved
-    Assert.assertTrue(app.getReservedContainers().isEmpty());
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertTrue(app.getReservedContainers().isEmpty());
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will be changed since it's satisfied
     // Pending resource will be changed since it's satisfied
     checkPendingResource(rm1, "default", 0 * GB, null);
     checkPendingResource(rm1, "default", 0 * GB, null);
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 7 * GB, null);
     checkUsedResource(rm1, "default", 7 * GB, null);
-    Assert.assertEquals(7 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(7 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
-    Assert.assertEquals(7 * GB,
+    assertEquals(7 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 1 * GB);
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 1 * GB);
 
 
@@ -396,7 +403,7 @@ public class TestContainerResizing {
         null);
         null);
     ContainerId containerId2 =
     ContainerId containerId2 =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm1.waitForState(nm1, containerId2,
+    assertTrue(rm1.waitForState(nm1, containerId2,
             RMContainerState.ALLOCATED));
             RMContainerState.ALLOCATED));
     // Acquire them, and NM report RUNNING
     // Acquire them, and NM report RUNNING
     am1.allocate(null, null);
     am1.allocate(null, null);
@@ -411,7 +418,7 @@ public class TestContainerResizing {
                     Resources.createResource(8 * GB), null)));
                     Resources.createResource(8 * GB), null)));
 
 
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
 
 
     // NM1 do 1 heartbeats
     // NM1 do 1 heartbeats
@@ -421,19 +428,19 @@ public class TestContainerResizing {
 
 
     /* Check reservation statuses */
     /* Check reservation statuses */
     // Increase request should *NOT* be reserved as it exceeds user limit
     // Increase request should *NOT* be reserved as it exceeds user limit
-    Assert.assertTrue(app.getReservedContainers().isEmpty());
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertTrue(app.getReservedContainers().isEmpty());
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will not be changed since it's not satisfied
     // Pending resource will not be changed since it's not satisfied
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will *NOT* be updated
     // Queue/user/application's usage will *NOT* be updated
     checkUsedResource(rm1, "default", 3 * GB, null);
     checkUsedResource(rm1, "default", 3 * GB, null);
-    Assert.assertEquals(3 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(3 * GB, ((LeafQueue) cs.getQueue("default"))
             .getUser("user").getUsed().getMemorySize());
             .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
     rm1.close();
     rm1.close();
   }
   }
@@ -479,7 +486,7 @@ public class TestContainerResizing {
         null);
         null);
     ContainerId containerId2 =
     ContainerId containerId2 =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm1.waitForState(nm1, containerId2,
+    assertTrue(rm1.waitForState(nm1, containerId2,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     // Acquire them, and NM report RUNNING
     // Acquire them, and NM report RUNNING
     am1.allocate(null, null);
     am1.allocate(null, null);
@@ -497,7 +504,7 @@ public class TestContainerResizing {
                     Resources.createResource(7 * GB), null)));
                     Resources.createResource(7 * GB), null)));
 
 
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
 
 
     // NM1 do 1 heartbeats
     // NM1 do 1 heartbeats
@@ -507,19 +514,19 @@ public class TestContainerResizing {
     
     
     /* Check reservation statuses */
     /* Check reservation statuses */
     // Increase request should be reserved
     // Increase request should be reserved
-    Assert.assertFalse(app.getReservedContainers().isEmpty());
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertFalse(app.getReservedContainers().isEmpty());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will not be changed since it's not satisfied
     // Pending resource will not be changed since it's not satisfied
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 9 * GB, null);
     checkUsedResource(rm1, "default", 9 * GB, null);
-    Assert.assertEquals(9 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(9 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
 
 
     // Complete one container and cancel increase request (via send a increase
     // Complete one container and cancel increase request (via send a increase
@@ -537,19 +544,19 @@ public class TestContainerResizing {
     
     
     /* Check statuses after reservation satisfied */
     /* Check statuses after reservation satisfied */
     // Increase request should be unreserved
     // Increase request should be unreserved
-    Assert.assertTrue(app.getReservedContainers().isEmpty());
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertTrue(app.getReservedContainers().isEmpty());
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will be changed since it's satisfied
     // Pending resource will be changed since it's satisfied
     checkPendingResource(rm1, "default", 0 * GB, null);
     checkPendingResource(rm1, "default", 0 * GB, null);
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 1 * GB, null);
     checkUsedResource(rm1, "default", 1 * GB, null);
-    Assert.assertEquals(1 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(1 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
-    Assert.assertEquals(1 * GB,
+    assertEquals(1 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
 
 
     rm1.close();
     rm1.close();
@@ -601,7 +608,7 @@ public class TestContainerResizing {
         null);
         null);
     ContainerId containerId2 =
     ContainerId containerId2 =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm1.waitForState(nm1, containerId2,
+    assertTrue(rm1.waitForState(nm1, containerId2,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     // Acquire them, and NM report RUNNING
     // Acquire them, and NM report RUNNING
     am1.allocate(null, null);
     am1.allocate(null, null);
@@ -620,7 +627,7 @@ public class TestContainerResizing {
                     Resources.createResource(8 * GB), null)));
                     Resources.createResource(8 * GB), null)));
 
 
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
 
 
     // NM1 do 1 heartbeats
     // NM1 do 1 heartbeats
@@ -630,19 +637,19 @@ public class TestContainerResizing {
     
     
     /* Check reservation statuses */
     /* Check reservation statuses */
     // Increase request should be reserved
     // Increase request should be reserved
-    Assert.assertFalse(app.getReservedContainers().isEmpty());
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertFalse(app.getReservedContainers().isEmpty());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will not be changed since it's not satisfied
     // Pending resource will not be changed since it's not satisfied
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 10 * GB, null);
     checkUsedResource(rm1, "default", 10 * GB, null);
-    Assert.assertEquals(10 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(10 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(4 * GB,
+    assertEquals(4 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
 
 
     // Complete one container and cancel increase request (via send a increase
     // Complete one container and cancel increase request (via send a increase
@@ -660,19 +667,19 @@ public class TestContainerResizing {
     dispatcher.await();
     dispatcher.await();
     /* Check statuses after reservation satisfied */
     /* Check statuses after reservation satisfied */
     // Increase request should be unreserved
     // Increase request should be unreserved
-    Assert.assertTrue(app.getReservedContainers().isEmpty());
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertTrue(app.getReservedContainers().isEmpty());
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will be changed since it's satisfied
     // Pending resource will be changed since it's satisfied
     checkPendingResource(rm1, "default", 0 * GB, null);
     checkPendingResource(rm1, "default", 0 * GB, null);
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 1 * GB, null);
     checkUsedResource(rm1, "default", 1 * GB, null);
-    Assert.assertEquals(1 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(1 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
-    Assert.assertEquals(1 * GB,
+    assertEquals(1 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
 
 
     rm1.close();
     rm1.close();
@@ -726,7 +733,7 @@ public class TestContainerResizing {
         null);
         null);
     ContainerId containerId2 =
     ContainerId containerId2 =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm1.waitForState(nm1, containerId2,
+    assertTrue(rm1.waitForState(nm1, containerId2,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     // Acquire them, and NM report RUNNING
     // Acquire them, and NM report RUNNING
     am1.allocate(null, null);
     am1.allocate(null, null);
@@ -742,7 +749,7 @@ public class TestContainerResizing {
                     Resources.createResource(8 * GB), null)));
                     Resources.createResource(8 * GB), null)));
 
 
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
 
 
     // NM1 do 1 heartbeats
     // NM1 do 1 heartbeats
@@ -752,19 +759,19 @@ public class TestContainerResizing {
 
 
     /* Check reservation statuses */
     /* Check reservation statuses */
     // Increase request should be reserved
     // Increase request should be reserved
-    Assert.assertFalse(app.getReservedContainers().isEmpty());
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertFalse(app.getReservedContainers().isEmpty());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will not be changed since it's not satisfied
     // Pending resource will not be changed since it's not satisfied
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 9 * GB, null);
     checkUsedResource(rm1, "default", 9 * GB, null);
-    Assert.assertEquals(9 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(9 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
 
 
     // Complete container2, container will be unreserved and completed
     // Complete container2, container will be unreserved and completed
@@ -778,19 +785,19 @@ public class TestContainerResizing {
 
 
     /* Check statuses after reservation satisfied */
     /* Check statuses after reservation satisfied */
     // Increase request should be unreserved
     // Increase request should be unreserved
-    Assert.assertTrue(app.getReservedContainers().isEmpty());
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertTrue(app.getReservedContainers().isEmpty());
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will be changed since it's satisfied
     // Pending resource will be changed since it's satisfied
     checkPendingResource(rm1, "default", 0 * GB, null);
     checkPendingResource(rm1, "default", 0 * GB, null);
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 1 * GB, null);
     checkUsedResource(rm1, "default", 1 * GB, null);
-    Assert.assertEquals(1 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(1 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
-    Assert.assertEquals(1 * GB,
+    assertEquals(1 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
 
 
     rm1.close();
     rm1.close();
@@ -838,7 +845,7 @@ public class TestContainerResizing {
         null);
         null);
     ContainerId containerId2 =
     ContainerId containerId2 =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(
+    assertTrue(
         rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED));
         rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED));
     // Acquire them, and NM report RUNNING
     // Acquire them, and NM report RUNNING
     am1.allocate(null, null);
     am1.allocate(null, null);
@@ -852,7 +859,7 @@ public class TestContainerResizing {
                     Resources.createResource(8 * GB), null)));
                     Resources.createResource(8 * GB), null)));
 
 
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
 
 
     // NM1 do 1 heartbeats
     // NM1 do 1 heartbeats
@@ -862,19 +869,19 @@ public class TestContainerResizing {
 
 
     /* Check reservation statuses */
     /* Check reservation statuses */
     // Increase request should be reserved
     // Increase request should be reserved
-    Assert.assertFalse(app.getReservedContainers().isEmpty());
-    Assert.assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertFalse(app.getReservedContainers().isEmpty());
+    assertNotNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will not be changed since it's not satisfied
     // Pending resource will not be changed since it's not satisfied
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 9 * GB, null);
     checkUsedResource(rm1, "default", 9 * GB, null);
-    Assert.assertEquals(9 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(9 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
 
 
     // Kill the application by killing the AM container
     // Kill the application by killing the AM container
@@ -888,8 +895,8 @@ public class TestContainerResizing {
 
 
     /* Check statuses after reservation satisfied */
     /* Check statuses after reservation satisfied */
     // Increase request should be unreserved
     // Increase request should be unreserved
-    Assert.assertTrue(app.getReservedContainers().isEmpty());
-    Assert.assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
+    assertTrue(app.getReservedContainers().isEmpty());
+    assertNull(cs.getNode(nm1.getNodeId()).getReservedContainer());
     // Pending resource will be changed since it's satisfied
     // Pending resource will be changed since it's satisfied
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
 
 
@@ -898,10 +905,10 @@ public class TestContainerResizing {
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 0 * GB, null);
     checkUsedResource(rm1, "default", 0 * GB, null);
     // User will be removed
     // User will be removed
-    Assert.assertNull(((LeafQueue) cs.getQueue("default")).getUser("user"));
-    Assert.assertEquals(0 * GB,
+    assertNull(((LeafQueue) cs.getQueue("default")).getUser("user"));
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
 
 
     rm1.close();
     rm1.close();
@@ -916,7 +923,7 @@ public class TestContainerResizing {
         null);
         null);
     ContainerId lastContainerId = ContainerId.newContainerId(
     ContainerId lastContainerId = ContainerId.newContainerId(
         am.getApplicationAttemptId(), startContainerId + nContainer - 1);
         am.getApplicationAttemptId(), startContainerId + nContainer - 1);
-    Assert.assertTrue(rm.waitForState(nm, lastContainerId,
+    assertTrue(rm.waitForState(nm, lastContainerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     // Acquire them, and NM report RUNNING
     // Acquire them, and NM report RUNNING
     am.allocate(null, null);
     am.allocate(null, null);
@@ -986,7 +993,7 @@ public class TestContainerResizing {
     am1.sendContainerResizingRequest(increaseRequests);
     am1.sendContainerResizingRequest(increaseRequests);
 
 
     checkPendingResource(rm1, "default", 6 * GB, null);
     checkPendingResource(rm1, "default", 6 * GB, null);
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
 
 
     // Get rmNode1
     // Get rmNode1
@@ -997,7 +1004,7 @@ public class TestContainerResizing {
     // earlier allocated)
     // earlier allocated)
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     AllocateResponse allocateResponse = am1.allocate(null, null);
     AllocateResponse allocateResponse = am1.allocate(null, null);
-    Assert.assertEquals(3, allocateResponse.getUpdatedContainers().size());
+    assertEquals(3, allocateResponse.getUpdatedContainers().size());
     verifyContainerIncreased(allocateResponse,
     verifyContainerIncreased(allocateResponse,
         ContainerId.newContainerId(attemptId, 4), 2 * GB);
         ContainerId.newContainerId(attemptId, 4), 2 * GB);
     verifyContainerIncreased(allocateResponse,
     verifyContainerIncreased(allocateResponse,
@@ -1008,21 +1015,22 @@ public class TestContainerResizing {
     /* Check statuses after allocation */
     /* Check statuses after allocation */
     // There're still 3 pending increase requests
     // There're still 3 pending increase requests
     checkPendingResource(rm1, "default", 3 * GB, null);
     checkPendingResource(rm1, "default", 3 * GB, null);
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
         app.getAppAttemptResourceUsage().getPending().getMemorySize());
     // Queue/user/application's usage will be updated
     // Queue/user/application's usage will be updated
     checkUsedResource(rm1, "default", 10 * GB, null);
     checkUsedResource(rm1, "default", 10 * GB, null);
-    Assert.assertEquals(10 * GB, ((LeafQueue) cs.getQueue("default"))
+    assertEquals(10 * GB, ((LeafQueue) cs.getQueue("default"))
         .getUser("user").getUsed().getMemorySize());
         .getUser("user").getUsed().getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
         app.getAppAttemptResourceUsage().getReserved().getMemorySize());
-    Assert.assertEquals(10 * GB,
+    assertEquals(10 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test (timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testDecreaseContainerWillNotDeadlockContainerAllocation()
   public void testDecreaseContainerWillNotDeadlockContainerAllocation()
       throws Exception {
       throws Exception {
     // create and start MockRM with our MyScheduler
     // create and start MockRM with our MyScheduler
@@ -1052,7 +1060,7 @@ public class TestContainerResizing {
     checkUsedResource(rm, "default", 3 * GB, null);
     checkUsedResource(rm, "default", 3 * GB, null);
     FiCaSchedulerApp app = TestUtils.getFiCaSchedulerApp(
     FiCaSchedulerApp app = TestUtils.getFiCaSchedulerApp(
         rm, app1.getApplicationId());
         rm, app1.getApplicationId());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
     // making sure container is launched
     // making sure container is launched
     ContainerId containerId1 =
     ContainerId containerId1 =
@@ -1081,7 +1089,7 @@ public class TestContainerResizing {
       String label) {
       String label) {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = cs.getQueue(queueName);
     CSQueue queue = cs.getQueue(queueName);
-    Assert.assertEquals(memory,
+    assertEquals(memory,
         queue.getQueueResourceUsage()
         queue.getQueueResourceUsage()
             .getPending(label == null ? RMNodeLabelsManager.NO_LABEL : label)
             .getPending(label == null ? RMNodeLabelsManager.NO_LABEL : label)
             .getMemorySize());
             .getMemorySize());
@@ -1091,7 +1099,7 @@ public class TestContainerResizing {
       String label) {
       String label) {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = cs.getQueue(queueName);
     CSQueue queue = cs.getQueue(queueName);
-    Assert.assertEquals(memory,
+    assertEquals(memory,
         queue.getQueueResourceUsage()
         queue.getQueueResourceUsage()
             .getUsed(label == null ? RMNodeLabelsManager.NO_LABEL : label)
             .getUsed(label == null ? RMNodeLabelsManager.NO_LABEL : label)
             .getMemorySize());
             .getMemorySize());
@@ -1105,14 +1113,14 @@ public class TestContainerResizing {
     for (UpdatedContainer c : increasedContainers) {
     for (UpdatedContainer c : increasedContainers) {
       if (c.getContainer().getId().equals(containerId)) {
       if (c.getContainer().getId().equals(containerId)) {
         found = true;
         found = true;
-        Assert.assertEquals(ContainerUpdateType.INCREASE_RESOURCE,
+        assertEquals(ContainerUpdateType.INCREASE_RESOURCE,
             c.getUpdateType());
             c.getUpdateType());
-        Assert.assertEquals(mem,
+        assertEquals(mem,
             c.getContainer().getResource().getMemorySize());
             c.getContainer().getResource().getMemorySize());
       }
       }
     }
     }
     if (!found) {
     if (!found) {
-      Assert.fail("Container not increased: containerId=" + containerId);
+      fail("Container not increased: containerId=" + containerId);
     }
     }
   }
   }
 
 
@@ -1124,14 +1132,14 @@ public class TestContainerResizing {
     for (UpdatedContainer c : decreasedContainers) {
     for (UpdatedContainer c : decreasedContainers) {
       if (c.getContainer().getId().equals(containerId)) {
       if (c.getContainer().getId().equals(containerId)) {
         found = true;
         found = true;
-        Assert.assertEquals(ContainerUpdateType.DECREASE_RESOURCE,
+        assertEquals(ContainerUpdateType.DECREASE_RESOURCE,
             c.getUpdateType());
             c.getUpdateType());
-        Assert.assertEquals(mem,
+        assertEquals(mem,
             c.getContainer().getResource().getMemorySize());
             c.getContainer().getResource().getMemorySize());
       }
       }
     }
     }
     if (!found) {
     if (!found) {
-      Assert.fail("Container not decreased: containerId=" + containerId);
+      fail("Container not decreased: containerId=" + containerId);
     }
     }
   }
   }
 
 
@@ -1142,7 +1150,7 @@ public class TestContainerResizing {
       rmContainer.handle(
       rmContainer.handle(
           new RMContainerEvent(containerId, RMContainerEventType.LAUNCHED));
           new RMContainerEvent(containerId, RMContainerEventType.LAUNCHED));
     } else {
     } else {
-      Assert.fail("Cannot find RMContainer");
+      fail("Cannot find RMContainer");
     }
     }
   }
   }
 
 
@@ -1150,7 +1158,6 @@ public class TestContainerResizing {
       int expectedMemory) {
       int expectedMemory) {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     SchedulerNode node = cs.getNode(nodeId);
     SchedulerNode node = cs.getNode(nodeId);
-    Assert
-        .assertEquals(expectedMemory, node.getUnallocatedResource().getMemorySize());
+    assertEquals(expectedMemory, node.getUnallocatedResource().getMemorySize());
   }
   }
 }
 }

+ 42 - 41
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestIncreaseAllocationExpirer.java

@@ -18,6 +18,10 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
 import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
@@ -44,9 +48,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Collections;
@@ -57,7 +60,7 @@ public class TestIncreaseAllocationExpirer {
   private YarnConfiguration conf;
   private YarnConfiguration conf;
   RMNodeLabelsManager mgr;
   RMNodeLabelsManager mgr;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -106,12 +109,12 @@ public class TestIncreaseAllocationExpirer {
     // AM acquire a new container to start container allocation expirer
     // AM acquire a new container to start container allocation expirer
     List<Container> containers =
     List<Container> containers =
         am1.allocate(null, null).getAllocatedContainers();
         am1.allocate(null, null).getAllocatedContainers();
-    Assert.assertEquals(containerId2, containers.get(0).getId());
-    Assert.assertNotNull(containers.get(0).getContainerToken());
+    assertEquals(containerId2, containers.get(0).getId());
+    assertNotNull(containers.get(0).getContainerToken());
     checkUsedResource(rm1, "default", 2 * GB, null);
     checkUsedResource(rm1, "default", 2 * GB, null);
     FiCaSchedulerApp app = TestUtils.getFiCaSchedulerApp(
     FiCaSchedulerApp app = TestUtils.getFiCaSchedulerApp(
         rm1, app1.getApplicationId());
         rm1, app1.getApplicationId());
-    Assert.assertEquals(2 * GB,
+    assertEquals(2 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 18 * GB);
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 18 * GB);
     // Report container status
     // Report container status
@@ -139,15 +142,14 @@ public class TestIncreaseAllocationExpirer {
     // Wait long enough and verify that the container was removed
     // Wait long enough and verify that the container was removed
     // from allocation expirer, and the container is still running
     // from allocation expirer, and the container is still running
     Thread.sleep(10000);
     Thread.sleep(10000);
-    Assert.assertEquals(RMContainerState.RUNNING,
+    assertEquals(RMContainerState.RUNNING,
         rm1.getResourceScheduler().getRMContainer(containerId2).getState());
         rm1.getResourceScheduler().getRMContainer(containerId2).getState());
     // Verify container size is 3G
     // Verify container size is 3G
-      Assert.assertEquals(
-        3 * GB, rm1.getResourceScheduler().getRMContainer(containerId2)
-            .getAllocatedResource().getMemorySize());
+    assertEquals(3 * GB, rm1.getResourceScheduler().getRMContainer(containerId2)
+        .getAllocatedResource().getMemorySize());
     // Verify total resource usage
     // Verify total resource usage
     checkUsedResource(rm1, "default", 4 * GB, null);
     checkUsedResource(rm1, "default", 4 * GB, null);
-    Assert.assertEquals(4 * GB,
+    assertEquals(4 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
     // Verify available resource
     // Verify available resource
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 16 * GB);
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 16 * GB);
@@ -195,12 +197,12 @@ public class TestIncreaseAllocationExpirer {
     rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED);
     rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED);
     List<Container> containers =
     List<Container> containers =
         am1.allocate(null, null).getAllocatedContainers();
         am1.allocate(null, null).getAllocatedContainers();
-    Assert.assertEquals(containerId2, containers.get(0).getId());
-    Assert.assertNotNull(containers.get(0).getContainerToken());
+    assertEquals(containerId2, containers.get(0).getId());
+    assertNotNull(containers.get(0).getContainerToken());
     checkUsedResource(rm1, "default", 2 * GB, null);
     checkUsedResource(rm1, "default", 2 * GB, null);
     FiCaSchedulerApp app = TestUtils.getFiCaSchedulerApp(
     FiCaSchedulerApp app = TestUtils.getFiCaSchedulerApp(
         rm1, app1.getApplicationId());
         rm1, app1.getApplicationId());
-    Assert.assertEquals(2 * GB,
+    assertEquals(2 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 18 * GB);
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 18 * GB);
     nm1.nodeHeartbeat(
     nm1.nodeHeartbeat(
@@ -219,7 +221,7 @@ public class TestIncreaseAllocationExpirer {
     am1.allocate(null, null);
     am1.allocate(null, null);
     // Verify resource usage
     // Verify resource usage
     checkUsedResource(rm1, "default", 4 * GB, null);
     checkUsedResource(rm1, "default", 4 * GB, null);
-    Assert.assertEquals(4 * GB,
+    assertEquals(4 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 16 * GB);
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 16 * GB);
     // Wait long enough for the increase token to expire, and for the roll
     // Wait long enough for the increase token to expire, and for the roll
@@ -228,13 +230,13 @@ public class TestIncreaseAllocationExpirer {
     // Verify container size is 1G
     // Verify container size is 1G
     am1.allocate(null, null);
     am1.allocate(null, null);
     rm1.drainEvents();
     rm1.drainEvents();
-    Assert.assertEquals(
+    assertEquals(
         1 * GB, rm1.getResourceScheduler().getRMContainer(containerId2)
         1 * GB, rm1.getResourceScheduler().getRMContainer(containerId2)
             .getAllocatedResource().getMemorySize());
             .getAllocatedResource().getMemorySize());
     disp.waitForEventThreadToWait();
     disp.waitForEventThreadToWait();
     // Verify total resource usage is 2G
     // Verify total resource usage is 2G
     checkUsedResource(rm1, "default", 2 * GB, null);
     checkUsedResource(rm1, "default", 2 * GB, null);
-    Assert.assertEquals(2 * GB,
+    assertEquals(2 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
     // Verify available resource is rolled back to 18GB
     // Verify available resource is rolled back to 18GB
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 18 * GB);
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 18 * GB);
@@ -311,10 +313,10 @@ public class TestIncreaseAllocationExpirer {
             ContainerUpdateType.INCREASE_RESOURCE,
             ContainerUpdateType.INCREASE_RESOURCE,
             Resources.createResource(5 * GB), null)));
             Resources.createResource(5 * GB), null)));
     List<UpdateContainerError> updateErrors = response.getUpdateErrors();
     List<UpdateContainerError> updateErrors = response.getUpdateErrors();
-    Assert.assertEquals(1, updateErrors.size());
-    Assert.assertEquals("INCORRECT_CONTAINER_VERSION_ERROR",
+    assertEquals(1, updateErrors.size());
+    assertEquals("INCORRECT_CONTAINER_VERSION_ERROR",
         updateErrors.get(0).getReason());
         updateErrors.get(0).getReason());
-    Assert.assertEquals(1,
+    assertEquals(1,
         updateErrors.get(0).getCurrentContainerVersion());
         updateErrors.get(0).getCurrentContainerVersion());
 
 
     // am1 asks to change containerId2 from 3GB to 5GB
     // am1 asks to change containerId2 from 3GB to 5GB
@@ -332,7 +334,7 @@ public class TestIncreaseAllocationExpirer {
     checkUsedResource(rm1, "default", 6 * GB, null);
     checkUsedResource(rm1, "default", 6 * GB, null);
     FiCaSchedulerApp app = TestUtils.getFiCaSchedulerApp(
     FiCaSchedulerApp app = TestUtils.getFiCaSchedulerApp(
         rm1, app1.getApplicationId());
         rm1, app1.getApplicationId());
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
     // Verify available resource is now reduced to 14GB
     // Verify available resource is now reduced to 14GB
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 14 * GB);
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 14 * GB);
@@ -344,20 +346,20 @@ public class TestIncreaseAllocationExpirer {
     am1.allocate(null, null);
     am1.allocate(null, null);
     Thread.sleep(2000);
     Thread.sleep(2000);
     // Verify container size is rolled back to 3G
     // Verify container size is rolled back to 3G
-    Assert.assertEquals(
+    assertEquals(
         3 * GB, rm1.getResourceScheduler().getRMContainer(containerId2)
         3 * GB, rm1.getResourceScheduler().getRMContainer(containerId2)
             .getAllocatedResource().getMemorySize());
             .getAllocatedResource().getMemorySize());
     // Verify total resource usage is 4G
     // Verify total resource usage is 4G
     checkUsedResource(rm1, "default", 4 * GB, null);
     checkUsedResource(rm1, "default", 4 * GB, null);
-    Assert.assertEquals(4 * GB,
+    assertEquals(4 * GB,
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
         app.getAppAttemptResourceUsage().getUsed().getMemorySize());
     // Verify available resource is rolled back to 14GB
     // Verify available resource is rolled back to 14GB
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 16 * GB);
     verifyAvailableResourceOfSchedulerNode(rm1, nm1.getNodeId(), 16 * GB);
     // Verify NM receives the decrease message (3G)
     // Verify NM receives the decrease message (3G)
     List<Container> containersToDecrease =
     List<Container> containersToDecrease =
         nm1.nodeHeartbeat(true).getContainersToUpdate();
         nm1.nodeHeartbeat(true).getContainersToUpdate();
-    Assert.assertEquals(1, containersToDecrease.size());
-    Assert.assertEquals(
+    assertEquals(1, containersToDecrease.size());
+    assertEquals(
         3 * GB, containersToDecrease.get(0).getResource().getMemorySize());
         3 * GB, containersToDecrease.get(0).getResource().getMemorySize());
     rm1.stop();
     rm1.stop();
   }
   }
@@ -413,10 +415,10 @@ public class TestIncreaseAllocationExpirer {
     // AM acquires tokens to start container allocation expirer
     // AM acquires tokens to start container allocation expirer
     List<Container> containers =
     List<Container> containers =
         am1.allocate(null, null).getAllocatedContainers();
         am1.allocate(null, null).getAllocatedContainers();
-    Assert.assertEquals(3, containers.size());
-    Assert.assertNotNull(containers.get(0).getContainerToken());
-    Assert.assertNotNull(containers.get(1).getContainerToken());
-    Assert.assertNotNull(containers.get(2).getContainerToken());
+    assertEquals(3, containers.size());
+    assertNotNull(containers.get(0).getContainerToken());
+    assertNotNull(containers.get(1).getContainerToken());
+    assertNotNull(containers.get(2).getContainerToken());
     // Report container status
     // Report container status
     nm1.nodeHeartbeat(app1.getCurrentAppAttempt().getAppAttemptId(),
     nm1.nodeHeartbeat(app1.getCurrentAppAttempt().getAppAttemptId(),
         2, ContainerState.RUNNING);
         2, ContainerState.RUNNING);
@@ -458,7 +460,7 @@ public class TestIncreaseAllocationExpirer {
     AllocateResponse response =
     AllocateResponse response =
         am1.sendContainerResizingRequest(decreaseRequests);
         am1.sendContainerResizingRequest(decreaseRequests);
     // Verify containers are decreased in scheduler
     // Verify containers are decreased in scheduler
-    Assert.assertEquals(3, response.getUpdatedContainers().size());
+    assertEquals(3, response.getUpdatedContainers().size());
     // Use the token for containerId4 on NM (6G). This should set the last
     // Use the token for containerId4 on NM (6G). This should set the last
     // confirmed resource to 4G, and cancel the allocation expirer
     // confirmed resource to 4G, and cancel the allocation expirer
     nm1.containerIncreaseStatus(getContainer(
     nm1.containerIncreaseStatus(getContainer(
@@ -469,13 +471,13 @@ public class TestIncreaseAllocationExpirer {
     am1.allocate(null, null);
     am1.allocate(null, null);
 
 
     rm1.drainEvents();
     rm1.drainEvents();
-    Assert.assertEquals(
+    assertEquals(
         2 * GB, rm1.getResourceScheduler().getRMContainer(containerId2)
         2 * GB, rm1.getResourceScheduler().getRMContainer(containerId2)
             .getAllocatedResource().getMemorySize());
             .getAllocatedResource().getMemorySize());
-    Assert.assertEquals(
+    assertEquals(
         3 * GB, rm1.getResourceScheduler().getRMContainer(containerId3)
         3 * GB, rm1.getResourceScheduler().getRMContainer(containerId3)
             .getAllocatedResource().getMemorySize());
             .getAllocatedResource().getMemorySize());
-    Assert.assertEquals(
+    assertEquals(
         4 * GB, rm1.getResourceScheduler().getRMContainer(containerId4)
         4 * GB, rm1.getResourceScheduler().getRMContainer(containerId4)
             .getAllocatedResource().getMemorySize());
             .getAllocatedResource().getMemorySize());
     // Verify NM receives 2 decrease message
     // Verify NM receives 2 decrease message
@@ -483,18 +485,18 @@ public class TestIncreaseAllocationExpirer {
         nm1.nodeHeartbeat(true).getContainersToUpdate();
         nm1.nodeHeartbeat(true).getContainersToUpdate();
     // NOTE: Can be more that 2 depending on which event arrives first.
     // NOTE: Can be more that 2 depending on which event arrives first.
     // What is important is the final size of the containers.
     // What is important is the final size of the containers.
-    Assert.assertTrue(containersToDecrease.size() >= 2);
+    assertTrue(containersToDecrease.size() >= 2);
 
 
     // Sort the list to make sure containerId3 is the first
     // Sort the list to make sure containerId3 is the first
     Collections.sort(containersToDecrease);
     Collections.sort(containersToDecrease);
     int i = 0;
     int i = 0;
     if (containersToDecrease.size() > 2) {
     if (containersToDecrease.size() > 2) {
-      Assert.assertEquals(
+      assertEquals(
           2 * GB, containersToDecrease.get(i++).getResource().getMemorySize());
           2 * GB, containersToDecrease.get(i++).getResource().getMemorySize());
     }
     }
-    Assert.assertEquals(
+    assertEquals(
         3 * GB, containersToDecrease.get(i++).getResource().getMemorySize());
         3 * GB, containersToDecrease.get(i++).getResource().getMemorySize());
-    Assert.assertEquals(
+    assertEquals(
         4 * GB, containersToDecrease.get(i++).getResource().getMemorySize());
         4 * GB, containersToDecrease.get(i++).getResource().getMemorySize());
     rm1.stop();
     rm1.stop();
   }
   }
@@ -503,7 +505,7 @@ public class TestIncreaseAllocationExpirer {
       String label) {
       String label) {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = cs.getQueue(queueName);
     CSQueue queue = cs.getQueue(queueName);
-    Assert.assertEquals(memory,
+    assertEquals(memory,
         queue.getQueueResourceUsage()
         queue.getQueueResourceUsage()
             .getUsed(label == null ? RMNodeLabelsManager.NO_LABEL : label)
             .getUsed(label == null ? RMNodeLabelsManager.NO_LABEL : label)
             .getMemorySize());
             .getMemorySize());
@@ -513,8 +515,7 @@ public class TestIncreaseAllocationExpirer {
       int expectedMemory) {
       int expectedMemory) {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     SchedulerNode node = cs.getNode(nodeId);
     SchedulerNode node = cs.getNode(nodeId);
-    Assert
-        .assertEquals(expectedMemory, node.getUnallocatedResource().getMemorySize());
+    assertEquals(expectedMemory, node.getUnallocatedResource().getMemorySize());
   }
   }
 
 
   private Container getContainer(
   private Container getContainer(

+ 78 - 79
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java

@@ -26,10 +26,11 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
     .capacity.CapacitySchedulerConfiguration.DOT;
     .capacity.CapacitySchedulerConfiguration.DOT;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
     .capacity.CapacitySchedulerConfiguration.ROOT;
     .capacity.CapacitySchedulerConfiguration.ROOT;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doNothing;
@@ -122,10 +123,10 @@ import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.mockito.ArgumentMatchers;
 import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
@@ -160,7 +161,7 @@ public class TestLeafQueue {
   private final ResourceCalculator dominantResourceCalculator =
   private final ResourceCalculator dominantResourceCalculator =
       new DominantResourceCalculator();
       new DominantResourceCalculator();
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     setUpInternal(resourceCalculator, false);
     setUpInternal(resourceCalculator, false);
   }
   }
@@ -932,8 +933,8 @@ public class TestLeafQueue {
             priority, recordFactory, NO_LABEL)));
             priority, recordFactory, NO_LABEL)));
     assign = b.assignContainers(clusterResource, node0, new ResourceLimits(
     assign = b.assignContainers(clusterResource, node0, new ResourceLimits(
         clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
         clusterResource), SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY);
-    assertTrue("Still within limits, should assign",
-        assign.getResource().getMemorySize() > 0);
+    assertTrue(assign.getResource().getMemorySize() > 0,
+        "Still within limits, should assign");
   }
   }
 
 
   private void applyCSAssignment(Resource clusterResource, CSAssignment assign,
   private void applyCSAssignment(Resource clusterResource, CSAssignment assign,
@@ -1014,8 +1015,8 @@ public class TestLeafQueue {
     User queueUser0 = b.getUser(user0);
     User queueUser0 = b.getUser(user0);
     User queueUser1 = b.getUser(user1);
     User queueUser1 = b.getUser(user1);
 
 
-    assertEquals("There should 2 active users!", 2, b
-        .getAbstractUsersManager().getNumActiveUsers());
+    assertEquals(2, b.getAbstractUsersManager().getNumActiveUsers(),
+        "There should 2 active users!");
     // Fill both Nodes as far as we can
     // Fill both Nodes as far as we can
     CSAssignment assign;
     CSAssignment assign;
     do {
     do {
@@ -1034,13 +1035,12 @@ public class TestLeafQueue {
     } while (assign.getResource().getMemorySize() > 0 &&
     } while (assign.getResource().getMemorySize() > 0 &&
         assign.getAssignmentInformation().getNumReservations() == 0);
         assign.getAssignmentInformation().getNumReservations() == 0);
 
 
-    assertTrue("Verify user_0 got resources ", queueUser0.getUsed()
-        .getMemorySize() > 0);
-    assertTrue("Verify user_1 got resources ", queueUser1.getUsed()
-        .getMemorySize() > 0);
-    assertTrue(
-        "Expected AbsoluteUsedCapacity > 0.95, got: "
-            + b.getAbsoluteUsedCapacity(), b.getAbsoluteUsedCapacity() > 0.95);
+    assertTrue(queueUser0.getUsed().getMemorySize() > 0,
+        "Verify user_0 got resources ");
+    assertTrue(queueUser1.getUsed().getMemorySize() > 0,
+        "Verify user_1 got resources ");
+    assertTrue(b.getAbsoluteUsedCapacity() > 0.95,
+        "Expected AbsoluteUsedCapacity > 0.95, got: " + b.getAbsoluteUsedCapacity());
 
 
     // Verify consumedRatio is based on dominant resources
     // Verify consumedRatio is based on dominant resources
     float expectedRatio =
     float expectedRatio =
@@ -1809,8 +1809,8 @@ public class TestLeafQueue {
     assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
     assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
 
 
     // app_0 doesn't have outstanding resources, there's only one active user.
     // app_0 doesn't have outstanding resources, there's only one active user.
-    assertEquals("There should only be 1 active user!", 
-        1, a.getAbstractUsersManager().getNumActiveUsers());
+    assertEquals(1, a.getAbstractUsersManager().getNumActiveUsers(),
+        "There should only be 1 active user!");
   }
   }
 
 
   @Test
   @Test
@@ -1914,8 +1914,8 @@ public class TestLeafQueue {
     assertEquals(GB, app1.getCurrentConsumption().getMemorySize());
     assertEquals(GB, app1.getCurrentConsumption().getMemorySize());
 
 
     // app_0 doesn't have outstanding resources, there's only one active user.
     // app_0 doesn't have outstanding resources, there's only one active user.
-    assertEquals("There should only be 1 active user!",
-        1, a.getAbstractUsersManager().getNumActiveUsers());
+    assertEquals(1, a.getAbstractUsersManager().getNumActiveUsers(),
+        "There should only be 1 active user!");
   }
   }
 
 
   @Test
   @Test
@@ -1941,7 +1941,7 @@ public class TestLeafQueue {
     when(csContext.getClusterResource())
     when(csContext.getClusterResource())
         .thenReturn(Resources.createResource(16 * GB, 32));
         .thenReturn(Resources.createResource(16 * GB, 32));
     // Verify that configs were updated and parsed correctly.
     // Verify that configs were updated and parsed correctly.
-    Assert.assertEquals(UserWeights.DEFAULT_WEIGHT, a.getUserWeights().getByUser("user_0"), 0.0f);
+    assertEquals(UserWeights.DEFAULT_WEIGHT, a.getUserWeights().getByUser("user_0"), 0.0f);
     a.reinitialize(a, csContext.getClusterResource());
     a.reinitialize(a, csContext.getClusterResource());
     assertEquals(1.5f, a.getUserWeights().getByUser("user_0"), 0.0f);
     assertEquals(1.5f, a.getUserWeights().getByUser("user_0"), 0.0f);
     assertEquals(0.7f, a.getUserWeights().getByUser("firstname.lastname"), 0.0f);
     assertEquals(0.7f, a.getUserWeights().getByUser("firstname.lastname"), 0.0f);
@@ -2115,8 +2115,8 @@ public class TestLeafQueue {
         TestUtils.createResourceRequest(ResourceRequest.ANY, 4*GB, 1, true,
         TestUtils.createResourceRequest(ResourceRequest.ANY, 4*GB, 1, true,
             u0Priority, recordFactory)));
             u0Priority, recordFactory)));
 
 
-    assertEquals("There should only be 1 active user!",
-        1, qb.getAbstractUsersManager().getNumActiveUsers());
+    assertEquals(1, qb.getAbstractUsersManager().getNumActiveUsers(),
+        "There should only be 1 active user!");
     //get headroom
     //get headroom
     applyCSAssignment(clusterResource,
     applyCSAssignment(clusterResource,
         qb.assignContainers(clusterResource, node_0,
         qb.assignContainers(clusterResource, node_0,
@@ -2308,8 +2308,8 @@ public class TestLeafQueue {
 
 
     // Now, only user_0 should be active since he is the only one with
     // Now, only user_0 should be active since he is the only one with
     // outstanding requests
     // outstanding requests
-    assertEquals("There should only be 1 active user!", 
-        1, a.getAbstractUsersManager().getNumActiveUsers());
+    assertEquals(1, a.getAbstractUsersManager().getNumActiveUsers(),
+        "There should only be 1 active user!");
 
 
     // 1 container to user_0
     // 1 container to user_0
     applyCSAssignment(clusterResource,
     applyCSAssignment(clusterResource,
@@ -2992,18 +2992,16 @@ public class TestLeafQueue {
   }
   }
   
   
   private void verifyContainerAllocated(CSAssignment assignment, NodeType nodeType) {
   private void verifyContainerAllocated(CSAssignment assignment, NodeType nodeType) {
-    Assert.assertTrue(Resources.greaterThan(resourceCalculator, null,
+    assertTrue(Resources.greaterThan(resourceCalculator, null,
         assignment.getResource(), Resources.none()));
         assignment.getResource(), Resources.none()));
-    Assert
-        .assertTrue(assignment.getAssignmentInformation().getNumAllocations() > 0);
-    Assert.assertEquals(nodeType, assignment.getType());
+    assertTrue(assignment.getAssignmentInformation().getNumAllocations() > 0);
+    assertEquals(nodeType, assignment.getType());
   }
   }
 
 
   private void verifyNoContainerAllocated(CSAssignment assignment) {
   private void verifyNoContainerAllocated(CSAssignment assignment) {
-    Assert.assertTrue(Resources.equals(assignment.getResource(),
+    assertTrue(Resources.equals(assignment.getResource(),
         Resources.none()));
         Resources.none()));
-    Assert
-        .assertTrue(assignment.getAssignmentInformation().getNumAllocations() == 0);
+    assertTrue(assignment.getAssignmentInformation().getNumAllocations() == 0);
   }
   }
 
 
   @Test
   @Test
@@ -3629,7 +3627,8 @@ public class TestLeafQueue {
     assertEquals(0, app_0.getOutstandingAsksCount(schedulerKey));
     assertEquals(0, app_0.getOutstandingAsksCount(schedulerKey));
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testActivateApplicationAfterQueueRefresh() throws Exception {
   public void testActivateApplicationAfterQueueRefresh() throws Exception {
 
 
     // Manipulate queue 'e'
     // Manipulate queue 'e'
@@ -3690,7 +3689,8 @@ public class TestLeafQueue {
     assertEquals(0, e.getNumPendingApplications());
     assertEquals(0, e.getNumPendingApplications());
   }
   }
   
   
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testLocalityDelaysAfterQueueRefresh() throws Exception {
   public void testLocalityDelaysAfterQueueRefresh() throws Exception {
 
 
     // Manipulate queue 'e'
     // Manipulate queue 'e'
@@ -3718,7 +3718,8 @@ public class TestLeafQueue {
     assertEquals(600, e.getRackLocalityAdditionalDelay());
     assertEquals(600, e.getRackLocalityAdditionalDelay());
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testActivateApplicationByUpdatingClusterResource()
   public void testActivateApplicationByUpdatingClusterResource()
       throws Exception {
       throws Exception {
 
 
@@ -4154,7 +4155,7 @@ public class TestLeafQueue {
           new ResourceLimits(clusterResource),
           new ResourceLimits(clusterResource),
           SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
           SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
     } catch (NullPointerException e) {
     } catch (NullPointerException e) {
-      Assert.fail("NPE when allocating container on node but "
+      fail("NPE when allocating container on node but "
           + "forget to set off-switch request should be handled");
           + "forget to set off-switch request should be handled");
     }
     }
   }
   }
@@ -4221,12 +4222,12 @@ public class TestLeafQueue {
         a.assignContainers(clusterResource, node_0_0,
         a.assignContainers(clusterResource, node_0_0,
             new ResourceLimits(clusterResource),
             new ResourceLimits(clusterResource),
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(1 * GB, app_1.getCurrentConsumption().getMemorySize());
+    assertEquals(1 * GB, app_1.getCurrentConsumption().getMemorySize());
     applyCSAssignment(clusterResource,
     applyCSAssignment(clusterResource,
         a.assignContainers(clusterResource, node_0_0,
         a.assignContainers(clusterResource, node_0_0,
             new ResourceLimits(clusterResource),
             new ResourceLimits(clusterResource),
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
+    assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
 
 
     app_0_requests_0.clear();
     app_0_requests_0.clear();
     app_0_requests_0.add(TestUtils
     app_0_requests_0.add(TestUtils
@@ -4245,15 +4246,15 @@ public class TestLeafQueue {
         a.assignContainers(clusterResource, node_0_0,
         a.assignContainers(clusterResource, node_0_0,
             new ResourceLimits(clusterResource),
             new ResourceLimits(clusterResource),
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(2 * GB, app_1.getCurrentConsumption().getMemorySize());
-    Assert.assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
+    assertEquals(2 * GB, app_1.getCurrentConsumption().getMemorySize());
+    assertEquals(2 * GB, app_0.getCurrentConsumption().getMemorySize());
 
 
     //and only then will app_2
     //and only then will app_2
     applyCSAssignment(clusterResource,
     applyCSAssignment(clusterResource,
         a.assignContainers(clusterResource, node_0_0,
         a.assignContainers(clusterResource, node_0_0,
             new ResourceLimits(clusterResource),
             new ResourceLimits(clusterResource),
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(3 * GB, app_0.getCurrentConsumption().getMemorySize());
+    assertEquals(3 * GB, app_0.getCurrentConsumption().getMemorySize());
   }
   }
 
 
   @Test
   @Test
@@ -4325,7 +4326,7 @@ public class TestLeafQueue {
         a.assignContainers(clusterResource, node00,
         a.assignContainers(clusterResource, node00,
             new ResourceLimits(clusterResource),
             new ResourceLimits(clusterResource),
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(1 * GB, app1.getSchedulingResourceUsage()
+    assertEquals(1 * GB, app1.getSchedulingResourceUsage()
         .getUsed(LABEL).getMemorySize());
         .getUsed(LABEL).getMemorySize());
     // app_0 should not get resources from node_0_0 since the labels
     // app_0 should not get resources from node_0_0 since the labels
     // don't match
     // don't match
@@ -4333,7 +4334,7 @@ public class TestLeafQueue {
         a.assignContainers(clusterResource, node00,
         a.assignContainers(clusterResource, node00,
             new ResourceLimits(clusterResource),
             new ResourceLimits(clusterResource),
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(0 * GB, app0.getCurrentConsumption().getMemorySize());
+    assertEquals(0 * GB, app0.getCurrentConsumption().getMemorySize());
 
 
     app1Requests.clear();
     app1Requests.clear();
     app1Requests.add(TestUtils
     app1Requests.add(TestUtils
@@ -4346,8 +4347,8 @@ public class TestLeafQueue {
         a.assignContainers(clusterResource, node01,
         a.assignContainers(clusterResource, node01,
             new ResourceLimits(clusterResource),
             new ResourceLimits(clusterResource),
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(2 * GB, app0.getCurrentConsumption().getMemorySize());
-    Assert.assertEquals(1 * GB, app1.getSchedulingResourceUsage()
+    assertEquals(2 * GB, app0.getCurrentConsumption().getMemorySize());
+    assertEquals(1 * GB, app1.getSchedulingResourceUsage()
         .getUsed(LABEL).getMemorySize());
         .getUsed(LABEL).getMemorySize());
 
 
     app0Requests.clear();
     app0Requests.clear();
@@ -4361,8 +4362,8 @@ public class TestLeafQueue {
         a.assignContainers(clusterResource, node00,
         a.assignContainers(clusterResource, node00,
             new ResourceLimits(clusterResource),
             new ResourceLimits(clusterResource),
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
             SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(2 * GB, app0.getCurrentConsumption().getMemorySize());
-    Assert.assertEquals(2 * GB, app1.getSchedulingResourceUsage()
+    assertEquals(2 * GB, app0.getCurrentConsumption().getMemorySize());
+    assertEquals(2 * GB, app1.getSchedulingResourceUsage()
         .getUsed(LABEL).getMemorySize());
         .getUsed(LABEL).getMemorySize());
   }
   }
 
 
@@ -4429,8 +4430,8 @@ public class TestLeafQueue {
     submitAndRemove.join();
     submitAndRemove.join();
     getAppsInQueue.join();
     getAppsInQueue.join();
 
 
-    assertTrue("ConcurrentModificationException is thrown",
-        conException.isEmpty());
+    assertTrue(conException.isEmpty(),
+        "ConcurrentModificationException is thrown");
     rm.stop();
     rm.stop();
 
 
   }
   }
@@ -4499,12 +4500,12 @@ public class TestLeafQueue {
         a.assignContainers(clusterResource, node_0_0,
         a.assignContainers(clusterResource, node_0_0,
         new ResourceLimits(clusterResource),
         new ResourceLimits(clusterResource),
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
+    assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
     applyCSAssignment(clusterResource,
     applyCSAssignment(clusterResource,
         a.assignContainers(clusterResource, node_0_0,
         a.assignContainers(clusterResource, node_0_0,
         new ResourceLimits(clusterResource),
         new ResourceLimits(clusterResource),
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
+    assertEquals(1*GB, app_1.getCurrentConsumption().getMemorySize());
 
 
     app_0_requests_0.clear();
     app_0_requests_0.clear();
     app_0_requests_0.add(
     app_0_requests_0.add(
@@ -4524,15 +4525,15 @@ public class TestLeafQueue {
         a.assignContainers(clusterResource, node_0_0,
         a.assignContainers(clusterResource, node_0_0,
         new ResourceLimits(clusterResource),
         new ResourceLimits(clusterResource),
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
-    Assert.assertEquals(2*GB, app_1.getCurrentConsumption().getMemorySize());
+    assertEquals(2*GB, app_0.getCurrentConsumption().getMemorySize());
+    assertEquals(2*GB, app_1.getCurrentConsumption().getMemorySize());
 
 
     //and only then will app_0
     //and only then will app_0
     applyCSAssignment(clusterResource,
     applyCSAssignment(clusterResource,
         a.assignContainers(clusterResource, node_0_0,
         a.assignContainers(clusterResource, node_0_0,
         new ResourceLimits(clusterResource),
         new ResourceLimits(clusterResource),
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY), a, nodes, apps);
-    Assert.assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
+    assertEquals(3*GB, app_0.getCurrentConsumption().getMemorySize());
 
 
   }
   }
   
   
@@ -5261,9 +5262,8 @@ public class TestLeafQueue {
 
 
     LeafQueue e = (LeafQueue) cs.getQueue("e");
     LeafQueue e = (LeafQueue) cs.getQueue("e");
     // Maximum application should be calculated with the default node label
     // Maximum application should be calculated with the default node label
-    Assert.assertEquals("Maximum application is not calculated properly",
-            (int)(conf.getMaximumSystemApplications()
-                * e.getAbsoluteCapacity()), e.getMaxApplications());
+    assertEquals((int)(conf.getMaximumSystemApplications() * e.getAbsoluteCapacity()),
+        e.getMaxApplications(), "Maximum application is not calculated properly");
 
 
     conf.setCapacityByLabel(new QueuePath(rootChild, A), "test", 10);
     conf.setCapacityByLabel(new QueuePath(rootChild, A), "test", 10);
     conf.setCapacityByLabel(new QueuePath(rootChild, B), "test", 10);
     conf.setCapacityByLabel(new QueuePath(rootChild, B), "test", 10);
@@ -5275,10 +5275,9 @@ public class TestLeafQueue {
     e = (LeafQueue) cs.getQueue("e");
     e = (LeafQueue) cs.getQueue("e");
     // Maximum application is now determined by test label, because that would
     // Maximum application is now determined by test label, because that would
     // yield a higher value than with default node label
     // yield a higher value than with default node label
-    Assert.assertEquals("Maximum application is not calculated properly",
-        (int)(conf.getMaximumSystemApplications() *
-            e.getQueueCapacities().getAbsoluteCapacity("test")),
-        e.getMaxApplications());
+    assertEquals((int)(conf.getMaximumSystemApplications() *
+        e.getQueueCapacities().getAbsoluteCapacity("test")),
+        e.getMaxApplications(), "Maximum application is not calculated properly");
   }
   }
 
 
   @Test
   @Test
@@ -5308,11 +5307,11 @@ public class TestLeafQueue {
 
 
     ParentQueue rootQueue = (ParentQueue) cs.getRootQueue();
     ParentQueue rootQueue = (ParentQueue) cs.getRootQueue();
 
 
-    Assert.assertEquals(Sets.newHashSet("", "test", "test2"),
+    assertEquals(Sets.newHashSet("", "test", "test2"),
         rootQueue.queueNodeLabelsSettings.getConfiguredNodeLabels());
         rootQueue.queueNodeLabelsSettings.getConfiguredNodeLabels());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     if (cs != null) {
     if (cs != null) {
       cs.stop();
       cs.stop();
@@ -5388,12 +5387,12 @@ public class TestLeafQueue {
     // USE_REAL_ACLS character prepended.
     // USE_REAL_ACLS character prepended.
     try {
     try {
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi0);
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi0);
-      Assert.fail(user0 + " should not be allowed to submit to the "
+      fail(user0 + " should not be allowed to submit to the "
                   + queue + " queue when only admin user is in submit ACL.");
                   + queue + " queue when only admin user is in submit ACL.");
     } catch (YarnException e) {
     } catch (YarnException e) {
       // This is the expected behavior.
       // This is the expected behavior.
-      assertTrue("Should have received an AccessControlException.",
-          e.getCause() instanceof AccessControlException);
+      assertTrue(e.getCause() instanceof AccessControlException,
+          "Should have received an AccessControlException.");
     }
     }
 
 
     // With only user0 in the list of users authorized to submit apps to the
     // With only user0 in the list of users authorized to submit apps to the
@@ -5403,7 +5402,7 @@ public class TestLeafQueue {
     try {
     try {
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi0);
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi0);
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail(user0 + " should be allowed to submit to the "
+      fail(user0 + " should be allowed to submit to the "
                   + queue + " queue.");
                   + queue + " queue.");
     }
     }
 
 
@@ -5411,12 +5410,12 @@ public class TestLeafQueue {
     // queue, ensure that user1 is NOT allowed to submit to the default queue
     // queue, ensure that user1 is NOT allowed to submit to the default queue
     try {
     try {
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi1);
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi1);
-      Assert.fail(user1 + " should not be allowed to submit to the "
+      fail(user1 + " should not be allowed to submit to the "
           + queue + " queue.");
           + queue + " queue.");
     } catch (YarnException e) {
     } catch (YarnException e) {
       // This is the expected behavior.
       // This is the expected behavior.
-      assertTrue("Should have received an AccessControlException.",
-          e.getCause() instanceof AccessControlException);
+      assertTrue(e.getCause() instanceof AccessControlException,
+          "Should have received an AccessControlException.");
     }
     }
 
 
     // Even though the admin user is in the list of users allowed to submit to
     // Even though the admin user is in the list of users allowed to submit to
@@ -5427,12 +5426,12 @@ public class TestLeafQueue {
         new AccessControlList(user0 + "," + realUser));
         new AccessControlList(user0 + "," + realUser));
     try {
     try {
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi1);
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi1);
-      Assert.fail(user1 + " should not be allowed to submit to the "
+      fail(user1 + " should not be allowed to submit to the "
                   + queue + " queue.");
                   + queue + " queue.");
     } catch (YarnException e) {
     } catch (YarnException e) {
       // This is the expected behavior.
       // This is the expected behavior.
-      assertTrue("Should have received an AccessControlException.",
-          e.getCause() instanceof AccessControlException);
+      assertTrue(e.getCause() instanceof AccessControlException,
+          "Should have received an AccessControlException.");
     }
     }
 
 
     // user1 should now be allowed to submit to the default queue because the
     // user1 should now be allowed to submit to the default queue because the
@@ -5446,8 +5445,8 @@ public class TestLeafQueue {
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi1);
       testRmAppManager.submitApplication(asc, System.currentTimeMillis(), ugi1);
     } catch (YarnException e) {
     } catch (YarnException e) {
       LOG.error("failed to submit", e);
       LOG.error("failed to submit", e);
-      Assert.fail(user1 + " should be allowed to submit to the "
-                  + queue + " queue when real user is" + realUser + ".");
+      fail(user1 + " should be allowed to submit to the " +
+          queue + " queue when real user is" + realUser + ".");
     }
     }
 
 
     rm.stop();
     rm.stop();

+ 16 - 12
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestMixedQueueResourceCalculation.java

@@ -26,8 +26,8 @@ import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueUpdateWarning.QueueUpdateWarningType;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueUpdateWarning.QueueUpdateWarningType;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Collection;
@@ -36,6 +36,9 @@ import java.util.Optional;
 import static org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager.NO_LABEL;
 import static org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager.NO_LABEL;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.ROOT;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.ROOT;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerAutoCreatedQueueBase.GB;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacitySchedulerAutoCreatedQueueBase.GB;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestMixedQueueResourceCalculation extends CapacitySchedulerQueueCalculationTestBase {
 public class TestMixedQueueResourceCalculation extends CapacitySchedulerQueueCalculationTestBase {
   private static final long MEMORY = 16384;
   private static final long MEMORY = 16384;
@@ -201,6 +204,7 @@ public class TestMixedQueueResourceCalculation extends CapacitySchedulerQueueCal
   private static final String B1_VECTOR_WITH_WARNING =
   private static final String B1_VECTOR_WITH_WARNING =
       createCapacityVector(absolute(10256), absolute(3));
       createCapacityVector(absolute(10256), absolute(3));
 
 
+  @BeforeEach
   @Override
   @Override
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     super.setUp();
     super.setUp();
@@ -323,10 +327,10 @@ public class TestMixedQueueResourceCalculation extends CapacitySchedulerQueueCal
     Optional<QueueUpdateWarning> queueA11ZeroResourceWarning = getSpecificWarning(
     Optional<QueueUpdateWarning> queueA11ZeroResourceWarning = getSpecificWarning(
         updateContext.getUpdateWarnings(), QueueUpdateWarningType.QUEUE_ZERO_RESOURCE, A11);
         updateContext.getUpdateWarnings(), QueueUpdateWarningType.QUEUE_ZERO_RESOURCE, A11);
 
 
-    Assert.assertTrue(queueCZeroResourceWarning.isPresent());
-    Assert.assertTrue(queueARemainingResourceWarning.isPresent());
-    Assert.assertTrue(queueBDownscalingWarning.isPresent());
-    Assert.assertTrue(queueA11ZeroResourceWarning.isPresent());
+    assertTrue(queueCZeroResourceWarning.isPresent());
+    assertTrue(queueARemainingResourceWarning.isPresent());
+    assertTrue(queueBDownscalingWarning.isPresent());
+    assertTrue(queueA11ZeroResourceWarning.isPresent());
   }
   }
 
 
   @Test
   @Test
@@ -346,8 +350,8 @@ public class TestMixedQueueResourceCalculation extends CapacitySchedulerQueueCal
         updateContext.getUpdateWarnings(), QueueUpdateWarningType.QUEUE_ZERO_RESOURCE, A);
         updateContext.getUpdateWarnings(), QueueUpdateWarningType.QUEUE_ZERO_RESOURCE, A);
     Optional<QueueUpdateWarning> rootUnderUtilizedWarning = getSpecificWarning(
     Optional<QueueUpdateWarning> rootUnderUtilizedWarning = getSpecificWarning(
         updateContext.getUpdateWarnings(), QueueUpdateWarningType.BRANCH_UNDERUTILIZED, ROOT);
         updateContext.getUpdateWarnings(), QueueUpdateWarningType.BRANCH_UNDERUTILIZED, ROOT);
-    Assert.assertTrue(queueAZeroResourceWarning.isPresent());
-    Assert.assertTrue(rootUnderUtilizedWarning.isPresent());
+    assertTrue(queueAZeroResourceWarning.isPresent());
+    assertTrue(rootUnderUtilizedWarning.isPresent());
   }
   }
 
 
   @Test
   @Test
@@ -367,14 +371,14 @@ public class TestMixedQueueResourceCalculation extends CapacitySchedulerQueueCal
         .build();
         .build();
 
 
     QueueCapacityUpdateContext updateContext = update(assertionBuilder, UPDATE_RESOURCE);
     QueueCapacityUpdateContext updateContext = update(assertionBuilder, UPDATE_RESOURCE);
-    Assert.assertEquals(0, updateContext.getUpdateWarnings().size());
+    assertEquals(0, updateContext.getUpdateWarnings().size());
 
 
     // WEIGHT capacity type for maximum capacity is not supported
     // WEIGHT capacity type for maximum capacity is not supported
     csConf.setMaximumCapacityVector(B, NO_LABEL, B_INVALID_MAX_VECTOR);
     csConf.setMaximumCapacityVector(B, NO_LABEL, B_INVALID_MAX_VECTOR);
     try {
     try {
       cs.reinitialize(csConf, mockRM.getRMContext());
       cs.reinitialize(csConf, mockRM.getRMContext());
       update(assertionBuilder, UPDATE_RESOURCE);
       update(assertionBuilder, UPDATE_RESOURCE);
-      Assert.fail("WEIGHT maximum capacity type is not supported, an error should be thrown when " +
+      fail("WEIGHT maximum capacity type is not supported, an error should be thrown when " +
           "set up");
           "set up");
     } catch (IOException ignored) {
     } catch (IOException ignored) {
     }
     }
@@ -402,8 +406,8 @@ public class TestMixedQueueResourceCalculation extends CapacitySchedulerQueueCal
         A11);
         A11);
     Optional<QueueUpdateWarning> queueA11MinExceedsMaxWarning = getSpecificWarning(
     Optional<QueueUpdateWarning> queueA11MinExceedsMaxWarning = getSpecificWarning(
         updateContext.getUpdateWarnings(), QueueUpdateWarningType.QUEUE_EXCEEDS_MAX_RESOURCE, A11);
         updateContext.getUpdateWarnings(), QueueUpdateWarningType.QUEUE_EXCEEDS_MAX_RESOURCE, A11);
-    Assert.assertTrue(queueA11ExceedsParentMaxResourceWarning.isPresent());
-    Assert.assertTrue(queueA11MinExceedsMaxWarning.isPresent());
+    assertTrue(queueA11ExceedsParentMaxResourceWarning.isPresent());
+    assertTrue(queueA11MinExceedsMaxWarning.isPresent());
   }
   }
 
 
   @Test
   @Test

+ 186 - 177
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestNodeLabelContainerAllocation.java

@@ -18,7 +18,10 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
@@ -68,9 +71,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptR
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.PendingAsk;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.PendingAsk;
 import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
 import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
@@ -104,7 +107,7 @@ public class TestNodeLabelContainerAllocation {
   
   
   RMNodeLabelsManager mgr;
   RMNodeLabelsManager mgr;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -161,10 +164,10 @@ public class TestNodeLabelContainerAllocation {
     YarnScheduler scheduler = rm.getRMContext().getScheduler();
     YarnScheduler scheduler = rm.getRMContext().getScheduler();
     SchedulerAppReport appReport = scheduler.getSchedulerAppInfo(attemptId);
     SchedulerAppReport appReport = scheduler.getSchedulerAppInfo(attemptId);
 
 
-    Assert.assertTrue(appReport.getLiveContainers().size() > 0);
+    assertTrue(appReport.getLiveContainers().size() > 0);
     for (RMContainer c : appReport.getLiveContainers()) {
     for (RMContainer c : appReport.getLiveContainers()) {
       if (c.getContainerId().equals(containerId)) {
       if (c.getContainerId().equals(containerId)) {
-        Assert.assertEquals(host, c.getAllocatedNode().getHost());
+        assertEquals(host, c.getAllocatedNode().getHost());
       }
       }
     }
     }
   }
   }
@@ -176,7 +179,8 @@ public class TestNodeLabelContainerAllocation {
   }
   }
   
   
   
   
-  @Test (timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testContainerAllocationWithSingleUserLimits() throws Exception {
   public void testContainerAllocationWithSingleUserLimits() throws Exception {
     final RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
     final RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
     mgr.init(conf);
     mgr.init(conf);
@@ -217,13 +221,13 @@ public class TestNodeLabelContainerAllocation {
     ContainerId containerId =
     ContainerId containerId =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "");
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "");
-    Assert.assertTrue(rm1.waitForState(nm3, containerId,
+    assertTrue(rm1.waitForState(nm3, containerId,
           RMContainerState.ALLOCATED));
           RMContainerState.ALLOCATED));
     // Cannot allocate 2nd label=empty container
     // Cannot allocate 2nd label=empty container
     containerId =
     containerId =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 3);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 3);
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "");
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "");
-    Assert.assertFalse(rm1.waitForState(nm3, containerId,
+    assertFalse(rm1.waitForState(nm3, containerId,
           RMContainerState.ALLOCATED));
           RMContainerState.ALLOCATED));
 
 
     // A has default user limit = 100, so it can use all resource in label = x
     // A has default user limit = 100, so it can use all resource in label = x
@@ -232,13 +236,14 @@ public class TestNodeLabelContainerAllocation {
       containerId =
       containerId =
           ContainerId.newContainerId(am1.getApplicationAttemptId(), id);
           ContainerId.newContainerId(am1.getApplicationAttemptId(), id);
       am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "x");
       am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "x");
-      Assert.assertTrue(rm1.waitForState(nm1, containerId,
+      assertTrue(rm1.waitForState(nm1, containerId,
           RMContainerState.ALLOCATED));
           RMContainerState.ALLOCATED));
     }
     }
     rm1.close();
     rm1.close();
   }
   }
   
   
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testContainerAllocateWithComplexLabels() throws Exception {
   public void testContainerAllocateWithComplexLabels() throws Exception {
     /*
     /*
      * Queue structure:
      * Queue structure:
@@ -315,7 +320,7 @@ public class TestNodeLabelContainerAllocation {
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     containerId =
     containerId =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2L);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2L);
-    Assert.assertTrue(rm1.waitForState(nm2, containerId,
+    assertTrue(rm1.waitForState(nm2, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
         "h2");
         "h2");
@@ -338,9 +343,9 @@ public class TestNodeLabelContainerAllocation {
     // (Maximum capacity reached)
     // (Maximum capacity reached)
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm4, containerId,
+    assertFalse(rm1.waitForState(nm4, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertFalse(rm1.waitForState(nm5, containerId,
+    assertFalse(rm1.waitForState(nm5, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     
     
     // launch an app to queue b2
     // launch an app to queue b2
@@ -359,9 +364,9 @@ public class TestNodeLabelContainerAllocation {
     // y,z). Will successfully allocate on nm3
     // y,z). Will successfully allocate on nm3
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm1, containerId,
+    assertFalse(rm1.waitForState(nm1, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertTrue(rm1.waitForState(nm3, containerId,
+    assertTrue(rm1.waitForState(nm3, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
         "h3");
         "h3");
@@ -370,7 +375,7 @@ public class TestNodeLabelContainerAllocation {
     // Will successfully allocate on nm4 only.
     // Will successfully allocate on nm4 only.
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "z");
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "z");
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 3L);
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 3L);
-    Assert.assertTrue(rm1.waitForState(nm4, containerId,
+    assertTrue(rm1.waitForState(nm4, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
         "h4");
         "h4");
@@ -378,7 +383,8 @@ public class TestNodeLabelContainerAllocation {
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test (timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testContainerAllocateWithLabels() throws Exception {
   public void testContainerAllocateWithLabels() throws Exception {
     // set node -> label
     // set node -> label
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y"));
@@ -418,9 +424,9 @@ public class TestNodeLabelContainerAllocation {
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "x");
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "x");
     containerId =
     containerId =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm2, containerId,
+    assertFalse(rm1.waitForState(nm2, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertTrue(rm1.waitForState(nm1, containerId,
+    assertTrue(rm1.waitForState(nm1, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
         "h1");
         "h1");
@@ -441,9 +447,9 @@ public class TestNodeLabelContainerAllocation {
     // request a container.
     // request a container.
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y");
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm1, containerId,
+    assertFalse(rm1.waitForState(nm1, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertTrue(rm1.waitForState(nm2, containerId,
+    assertTrue(rm1.waitForState(nm2, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am2.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am2.getApplicationAttemptId(), containerId, rm1,
         "h2");
         "h2");
@@ -464,9 +470,9 @@ public class TestNodeLabelContainerAllocation {
     // request a container.
     // request a container.
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm2, containerId,
+    assertFalse(rm1.waitForState(nm2, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertTrue(rm1.waitForState(nm3, containerId,
+    assertTrue(rm1.waitForState(nm3, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
         "h3");
         "h3");
@@ -474,7 +480,8 @@ public class TestNodeLabelContainerAllocation {
     rm1.close();
     rm1.close();
   }
   }
   
   
-  @Test (timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testContainerAllocateWithDefaultQueueLabels() throws Exception {
   public void testContainerAllocateWithDefaultQueueLabels() throws Exception {
     // This test is pretty much similar to testContainerAllocateWithLabel.
     // This test is pretty much similar to testContainerAllocateWithLabel.
     // Difference is, this test doesn't specify label expression in ResourceRequest,
     // Difference is, this test doesn't specify label expression in ResourceRequest,
@@ -518,9 +525,9 @@ public class TestNodeLabelContainerAllocation {
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId =
     containerId =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm3, containerId,
+    assertFalse(rm1.waitForState(nm3, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertTrue(rm1.waitForState(nm1, containerId,
+    assertTrue(rm1.waitForState(nm1, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
         "h1");
         "h1");
@@ -541,9 +548,9 @@ public class TestNodeLabelContainerAllocation {
     // request a container.
     // request a container.
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm3, containerId,
+    assertFalse(rm1.waitForState(nm3, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertTrue(rm1.waitForState(nm2, containerId,
+    assertTrue(rm1.waitForState(nm2, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am2.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am2.getApplicationAttemptId(), containerId, rm1,
         "h2");
         "h2");
@@ -564,9 +571,9 @@ public class TestNodeLabelContainerAllocation {
     // request a container.
     // request a container.
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
-    Assert.assertFalse(rm1.waitForState(nm2, containerId,
+    assertFalse(rm1.waitForState(nm2, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
-    Assert.assertTrue(rm1.waitForState(nm3, containerId,
+    assertTrue(rm1.waitForState(nm3, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1,
         "h3");
         "h3");
@@ -574,7 +581,8 @@ public class TestNodeLabelContainerAllocation {
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test (timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testContainerReservationWithLabels() throws Exception {
   public void testContainerReservationWithLabels() throws Exception {
     // This test is pretty much similar to testContainerAllocateWithLabel.
     // This test is pretty much similar to testContainerAllocateWithLabel.
     // Difference is, this test doesn't specify label expression in
     // Difference is, this test doesn't specify label expression in
@@ -637,29 +645,30 @@ public class TestNodeLabelContainerAllocation {
     // Check if a 4G container allocated for app1, and 4G is reserved
     // Check if a 4G container allocated for app1, and 4G is reserved
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(am1
     FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(am1
         .getApplicationAttemptId());
         .getApplicationAttemptId());
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertTrue(schedulerApp1.getReservedContainers().size() > 0);
-    Assert.assertEquals(9 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertTrue(schedulerApp1.getReservedContainers().size() > 0);
+    assertEquals(9 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(4 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(4 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(4 * GB,
+    assertEquals(4 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     // Cancel asks of app2 and re-kick RM
     // Cancel asks of app2 and re-kick RM
     am1.allocate("*", 4 * GB, 0, new ArrayList<ContainerId>());
     am1.allocate("*", 4 * GB, 0, new ArrayList<ContainerId>());
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
 
 
-    Assert.assertEquals(5 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(5 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(0, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(0, leafQueue.getQueueResourceUsage().getReserved("x")
+    assertEquals(0, leafQueue.getQueueResourceUsage().getReserved("x")
         .getMemorySize());
         .getMemorySize());
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test (timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testContainerReservationContinueLookingWithLabels()
   public void testContainerReservationContinueLookingWithLabels()
       throws Exception {
       throws Exception {
     // set node -> label
     // set node -> label
@@ -708,15 +717,15 @@ public class TestNodeLabelContainerAllocation {
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
         "h1");
         "h1");
 
 
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertFalse(schedulerApp1.getReservedContainers().size() > 0);
-    Assert.assertEquals(2 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertFalse(schedulerApp1.getReservedContainers().size() > 0);
+    assertEquals(2 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(2 * GB,
+    assertEquals(2 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     // request map containers for app1.
     // request map containers for app1.
@@ -730,15 +739,15 @@ public class TestNodeLabelContainerAllocation {
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
         "h1");
         "h1");
 
 
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertFalse(schedulerApp1.getReservedContainers().size() > 0);
-    Assert.assertEquals(7 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertFalse(schedulerApp1.getReservedContainers().size() > 0);
+    assertEquals(7 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(7 * GB,
+    assertEquals(7 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     // Do node heartbeat to allocate second mapper on node2
     // Do node heartbeat to allocate second mapper on node2
@@ -750,15 +759,15 @@ public class TestNodeLabelContainerAllocation {
         "h2");
         "h2");
 
 
     // node1 7 GB used, node2 5 GB used
     // node1 7 GB used, node2 5 GB used
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
-    Assert.assertFalse(schedulerApp1.getReservedContainers().size() > 0);
-    Assert.assertEquals(12 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertFalse(schedulerApp1.getReservedContainers().size() > 0);
+    assertEquals(12 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(12 * GB,
+    assertEquals(12 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     // request reducer containers for app1.
     // request reducer containers for app1.
@@ -768,15 +777,15 @@ public class TestNodeLabelContainerAllocation {
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
 
 
     // node1 7 GB used and 3 GB reserved, node2 5 GB used
     // node1 7 GB used and 3 GB reserved, node2 5 GB used
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp1.getReservedContainers().size());
-    Assert.assertEquals(15 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp1.getReservedContainers().size());
+    assertEquals(15 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(3 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(3 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(15 * GB,
+    assertEquals(15 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     // Do node heartbeat to allocate container for second reducer on node2
     // Do node heartbeat to allocate container for second reducer on node2
@@ -789,21 +798,22 @@ public class TestNodeLabelContainerAllocation {
         "h2");
         "h2");
 
 
     // node1 7 GB used and 0 GB reserved, node2 8 GB used
     // node1 7 GB used and 0 GB reserved, node2 8 GB used
-    Assert.assertEquals(4, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(0, schedulerApp1.getReservedContainers().size());
-    Assert.assertEquals(15 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(4, schedulerApp1.getLiveContainers().size());
+    assertEquals(0, schedulerApp1.getReservedContainers().size());
+    assertEquals(15 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(15 * GB,
+    assertEquals(15 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test (timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testContainerReservationContinueLookingWithDefaultLabels()
   public void testContainerReservationContinueLookingWithDefaultLabels()
       throws Exception {
       throws Exception {
     // This is the same as testContainerReservationContinueLookingWithLabels,
     // This is the same as testContainerReservationContinueLookingWithLabels,
@@ -853,15 +863,15 @@ public class TestNodeLabelContainerAllocation {
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
         "h1");
         "h1");
 
 
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertFalse(schedulerApp1.getReservedContainers().size() > 0);
-    Assert.assertEquals(2 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertFalse(schedulerApp1.getReservedContainers().size() > 0);
+    assertEquals(2 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(2 * GB,
+    assertEquals(2 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     // request map containers for app1.
     // request map containers for app1.
@@ -875,15 +885,15 @@ public class TestNodeLabelContainerAllocation {
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
     checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1,
         "h1");
         "h1");
 
 
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertFalse(schedulerApp1.getReservedContainers().size() > 0);
-    Assert.assertEquals(7 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertFalse(schedulerApp1.getReservedContainers().size() > 0);
+    assertEquals(7 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(7 * GB,
+    assertEquals(7 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     // Do node heartbeat to allocate second mapper on node2
     // Do node heartbeat to allocate second mapper on node2
@@ -895,15 +905,15 @@ public class TestNodeLabelContainerAllocation {
         "h2");
         "h2");
 
 
     // node1 7 GB used, node2 5 GB used
     // node1 7 GB used, node2 5 GB used
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
-    Assert.assertFalse(schedulerApp1.getReservedContainers().size() > 0);
-    Assert.assertEquals(12 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertFalse(schedulerApp1.getReservedContainers().size() > 0);
+    assertEquals(12 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(12 * GB,
+    assertEquals(12 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     // request reducer containers for app1.
     // request reducer containers for app1.
@@ -913,15 +923,15 @@ public class TestNodeLabelContainerAllocation {
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
 
 
     // node1 7 GB used and 3 GB reserved, node2 5 GB used
     // node1 7 GB used and 3 GB reserved, node2 5 GB used
-    Assert.assertEquals(3, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp1.getReservedContainers().size());
-    Assert.assertEquals(15 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(3, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp1.getReservedContainers().size());
+    assertEquals(15 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(3 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(3 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(15 * GB,
+    assertEquals(15 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(3 * GB,
+    assertEquals(3 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     // Do node heartbeat to allocate container for second reducer on node2
     // Do node heartbeat to allocate container for second reducer on node2
@@ -934,21 +944,22 @@ public class TestNodeLabelContainerAllocation {
         "h2");
         "h2");
 
 
     // node1 7 GB used and 0 GB reserved, node2 8 GB used
     // node1 7 GB used and 0 GB reserved, node2 8 GB used
-    Assert.assertEquals(4, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(0, schedulerApp1.getReservedContainers().size());
-    Assert.assertEquals(15 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(4, schedulerApp1.getLiveContainers().size());
+    assertEquals(0, schedulerApp1.getReservedContainers().size());
+    assertEquals(15 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getUsed("x").getMemorySize());
         .getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
+    assertEquals(0 * GB, cs.getRootQueue().getQueueResourceUsage()
         .getReserved("x").getMemorySize());
         .getReserved("x").getMemorySize());
-    Assert.assertEquals(15 * GB,
+    assertEquals(15 * GB,
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getUsed("x").getMemorySize());
-    Assert.assertEquals(0 * GB,
+    assertEquals(0 * GB,
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
         leafQueue.getQueueResourceUsage().getReserved("x").getMemorySize());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test (timeout = 120000)
+  @Test
+  @Timeout(value = 120)
   public void testRMContainerLeakInLeafQueue() throws Exception {
   public void testRMContainerLeakInLeafQueue() throws Exception {
     // set node -> label
     // set node -> label
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x"));
@@ -1006,22 +1017,22 @@ public class TestNodeLabelContainerAllocation {
     // Check if a 4G container allocated for app1, and 4G is reserved
     // Check if a 4G container allocated for app1, and 4G is reserved
     FiCaSchedulerApp schedulerApp1 =
     FiCaSchedulerApp schedulerApp1 =
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
         cs.getApplicationAttempt(am1.getApplicationAttemptId());
-    Assert.assertEquals(1, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(1, schedulerApp1.getReservedContainers().size());
+    assertEquals(1, schedulerApp1.getLiveContainers().size());
+    assertEquals(1, schedulerApp1.getReservedContainers().size());
 
 
     // kill app2 then do node heartbeat 1 time
     // kill app2 then do node heartbeat 1 time
     // scheduler will allocate a container from the reserved container on nm1
     // scheduler will allocate a container from the reserved container on nm1
     rm1.killApp(app2.getApplicationId());
     rm1.killApp(app2.getApplicationId());
     rm1.waitForState(app2.getApplicationId(), RMAppState.KILLED);
     rm1.waitForState(app2.getApplicationId(), RMAppState.KILLED);
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
-    Assert.assertEquals(2, schedulerApp1.getLiveContainers().size());
-    Assert.assertEquals(0, schedulerApp1.getReservedContainers().size());
+    assertEquals(2, schedulerApp1.getLiveContainers().size());
+    assertEquals(0, schedulerApp1.getReservedContainers().size());
 
 
     // After kill app1, LeafQueue#ignorePartitionExclusivityRMContainers should
     // After kill app1, LeafQueue#ignorePartitionExclusivityRMContainers should
     // be clean, otherwise resource leak happened
     // be clean, otherwise resource leak happened
     rm1.killApp(app1.getApplicationId());
     rm1.killApp(app1.getApplicationId());
     rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED);
     rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED);
-    Assert.assertEquals(0, leafQueue.getIgnoreExclusivityRMContainers().size());
+    assertEquals(0, leafQueue.getIgnoreExclusivityRMContainers().size());
 
 
     rm1.close();
     rm1.close();
   }
   }
@@ -1033,7 +1044,7 @@ public class TestNodeLabelContainerAllocation {
     PendingAsk ask =
     PendingAsk ask =
         app.getAppSchedulingInfo().getPendingAsk(
         app.getAppSchedulingInfo().getPendingAsk(
             TestUtils.toSchedulerKey(priority), "*");
             TestUtils.toSchedulerKey(priority), "*");
-    Assert.assertEquals(memory,
+    assertEquals(memory,
         ask.getPerAllocationResource().getMemorySize() * ask
         ask.getPerAllocationResource().getMemorySize() * ask
             .getCount());
             .getCount());
   }
   }
@@ -1042,7 +1053,7 @@ public class TestNodeLabelContainerAllocation {
       int numContainers) {
       int numContainers) {
     CapacityScheduler cs = (CapacityScheduler) rm.getRMContext().getScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getRMContext().getScheduler();
     SchedulerNode node = cs.getSchedulerNode(nodeId);
     SchedulerNode node = cs.getSchedulerNode(nodeId);
-    Assert.assertEquals(numContainers, node.getNumContainers());
+    assertEquals(numContainers, node.getNumContainers());
   }
   }
 
 
   /**
   /**
@@ -1142,10 +1153,9 @@ public class TestNodeLabelContainerAllocation {
       int priority, String expectedPartition) {
       int priority, String expectedPartition) {
     for (SchedulerRequestKey key : info.getSchedulerKeys()) {
     for (SchedulerRequestKey key : info.getSchedulerKeys()) {
       if (key.getPriority().getPriority() == priority) {
       if (key.getPriority().getPriority() == priority) {
-        Assert.assertEquals("Expected partition is " + expectedPartition,
-            expectedPartition,
-            info.getAppPlacementAllocator(key)
-                .getPrimaryRequestedNodePartition());
+        assertEquals(expectedPartition,
+            info.getAppPlacementAllocator(key).getPrimaryRequestedNodePartition(),
+            "Expected partition is " + expectedPartition);
       }
       }
     }
     }
   }
   }
@@ -1239,7 +1249,7 @@ public class TestNodeLabelContainerAllocation {
         num++;
         num++;
       }
       }
     }
     }
-    Assert.assertEquals(expectedNum, num);
+    assertEquals(expectedNum, num);
   }
   }
   
   
   @Test
   @Test
@@ -1352,7 +1362,7 @@ public class TestNodeLabelContainerAllocation {
     for (int i = 2; i < 2 + 6; i++) {
     for (int i = 2; i < 2 + 6; i++) {
       nextContainerId =
       nextContainerId =
           ContainerId.newContainerId(am1.getApplicationAttemptId(), i);
           ContainerId.newContainerId(am1.getApplicationAttemptId(), i);
-      Assert.assertTrue(rm1.waitForState(Arrays.asList(nm1, nm2),
+      assertTrue(rm1.waitForState(Arrays.asList(nm1, nm2),
           nextContainerId, RMContainerState.ALLOCATED));
           nextContainerId, RMContainerState.ALLOCATED));
     }
     }
     // no more container allocated on nm1
     // no more container allocated on nm1
@@ -1638,7 +1648,7 @@ public class TestNodeLabelContainerAllocation {
     // NM2 can allocate 10 containers totally, exclude already allocated AM
     // NM2 can allocate 10 containers totally, exclude already allocated AM
     // container, we will wait 9 to fulfill non-partitioned node, and need wait
     // container, we will wait 9 to fulfill non-partitioned node, and need wait
     // one more cycle before allocating to non-partitioned node 
     // one more cycle before allocating to non-partitioned node 
-    Assert.assertEquals(10, cycleWaited);
+    assertEquals(10, cycleWaited);
     
     
     // Both NM1/NM2 launched 10 containers, cluster resource is exhausted
     // Both NM1/NM2 launched 10 containers, cluster resource is exhausted
     checkLaunchedContainerNumOnNode(rm1, nm1.getNodeId(), 10);
     checkLaunchedContainerNumOnNode(rm1, nm1.getNodeId(), 10);
@@ -1695,23 +1705,22 @@ public class TestNodeLabelContainerAllocation {
       cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
       cs.handle(new NodeUpdateSchedulerEvent(rmNode1));
     }
     }
 
 
-    Assert.assertTrue(
-        "Scheduler diagnostics should have reason for not assigning the node",
-        app.getDiagnostics().toString().contains(
-            CSAMContainerLaunchDiagnosticsConstants.SKIP_AM_ALLOCATION_IN_IGNORE_EXCLUSIVE_MODE));
-
-    Assert.assertTrue(
-        "Scheduler diagnostics should have last processed node information",
-        app.getDiagnostics().toString().contains(
-            CSAMContainerLaunchDiagnosticsConstants.LAST_NODE_PROCESSED_MSG
-                + nodeIdStr + " ( Partition : [x]"));
-    Assert.assertEquals(0, cs.getSchedulerNode(nm1.getNodeId())
+    assertTrue(app.getDiagnostics().toString().contains(
+        CSAMContainerLaunchDiagnosticsConstants.SKIP_AM_ALLOCATION_IN_IGNORE_EXCLUSIVE_MODE),
+        "Scheduler diagnostics should have reason for not assigning the node");
+
+    assertTrue(app.getDiagnostics().toString().contains(
+        CSAMContainerLaunchDiagnosticsConstants.LAST_NODE_PROCESSED_MSG
+        + nodeIdStr + " ( Partition : [x]"),
+        "Scheduler diagnostics should have last processed node information");
+    assertEquals(0, cs.getSchedulerNode(nm1.getNodeId())
         .getNumContainers());
         .getNumContainers());
     
     
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout=60000)
+  @Test
+  @Timeout(value = 60)
   public void
   public void
       testQueueMaxCapacitiesWillNotBeHonoredWhenNotRespectingExclusivity()
       testQueueMaxCapacitiesWillNotBeHonoredWhenNotRespectingExclusivity()
           throws Exception {
           throws Exception {
@@ -1795,20 +1804,20 @@ public class TestNodeLabelContainerAllocation {
     }
     }
     
     
     // app1 gets all resource in partition=x
     // app1 gets all resource in partition=x
-    Assert.assertEquals(10, schedulerNode1.getNumContainers());
+    assertEquals(10, schedulerNode1.getNumContainers());
 
 
     // check non-exclusive containers of LeafQueue is correctly updated
     // check non-exclusive containers of LeafQueue is correctly updated
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a");
     LeafQueue leafQueue = (LeafQueue) cs.getQueue("a");
-    Assert.assertFalse(leafQueue.getIgnoreExclusivityRMContainers().containsKey(
+    assertFalse(leafQueue.getIgnoreExclusivityRMContainers().containsKey(
         "y"));
         "y"));
-    Assert.assertEquals(10,
+    assertEquals(10,
         leafQueue.getIgnoreExclusivityRMContainers().get("x").size());
         leafQueue.getIgnoreExclusivityRMContainers().get("x").size());
 
 
     // completes all containers of app1, ignoreExclusivityRMContainers should be
     // completes all containers of app1, ignoreExclusivityRMContainers should be
     // updated as well.
     // updated as well.
     cs.handle(new AppAttemptRemovedSchedulerEvent(
     cs.handle(new AppAttemptRemovedSchedulerEvent(
         am1.getApplicationAttemptId(), RMAppAttemptState.FINISHED, false));
         am1.getApplicationAttemptId(), RMAppAttemptState.FINISHED, false));
-    Assert.assertFalse(leafQueue.getIgnoreExclusivityRMContainers().containsKey(
+    assertFalse(leafQueue.getIgnoreExclusivityRMContainers().containsKey(
         "x"));
         "x"));
 
 
     rm1.close();
     rm1.close();
@@ -1818,11 +1827,11 @@ public class TestNodeLabelContainerAllocation {
       String nodePartition, float usedCapacity, float absoluteUsedCapacity) {
       String nodePartition, float usedCapacity, float absoluteUsedCapacity) {
     float epsilon = 1e-6f;
     float epsilon = 1e-6f;
     CSQueue queue = cs.getQueue(queueName);
     CSQueue queue = cs.getQueue(queueName);
-    Assert.assertNotNull("Failed to get queue=" + queueName, queue);
+    assertNotNull(queue, "Failed to get queue=" + queueName);
 
 
-    Assert.assertEquals(usedCapacity, queue.getQueueCapacities()
+    assertEquals(usedCapacity, queue.getQueueCapacities()
         .getUsedCapacity(nodePartition), epsilon);
         .getUsedCapacity(nodePartition), epsilon);
-    Assert.assertEquals(absoluteUsedCapacity, queue.getQueueCapacities()
+    assertEquals(absoluteUsedCapacity, queue.getQueueCapacities()
         .getAbsoluteUsedCapacity(nodePartition), epsilon);
         .getAbsoluteUsedCapacity(nodePartition), epsilon);
   }
   }
   
   
@@ -2604,18 +2613,18 @@ public class TestNodeLabelContainerAllocation {
     }
     }
 
 
     // app1 gets all resource in partition=x
     // app1 gets all resource in partition=x
-    Assert.assertEquals(5, schedulerNode1.getNumContainers());
+    assertEquals(5, schedulerNode1.getNumContainers());
 
 
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
         .getNodeReport(nm1.getNodeId());
         .getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(5 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(5 * GB,
+    assertEquals(5 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(5 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
 
 
     SchedulerNodeReport reportNm2 = rm1.getResourceScheduler()
     SchedulerNodeReport reportNm2 = rm1.getResourceScheduler()
         .getNodeReport(nm2.getNodeId());
         .getNodeReport(nm2.getNodeId());
-    Assert.assertEquals(0 * GB, reportNm2.getUsedResource().getMemorySize());
-    Assert.assertEquals(10 * GB,
+    assertEquals(0 * GB, reportNm2.getUsedResource().getMemorySize());
+    assertEquals(10 * GB,
         reportNm2.getAvailableResource().getMemorySize());
         reportNm2.getAvailableResource().getMemorySize());
 
 
     assertEquals(0 * GB, leafQueueA.getMetrics().getAvailableMB());
     assertEquals(0 * GB, leafQueueA.getMetrics().getAvailableMB());
@@ -2764,16 +2773,16 @@ public class TestNodeLabelContainerAllocation {
     }
     }
 
 
     // app1 gets all resource in partition=x (non-exclusive)
     // app1 gets all resource in partition=x (non-exclusive)
-    Assert.assertEquals(3, schedulerNode1.getNumContainers());
+    assertEquals(3, schedulerNode1.getNumContainers());
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
         .getNodeReport(nm1.getNodeId());
         .getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(3 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(7 * GB,
+    assertEquals(3 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(7 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
     SchedulerNodeReport reportNm2 = rm1.getResourceScheduler()
     SchedulerNodeReport reportNm2 = rm1.getResourceScheduler()
         .getNodeReport(nm2.getNodeId());
         .getNodeReport(nm2.getNodeId());
-    Assert.assertEquals(1 * GB, reportNm2.getUsedResource().getMemorySize());
-    Assert.assertEquals(9 * GB,
+    assertEquals(1 * GB, reportNm2.getUsedResource().getMemorySize());
+    assertEquals(9 * GB,
         reportNm2.getAvailableResource().getMemorySize());
         reportNm2.getAvailableResource().getMemorySize());
     assertEquals(7 * GB, partXMetrics.getAvailableMB(), delta);
     assertEquals(7 * GB, partXMetrics.getAvailableMB(), delta);
     assertEquals(9 * GB, partDefaultMetrics.getAvailableMB(), delta);
     assertEquals(9 * GB, partDefaultMetrics.getAvailableMB(), delta);
@@ -2821,8 +2830,8 @@ public class TestNodeLabelContainerAllocation {
 
 
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
     cs.handle(new NodeUpdateSchedulerEvent(rmNode2));
 
 
-    Assert.assertEquals(2, schedulerNode2.getNumContainers());
-    Assert.assertEquals(3, schedulerNode1.getNumContainers());
+    assertEquals(2, schedulerNode2.getNumContainers());
+    assertEquals(3, schedulerNode1.getNumContainers());
 
 
     // 3GB is used from label x quota. 2GB used from default label.
     // 3GB is used from label x quota. 2GB used from default label.
     // So 0.5 GB is remaining from default label.
     // So 0.5 GB is remaining from default label.
@@ -2996,18 +3005,18 @@ public class TestNodeLabelContainerAllocation {
     }
     }
 
 
     // app1 gets all resource in partition=x
     // app1 gets all resource in partition=x
-    Assert.assertEquals(6, schedulerNode1.getNumContainers());
+    assertEquals(6, schedulerNode1.getNumContainers());
 
 
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
         .getNodeReport(nm1.getNodeId());
         .getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(4 * GB,
+    assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(4 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
 
 
     SchedulerNodeReport reportNm2 = rm1.getResourceScheduler()
     SchedulerNodeReport reportNm2 = rm1.getResourceScheduler()
         .getNodeReport(nm2.getNodeId());
         .getNodeReport(nm2.getNodeId());
-    Assert.assertEquals(0 * GB, reportNm2.getUsedResource().getMemorySize());
-    Assert.assertEquals(12 * GB,
+    assertEquals(0 * GB, reportNm2.getUsedResource().getMemorySize());
+    assertEquals(12 * GB,
         reportNm2.getAvailableResource().getMemorySize());
         reportNm2.getAvailableResource().getMemorySize());
 
 
     assertEquals(12 * GB, leafQueueA.getMetrics().getAvailableMB());
     assertEquals(12 * GB, leafQueueA.getMetrics().getAvailableMB());
@@ -3036,16 +3045,16 @@ public class TestNodeLabelContainerAllocation {
     }
     }
 
 
     // app1 gets all resource in partition=x
     // app1 gets all resource in partition=x
-    Assert.assertEquals(6, schedulerNode2.getNumContainers());
+    assertEquals(6, schedulerNode2.getNumContainers());
 
 
     reportNm1 = rm1.getResourceScheduler().getNodeReport(nm1.getNodeId());
     reportNm1 = rm1.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(4 * GB,
+    assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(4 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
 
 
     reportNm2 = rm1.getResourceScheduler().getNodeReport(nm2.getNodeId());
     reportNm2 = rm1.getResourceScheduler().getNodeReport(nm2.getNodeId());
-    Assert.assertEquals(6 * GB, reportNm2.getUsedResource().getMemorySize());
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB, reportNm2.getUsedResource().getMemorySize());
+    assertEquals(6 * GB,
         reportNm2.getAvailableResource().getMemorySize());
         reportNm2.getAvailableResource().getMemorySize());
 
 
     assertEquals(6 * GB, leafQueueA.getMetrics().getAvailableMB());
     assertEquals(6 * GB, leafQueueA.getMetrics().getAvailableMB());
@@ -3174,17 +3183,17 @@ public class TestNodeLabelContainerAllocation {
     }
     }
 
 
     // app1 gets all resource in partition=x
     // app1 gets all resource in partition=x
-    Assert.assertEquals(6, schedulerNode1.getNumContainers());
+    assertEquals(6, schedulerNode1.getNumContainers());
 
 
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
         .getNodeReport(nm1.getNodeId());
         .getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(4 * GB, reportNm1.getAvailableResource().getMemorySize());
+    assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(4 * GB, reportNm1.getAvailableResource().getMemorySize());
 
 
     SchedulerNodeReport reportNm2 = rm1.getResourceScheduler()
     SchedulerNodeReport reportNm2 = rm1.getResourceScheduler()
         .getNodeReport(nm2.getNodeId());
         .getNodeReport(nm2.getNodeId());
-    Assert.assertEquals(0 * GB, reportNm2.getUsedResource().getMemorySize());
-    Assert.assertEquals(12 * GB,
+    assertEquals(0 * GB, reportNm2.getUsedResource().getMemorySize());
+    assertEquals(12 * GB,
         reportNm2.getAvailableResource().getMemorySize());
         reportNm2.getAvailableResource().getMemorySize());
 
 
     assertEquals(0 * GB, queueAMetrics.getAllocatedMB());
     assertEquals(0 * GB, queueAMetrics.getAllocatedMB());
@@ -3224,16 +3233,16 @@ public class TestNodeLabelContainerAllocation {
     }
     }
 
 
     // app1 gets all resource in partition=x
     // app1 gets all resource in partition=x
-    Assert.assertEquals(6, schedulerNode2.getNumContainers());
+    assertEquals(6, schedulerNode2.getNumContainers());
 
 
     reportNm1 = rm1.getResourceScheduler().getNodeReport(nm1.getNodeId());
     reportNm1 = rm1.getResourceScheduler().getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(4 * GB,
+    assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(4 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
 
 
     reportNm2 = rm1.getResourceScheduler().getNodeReport(nm2.getNodeId());
     reportNm2 = rm1.getResourceScheduler().getNodeReport(nm2.getNodeId());
-    Assert.assertEquals(6 * GB, reportNm2.getUsedResource().getMemorySize());
-    Assert.assertEquals(6 * GB,
+    assertEquals(6 * GB, reportNm2.getUsedResource().getMemorySize());
+    assertEquals(6 * GB,
         reportNm2.getAvailableResource().getMemorySize());
         reportNm2.getAvailableResource().getMemorySize());
 
 
     assertEquals(6 * GB, leafQueueA.getMetrics().getAvailableMB());
     assertEquals(6 * GB, leafQueueA.getMetrics().getAvailableMB());
@@ -3363,8 +3372,8 @@ public class TestNodeLabelContainerAllocation {
 
 
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
     SchedulerNodeReport reportNm1 = rm1.getResourceScheduler()
         .getNodeReport(nm1.getNodeId());
         .getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(14 * GB,
+    assertEquals(6 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(14 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
 
 
     // Try to launch app2 in a2, asked 2GB, should success
     // Try to launch app2 in a2, asked 2GB, should success
@@ -3390,8 +3399,8 @@ public class TestNodeLabelContainerAllocation {
 
 
     reportNm1 = rm1.getResourceScheduler()
     reportNm1 = rm1.getResourceScheduler()
         .getNodeReport(nm1.getNodeId());
         .getNodeReport(nm1.getNodeId());
-    Assert.assertEquals(10 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(10 * GB,
+    assertEquals(10 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(10 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
 
 
     // Kill all apps in queue a2
     // Kill all apps in queue a2
@@ -3419,8 +3428,8 @@ public class TestNodeLabelContainerAllocation {
     checkNumOfContainersInAnAppOnGivenNode(4, nm1.getNodeId(),
     checkNumOfContainersInAnAppOnGivenNode(4, nm1.getNodeId(),
         cs.getApplicationAttempt(am3.getApplicationAttemptId()));
         cs.getApplicationAttempt(am3.getApplicationAttemptId()));
 
 
-    Assert.assertEquals(10 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(10 * GB,
+    assertEquals(10 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(10 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
 
 
     // Kill all apps in queue a1
     // Kill all apps in queue a1
@@ -3450,8 +3459,8 @@ public class TestNodeLabelContainerAllocation {
     checkNumOfContainersInAnAppOnGivenNode(6, nm1.getNodeId(),
     checkNumOfContainersInAnAppOnGivenNode(6, nm1.getNodeId(),
         cs.getApplicationAttempt(am4.getApplicationAttemptId()));
         cs.getApplicationAttempt(am4.getApplicationAttemptId()));
 
 
-    Assert.assertEquals(10 * GB, reportNm1.getUsedResource().getMemorySize());
-    Assert.assertEquals(10 * GB,
+    assertEquals(10 * GB, reportNm1.getUsedResource().getMemorySize());
+    assertEquals(10 * GB,
         reportNm1.getAvailableResource().getMemorySize());
         reportNm1.getAvailableResource().getMemorySize());
 
 
     rm1.close();
     rm1.close();

+ 72 - 68
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java

@@ -18,12 +18,12 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doAnswer;
@@ -59,10 +59,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.security.AppPriorityACLsMan
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.InOrder;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.mockito.stubbing.Answer;
@@ -117,7 +116,7 @@ public class TestParentQueue {
   private static final QueuePath Q_C111 = Q_C11.createNewLeaf(C111);
   private static final QueuePath Q_C111 = Q_C11.createNewLeaf(C111);
   private static final QueuePath Q_C1111 = Q_C111.createNewLeaf(C1111);
   private static final QueuePath Q_C1111 = Q_C111.createNewLeaf(C1111);
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     rmContext = TestUtils.getMockRMContext();
     rmContext = TestUtils.getMockRMContext();
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
@@ -408,7 +407,7 @@ public class TestParentQueue {
 
 
     // If the new queue mode is used it's allowed to over allocate the resources,
     // If the new queue mode is used it's allowed to over allocate the resources,
     // as they'll be scaled down accordingly
     // as they'll be scaled down accordingly
-    assumeThat(csConf.isLegacyQueueMode(), is(true));
+    assumeTrue(csConf.isLegacyQueueMode() == true);
 
 
     CSQueueStore queues = new CSQueueStore();
     CSQueueStore queues = new CSQueueStore();
     boolean exceptionOccurred = false;
     boolean exceptionOccurred = false;
@@ -420,7 +419,7 @@ public class TestParentQueue {
       exceptionOccurred = true;
       exceptionOccurred = true;
     }
     }
     if (!exceptionOccurred) {
     if (!exceptionOccurred) {
-      Assert.fail("Capacity is more then 100% so should be failed.");
+      fail("Capacity is more then 100% so should be failed.");
     }
     }
     csConf.setCapacity(Q_A, 30);
     csConf.setCapacity(Q_A, 30);
     csConf.setCapacity(Q_B, 70);
     csConf.setCapacity(Q_B, 70);
@@ -435,7 +434,7 @@ public class TestParentQueue {
       exceptionOccurred = true;
       exceptionOccurred = true;
     }
     }
     if (exceptionOccurred) {
     if (exceptionOccurred) {
-      Assert.fail("Capacity is 100% so should not be failed.");
+      fail("Capacity is 100% so should not be failed.");
     }
     }
     csConf.setCapacity(Q_A, 30);
     csConf.setCapacity(Q_A, 30);
     csConf.setCapacity(Q_B, 70.005F);
     csConf.setCapacity(Q_B, 70.005F);
@@ -450,8 +449,7 @@ public class TestParentQueue {
       exceptionOccurred = true;
       exceptionOccurred = true;
     }
     }
     if (exceptionOccurred) {
     if (exceptionOccurred) {
-      Assert
-          .fail("Capacity is under PRECISION which is .05% so should not be failed.");
+      fail("Capacity is under PRECISION which is .05% so should not be failed.");
     }
     }
   }
   }
   
   
@@ -669,45 +667,49 @@ public class TestParentQueue {
     reset(a); reset(b); reset(c);
     reset(a); reset(b); reset(c);
   }
   }
   
   
-  @Test (expected=IOException.class)
+  @Test
   public void testQueueCapacitySettingChildZero() throws Exception {
   public void testQueueCapacitySettingChildZero() throws Exception {
-    // Setup queue configs
-    setupMultiLevelQueues(csConf);
+    assertThrows(IOException.class, () -> {
+      // Setup queue configs
+      setupMultiLevelQueues(csConf);
 
 
-    // If the new queue mode is used it's allowed to have
-    // zero-capacity queues under a non-zero parent
-    assumeThat(csConf.isLegacyQueueMode(), is(true));
+      // If the new queue mode is used it's allowed to have
+      // zero-capacity queues under a non-zero parent
+      assumeTrue(csConf.isLegacyQueueMode() == true);
 
 
-    // set child queues capacity to 0 when parents not 0
-    csConf.setCapacity(Q_B1, 0);
-    csConf.setCapacity(Q_B2, 0);
-    csConf.setCapacity(Q_B3, 0);
-    queueContext.reinitialize();
+      // set child queues capacity to 0 when parents not 0
+      csConf.setCapacity(Q_B1, 0);
+      csConf.setCapacity(Q_B2, 0);
+      csConf.setCapacity(Q_B3, 0);
+      queueContext.reinitialize();
 
 
-    CSQueueStore queues = new CSQueueStore();
-    CapacitySchedulerQueueManager.parseQueue(queueContext, csConf, null,
-        CapacitySchedulerConfiguration.ROOT, queues, queues,
-        TestUtils.spyHook);
+      CSQueueStore queues = new CSQueueStore();
+      CapacitySchedulerQueueManager.parseQueue(queueContext, csConf, null,
+          CapacitySchedulerConfiguration.ROOT, queues, queues,
+          TestUtils.spyHook);
+    });
   }
   }
   
   
-  @Test (expected=IOException.class)
+  @Test
   public void testQueueCapacitySettingParentZero() throws Exception {
   public void testQueueCapacitySettingParentZero() throws Exception {
-    // Setup queue configs
-    setupMultiLevelQueues(csConf);
+    assertThrows(IOException.class, () -> {
+      // Setup queue configs
+      setupMultiLevelQueues(csConf);
 
 
-    // If the new queue mode is used it's allowed to have
-    // non-zero capacity queues under a zero capacity parent
-    assumeThat(csConf.isLegacyQueueMode(), is(true));
+      // If the new queue mode is used it's allowed to have
+      // non-zero capacity queues under a zero capacity parent
+      assumeTrue(csConf.isLegacyQueueMode() == true);
 
 
-    // set parent capacity to 0 when child not 0
-    csConf.setCapacity(Q_B, 0);
-    csConf.setCapacity(Q_A, 60);
-    queueContext.reinitialize();
+      // set parent capacity to 0 when child not 0
+      csConf.setCapacity(Q_B, 0);
+      csConf.setCapacity(Q_A, 60);
+      queueContext.reinitialize();
 
 
-    CSQueueStore queues = new CSQueueStore();
-    CapacitySchedulerQueueManager.parseQueue(queueContext, csConf, null,
-        CapacitySchedulerConfiguration.ROOT, queues, queues,
-        TestUtils.spyHook);
+      CSQueueStore queues = new CSQueueStore();
+      CapacitySchedulerQueueManager.parseQueue(queueContext, csConf, null,
+          CapacitySchedulerConfiguration.ROOT, queues, queues,
+          TestUtils.spyHook);
+    });
   }
   }
 
 
   @Test
   @Test
@@ -728,29 +730,31 @@ public class TestParentQueue {
         TestUtils.spyHook);
         TestUtils.spyHook);
   }
   }
 
 
-  @Test(expected = IOException.class)
+  @Test
   public void testQueueCapacitySettingParentZeroChildren50pctZeroSumAllowed()
   public void testQueueCapacitySettingParentZeroChildren50pctZeroSumAllowed()
       throws Exception {
       throws Exception {
-    // Setup queue configs
-    setupMultiLevelQueues(csConf);
-
-    // If the new queue mode is used it's allowed to have
-    // non-zero capacity queues under a zero capacity parent
-    assumeThat(csConf.isLegacyQueueMode(), is(true));
-
-    // set parent capacity to 0 when sum(children) is 50
-    // and allow zero capacity sum
-    csConf.setCapacity(Q_B, 0);
-    csConf.setCapacity(Q_A, 100);
-    csConf.setCapacity(Q_B1, 10);
-    csConf.setCapacity(Q_B2, 20);
-    csConf.setCapacity(Q_B3, 20);
-    csConf.setAllowZeroCapacitySum(Q_B, true);
-    queueContext.reinitialize();
-    CSQueueStore queues = new CSQueueStore();
-    CapacitySchedulerQueueManager.parseQueue(queueContext, csConf, null,
-        CapacitySchedulerConfiguration.ROOT, queues, queues,
-        TestUtils.spyHook);
+    assertThrows(IOException.class, () -> {
+      // Setup queue configs
+      setupMultiLevelQueues(csConf);
+
+      // If the new queue mode is used it's allowed to have
+      // non-zero capacity queues under a zero capacity parent
+      assumeTrue(csConf.isLegacyQueueMode() == true);
+
+      // set parent capacity to 0 when sum(children) is 50
+      // and allow zero capacity sum
+      csConf.setCapacity(Q_B, 0);
+      csConf.setCapacity(Q_A, 100);
+      csConf.setCapacity(Q_B1, 10);
+      csConf.setCapacity(Q_B2, 20);
+      csConf.setCapacity(Q_B3, 20);
+      csConf.setAllowZeroCapacitySum(Q_B, true);
+      queueContext.reinitialize();
+      CSQueueStore queues = new CSQueueStore();
+      CapacitySchedulerQueueManager.parseQueue(queueContext, csConf, null,
+          CapacitySchedulerConfiguration.ROOT, queues, queues,
+          TestUtils.spyHook);
+    });
   }
   }
 
 
   @Test
   @Test
@@ -795,7 +799,7 @@ public class TestParentQueue {
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       fail("Failed to create queues with 0 capacity: " + e);
       fail("Failed to create queues with 0 capacity: " + e);
     }
     }
-    assertTrue("Failed to create queues with 0 capacity", true);
+    assertTrue(true, "Failed to create queues with 0 capacity");
   }
   }
 
 
   @Test
   @Test
@@ -1248,7 +1252,7 @@ public class TestParentQueue {
 
 
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
   }
   }
 
 

+ 19 - 18
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueCapacities.java

@@ -22,20 +22,17 @@ import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collection;
 
 
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.Assertions;
 
 
-@RunWith(Parameterized.class)
 public class TestQueueCapacities {
 public class TestQueueCapacities {
   private static final Logger LOG =
   private static final Logger LOG =
       LoggerFactory.getLogger(TestQueueCapacities.class);
       LoggerFactory.getLogger(TestQueueCapacities.class);
   private String suffix;
   private String suffix;
 
 
-  @Parameterized.Parameters
   public static Collection<String[]> getParameters() {
   public static Collection<String[]> getParameters() {
     return Arrays.asList(new String[][] { 
     return Arrays.asList(new String[][] { 
         { "Capacity" },
         { "Capacity" },
@@ -51,8 +48,8 @@ public class TestQueueCapacities {
         { "NormalizedWeight" }});
         { "NormalizedWeight" }});
   }
   }
 
 
-  public TestQueueCapacities(String suffix) {
-    this.suffix = suffix;
+  public void initTestQueueCapacities(String pSuffix) {
+    this.suffix = pSuffix;
   }
   }
 
 
   private static float get(QueueCapacities obj, String suffix,
   private static float get(QueueCapacities obj, String suffix,
@@ -108,26 +105,30 @@ public class TestQueueCapacities {
 
 
     // Set to 1, and check
     // Set to 1, and check
     set(qc, suffix, label, 1f);
     set(qc, suffix, label, 1f);
-    Assert.assertEquals(1f, get(qc, suffix, label), 1e-8);
+    Assertions.assertEquals(1f, get(qc, suffix, label), 1e-8);
 
 
     // Set to 2, and check
     // Set to 2, and check
     set(qc, suffix, label, 2f);
     set(qc, suffix, label, 2f);
-    Assert.assertEquals(2f, get(qc, suffix, label), 1e-8);
+    Assertions.assertEquals(2f, get(qc, suffix, label), 1e-8);
   }
   }
 
 
-  @Test
-  public void testModifyAndRead() throws Exception {
+  @MethodSource("getParameters")
+  @ParameterizedTest
+  public void testModifyAndRead(String pSuffix) throws Exception {
+    initTestQueueCapacities(pSuffix);
     LOG.info("Test - " + suffix);
     LOG.info("Test - " + suffix);
     internalTestModifyAndRead(null);
     internalTestModifyAndRead(null);
     internalTestModifyAndRead("label");
     internalTestModifyAndRead("label");
   }
   }
 
 
-  @Test
-  public void testDefaultValues() {
+  @MethodSource("getParameters")
+  @ParameterizedTest
+  public void testDefaultValues(String pSuffix) {
+    initTestQueueCapacities(pSuffix);
     QueueCapacities qc = new QueueCapacities(false);
     QueueCapacities qc = new QueueCapacities(false);
-    Assert.assertEquals(-1, qc.getWeight(""), 1e-6);
-    Assert.assertEquals(-1, qc.getWeight("x"), 1e-6);
-    Assert.assertEquals(0, qc.getCapacity(""), 1e-6);
-    Assert.assertEquals(0, qc.getCapacity("x"), 1e-6);
+    Assertions.assertEquals(-1, qc.getWeight(""), 1e-6);
+    Assertions.assertEquals(-1, qc.getWeight("x"), 1e-6);
+    Assertions.assertEquals(0, qc.getCapacity(""), 1e-6);
+    Assertions.assertEquals(0, qc.getCapacity("x"), 1e-6);
   }
   }
 }
 }

+ 23 - 21
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueCapacityVector.java

@@ -23,15 +23,17 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacityVector.ResourceUnitCapacityType;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacityVector.ResourceUnitCapacityType;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacityVector.QueueCapacityVectorEntry;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacityVector.QueueCapacityVectorEntry;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.List;
 import java.util.List;
 
 
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.MEMORY_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.MEMORY_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.VCORES_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.VCORES_URI;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestQueueCapacityVector {
 public class TestQueueCapacityVector {
   private static final String CUSTOM_RESOURCE = "custom";
   private static final String CUSTOM_RESOURCE = "custom";
@@ -40,7 +42,7 @@ public class TestQueueCapacityVector {
 
 
   private final YarnConfiguration conf = new YarnConfiguration();
   private final YarnConfiguration conf = new YarnConfiguration();
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     conf.set(YarnConfiguration.RESOURCE_TYPES, CUSTOM_RESOURCE);
     conf.set(YarnConfiguration.RESOURCE_TYPES, CUSTOM_RESOURCE);
     ResourceUtils.resetResourceTypes(conf);
     ResourceUtils.resetResourceTypes(conf);
@@ -54,19 +56,19 @@ public class TestQueueCapacityVector {
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.PERCENTAGE);
 
 
     // custom is not set, defaults to 0
     // custom is not set, defaults to 0
-    Assert.assertEquals(1, capacityVector.getResourceNamesByCapacityType(
+    assertEquals(1, capacityVector.getResourceNamesByCapacityType(
         ResourceUnitCapacityType.ABSOLUTE).size());
         ResourceUnitCapacityType.ABSOLUTE).size());
-    Assert.assertTrue(capacityVector.getResourceNamesByCapacityType(
+    assertTrue(capacityVector.getResourceNamesByCapacityType(
         ResourceUnitCapacityType.ABSOLUTE).contains(CUSTOM_RESOURCE));
         ResourceUnitCapacityType.ABSOLUTE).contains(CUSTOM_RESOURCE));
 
 
-    Assert.assertEquals(2, capacityVector.getResourceNamesByCapacityType(
+    assertEquals(2, capacityVector.getResourceNamesByCapacityType(
         ResourceUnitCapacityType.PERCENTAGE).size());
         ResourceUnitCapacityType.PERCENTAGE).size());
-    Assert.assertTrue(capacityVector.getResourceNamesByCapacityType(
+    assertTrue(capacityVector.getResourceNamesByCapacityType(
         ResourceUnitCapacityType.PERCENTAGE).contains(VCORES_URI));
         ResourceUnitCapacityType.PERCENTAGE).contains(VCORES_URI));
-    Assert.assertTrue(capacityVector.getResourceNamesByCapacityType(
+    assertTrue(capacityVector.getResourceNamesByCapacityType(
         ResourceUnitCapacityType.PERCENTAGE).contains(MEMORY_URI));
         ResourceUnitCapacityType.PERCENTAGE).contains(MEMORY_URI));
-    Assert.assertEquals(10, capacityVector.getResource(MEMORY_URI).getResourceValue(), EPSILON);
-    Assert.assertEquals(6, capacityVector.getResource(VCORES_URI).getResourceValue(), EPSILON);
+    assertEquals(10, capacityVector.getResource(MEMORY_URI).getResourceValue(), EPSILON);
+    assertEquals(6, capacityVector.getResource(VCORES_URI).getResourceValue(), EPSILON);
   }
   }
 
 
   @Test
   @Test
@@ -77,10 +79,10 @@ public class TestQueueCapacityVector {
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(CUSTOM_RESOURCE, 3, ResourceUnitCapacityType.ABSOLUTE);
     capacityVector.setResource(CUSTOM_RESOURCE, 3, ResourceUnitCapacityType.ABSOLUTE);
 
 
-    Assert.assertTrue(capacityVector.isResourceOfType(MEMORY_URI, ResourceUnitCapacityType.WEIGHT));
-    Assert.assertTrue(capacityVector.isResourceOfType(VCORES_URI,
+    assertTrue(capacityVector.isResourceOfType(MEMORY_URI, ResourceUnitCapacityType.WEIGHT));
+    assertTrue(capacityVector.isResourceOfType(VCORES_URI,
         ResourceUnitCapacityType.PERCENTAGE));
         ResourceUnitCapacityType.PERCENTAGE));
-    Assert.assertTrue(capacityVector.isResourceOfType(CUSTOM_RESOURCE,
+    assertTrue(capacityVector.isResourceOfType(CUSTOM_RESOURCE,
         ResourceUnitCapacityType.ABSOLUTE));
         ResourceUnitCapacityType.ABSOLUTE));
   }
   }
 
 
@@ -89,12 +91,12 @@ public class TestQueueCapacityVector {
     QueueCapacityVector capacityVector = QueueCapacityVector.newInstance();
     QueueCapacityVector capacityVector = QueueCapacityVector.newInstance();
     List<QueueCapacityVectorEntry> entries = Lists.newArrayList(capacityVector);
     List<QueueCapacityVectorEntry> entries = Lists.newArrayList(capacityVector);
 
 
-    Assert.assertEquals(3, entries.size());
+    assertEquals(3, entries.size());
 
 
     QueueCapacityVector emptyCapacityVector = new QueueCapacityVector();
     QueueCapacityVector emptyCapacityVector = new QueueCapacityVector();
     List<QueueCapacityVectorEntry> emptyEntries = Lists.newArrayList(emptyCapacityVector);
     List<QueueCapacityVectorEntry> emptyEntries = Lists.newArrayList(emptyCapacityVector);
 
 
-    Assert.assertEquals(0, emptyEntries.size());
+    assertEquals(0, emptyEntries.size());
   }
   }
 
 
   @Test
   @Test
@@ -105,24 +107,24 @@ public class TestQueueCapacityVector {
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(CUSTOM_RESOURCE, 3, ResourceUnitCapacityType.ABSOLUTE);
     capacityVector.setResource(CUSTOM_RESOURCE, 3, ResourceUnitCapacityType.ABSOLUTE);
 
 
-    Assert.assertEquals(MIXED_CAPACITY_VECTOR_STRING, capacityVector.toString());
+    assertEquals(MIXED_CAPACITY_VECTOR_STRING, capacityVector.toString());
 
 
     QueueCapacityVector emptyCapacityVector = new QueueCapacityVector();
     QueueCapacityVector emptyCapacityVector = new QueueCapacityVector();
-    Assert.assertEquals("[]", emptyCapacityVector.toString());
+    assertEquals("[]", emptyCapacityVector.toString());
   }
   }
 
 
   @Test
   @Test
   public void testIsMixedType() {
   public void testIsMixedType() {
     // Starting from ABSOLUTE mode
     // Starting from ABSOLUTE mode
     QueueCapacityVector capacityVector = QueueCapacityVector.newInstance();
     QueueCapacityVector capacityVector = QueueCapacityVector.newInstance();
-    Assert.assertFalse(capacityVector.isMixedCapacityVector());
+    assertFalse(capacityVector.isMixedCapacityVector());
 
 
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(MEMORY_URI, 10, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(MEMORY_URI, 10, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(CUSTOM_RESOURCE, 3, ResourceUnitCapacityType.PERCENTAGE);
     capacityVector.setResource(CUSTOM_RESOURCE, 3, ResourceUnitCapacityType.PERCENTAGE);
-    Assert.assertFalse(capacityVector.isMixedCapacityVector());
+    assertFalse(capacityVector.isMixedCapacityVector());
 
 
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.WEIGHT);
     capacityVector.setResource(VCORES_URI, 6, ResourceUnitCapacityType.WEIGHT);
-    Assert.assertTrue(capacityVector.isMixedCapacityVector());
+    assertTrue(capacityVector.isMixedCapacityVector());
   }
   }
 }
 }

+ 20 - 16
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueConfigurationAutoRefreshPolicy.java

@@ -17,6 +17,11 @@
  */
  */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
@@ -27,10 +32,9 @@ import org.apache.hadoop.yarn.LocalConfigurationProvider;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
 import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.DataOutputStream;
 import java.io.DataOutputStream;
 import java.io.File;
 import java.io.File;
@@ -55,7 +59,7 @@ public class TestQueueConfigurationAutoRefreshPolicy  {
         YarnConfiguration.DR_CONFIGURATION_FILE);
         YarnConfiguration.DR_CONFIGURATION_FILE);
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     QueueMetrics.clearQueueMetrics();
     QueueMetrics.clearQueueMetrics();
     DefaultMetricsSystem.setMiniClusterMode(true);
     DefaultMetricsSystem.setMiniClusterMode(true);
@@ -94,7 +98,7 @@ public class TestQueueConfigurationAutoRefreshPolicy  {
         confFile.delete();
         confFile.delete();
       }
       }
       if (!confFile.createNewFile()) {
       if (!confFile.createNewFile()) {
-        Assert.fail("Can not create " + confXMLName);
+        fail("Can not create " + confXMLName);
       }
       }
       output = new DataOutputStream(
       output = new DataOutputStream(
           new FileOutputStream(confFile));
           new FileOutputStream(confFile));
@@ -249,15 +253,15 @@ public class TestQueueConfigurationAutoRefreshPolicy  {
     policy.editSchedule();
     policy.editSchedule();
 
 
     // Make sure refresh successfully.
     // Make sure refresh successfully.
-    Assert.assertFalse(policy.getLastReloadAttemptFailed());
+    assertFalse(policy.getLastReloadAttemptFailed());
     long oldModified = policy.getLastModified();
     long oldModified = policy.getLastModified();
     long oldSuccess = policy.getLastReloadAttempt();
     long oldSuccess = policy.getLastReloadAttempt();
 
 
-    Assert.assertTrue(oldSuccess > oldModified);
+    assertTrue(oldSuccess > oldModified);
 
 
     int maxAppsAfter = cs.getConfiguration().getMaximumSystemApplications();
     int maxAppsAfter = cs.getConfiguration().getMaximumSystemApplications();
-    Assert.assertEquals(maxAppsAfter, 5000);
-    Assert.assertTrue(maxAppsAfter != maxAppsBefore);
+    assertEquals(maxAppsAfter, 5000);
+    assertTrue(maxAppsAfter != maxAppsBefore);
 
 
     // Trigger interval for refresh.
     // Trigger interval for refresh.
     GenericTestUtils.waitFor(() -> (policy.getClock().getTime() -
     GenericTestUtils.waitFor(() -> (policy.getClock().getTime() -
@@ -277,11 +281,11 @@ public class TestQueueConfigurationAutoRefreshPolicy  {
         500, 3000);
         500, 3000);
 
 
     // Make sure refresh successfully.
     // Make sure refresh successfully.
-    Assert.assertFalse(policy.getLastReloadAttemptFailed());
+    assertFalse(policy.getLastReloadAttemptFailed());
     oldModified = policy.getLastModified();
     oldModified = policy.getLastModified();
     oldSuccess = policy.getLastReloadAttempt();
     oldSuccess = policy.getLastReloadAttempt();
-    Assert.assertTrue(oldSuccess > oldModified);
-    Assert.assertEquals(cs.getConfiguration().
+    assertTrue(oldSuccess > oldModified);
+    assertEquals(cs.getConfiguration().
         getMaximumSystemApplications(), 3000);
         getMaximumSystemApplications(), 3000);
 
 
     // Trigger interval for refresh.
     // Trigger interval for refresh.
@@ -291,13 +295,13 @@ public class TestQueueConfigurationAutoRefreshPolicy  {
 
 
     // Without modified
     // Without modified
     policy.editSchedule();
     policy.editSchedule();
-    Assert.assertEquals(oldModified,
+    assertEquals(oldModified,
         policy.getLastModified());
         policy.getLastModified());
-    Assert.assertEquals(oldSuccess,
+    assertEquals(oldSuccess,
         policy.getLastReloadAttempt());
         policy.getLastReloadAttempt());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     if (rm != null) {
     if (rm != null) {
       rm.stop();
       rm.stop();

+ 4 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueManagementDynamicEditPolicy.java

@@ -21,8 +21,8 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity
     .queuemanagement.GuaranteedOrZeroCapacityOverTimePolicy;
     .queuemanagement.GuaranteedOrZeroCapacityOverTimePolicy;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.Map;
 import java.util.Map;
 
 
@@ -30,14 +30,14 @@ import static org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager
     .NO_LABEL;
     .NO_LABEL;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
     .capacity.CSQueueUtils.EPSILON;
     .capacity.CSQueueUtils.EPSILON;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 public class TestQueueManagementDynamicEditPolicy extends
 public class TestQueueManagementDynamicEditPolicy extends
     TestCapacitySchedulerAutoCreatedQueueBase {
     TestCapacitySchedulerAutoCreatedQueueBase {
    private QueueManagementDynamicEditPolicy policy = new
    private QueueManagementDynamicEditPolicy policy = new
        QueueManagementDynamicEditPolicy();
        QueueManagementDynamicEditPolicy();
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     super.setUp();
     super.setUp();
     policy.init(cs.getConfiguration(), cs.getRMContext(), cs);
     policy.init(cs.getConfiguration(), cs.getRMContext(), cs);

+ 23 - 19
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueMappings.java

@@ -17,19 +17,22 @@
  */
  */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import java.io.IOException;
 import java.io.IOException;
 import java.util.List;
 import java.util.List;
 
 
 import org.apache.hadoop.yarn.server.resourcemanager.placement.csmappingrule.MappingRule;
 import org.apache.hadoop.yarn.server.resourcemanager.placement.csmappingrule.MappingRule;
 import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping;
 import org.apache.hadoop.yarn.server.resourcemanager.placement.QueueMapping;
-import org.junit.After;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 public class TestQueueMappings {
 public class TestQueueMappings {
 
 
@@ -50,7 +53,7 @@ public class TestQueueMappings {
   private CapacityScheduler cs;
   private CapacityScheduler cs;
   private YarnConfiguration conf;
   private YarnConfiguration conf;
 
 
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     CapacitySchedulerConfiguration csConf =
     CapacitySchedulerConfiguration csConf =
         new CapacitySchedulerConfiguration();
         new CapacitySchedulerConfiguration();
@@ -65,7 +68,7 @@ public class TestQueueMappings {
     cs.start();
     cs.start();
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (cs != null) {
     if (cs != null) {
       cs.stop();
       cs.stop();
@@ -94,7 +97,7 @@ public class TestQueueMappings {
     } catch (IOException ioex) {
     } catch (IOException ioex) {
       fail = true;
       fail = true;
     }
     }
-    Assert.assertTrue("queue initialization failed for non-existent q", fail);
+    assertTrue(fail, "queue initialization failed for non-existent q");
   }
   }
 
 
   @Test
   @Test
@@ -117,28 +120,29 @@ public class TestQueueMappings {
         .parsePathString("leaf")
         .parsePathString("leaf")
         .build();
         .build();
 
 
-    Assert.assertEquals("leaf", leafOnly.getQueue());
-    Assert.assertEquals(null, leafOnly.getParentQueue());
-    Assert.assertEquals("leaf", leafOnly.getFullPath());
+    assertEquals("leaf", leafOnly.getQueue());
+    assertEquals(null, leafOnly.getParentQueue());
+    assertEquals("leaf", leafOnly.getFullPath());
 
 
     QueueMapping twoLevels = QueueMapping.QueueMappingBuilder.create()
     QueueMapping twoLevels = QueueMapping.QueueMappingBuilder.create()
         .parsePathString("root.leaf")
         .parsePathString("root.leaf")
         .build();
         .build();
 
 
-    Assert.assertEquals("leaf", twoLevels.getQueue());
-    Assert.assertEquals("root", twoLevels.getParentQueue());
-    Assert.assertEquals("root.leaf", twoLevels.getFullPath());
+    assertEquals("leaf", twoLevels.getQueue());
+    assertEquals("root", twoLevels.getParentQueue());
+    assertEquals("root.leaf", twoLevels.getFullPath());
 
 
     QueueMapping deep = QueueMapping.QueueMappingBuilder.create()
     QueueMapping deep = QueueMapping.QueueMappingBuilder.create()
         .parsePathString("root.a.b.c.d.e.leaf")
         .parsePathString("root.a.b.c.d.e.leaf")
         .build();
         .build();
 
 
-    Assert.assertEquals("leaf", deep.getQueue());
-    Assert.assertEquals("root.a.b.c.d.e", deep.getParentQueue());
-    Assert.assertEquals("root.a.b.c.d.e.leaf", deep.getFullPath());
+    assertEquals("leaf", deep.getQueue());
+    assertEquals("root.a.b.c.d.e", deep.getParentQueue());
+    assertEquals("root.a.b.c.d.e.leaf", deep.getFullPath());
   }
   }
 
 
-  @Test (timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testQueueMappingParsingInvalidCases() throws Exception {
   public void testQueueMappingParsingInvalidCases() throws Exception {
     // configuration parsing tests - negative test cases
     // configuration parsing tests - negative test cases
     checkInvalidQMapping(conf, cs, "x:a:b", "invalid specifier");
     checkInvalidQMapping(conf, cs, "x:a:b", "invalid specifier");
@@ -163,7 +167,7 @@ public class TestQueueMappings {
     } catch (IOException ex) {
     } catch (IOException ex) {
       fail = true;
       fail = true;
     }
     }
-    Assert.assertTrue("invalid mapping did not throw exception for " + reason,
-        fail);
+    assertTrue(fail,
+        "invalid mapping did not throw exception for " + reason);
   }
   }
 }
 }

+ 204 - 184
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueParsing.java

@@ -39,16 +39,19 @@ import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NullRMNodeLabels
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.policy.PriorityUtilizationQueueOrderingPolicy;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.policy.PriorityUtilizationQueueOrderingPolicy;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 
 
 import static java.util.Collections.emptySet;
 import static java.util.Collections.emptySet;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestUtils.toSet;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestUtils.toSet;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assume.assumeThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 
 public class TestQueueParsing {
 public class TestQueueParsing {
 
 
@@ -99,7 +102,7 @@ public class TestQueueParsing {
 
 
   private RMNodeLabelsManager nodeLabelManager;
   private RMNodeLabelsManager nodeLabelManager;
 
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception{
   public void setup() throws Exception{
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -428,25 +431,27 @@ public class TestQueueParsing {
     CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
 
 
     CSQueue a = capacityScheduler.getQueue("a");
     CSQueue a = capacityScheduler.getQueue("a");
-    Assert.assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
 
 
     CSQueue b1 = capacityScheduler.getQueue("b1");
     CSQueue b1 = capacityScheduler.getQueue("b1");
-    Assert.assertEquals(0.2 * 0.5, b1.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Parent B has no MAX_CAP",
-        0.85, b1.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(0.2 * 0.5, b1.getAbsoluteCapacity(), DELTA);
+    assertEquals(
+        0.85, b1.getAbsoluteMaximumCapacity(), DELTA, "Parent B has no MAX_CAP");
 
 
     CSQueue c12 = capacityScheduler.getQueue("c12");
     CSQueue c12 = capacityScheduler.getQueue("c12");
-    Assert.assertEquals(0.7 * 0.5 * 0.45, c12.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.7 * 0.55 * 0.7,
+    assertEquals(0.7 * 0.5 * 0.45, c12.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.7 * 0.55 * 0.7,
         c12.getAbsoluteMaximumCapacity(), DELTA);
         c12.getAbsoluteMaximumCapacity(), DELTA);
   }
   }
 
 
-  @Test (expected=java.lang.IllegalArgumentException.class)
+  @Test
   public void testRootQueueParsing() throws Exception {
   public void testRootQueueParsing() throws Exception {
-    CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();
-    // non-100 percent value will throw IllegalArgumentException
-    csConf.setCapacity(ROOT, 90);
+    assertThrows(IllegalArgumentException.class, ()->{
+      CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();
+      // non-100 percent value will throw IllegalArgumentException
+      csConf.setCapacity(ROOT, 90);
+    });
   }
   }
   
   
   @Test
   @Test
@@ -483,42 +488,42 @@ public class TestQueueParsing {
 
 
   private void checkQueueLabels(CapacityScheduler capacityScheduler) {
   private void checkQueueLabels(CapacityScheduler capacityScheduler) {
     // queue-A is red, blue
     // queue-A is red, blue
-    Assert.assertTrue(capacityScheduler.getQueue("a").getAccessibleNodeLabels()
+    assertTrue(capacityScheduler.getQueue("a").getAccessibleNodeLabels()
         .containsAll(ImmutableSet.of("red", "blue")));
         .containsAll(ImmutableSet.of("red", "blue")));
 
 
     // queue-A1 inherits A's configuration
     // queue-A1 inherits A's configuration
-    Assert.assertTrue(capacityScheduler.getQueue("a1")
+    assertTrue(capacityScheduler.getQueue("a1")
         .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
         .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
 
 
     // queue-A2 is "red"
     // queue-A2 is "red"
-    Assert.assertEquals(1, capacityScheduler.getQueue("a2")
+    assertEquals(1, capacityScheduler.getQueue("a2")
         .getAccessibleNodeLabels().size());
         .getAccessibleNodeLabels().size());
-    Assert.assertTrue(capacityScheduler.getQueue("a2")
+    assertTrue(capacityScheduler.getQueue("a2")
         .getAccessibleNodeLabels().contains("red"));
         .getAccessibleNodeLabels().contains("red"));
 
 
     // queue-B is "red"/"blue"
     // queue-B is "red"/"blue"
-    Assert.assertTrue(capacityScheduler.getQueue("b").getAccessibleNodeLabels()
+    assertTrue(capacityScheduler.getQueue("b").getAccessibleNodeLabels()
         .containsAll(ImmutableSet.of("red", "blue")));
         .containsAll(ImmutableSet.of("red", "blue")));
 
 
     // queue-B2 inherits "red"/"blue"
     // queue-B2 inherits "red"/"blue"
-    Assert.assertTrue(capacityScheduler.getQueue("b2")
+    assertTrue(capacityScheduler.getQueue("b2")
         .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
         .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
 
 
     // check capacity of A2
     // check capacity of A2
     CSQueue qA2 = capacityScheduler.getQueue("a2");
     CSQueue qA2 = capacityScheduler.getQueue("a2");
-    Assert.assertEquals(0.7, qA2.getCapacity(), DELTA);
-    Assert.assertEquals(0.5, qA2.getQueueCapacities().getCapacity("red"), DELTA);
-    Assert.assertEquals(0.07, qA2.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.25, qA2.getQueueCapacities().getAbsoluteCapacity("red"), DELTA);
-    Assert.assertEquals(0.1275, qA2.getAbsoluteMaximumCapacity(), DELTA);
-    Assert.assertEquals(0.3, qA2.getQueueCapacities().getAbsoluteMaximumCapacity("red"), DELTA);
+    assertEquals(0.7, qA2.getCapacity(), DELTA);
+    assertEquals(0.5, qA2.getQueueCapacities().getCapacity("red"), DELTA);
+    assertEquals(0.07, qA2.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.25, qA2.getQueueCapacities().getAbsoluteCapacity("red"), DELTA);
+    assertEquals(0.1275, qA2.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(0.3, qA2.getQueueCapacities().getAbsoluteMaximumCapacity("red"), DELTA);
 
 
     // check capacity of B3
     // check capacity of B3
     CSQueue qB3 = capacityScheduler.getQueue("b3");
     CSQueue qB3 = capacityScheduler.getQueue("b3");
-    Assert.assertEquals(0.18, qB3.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.125, qB3.getQueueCapacities().getAbsoluteCapacity("red"), DELTA);
-    Assert.assertEquals(0.35, qB3.getAbsoluteMaximumCapacity(), DELTA);
-    Assert.assertEquals(1, qB3.getQueueCapacities().getAbsoluteMaximumCapacity("red"), DELTA);
+    assertEquals(0.18, qB3.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.125, qB3.getQueueCapacities().getAbsoluteCapacity("red"), DELTA);
+    assertEquals(0.35, qB3.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(1, qB3.getQueueCapacities().getAbsoluteMaximumCapacity("red"), DELTA);
   }
   }
 
 
   @Test
   @Test
@@ -538,64 +543,64 @@ public class TestQueueParsing {
   private void checkQueueLabelsWithLeafQueueDisableElasticity(
   private void checkQueueLabelsWithLeafQueueDisableElasticity(
       CapacityScheduler capacityScheduler) {
       CapacityScheduler capacityScheduler) {
     // queue-A is red, blue
     // queue-A is red, blue
-    Assert.assertTrue(capacityScheduler.getQueue("a").getAccessibleNodeLabels()
+    assertTrue(capacityScheduler.getQueue("a").getAccessibleNodeLabels()
             .containsAll(ImmutableSet.of("red", "blue")));
             .containsAll(ImmutableSet.of("red", "blue")));
 
 
     // queue-A1 inherits A's configuration
     // queue-A1 inherits A's configuration
-    Assert.assertTrue(capacityScheduler.getQueue("a1")
+    assertTrue(capacityScheduler.getQueue("a1")
             .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
             .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
 
 
     // queue-A2 is "red"
     // queue-A2 is "red"
-    Assert.assertEquals(1, capacityScheduler.getQueue("a2")
+    assertEquals(1, capacityScheduler.getQueue("a2")
             .getAccessibleNodeLabels().size());
             .getAccessibleNodeLabels().size());
-    Assert.assertTrue(capacityScheduler.getQueue("a2")
+    assertTrue(capacityScheduler.getQueue("a2")
             .getAccessibleNodeLabels().contains("red"));
             .getAccessibleNodeLabels().contains("red"));
 
 
     // queue-B is "red"/"blue"
     // queue-B is "red"/"blue"
-    Assert.assertTrue(capacityScheduler.getQueue("b").getAccessibleNodeLabels()
+    assertTrue(capacityScheduler.getQueue("b").getAccessibleNodeLabels()
             .containsAll(ImmutableSet.of("red", "blue")));
             .containsAll(ImmutableSet.of("red", "blue")));
 
 
     // queue-B2 inherits "red"/"blue"
     // queue-B2 inherits "red"/"blue"
-    Assert.assertTrue(capacityScheduler.getQueue("b2")
+    assertTrue(capacityScheduler.getQueue("b2")
             .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
             .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
 
 
     // check capacity of A2
     // check capacity of A2
     CSQueue qA2 = capacityScheduler.getQueue("a2");
     CSQueue qA2 = capacityScheduler.getQueue("a2");
-    Assert.assertEquals(0.4, qA2.getCapacity(), DELTA);
-    Assert.assertEquals(0.4, qA2.getQueueCapacities()
+    assertEquals(0.4, qA2.getCapacity(), DELTA);
+    assertEquals(0.4, qA2.getQueueCapacities()
             .getCapacity("red"), DELTA);
             .getCapacity("red"), DELTA);
-    Assert.assertEquals(0.2, qA2.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.2, qA2.getQueueCapacities()
+    assertEquals(0.2, qA2.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.2, qA2.getQueueCapacities()
             .getAbsoluteCapacity("red"), DELTA);
             .getAbsoluteCapacity("red"), DELTA);
-    Assert.assertEquals(0.85, qA2.getAbsoluteMaximumCapacity(), DELTA);
-    Assert.assertEquals(0.6, qA2.getQueueCapacities()
+    assertEquals(0.85, qA2.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(0.6, qA2.getQueueCapacities()
             .getAbsoluteMaximumCapacity("red"), DELTA);
             .getAbsoluteMaximumCapacity("red"), DELTA);
 
 
     // check disable elasticity at leaf queue level without label
     // check disable elasticity at leaf queue level without label
     CSQueue qB2 = capacityScheduler.getQueue("b2");
     CSQueue qB2 = capacityScheduler.getQueue("b2");
-    Assert.assertEquals(0.4, qB2.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.4, qB2.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(0.4, qB2.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.4, qB2.getAbsoluteMaximumCapacity(), DELTA);
 
 
     // check disable elasticity at leaf queue level with label
     // check disable elasticity at leaf queue level with label
     CSQueue qA1 = capacityScheduler.getQueue("a1");
     CSQueue qA1 = capacityScheduler.getQueue("a1");
-    Assert.assertEquals(0.3, qA1.getQueueCapacities().
+    assertEquals(0.3, qA1.getQueueCapacities().
             getAbsoluteCapacity("red"), DELTA);
             getAbsoluteCapacity("red"), DELTA);
-    Assert.assertEquals(0.3, qA1.getQueueCapacities().
+    assertEquals(0.3, qA1.getQueueCapacities().
             getAbsoluteMaximumCapacity("red"), DELTA);
             getAbsoluteMaximumCapacity("red"), DELTA);
 
 
     CSQueue qB1 = capacityScheduler.getQueue("b1");
     CSQueue qB1 = capacityScheduler.getQueue("b1");
-    Assert.assertEquals(0.3, qB1.getQueueCapacities()
+    assertEquals(0.3, qB1.getQueueCapacities()
             .getAbsoluteCapacity("red"), DELTA);
             .getAbsoluteCapacity("red"), DELTA);
-    Assert.assertEquals(0.3, qB1.getQueueCapacities()
+    assertEquals(0.3, qB1.getQueueCapacities()
             .getAbsoluteMaximumCapacity("red"), DELTA);
             .getAbsoluteMaximumCapacity("red"), DELTA);
 
 
     // check capacity of B3
     // check capacity of B3
     CSQueue qB3 = capacityScheduler.getQueue("b3");
     CSQueue qB3 = capacityScheduler.getQueue("b3");
-    Assert.assertEquals(0.05, qB3.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.175, qB3.getQueueCapacities()
+    assertEquals(0.05, qB3.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.175, qB3.getQueueCapacities()
             .getAbsoluteCapacity("blue"), DELTA);
             .getAbsoluteCapacity("blue"), DELTA);
-    Assert.assertEquals(0.25, qB3.getAbsoluteMaximumCapacity(), DELTA);
-    Assert.assertEquals(1, qB3.getQueueCapacities()
+    assertEquals(0.25, qB3.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(1, qB3.getQueueCapacities()
             .getAbsoluteMaximumCapacity("blue"), DELTA);
             .getAbsoluteMaximumCapacity("blue"), DELTA);
   }
   }
 
 
@@ -615,21 +620,21 @@ public class TestQueueParsing {
 
 
   private void checkQueueLabelsInheritConfig(CapacityScheduler capacityScheduler) {
   private void checkQueueLabelsInheritConfig(CapacityScheduler capacityScheduler) {
     // queue-A is red, blue
     // queue-A is red, blue
-    Assert.assertTrue(capacityScheduler.getQueue("a").getAccessibleNodeLabels()
+    assertTrue(capacityScheduler.getQueue("a").getAccessibleNodeLabels()
             .containsAll(ImmutableSet.of("red", "blue")));
             .containsAll(ImmutableSet.of("red", "blue")));
 
 
     // queue-A1 inherits A's configuration
     // queue-A1 inherits A's configuration
-    Assert.assertTrue(capacityScheduler.getQueue("a1")
+    assertTrue(capacityScheduler.getQueue("a1")
             .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
             .getAccessibleNodeLabels().containsAll(ImmutableSet.of("red", "blue")));
 
 
     // queue-A2 is "red"
     // queue-A2 is "red"
-    Assert.assertEquals(1, capacityScheduler.getQueue("a2")
+    assertEquals(1, capacityScheduler.getQueue("a2")
             .getAccessibleNodeLabels().size());
             .getAccessibleNodeLabels().size());
-    Assert.assertTrue(capacityScheduler.getQueue("a2")
+    assertTrue(capacityScheduler.getQueue("a2")
             .getAccessibleNodeLabels().contains("red"));
             .getAccessibleNodeLabels().contains("red"));
 
 
     // queue-B is "red"/"blue"
     // queue-B is "red"/"blue"
-    Assert.assertTrue(capacityScheduler.getQueue("b").getAccessibleNodeLabels()
+    assertTrue(capacityScheduler.getQueue("b").getAccessibleNodeLabels()
             .isEmpty());
             .isEmpty());
   }
   }
   
   
@@ -699,21 +704,21 @@ public class TestQueueParsing {
 
 
     // check root queue's capacity by label -- they should be all zero
     // check root queue's capacity by label -- they should be all zero
     CSQueue root = capacityScheduler.getQueue(CapacitySchedulerConfiguration.ROOT);
     CSQueue root = capacityScheduler.getQueue(CapacitySchedulerConfiguration.ROOT);
-    Assert.assertEquals(0, root.getQueueCapacities().getCapacity("red"), DELTA);
-    Assert.assertEquals(0, root.getQueueCapacities().getCapacity("blue"), DELTA);
+    assertEquals(0, root.getQueueCapacities().getCapacity("red"), DELTA);
+    assertEquals(0, root.getQueueCapacities().getCapacity("blue"), DELTA);
 
 
     CSQueue a = capacityScheduler.getQueue("a");
     CSQueue a = capacityScheduler.getQueue("a");
-    Assert.assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
 
 
     CSQueue b1 = capacityScheduler.getQueue("b1");
     CSQueue b1 = capacityScheduler.getQueue("b1");
-    Assert.assertEquals(0.2 * 0.5, b1.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals("Parent B has no MAX_CAP", 0.85,
-        b1.getAbsoluteMaximumCapacity(), DELTA);
+    assertEquals(0.2 * 0.5, b1.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.85,
+        b1.getAbsoluteMaximumCapacity(), DELTA, "Parent B has no MAX_CAP");
 
 
     CSQueue c12 = capacityScheduler.getQueue("c12");
     CSQueue c12 = capacityScheduler.getQueue("c12");
-    Assert.assertEquals(0.7 * 0.5 * 0.45, c12.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.7 * 0.55 * 0.7, c12.getAbsoluteMaximumCapacity(),
+    assertEquals(0.7 * 0.5 * 0.45, c12.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.7 * 0.55 * 0.7, c12.getAbsoluteMaximumCapacity(),
         DELTA);
         DELTA);
     ServiceOperations.stopQuietly(rm);
     ServiceOperations.stopQuietly(rm);
   }
   }
@@ -729,14 +734,14 @@ public class TestQueueParsing {
 
 
     CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue a = capacityScheduler.getQueue("a");
     CSQueue a = capacityScheduler.getQueue("a");
-    Assert.assertNotNull(a);
-    Assert.assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
+    assertNotNull(a);
+    assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
     
     
     CSQueue c = capacityScheduler.getQueue("c");
     CSQueue c = capacityScheduler.getQueue("c");
-    Assert.assertNotNull(c);
-    Assert.assertEquals(0.70, c.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.70, c.getAbsoluteMaximumCapacity(), DELTA);
+    assertNotNull(c);
+    assertEquals(0.70, c.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.70, c.getAbsoluteMaximumCapacity(), DELTA);
   }
   }
   
   
   @Test
   @Test
@@ -750,142 +755,156 @@ public class TestQueueParsing {
     CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
 
 
     CSQueue a = capacityScheduler.getQueue("a");
     CSQueue a = capacityScheduler.getQueue("a");
-    Assert.assertNotNull(a);
-    Assert.assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
+    assertNotNull(a);
+    assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
     
     
     CSQueue c = capacityScheduler.getQueue("c");
     CSQueue c = capacityScheduler.getQueue("c");
-    Assert.assertNotNull(c);
-    Assert.assertEquals(0.70, c.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.70, c.getAbsoluteMaximumCapacity(), DELTA);
+    assertNotNull(c);
+    assertEquals(0.70, c.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.70, c.getAbsoluteMaximumCapacity(), DELTA);
     
     
     CSQueue a1 = capacityScheduler.getQueue("a1");
     CSQueue a1 = capacityScheduler.getQueue("a1");
-    Assert.assertNotNull(a1);
-    Assert.assertEquals(0.10 * 0.6, a1.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.15, a1.getAbsoluteMaximumCapacity(), DELTA);
+    assertNotNull(a1);
+    assertEquals(0.10 * 0.6, a1.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.15, a1.getAbsoluteMaximumCapacity(), DELTA);
     
     
     CSQueue a2 = capacityScheduler.getQueue("a2");
     CSQueue a2 = capacityScheduler.getQueue("a2");
-    Assert.assertNotNull(a2);
-    Assert.assertEquals(0.10 * 0.4, a2.getAbsoluteCapacity(), DELTA);
-    Assert.assertEquals(0.15, a2.getAbsoluteMaximumCapacity(), DELTA);
+    assertNotNull(a2);
+    assertEquals(0.10 * 0.4, a2.getAbsoluteCapacity(), DELTA);
+    assertEquals(0.15, a2.getAbsoluteMaximumCapacity(), DELTA);
   }
   }
   
   
   /**
   /**
    * Test init a queue configuration, children's capacity for a given label
    * Test init a queue configuration, children's capacity for a given label
    * doesn't equals to 100%. This expect IllegalArgumentException thrown.
    * doesn't equals to 100%. This expect IllegalArgumentException thrown.
    */
    */
-  @Test(expected = ServiceStateException.class)
+  @Test
   public void testQueueParsingFailWhenSumOfChildrenNonLabeledCapacityNot100Percent()
   public void testQueueParsingFailWhenSumOfChildrenNonLabeledCapacityNot100Percent()
       throws Exception {
       throws Exception {
-    CapacitySchedulerConfiguration csConf =
-        new CapacitySchedulerConfiguration();
-
-    // If the new queue mode is used it's allowed to leave
-    // some of the resources of a parent queue unallocated
-    assumeThat(csConf.isLegacyQueueMode(), is(true));
-    setupQueueConfiguration(csConf);
-    csConf.setCapacity(C2, 5);
-    YarnConfiguration conf = new YarnConfiguration(csConf);
-
-    MockRM rm = createMockRMWithLabels(conf, ImmutableSet.of("red", "blue"));
-    ServiceOperations.stopQuietly(rm);
+    assertThrows(ServiceStateException.class, ()->{
+      CapacitySchedulerConfiguration csConf =
+              new CapacitySchedulerConfiguration();
+
+      // If the new queue mode is used it's allowed to leave
+      // some of the resources of a parent queue unallocated
+      assumeTrue(csConf.isLegacyQueueMode() == true);
+      setupQueueConfiguration(csConf);
+      csConf.setCapacity(C2, 5);
+      YarnConfiguration conf = new YarnConfiguration(csConf);
+
+      MockRM rm = createMockRMWithLabels(conf, ImmutableSet.of("red", "blue"));
+      ServiceOperations.stopQuietly(rm);
+    });
   }
   }
   
   
   /**
   /**
    * Test init a queue configuration, children's capacity for a given label
    * Test init a queue configuration, children's capacity for a given label
    * doesn't equals to 100%. This expect IllegalArgumentException thrown.
    * doesn't equals to 100%. This expect IllegalArgumentException thrown.
    */
    */
-  @Test(expected = ServiceStateException.class)
+  @Test
   public void testQueueParsingFailWhenSumOfChildrenLabeledCapacityNot100Percent()
   public void testQueueParsingFailWhenSumOfChildrenLabeledCapacityNot100Percent()
       throws Exception {
       throws Exception {
-    CapacitySchedulerConfiguration csConf =
-        new CapacitySchedulerConfiguration();
 
 
-    // If the new queue mode is used it's allowed to leave
-    // some of the resources of a parent queue unallocated
-    assumeThat(csConf.isLegacyQueueMode(), is(true));
+    assertThrows(ServiceStateException.class, ()->{
+      CapacitySchedulerConfiguration csConf =
+              new CapacitySchedulerConfiguration();
+
+      // If the new queue mode is used it's allowed to leave
+      // some of the resources of a parent queue unallocated
+      assumeTrue(csConf.isLegacyQueueMode() == true);
+
+      setupQueueConfigurationWithLabels(csConf);
+      csConf.setCapacityByLabel(B3, "red", 24);
+      YarnConfiguration conf = new YarnConfiguration(csConf);
+
+      MockRM rm = createMockRMWithLabels(conf, ImmutableSet.of("red", "blue"));
+      ServiceOperations.stopQuietly(rm);
+    });
 
 
-    setupQueueConfigurationWithLabels(csConf);
-    csConf.setCapacityByLabel(B3, "red", 24);
-    YarnConfiguration conf = new YarnConfiguration(csConf);
 
 
-    MockRM rm = createMockRMWithLabels(conf, ImmutableSet.of("red", "blue"));
-    ServiceOperations.stopQuietly(rm);
   }
   }
 
 
   /**
   /**
    * Test init a queue configuration, children's capacity for a given label
    * Test init a queue configuration, children's capacity for a given label
    * doesn't equals to 100%. This expect IllegalArgumentException thrown.
    * doesn't equals to 100%. This expect IllegalArgumentException thrown.
    */
    */
-  @Test(expected = ServiceStateException.class)
+  @Test
   public void testQueueParsingWithSumOfChildLabelCapacityNot100PercentWithWildCard()
   public void testQueueParsingWithSumOfChildLabelCapacityNot100PercentWithWildCard()
       throws Exception {
       throws Exception {
-    CapacitySchedulerConfiguration csConf =
-            new CapacitySchedulerConfiguration();
-
-    // If the new queue mode is used it's allowed to leave
-    // some of the resources of a parent queue unallocated
-    assumeThat(csConf.isLegacyQueueMode(), is(true));
-
-    setupQueueConfigurationWithLabels(csConf);
-    csConf.setCapacityByLabel(B3, "red", 24);
-    csConf.setAccessibleNodeLabels(ROOT, ImmutableSet.of(RMNodeLabelsManager.ANY));
-    csConf.setAccessibleNodeLabels(B, ImmutableSet.of(RMNodeLabelsManager.ANY));
-    YarnConfiguration conf = new YarnConfiguration(csConf);
-
-    MockRM rm = createMockRMWithLabels(conf, ImmutableSet.of("red", "blue"));
-    ServiceOperations.stopQuietly(rm);
+    assertThrows(ServiceStateException.class, ()->{
+      CapacitySchedulerConfiguration csConf =
+              new CapacitySchedulerConfiguration();
+
+      // If the new queue mode is used it's allowed to leave
+      // some of the resources of a parent queue unallocated
+      assumeTrue(csConf.isLegacyQueueMode() == true);
+
+      setupQueueConfigurationWithLabels(csConf);
+      csConf.setCapacityByLabel(B3, "red", 24);
+      csConf.setAccessibleNodeLabels(ROOT, ImmutableSet.of(RMNodeLabelsManager.ANY));
+      csConf.setAccessibleNodeLabels(B, ImmutableSet.of(RMNodeLabelsManager.ANY));
+      YarnConfiguration conf = new YarnConfiguration(csConf);
+
+      MockRM rm = createMockRMWithLabels(conf, ImmutableSet.of("red", "blue"));
+      ServiceOperations.stopQuietly(rm);
+    });
   }
   }
   
   
-  @Test(expected = IOException.class)
+  @Test
   public void testQueueParsingWithMoveQueue() throws Exception {
   public void testQueueParsingWithMoveQueue() throws Exception {
-    CapacitySchedulerConfiguration csConf =
-        new CapacitySchedulerConfiguration();
-    csConf.setQueues(ROOT, new String[] {"a"});
-    csConf.setQueues(A, new String[] {"x", "y"});
-    csConf.setCapacity(A, 100);
-    csConf.setCapacity(AX, 50);
-    csConf.setCapacity(AY, 50);
-    YarnConfiguration conf = new YarnConfiguration(csConf);
-
-    MockRM rm = createMockRMWithoutLabels(conf);
-    CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
-
-    csConf.setQueues(ROOT, new String[] {"a", "x"});
-    csConf.setQueues(A, new String[] {"y"});
-    csConf.setCapacity(X, 50);
-    csConf.setCapacity(A, 50);
-    csConf.setCapacity(AY, 100);
-    
-    capacityScheduler.reinitialize(csConf, rm.getRMContext());
-    ServiceOperations.stopQuietly(rm);
+    assertThrows(IOException.class, ()->{
+      CapacitySchedulerConfiguration csConf =
+              new CapacitySchedulerConfiguration();
+      csConf.setQueues(ROOT, new String[] {"a"});
+      csConf.setQueues(A, new String[] {"x", "y"});
+      csConf.setCapacity(A, 100);
+      csConf.setCapacity(AX, 50);
+      csConf.setCapacity(AY, 50);
+      YarnConfiguration conf = new YarnConfiguration(csConf);
+
+      MockRM rm = createMockRMWithoutLabels(conf);
+      CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
+
+      csConf.setQueues(ROOT, new String[] {"a", "x"});
+      csConf.setQueues(A, new String[] {"y"});
+      csConf.setCapacity(X, 50);
+      csConf.setCapacity(A, 50);
+      csConf.setCapacity(AY, 100);
+
+      capacityScheduler.reinitialize(csConf, rm.getRMContext());
+      ServiceOperations.stopQuietly(rm);
+    });
   }
   }
 
 
-  @Test(timeout = 60000, expected = ServiceStateException.class)
+  @Test
+  @Timeout(value = 60)
   public void testRMStartWrongNodeCapacity() throws Exception {
   public void testRMStartWrongNodeCapacity() throws Exception {
-    CapacitySchedulerConfiguration csConf =
-        new CapacitySchedulerConfiguration();
-    Set<String> labels = ImmutableSet.of("x", "y", "z");
-
-    // If the new queue mode is used it's allowed to leave
-    // some of the resources of a parent queue unallocated
-    assumeThat(csConf.isLegacyQueueMode(), is(true));
-
-    // Define top-level queues
-    csConf.setQueues(ROOT, new String[] {"a"});
-    csConf.setCapacityByLabel(ROOT, "x", 100);
-    csConf.setCapacityByLabel(ROOT, "y", 100);
-    csConf.setCapacityByLabel(ROOT, "z", 100);
-
-    csConf.setCapacity(A, 100);
-    csConf.setAccessibleNodeLabels(A, labels);
-    csConf.setCapacityByLabel(A, "x", 100);
-    csConf.setCapacityByLabel(A, "y", 100);
-    csConf.setCapacityByLabel(A, "z", 70);
-
-    YarnConfiguration conf = new YarnConfiguration(csConf);
-    MockRM rm = createMockRMWithLabels(conf, labels);
-    ServiceOperations.stopQuietly(rm);
+    assertThrows(ServiceStateException.class, ()->{
+      CapacitySchedulerConfiguration csConf =
+              new CapacitySchedulerConfiguration();
+      Set<String> labels = ImmutableSet.of("x", "y", "z");
+
+      // If the new queue mode is used it's allowed to leave
+      // some of the resources of a parent queue unallocated
+      assumeTrue(csConf.isLegacyQueueMode() == true);
+
+      // Define top-level queues
+      csConf.setQueues(ROOT, new String[] {"a"});
+      csConf.setCapacityByLabel(ROOT, "x", 100);
+      csConf.setCapacityByLabel(ROOT, "y", 100);
+      csConf.setCapacityByLabel(ROOT, "z", 100);
+
+      csConf.setCapacity(A, 100);
+      csConf.setAccessibleNodeLabels(A, labels);
+      csConf.setCapacityByLabel(A, "x", 100);
+      csConf.setCapacityByLabel(A, "y", 100);
+      csConf.setCapacityByLabel(A, "z", 70);
+
+      YarnConfiguration conf = new YarnConfiguration(csConf);
+      MockRM rm = createMockRMWithLabels(conf, labels);
+      ServiceOperations.stopQuietly(rm);
+    });
   }
   }
 
 
 
 
@@ -920,7 +939,8 @@ public class TestQueueParsing {
     ServiceOperations.stopQuietly(rm);
     ServiceOperations.stopQuietly(rm);
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testQueueCapacityWithWeight() throws Exception {
   public void testQueueCapacityWithWeight() throws Exception {
     Set<String> labels = ImmutableSet.of("x", "y", "z");
     Set<String> labels = ImmutableSet.of("x", "y", "z");
 
 
@@ -980,13 +1000,13 @@ public class TestQueueParsing {
     // Test
     // Test
     CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler capacityScheduler = (CapacityScheduler) rm.getResourceScheduler();
 
 
-    Assert.assertEquals(15,
+    assertEquals(15,
             ((LeafQueue)capacityScheduler.getQueue(A_PATH)).getUserLimit(), DELTA);
             ((LeafQueue)capacityScheduler.getQueue(A_PATH)).getUserLimit(), DELTA);
-    Assert.assertEquals(1.5,
+    assertEquals(1.5,
             ((LeafQueue)capacityScheduler.getQueue(A_PATH)).getUserLimitFactor(), DELTA);
             ((LeafQueue)capacityScheduler.getQueue(A_PATH)).getUserLimitFactor(), DELTA);
-    Assert.assertEquals(20,
+    assertEquals(20,
             ((LeafQueue)capacityScheduler.getQueue(B_PATH)).getUserLimit(), DELTA);
             ((LeafQueue)capacityScheduler.getQueue(B_PATH)).getUserLimit(), DELTA);
-    Assert.assertEquals(2.0,
+    assertEquals(2.0,
             ((LeafQueue)capacityScheduler.getQueue(B_PATH)).getUserLimitFactor(), DELTA);
             ((LeafQueue)capacityScheduler.getQueue(B_PATH)).getUserLimitFactor(), DELTA);
 
 
     // Use hadoop default value
     // Use hadoop default value
@@ -1000,13 +1020,13 @@ public class TestQueueParsing {
 
 
     capacityScheduler.reinitialize(csConf, rm.getRMContext());
     capacityScheduler.reinitialize(csConf, rm.getRMContext());
 
 
-    Assert.assertEquals(15,
+    assertEquals(15,
             ((LeafQueue)capacityScheduler.getQueue(A_PATH)).getUserLimit(), DELTA);
             ((LeafQueue)capacityScheduler.getQueue(A_PATH)).getUserLimit(), DELTA);
-    Assert.assertEquals(1.5,
+    assertEquals(1.5,
             ((LeafQueue)capacityScheduler.getQueue(A_PATH)).getUserLimitFactor(), DELTA);
             ((LeafQueue)capacityScheduler.getQueue(A_PATH)).getUserLimitFactor(), DELTA);
-    Assert.assertEquals(100,
+    assertEquals(100,
             ((LeafQueue)capacityScheduler.getQueue(B_PATH)).getUserLimit(), DELTA);
             ((LeafQueue)capacityScheduler.getQueue(B_PATH)).getUserLimit(), DELTA);
-    Assert.assertEquals(1,
+    assertEquals(1,
             ((LeafQueue)capacityScheduler.getQueue(B_PATH)).getUserLimitFactor(), DELTA);
             ((LeafQueue)capacityScheduler.getQueue(B_PATH)).getUserLimitFactor(), DELTA);
   }
   }
 
 
@@ -1014,7 +1034,7 @@ public class TestQueueParsing {
       float expectedAbsCapacity) {
       float expectedAbsCapacity) {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = cs.getQueue(queuePath);
     CSQueue queue = cs.getQueue(queuePath);
-    Assert.assertEquals(expectedAbsCapacity,
+    assertEquals(expectedAbsCapacity,
         queue.getQueueCapacities().getAbsoluteCapacity(label), 1e-6);
         queue.getQueueCapacities().getAbsoluteCapacity(label), 1e-6);
   }
   }
 
 
@@ -1024,8 +1044,8 @@ public class TestQueueParsing {
       existedQueues.add(q.getQueueShortName());
       existedQueues.add(q.getQueueShortName());
     }
     }
     for (String q : queueNames) {
     for (String q : queueNames) {
-      Assert.assertTrue(existedQueues.remove(q));
+      assertTrue(existedQueues.remove(q));
     }
     }
-    Assert.assertTrue(existedQueues.isEmpty());
+    assertTrue(existedQueues.isEmpty());
   }
   }
 }
 }

+ 56 - 50
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueuePath.java

@@ -18,9 +18,15 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
@@ -41,34 +47,34 @@ public class TestQueuePath {
 
 
   @Test
   @Test
   public void testCreation() {
   public void testCreation() {
-    Assert.assertEquals(TEST_QUEUE, TEST_QUEUE_PATH.getFullPath());
-    Assert.assertEquals("root.level_1.level_2", TEST_QUEUE_PATH.getParent());
-    Assert.assertEquals("level_3", TEST_QUEUE_PATH.getLeafName());
+    assertEquals(TEST_QUEUE, TEST_QUEUE_PATH.getFullPath());
+    assertEquals("root.level_1.level_2", TEST_QUEUE_PATH.getParent());
+    assertEquals("level_3", TEST_QUEUE_PATH.getLeafName());
 
 
-    Assert.assertNull(ROOT_PATH.getParent());
+    assertNull(ROOT_PATH.getParent());
 
 
     QueuePath appendedPath = TEST_QUEUE_PATH.createNewLeaf("level_4");
     QueuePath appendedPath = TEST_QUEUE_PATH.createNewLeaf("level_4");
-    Assert.assertEquals(TEST_QUEUE + CapacitySchedulerConfiguration.DOT
+    assertEquals(TEST_QUEUE + CapacitySchedulerConfiguration.DOT
         + "level_4", appendedPath.getFullPath());
         + "level_4", appendedPath.getFullPath());
-    Assert.assertEquals("root.level_1.level_2.level_3", appendedPath.getParent());
-    Assert.assertEquals("level_4", appendedPath.getLeafName());
+    assertEquals("root.level_1.level_2.level_3", appendedPath.getParent());
+    assertEquals("level_4", appendedPath.getLeafName());
   }
   }
 
 
   @Test
   @Test
   public void testEmptyPart() {
   public void testEmptyPart() {
-    Assert.assertTrue(QUEUE_PATH_WITH_EMPTY_PART.hasEmptyPart());
-    Assert.assertTrue(QUEUE_PATH_WITH_EMPTY_LEAF.hasEmptyPart());
-    Assert.assertFalse(TEST_QUEUE_PATH.hasEmptyPart());
+    assertTrue(QUEUE_PATH_WITH_EMPTY_PART.hasEmptyPart());
+    assertTrue(QUEUE_PATH_WITH_EMPTY_LEAF.hasEmptyPart());
+    assertFalse(TEST_QUEUE_PATH.hasEmptyPart());
   }
   }
 
 
   @Test
   @Test
   public void testNullPath() {
   public void testNullPath() {
     QueuePath queuePathWithNullPath = new QueuePath(null);
     QueuePath queuePathWithNullPath = new QueuePath(null);
 
 
-    Assert.assertNull(queuePathWithNullPath.getParent());
-    Assert.assertEquals("", queuePathWithNullPath.getLeafName());
-    Assert.assertEquals("", queuePathWithNullPath.getFullPath());
-    Assert.assertFalse(queuePathWithNullPath.isRoot());
+    assertNull(queuePathWithNullPath.getParent());
+    assertEquals("", queuePathWithNullPath.getLeafName());
+    assertEquals("", queuePathWithNullPath.getFullPath());
+    assertFalse(queuePathWithNullPath.isRoot());
   }
   }
 
 
   @Test
   @Test
@@ -78,17 +84,17 @@ public class TestQueuePath {
         QUEUE_PATH_WITH_EMPTY_PART.iterator());
         QUEUE_PATH_WITH_EMPTY_PART.iterator());
     List<String> rootPathCollection = ImmutableList.copyOf(ROOT_PATH.iterator());
     List<String> rootPathCollection = ImmutableList.copyOf(ROOT_PATH.iterator());
 
 
-    Assert.assertEquals(4, queuePathCollection.size());
-    Assert.assertEquals(CapacitySchedulerConfiguration.ROOT, queuePathCollection.get(0));
-    Assert.assertEquals("level_3", queuePathCollection.get(3));
+    assertEquals(4, queuePathCollection.size());
+    assertEquals(CapacitySchedulerConfiguration.ROOT, queuePathCollection.get(0));
+    assertEquals("level_3", queuePathCollection.get(3));
 
 
-    Assert.assertEquals(3, queuePathWithEmptyPartCollection.size());
-    Assert.assertEquals(CapacitySchedulerConfiguration.ROOT,
+    assertEquals(3, queuePathWithEmptyPartCollection.size());
+    assertEquals(CapacitySchedulerConfiguration.ROOT,
         queuePathWithEmptyPartCollection.get(0));
         queuePathWithEmptyPartCollection.get(0));
-    Assert.assertEquals("level_2", queuePathWithEmptyPartCollection.get(2));
+    assertEquals("level_2", queuePathWithEmptyPartCollection.get(2));
 
 
-    Assert.assertEquals(1, rootPathCollection.size());
-    Assert.assertEquals(CapacitySchedulerConfiguration.ROOT, rootPathCollection.get(0));
+    assertEquals(1, rootPathCollection.size());
+    assertEquals(CapacitySchedulerConfiguration.ROOT, rootPathCollection.get(0));
   }
   }
 
 
   @Test
   @Test
@@ -98,18 +104,18 @@ public class TestQueuePath {
         QUEUE_PATH_WITH_EMPTY_PART.reverseIterator());
         QUEUE_PATH_WITH_EMPTY_PART.reverseIterator());
     List<String> rootPathCollection = ImmutableList.copyOf(ROOT_PATH.reverseIterator());
     List<String> rootPathCollection = ImmutableList.copyOf(ROOT_PATH.reverseIterator());
 
 
-    Assert.assertEquals(4, queuePathCollection.size());
-    Assert.assertEquals(CapacitySchedulerConfiguration.ROOT,
+    assertEquals(4, queuePathCollection.size());
+    assertEquals(CapacitySchedulerConfiguration.ROOT,
         queuePathCollection.get(3));
         queuePathCollection.get(3));
-    Assert.assertEquals(TEST_QUEUE, queuePathCollection.get(0));
+    assertEquals(TEST_QUEUE, queuePathCollection.get(0));
 
 
-    Assert.assertEquals(3, queuePathWithEmptyPartCollection.size());
-    Assert.assertEquals(CapacitySchedulerConfiguration.ROOT,
+    assertEquals(3, queuePathWithEmptyPartCollection.size());
+    assertEquals(CapacitySchedulerConfiguration.ROOT,
         queuePathWithEmptyPartCollection.get(2));
         queuePathWithEmptyPartCollection.get(2));
-    Assert.assertEquals("root..level_2", queuePathWithEmptyPartCollection.get(0));
+    assertEquals("root..level_2", queuePathWithEmptyPartCollection.get(0));
 
 
-    Assert.assertEquals(1, rootPathCollection.size());
-    Assert.assertEquals(CapacitySchedulerConfiguration.ROOT,
+    assertEquals(1, rootPathCollection.size());
+    assertEquals(CapacitySchedulerConfiguration.ROOT,
         rootPathCollection.get(0));
         rootPathCollection.get(0));
   }
   }
 
 
@@ -121,33 +127,33 @@ public class TestQueuePath {
     QueuePath empty = new QueuePath("");
     QueuePath empty = new QueuePath("");
     QueuePath emptySame = new QueuePath("");
     QueuePath emptySame = new QueuePath("");
 
 
-    Assert.assertEquals(queuePath, queuePathSame);
-    Assert.assertEquals(empty, emptySame);
-    Assert.assertNotEquals(null, queuePath);
+    assertEquals(queuePath, queuePathSame);
+    assertEquals(empty, emptySame);
+    assertNotEquals(null, queuePath);
   }
   }
 
 
   @Test
   @Test
   public void testInvalidPath() {
   public void testInvalidPath() {
-    Assert.assertFalse(TEST_QUEUE_PATH.isInvalid());
-    Assert.assertFalse(ROOT_PATH.isInvalid());
-    Assert.assertTrue(EMPTY_PATH.isInvalid());
-    Assert.assertTrue(new QueuePath("invalidPath").isInvalid());
+    assertFalse(TEST_QUEUE_PATH.isInvalid());
+    assertFalse(ROOT_PATH.isInvalid());
+    assertTrue(EMPTY_PATH.isInvalid());
+    assertTrue(new QueuePath("invalidPath").isInvalid());
   }
   }
 
 
   @Test
   @Test
   public void testGetParentObject() {
   public void testGetParentObject() {
-    Assert.assertEquals(new QueuePath("root.level_1.level_2"),
+    assertEquals(new QueuePath("root.level_1.level_2"),
         TEST_QUEUE_PATH.getParentObject());
         TEST_QUEUE_PATH.getParentObject());
-    Assert.assertEquals(ROOT_PATH, new QueuePath("root.level_1").getParentObject());
-    Assert.assertNull(ROOT_PATH.getParentObject());
+    assertEquals(ROOT_PATH, new QueuePath("root.level_1").getParentObject());
+    assertNull(ROOT_PATH.getParentObject());
   }
   }
 
 
   @Test
   @Test
   public void testGetPathComponents() {
   public void testGetPathComponents() {
-    Assert.assertArrayEquals(TEST_QUEUE_PATH.getPathComponents(),
+    assertArrayEquals(TEST_QUEUE_PATH.getPathComponents(),
         new String[] {"root", "level_1", "level_2", "level_3"});
         new String[] {"root", "level_1", "level_2", "level_3"});
-    Assert.assertArrayEquals(ROOT_PATH.getPathComponents(), new String[] {"root"});
-    Assert.assertArrayEquals(EMPTY_PATH.getPathComponents(), new String[] {""});
+    assertArrayEquals(ROOT_PATH.getPathComponents(), new String[] {"root"});
+    assertArrayEquals(EMPTY_PATH.getPathComponents(), new String[] {""});
   }
   }
 
 
   @Test
   @Test
@@ -161,7 +167,7 @@ public class TestQueuePath {
     List<QueuePath> wildcardedPaths = TEST_QUEUE_PATH
     List<QueuePath> wildcardedPaths = TEST_QUEUE_PATH
         .getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
         .getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
 
 
-    Assert.assertEquals(expectedPaths, wildcardedPaths);
+    assertEquals(expectedPaths, wildcardedPaths);
   }
   }
 
 
   @Test
   @Test
@@ -176,7 +182,7 @@ public class TestQueuePath {
     List<QueuePath> wildcardedPaths = TEST_QUEUE_PATH
     List<QueuePath> wildcardedPaths = TEST_QUEUE_PATH
         .getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
         .getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
 
 
-    Assert.assertEquals(expectedPaths, wildcardedPaths);
+    assertEquals(expectedPaths, wildcardedPaths);
   }
   }
 
 
   @Test
   @Test
@@ -192,7 +198,7 @@ public class TestQueuePath {
     List<QueuePath> wildcardedPaths = TEST_QUEUE_PATH
     List<QueuePath> wildcardedPaths = TEST_QUEUE_PATH
         .getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
         .getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
 
 
-    Assert.assertEquals(expectedPaths, wildcardedPaths);
+    assertEquals(expectedPaths, wildcardedPaths);
   }
   }
 
 
   @Test
   @Test
@@ -208,7 +214,7 @@ public class TestQueuePath {
     List<QueuePath> wildcardedPaths = TEST_QUEUE_PATH
     List<QueuePath> wildcardedPaths = TEST_QUEUE_PATH
         .getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
         .getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
 
 
-    Assert.assertEquals(expectedPaths, wildcardedPaths);
+    assertEquals(expectedPaths, wildcardedPaths);
   }
   }
 
 
   @Test
   @Test
@@ -220,6 +226,6 @@ public class TestQueuePath {
 
 
     List<QueuePath> wildcardedPaths = ROOT_PATH.getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
     List<QueuePath> wildcardedPaths = ROOT_PATH.getWildcardedQueuePaths(maxAutoCreatedQueueDepth);
 
 
-    Assert.assertEquals(expectedPaths, wildcardedPaths);
+    assertEquals(expectedPaths, wildcardedPaths);
   }
   }
 }
 }

+ 42 - 36
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueState.java

@@ -18,6 +18,9 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
@@ -41,8 +44,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 /**
 /**
  * Test Queue States.
  * Test Queue States.
@@ -65,7 +68,8 @@ public class TestQueueState {
   private CapacityScheduler cs;
   private CapacityScheduler cs;
   private YarnConfiguration conf;
   private YarnConfiguration conf;
 
 
-  @Test (timeout = 15000)
+  @Test
+  @Timeout(value = 15)
   public void testQueueState() throws IOException {
   public void testQueueState() throws IOException {
     CapacitySchedulerConfiguration csConf =
     CapacitySchedulerConfiguration csConf =
         new CapacitySchedulerConfiguration();
         new CapacitySchedulerConfiguration();
@@ -84,16 +88,16 @@ public class TestQueueState {
     cs.init(conf);
     cs.init(conf);
 
 
     //by default, the state of both queues should be RUNNING
     //by default, the state of both queues should be RUNNING
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
 
 
     // Change the state of Q1 to STOPPED, and re-initiate the CS
     // Change the state of Q1 to STOPPED, and re-initiate the CS
     csConf.setState(Q1_PATH, QueueState.STOPPED);
     csConf.setState(Q1_PATH, QueueState.STOPPED);
     conf = new YarnConfiguration(csConf);
     conf = new YarnConfiguration(csConf);
     cs.reinitialize(conf, rmContext);
     cs.reinitialize(conf, rmContext);
     // The state of Q1 and its child: Q2 should be STOPPED
     // The state of Q1 and its child: Q2 should be STOPPED
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
 
 
     // Change the state of Q1 to RUNNING, and change the state of Q2 to STOPPED
     // Change the state of Q1 to RUNNING, and change the state of Q2 to STOPPED
     csConf.setState(Q1_PATH, QueueState.RUNNING);
     csConf.setState(Q1_PATH, QueueState.RUNNING);
@@ -101,8 +105,8 @@ public class TestQueueState {
     conf = new YarnConfiguration(csConf);
     conf = new YarnConfiguration(csConf);
     // reinitialize the CS, the operation should be successful
     // reinitialize the CS, the operation should be successful
     cs.reinitialize(conf, rmContext);
     cs.reinitialize(conf, rmContext);
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
 
 
     // Change the state of Q1 to STOPPED, and change the state of Q2 to RUNNING
     // Change the state of Q1 to STOPPED, and change the state of Q2 to RUNNING
     csConf.setState(Q1_PATH, QueueState.STOPPED);
     csConf.setState(Q1_PATH, QueueState.STOPPED);
@@ -111,15 +115,16 @@ public class TestQueueState {
     // reinitialize the CS, the operation should be failed.
     // reinitialize the CS, the operation should be failed.
     try {
     try {
       cs.reinitialize(conf, rmContext);
       cs.reinitialize(conf, rmContext);
-      Assert.fail("Should throw an Exception.");
+      fail("Should throw an Exception.");
     } catch (Exception ex) {
     } catch (Exception ex) {
-      Assert.assertTrue(ex.getCause().getMessage().contains(
+      assertTrue(ex.getCause().getMessage().contains(
           "The parent queue:root.q1 cannot be STOPPED as the child" +
           "The parent queue:root.q1 cannot be STOPPED as the child" +
           " queue:root.q1.q2 is in RUNNING state."));
           " queue:root.q1.q2 is in RUNNING state."));
     }
     }
   }
   }
 
 
-  @Test(timeout = 15000)
+  @Test
+  @Timeout(value = 15)
   public void testQueueStateTransit() throws Exception {
   public void testQueueStateTransit() throws Exception {
     CapacitySchedulerConfiguration csConf =
     CapacitySchedulerConfiguration csConf =
         new CapacitySchedulerConfiguration();
         new CapacitySchedulerConfiguration();
@@ -139,9 +144,9 @@ public class TestQueueState {
     cs.init(conf);
     cs.init(conf);
 
 
     //by default, the state of ALL queues should be RUNNING
     //by default, the state of ALL queues should be RUNNING
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
 
 
     // submit an application to Q2
     // submit an application to Q2
     ApplicationId appId = ApplicationId.newInstance(
     ApplicationId appId = ApplicationId.newInstance(
@@ -156,41 +161,41 @@ public class TestQueueState {
     csConf.setState(Q2_PATH, QueueState.STOPPED);
     csConf.setState(Q2_PATH, QueueState.STOPPED);
     conf = new YarnConfiguration(csConf);
     conf = new YarnConfiguration(csConf);
     cs.reinitialize(conf, rmContext);
     cs.reinitialize(conf, rmContext);
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.DRAINING, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.DRAINING, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
 
 
     // set Q2 state to RUNNING and do reinitialize.
     // set Q2 state to RUNNING and do reinitialize.
     // Q2 should transit from DRAINING to RUNNING
     // Q2 should transit from DRAINING to RUNNING
     csConf.setState(Q2_PATH, QueueState.RUNNING);
     csConf.setState(Q2_PATH, QueueState.RUNNING);
     conf = new YarnConfiguration(csConf);
     conf = new YarnConfiguration(csConf);
     cs.reinitialize(conf, rmContext);
     cs.reinitialize(conf, rmContext);
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
 
 
     // set Q2 state to stop and do reinitialize.
     // set Q2 state to stop and do reinitialize.
     csConf.setState(Q2_PATH, QueueState.STOPPED);
     csConf.setState(Q2_PATH, QueueState.STOPPED);
     conf = new YarnConfiguration(csConf);
     conf = new YarnConfiguration(csConf);
     cs.reinitialize(conf, rmContext);
     cs.reinitialize(conf, rmContext);
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.DRAINING, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.DRAINING, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
 
 
     // set Q1 state to stop and do reinitialize.
     // set Q1 state to stop and do reinitialize.
     csConf.setState(Q1_PATH, QueueState.STOPPED);
     csConf.setState(Q1_PATH, QueueState.STOPPED);
     conf = new YarnConfiguration(csConf);
     conf = new YarnConfiguration(csConf);
     cs.reinitialize(conf, rmContext);
     cs.reinitialize(conf, rmContext);
-    Assert.assertEquals(QueueState.DRAINING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.DRAINING, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.DRAINING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.DRAINING, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
 
 
     // Active Q3, should fail
     // Active Q3, should fail
     csConf.setState(Q3_PATH, QueueState.RUNNING);
     csConf.setState(Q3_PATH, QueueState.RUNNING);
     conf = new YarnConfiguration(csConf);
     conf = new YarnConfiguration(csConf);
     try {
     try {
       cs.reinitialize(conf, rmContext);
       cs.reinitialize(conf, rmContext);
-      Assert.fail("Should throw an Exception.");
+      fail("Should throw an Exception.");
     } catch (Exception ex) {
     } catch (Exception ex) {
       // Do Nothing
       // Do Nothing
     }
     }
@@ -198,9 +203,9 @@ public class TestQueueState {
     // stop the app running in q2
     // stop the app running in q2
     cs.getQueue(Q2).finishApplicationAttempt(app, Q2);
     cs.getQueue(Q2).finishApplicationAttempt(app, Q2);
     cs.getQueue(Q2).finishApplication(appId, userName);
     cs.getQueue(Q2).finishApplication(appId, userName);
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
     
     
   }
   }
 
 
@@ -225,7 +230,8 @@ public class TestQueueState {
     return application;
     return application;
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testRecoverDrainingStateAfterRMRestart() throws Exception {
   public void testRecoverDrainingStateAfterRMRestart() throws Exception {
     // init conf
     // init conf
     CapacitySchedulerConfiguration newConf =
     CapacitySchedulerConfiguration newConf =
@@ -266,9 +272,9 @@ public class TestQueueState {
         (CapacityScheduler) rm.getRMContext().getScheduler();
         (CapacityScheduler) rm.getRMContext().getScheduler();
     capacityScheduler.reinitialize(newConf, rm.getRMContext());
     capacityScheduler.reinitialize(newConf, rm.getRMContext());
     // current queue state should be DRAINING
     // current queue state should be DRAINING
-    Assert.assertEquals(QueueState.DRAINING,
+    assertEquals(QueueState.DRAINING,
         capacityScheduler.getQueue(Q2).getState());
         capacityScheduler.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.DRAINING,
+    assertEquals(QueueState.DRAINING,
         capacityScheduler.getQueue(Q1).getState());
         capacityScheduler.getQueue(Q1).getState());
 
 
     // RM restart
     // RM restart
@@ -279,9 +285,9 @@ public class TestQueueState {
     // queue state should be DRAINING after app recovered
     // queue state should be DRAINING after app recovered
     rm.waitForState(app.getApplicationId(), RMAppState.ACCEPTED);
     rm.waitForState(app.getApplicationId(), RMAppState.ACCEPTED);
     capacityScheduler = (CapacityScheduler) rm.getRMContext().getScheduler();
     capacityScheduler = (CapacityScheduler) rm.getRMContext().getScheduler();
-    Assert.assertEquals(QueueState.DRAINING,
+    assertEquals(QueueState.DRAINING,
         capacityScheduler.getQueue(Q2).getState());
         capacityScheduler.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.DRAINING,
+    assertEquals(QueueState.DRAINING,
         capacityScheduler.getQueue(Q1).getState());
         capacityScheduler.getQueue(Q1).getState());
 
 
     // close rm
     // close rm

+ 27 - 25
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueStateManager.java

@@ -17,6 +17,9 @@
  */
  */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
@@ -35,8 +38,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueStateManager;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueStateManager;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 /**
 /**
  * Test QueueStateManager.
  * Test QueueStateManager.
@@ -86,44 +88,44 @@ public class TestQueueStateManager {
         .getQueueStateManager();
         .getQueueStateManager();
 
 
     //by default, the state of both queues should be RUNNING
     //by default, the state of both queues should be RUNNING
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
 
 
     // Stop Q2, and verify that Q2 transmits to STOPPED STATE
     // Stop Q2, and verify that Q2 transmits to STOPPED STATE
     stateManager.stopQueue(Q2);
     stateManager.stopQueue(Q2);
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
 
 
     // Stop Q1, and verify that Q1, as well as its child: Q3,
     // Stop Q1, and verify that Q1, as well as its child: Q3,
     // transmits to STOPPED STATE
     // transmits to STOPPED STATE
     stateManager.stopQueue(Q1);
     stateManager.stopQueue(Q1);
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
 
 
-    Assert.assertTrue(stateManager.canDelete(Q1));
-    Assert.assertTrue(stateManager.canDelete(Q2));
-    Assert.assertTrue(stateManager.canDelete(Q3));
+    assertTrue(stateManager.canDelete(Q1));
+    assertTrue(stateManager.canDelete(Q2));
+    assertTrue(stateManager.canDelete(Q3));
 
 
     // Active Q2, it will fail.
     // Active Q2, it will fail.
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
 
 
     // Now active Q1
     // Now active Q1
     stateManager.activateQueue(Q1);
     stateManager.activateQueue(Q1);
     // Q1 should be in RUNNING state. Its children: Q2 and Q3
     // Q1 should be in RUNNING state. Its children: Q2 and Q3
     // should still be in STOPPED state.
     // should still be in STOPPED state.
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
 
 
     // Now active Q2 and Q3
     // Now active Q2 and Q3
     stateManager.activateQueue(Q2);
     stateManager.activateQueue(Q2);
     stateManager.activateQueue(Q3);
     stateManager.activateQueue(Q3);
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.RUNNING, cs.getQueue(Q3).getState());
 
 
-    Assert.assertFalse(stateManager.canDelete(Q1));
-    Assert.assertFalse(stateManager.canDelete(Q2));
-    Assert.assertFalse(stateManager.canDelete(Q3));
+    assertFalse(stateManager.canDelete(Q1));
+    assertFalse(stateManager.canDelete(Q2));
+    assertFalse(stateManager.canDelete(Q3));
 
 
     ApplicationId appId = ApplicationId.newInstance(
     ApplicationId appId = ApplicationId.newInstance(
         System.currentTimeMillis(), 1);
         System.currentTimeMillis(), 1);
@@ -134,15 +136,15 @@ public class TestQueueStateManager {
     cs.getQueue(Q2).submitApplicationAttempt(app, userName);
     cs.getQueue(Q2).submitApplicationAttempt(app, userName);
     stateManager.stopQueue(Q1);
     stateManager.stopQueue(Q1);
 
 
-    Assert.assertEquals(QueueState.DRAINING, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.DRAINING, cs.getQueue(Q2).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
+    assertEquals(QueueState.DRAINING, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.DRAINING, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q3).getState());
 
 
     cs.getQueue(Q2).finishApplicationAttempt(app, Q2);
     cs.getQueue(Q2).finishApplicationAttempt(app, Q2);
     cs.getQueue(Q2).finishApplication(appId, userName);
     cs.getQueue(Q2).finishApplication(appId, userName);
 
 
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q1).getState());
-    Assert.assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q1).getState());
+    assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
   }
   }
 
 
   private FiCaSchedulerApp getMockApplication(ApplicationId appId, String user,
   private FiCaSchedulerApp getMockApplication(ApplicationId appId, String user,

+ 8 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservationQueue.java

@@ -18,9 +18,9 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -38,8 +38,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.QueueEntit
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 /**
 /**
  * Test class for dynamic auto created leaf queues.
  * Test class for dynamic auto created leaf queues.
@@ -58,7 +58,7 @@ public class TestReservationQueue {
   private PlanQueue planQueue;
   private PlanQueue planQueue;
   private final Resource clusterResource = Resources.createResource(100 * 16 * GB, 100 * 32);
   private final Resource clusterResource = Resources.createResource(100 * 16 * GB, 100 * 32);
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException, SchedulerDynamicEditException {
   public void setup() throws IOException, SchedulerDynamicEditException {
     // setup a context / conf
     // setup a context / conf
     csConf = new CapacitySchedulerConfiguration();
     csConf = new CapacitySchedulerConfiguration();
@@ -97,8 +97,8 @@ public class TestReservationQueue {
   }
   }
 
 
   private void validateAutoCreatedLeafQueue(double capacity) {
   private void validateAutoCreatedLeafQueue(double capacity) {
-    assertTrue(" actual capacity: " + autoCreatedLeafQueue.getCapacity(),
-        autoCreatedLeafQueue.getCapacity() - capacity < CSQueueUtils.EPSILON);
+    assertTrue(autoCreatedLeafQueue.getCapacity() - capacity < CSQueueUtils.EPSILON,
+        " actual capacity: " + autoCreatedLeafQueue.getCapacity());
     assertEquals(autoCreatedLeafQueue.maxApplications, DEF_MAX_APPS);
     assertEquals(autoCreatedLeafQueue.maxApplications, DEF_MAX_APPS);
     assertEquals(autoCreatedLeafQueue.maxApplicationsPerUser, DEF_MAX_APPS);
     assertEquals(autoCreatedLeafQueue.maxApplicationsPerUser, DEF_MAX_APPS);
   }
   }

+ 22 - 23
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java

@@ -18,9 +18,9 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doReturn;
@@ -33,7 +33,6 @@ import java.util.Map;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.After;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.slf4j.event.Level;
 import org.slf4j.event.Level;
@@ -71,9 +70,9 @@ import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestUtils.toSchedulerKey;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestUtils.toSchedulerKey;
 
 
@@ -101,14 +100,14 @@ public class TestReservations {
   final static int GB = 1024;
   final static int GB = 1024;
   final static String DEFAULT_RACK = "/default";
   final static String DEFAULT_RACK = "/default";
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     CapacityScheduler spyCs = new CapacityScheduler();
     CapacityScheduler spyCs = new CapacityScheduler();
     cs = spy(spyCs);
     cs = spy(spyCs);
     rmContext = TestUtils.getMockRMContext();
     rmContext = TestUtils.getMockRMContext();
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (cs != null) {
     if (cs != null) {
       cs.stop();
       cs.stop();
@@ -232,7 +231,7 @@ public class TestReservations {
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_0 = spy(app_0);
     app_0 = spy(app_0);
-    Mockito.doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
 
 
@@ -243,7 +242,7 @@ public class TestReservations {
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_1 = spy(app_1);
     app_1 = spy(app_1);
-    Mockito.doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     a.submitApplicationAttempt(app_1, user_0); 
     a.submitApplicationAttempt(app_1, user_0); 
 
 
@@ -419,7 +418,7 @@ public class TestReservations {
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_0 = spy(app_0);
     app_0 = spy(app_0);
-    Mockito.doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
 
 
@@ -430,7 +429,7 @@ public class TestReservations {
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_1, a,
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_1, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_1 = spy(app_1);
     app_1 = spy(app_1);
-    Mockito.doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     rmContext.getRMApps().put(app_1.getApplicationId(), mock(RMApp.class));
     rmContext.getRMApps().put(app_1.getApplicationId(), mock(RMApp.class));
 
 
@@ -573,7 +572,7 @@ public class TestReservations {
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_0 = spy(app_0);
     app_0 = spy(app_0);
-    Mockito.doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
 
 
@@ -584,7 +583,7 @@ public class TestReservations {
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_1 = spy(app_1);
     app_1 = spy(app_1);
-    Mockito.doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     a.submitApplicationAttempt(app_1, user_0); 
     a.submitApplicationAttempt(app_1, user_0); 
 
 
@@ -757,7 +756,7 @@ public class TestReservations {
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_0 = spy(app_0);
     app_0 = spy(app_0);
-    Mockito.doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
 
 
@@ -768,7 +767,7 @@ public class TestReservations {
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_1 = spy(app_1);
     app_1 = spy(app_1);
-    Mockito.doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     a.submitApplicationAttempt(app_1, user_0); 
     a.submitApplicationAttempt(app_1, user_0); 
 
 
@@ -1047,7 +1046,7 @@ public class TestReservations {
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_0 = spy(app_0);
     app_0 = spy(app_0);
-    Mockito.doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
 
 
@@ -1058,7 +1057,7 @@ public class TestReservations {
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_1 = spy(app_1);
     app_1 = spy(app_1);
-    Mockito.doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     a.submitApplicationAttempt(app_1, user_0); 
     a.submitApplicationAttempt(app_1, user_0); 
 
 
@@ -1239,7 +1238,7 @@ public class TestReservations {
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_0 = spy(app_0);
     app_0 = spy(app_0);
-    Mockito.doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
     a.submitApplicationAttempt(app_0, user_0); 
     a.submitApplicationAttempt(app_0, user_0); 
@@ -1249,7 +1248,7 @@ public class TestReservations {
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_1 = spy(app_1);
     app_1 = spy(app_1);
-    Mockito.doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     a.submitApplicationAttempt(app_1, user_0); 
     a.submitApplicationAttempt(app_1, user_0); 
 
 
@@ -1402,7 +1401,7 @@ public class TestReservations {
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
     FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_0 = spy(app_0);
     app_0 = spy(app_0);
-    Mockito.doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_0).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
     rmContext.getRMApps().put(app_0.getApplicationId(), mock(RMApp.class));
 
 
@@ -1413,7 +1412,7 @@ public class TestReservations {
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
     FiCaSchedulerApp app_1 = new FiCaSchedulerApp(appAttemptId_1, user_0, a,
         mock(ActiveUsersManager.class), spyRMContext);
         mock(ActiveUsersManager.class), spyRMContext);
     app_1 = spy(app_1);
     app_1 = spy(app_1);
-    Mockito.doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
+    doNothing().when(app_1).updateAMContainerDiagnostics(any(AMState.class),
         any(String.class));
         any(String.class));
     a.submitApplicationAttempt(app_1, user_0); 
     a.submitApplicationAttempt(app_1, user_0); 
 
 

+ 28 - 27
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestResourceVector.java

@@ -21,9 +21,8 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
@@ -31,13 +30,15 @@ import java.util.Map;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.MEMORY_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.MEMORY_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.VCORES_URI;
 import static org.apache.hadoop.yarn.api.records.ResourceInformation.VCORES_URI;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
 import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils.EPSILON;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
 
 public class TestResourceVector {
 public class TestResourceVector {
   private final static String CUSTOM_RESOURCE = "custom";
   private final static String CUSTOM_RESOURCE = "custom";
 
 
   private final YarnConfiguration conf = new YarnConfiguration();
   private final YarnConfiguration conf = new YarnConfiguration();
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     conf.set(YarnConfiguration.RESOURCE_TYPES, CUSTOM_RESOURCE);
     conf.set(YarnConfiguration.RESOURCE_TYPES, CUSTOM_RESOURCE);
     ResourceUtils.resetResourceTypes(conf);
     ResourceUtils.resetResourceTypes(conf);
@@ -46,22 +47,22 @@ public class TestResourceVector {
   @Test
   @Test
   public void testCreation() {
   public void testCreation() {
     ResourceVector zeroResourceVector = ResourceVector.newInstance();
     ResourceVector zeroResourceVector = ResourceVector.newInstance();
-    Assert.assertEquals(0, zeroResourceVector.getValue(MEMORY_URI), EPSILON);
-    Assert.assertEquals(0, zeroResourceVector.getValue(VCORES_URI), EPSILON);
-    Assert.assertEquals(0, zeroResourceVector.getValue(CUSTOM_RESOURCE), EPSILON);
+    assertEquals(0, zeroResourceVector.getValue(MEMORY_URI), EPSILON);
+    assertEquals(0, zeroResourceVector.getValue(VCORES_URI), EPSILON);
+    assertEquals(0, zeroResourceVector.getValue(CUSTOM_RESOURCE), EPSILON);
 
 
     ResourceVector uniformResourceVector = ResourceVector.of(10);
     ResourceVector uniformResourceVector = ResourceVector.of(10);
-    Assert.assertEquals(10, uniformResourceVector.getValue(MEMORY_URI), EPSILON);
-    Assert.assertEquals(10, uniformResourceVector.getValue(VCORES_URI), EPSILON);
-    Assert.assertEquals(10, uniformResourceVector.getValue(CUSTOM_RESOURCE), EPSILON);
+    assertEquals(10, uniformResourceVector.getValue(MEMORY_URI), EPSILON);
+    assertEquals(10, uniformResourceVector.getValue(VCORES_URI), EPSILON);
+    assertEquals(10, uniformResourceVector.getValue(CUSTOM_RESOURCE), EPSILON);
 
 
     Map<String, Long> customResources = new HashMap<>();
     Map<String, Long> customResources = new HashMap<>();
     customResources.put(CUSTOM_RESOURCE, 2L);
     customResources.put(CUSTOM_RESOURCE, 2L);
     Resource resource = Resource.newInstance(10, 5, customResources);
     Resource resource = Resource.newInstance(10, 5, customResources);
     ResourceVector resourceVectorFromResource = ResourceVector.of(resource);
     ResourceVector resourceVectorFromResource = ResourceVector.of(resource);
-    Assert.assertEquals(10, resourceVectorFromResource.getValue(MEMORY_URI), EPSILON);
-    Assert.assertEquals(5, resourceVectorFromResource.getValue(VCORES_URI), EPSILON);
-    Assert.assertEquals(2, resourceVectorFromResource.getValue(CUSTOM_RESOURCE), EPSILON);
+    assertEquals(10, resourceVectorFromResource.getValue(MEMORY_URI), EPSILON);
+    assertEquals(5, resourceVectorFromResource.getValue(VCORES_URI), EPSILON);
+    assertEquals(2, resourceVectorFromResource.getValue(CUSTOM_RESOURCE), EPSILON);
   }
   }
 
 
   @Test
   @Test
@@ -70,17 +71,17 @@ public class TestResourceVector {
     ResourceVector rhsResourceVector = ResourceVector.of(5);
     ResourceVector rhsResourceVector = ResourceVector.of(5);
     lhsResourceVector.decrement(rhsResourceVector);
     lhsResourceVector.decrement(rhsResourceVector);
 
 
-    Assert.assertEquals(8, lhsResourceVector.getValue(MEMORY_URI), EPSILON);
-    Assert.assertEquals(8, lhsResourceVector.getValue(VCORES_URI), EPSILON);
-    Assert.assertEquals(8, lhsResourceVector.getValue(CUSTOM_RESOURCE), EPSILON);
+    assertEquals(8, lhsResourceVector.getValue(MEMORY_URI), EPSILON);
+    assertEquals(8, lhsResourceVector.getValue(VCORES_URI), EPSILON);
+    assertEquals(8, lhsResourceVector.getValue(CUSTOM_RESOURCE), EPSILON);
 
 
     ResourceVector negativeResourceVector = ResourceVector.of(-100);
     ResourceVector negativeResourceVector = ResourceVector.of(-100);
 
 
     // Check whether overflow causes any issues
     // Check whether overflow causes any issues
     negativeResourceVector.decrement(ResourceVector.of(Float.MAX_VALUE));
     negativeResourceVector.decrement(ResourceVector.of(Float.MAX_VALUE));
-    Assert.assertEquals(-Float.MAX_VALUE, negativeResourceVector.getValue(MEMORY_URI), EPSILON);
-    Assert.assertEquals(-Float.MAX_VALUE, negativeResourceVector.getValue(VCORES_URI), EPSILON);
-    Assert.assertEquals(-Float.MAX_VALUE, negativeResourceVector.getValue(CUSTOM_RESOURCE),
+    assertEquals(-Float.MAX_VALUE, negativeResourceVector.getValue(MEMORY_URI), EPSILON);
+    assertEquals(-Float.MAX_VALUE, negativeResourceVector.getValue(VCORES_URI), EPSILON);
+    assertEquals(-Float.MAX_VALUE, negativeResourceVector.getValue(CUSTOM_RESOURCE),
         EPSILON);
         EPSILON);
 
 
   }
   }
@@ -90,14 +91,14 @@ public class TestResourceVector {
     ResourceVector resourceVector = ResourceVector.of(13);
     ResourceVector resourceVector = ResourceVector.of(13);
     resourceVector.increment(MEMORY_URI, 5);
     resourceVector.increment(MEMORY_URI, 5);
 
 
-    Assert.assertEquals(18, resourceVector.getValue(MEMORY_URI), EPSILON);
-    Assert.assertEquals(13, resourceVector.getValue(VCORES_URI), EPSILON);
-    Assert.assertEquals(13, resourceVector.getValue(CUSTOM_RESOURCE), EPSILON);
+    assertEquals(18, resourceVector.getValue(MEMORY_URI), EPSILON);
+    assertEquals(13, resourceVector.getValue(VCORES_URI), EPSILON);
+    assertEquals(13, resourceVector.getValue(CUSTOM_RESOURCE), EPSILON);
 
 
     // Check whether overflow causes any issues
     // Check whether overflow causes any issues
     ResourceVector maxFloatResourceVector = ResourceVector.of(Float.MAX_VALUE);
     ResourceVector maxFloatResourceVector = ResourceVector.of(Float.MAX_VALUE);
     maxFloatResourceVector.increment(MEMORY_URI, 100);
     maxFloatResourceVector.increment(MEMORY_URI, 100);
-    Assert.assertEquals(Float.MAX_VALUE, maxFloatResourceVector.getValue(MEMORY_URI), EPSILON);
+    assertEquals(Float.MAX_VALUE, maxFloatResourceVector.getValue(MEMORY_URI), EPSILON);
   }
   }
 
 
   @Test
   @Test
@@ -106,13 +107,13 @@ public class TestResourceVector {
     ResourceVector resourceVectorOther = ResourceVector.of(14);
     ResourceVector resourceVectorOther = ResourceVector.of(14);
     Resource resource = Resource.newInstance(13, 13);
     Resource resource = Resource.newInstance(13, 13);
 
 
-    Assert.assertNotEquals(null, resourceVector);
-    Assert.assertNotEquals(resourceVectorOther, resourceVector);
-    Assert.assertNotEquals(resource, resourceVector);
+    assertNotEquals(null, resourceVector);
+    assertNotEquals(resourceVectorOther, resourceVector);
+    assertNotEquals(resource, resourceVector);
 
 
     ResourceVector resourceVectorOne = ResourceVector.of(1);
     ResourceVector resourceVectorOne = ResourceVector.of(1);
     resourceVectorOther.decrement(resourceVectorOne);
     resourceVectorOther.decrement(resourceVectorOne);
 
 
-    Assert.assertEquals(resourceVectorOther, resourceVector);
+    assertEquals(resourceVectorOther, resourceVector);
   }
   }
 }
 }

+ 132 - 100
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestSchedulingRequestContainerAllocation.java

@@ -50,12 +50,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
 import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
@@ -74,32 +71,35 @@ import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.and;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.cardinality;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.cardinality;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetIn;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetIn;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetNotIn;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetNotIn;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
 /**
  * Test Container Allocation with SchedulingRequest.
  * Test Container Allocation with SchedulingRequest.
  */
  */
-@RunWith(Parameterized.class)
 public class TestSchedulingRequestContainerAllocation {
 public class TestSchedulingRequestContainerAllocation {
   private static final int GB = 1024;
   private static final int GB = 1024;
   private YarnConfiguration conf;
   private YarnConfiguration conf;
   private String placementConstraintHandler;
   private String placementConstraintHandler;
   RMNodeLabelsManager mgr;
   RMNodeLabelsManager mgr;
 
 
-
-  @Parameters
   public static Collection<Object[]> placementConstarintHandlers() {
   public static Collection<Object[]> placementConstarintHandlers() {
-    Object[][] params = new Object[][] {
-        {YarnConfiguration.PROCESSOR_RM_PLACEMENT_CONSTRAINTS_HANDLER},
-        {YarnConfiguration.SCHEDULER_RM_PLACEMENT_CONSTRAINTS_HANDLER} };
+    Object[][] params = new Object[][]{
+            {YarnConfiguration.PROCESSOR_RM_PLACEMENT_CONSTRAINTS_HANDLER},
+            {YarnConfiguration.SCHEDULER_RM_PLACEMENT_CONSTRAINTS_HANDLER}};
     return Arrays.asList(params);
     return Arrays.asList(params);
   }
   }
 
 
-  public TestSchedulingRequestContainerAllocation(
-      String placementConstraintHandler) {
-    this.placementConstraintHandler = placementConstraintHandler;
+  private void initTestSchedulingRequestContainerAllocation(
+      String pPlacementConstraintHandler) throws Exception {
+    this.placementConstraintHandler = pPlacementConstraintHandler;
+    setUp();
   }
   }
 
 
-  @Before
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -126,8 +126,12 @@ public class TestSchedulingRequestContainerAllocation {
     return MockRMAppSubmitter.submit(rm, data);
     return MockRMAppSubmitter.submit(rm, data);
   }
   }
 
 
-  @Test(timeout = 30000L)
-  public void testIntraAppAntiAffinity() throws Exception {
+  @Timeout(30)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testIntraAppAntiAffinity(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocation(pPlacementConstraintHandler);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
 
 
     // inject node label manager
     // inject node label manager
@@ -168,8 +172,8 @@ public class TestSchedulingRequestContainerAllocation {
         Priority.newInstance(1), 1L, ImmutableSet.of("mapper"), "mapper");
         Priority.newInstance(1), 1L, ImmutableSet.of("mapper"), "mapper");
 
 
     List<Container> allocated = waitForAllocation(4, 3000, am1, nms);
     List<Container> allocated = waitForAllocation(4, 3000, am1, nms);
-    Assert.assertEquals(4, allocated.size());
-    Assert.assertEquals(4, getContainerNodesNum(allocated));
+    assertEquals(4, allocated.size());
+    assertEquals(4, getContainerNodesNum(allocated));
 
 
     // Similarly, app1 asks 10 anti-affinity containers at different priority,
     // Similarly, app1 asks 10 anti-affinity containers at different priority,
     // it should be satisfied as well.
     // it should be satisfied as well.
@@ -180,8 +184,8 @@ public class TestSchedulingRequestContainerAllocation {
         Priority.newInstance(2), 1L, ImmutableSet.of("reducer"), "reducer");
         Priority.newInstance(2), 1L, ImmutableSet.of("reducer"), "reducer");
 
 
     allocated = waitForAllocation(4, 3000, am1, nms);
     allocated = waitForAllocation(4, 3000, am1, nms);
-    Assert.assertEquals(4, allocated.size());
-    Assert.assertEquals(4, getContainerNodesNum(allocated));
+    assertEquals(4, allocated.size());
+    assertEquals(4, getContainerNodesNum(allocated));
 
 
     // Test anti-affinity to both of "mapper/reducer", we should only get no
     // Test anti-affinity to both of "mapper/reducer", we should only get no
     // container allocated
     // container allocated
@@ -195,13 +199,17 @@ public class TestSchedulingRequestContainerAllocation {
     } catch (Exception e) {
     } catch (Exception e) {
       caughtException = true;
       caughtException = true;
     }
     }
-    Assert.assertTrue(caughtException);
+    assertTrue(caughtException);
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 30000L)
-  public void testIntraAppAntiAffinityWithMultipleTags() throws Exception {
+  @Timeout(30)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testIntraAppAntiAffinityWithMultipleTags(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocation(pPlacementConstraintHandler);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
 
 
     // inject node label manager
     // inject node label manager
@@ -242,8 +250,8 @@ public class TestSchedulingRequestContainerAllocation {
         "tag_1_1", "tag_1_2");
         "tag_1_1", "tag_1_2");
 
 
     List<Container> allocated = waitForAllocation(2, 3000, am1, nms);
     List<Container> allocated = waitForAllocation(2, 3000, am1, nms);
-    Assert.assertEquals(2, allocated.size());
-    Assert.assertEquals(2, getContainerNodesNum(allocated));
+    assertEquals(2, allocated.size());
+    assertEquals(2, getContainerNodesNum(allocated));
 
 
     // app1 asks for 1 anti-affinity containers for the same app. anti-affinity
     // app1 asks for 1 anti-affinity containers for the same app. anti-affinity
     // to tag_1_1/tag_1_2. With allocation_tag = tag_2_1/tag_2_2
     // to tag_1_1/tag_1_2. With allocation_tag = tag_2_1/tag_2_2
@@ -253,9 +261,9 @@ public class TestSchedulingRequestContainerAllocation {
         "tag_1_1", "tag_1_2");
         "tag_1_1", "tag_1_2");
 
 
     List<Container> allocated1 = waitForAllocation(1, 3000, am1, nms);
     List<Container> allocated1 = waitForAllocation(1, 3000, am1, nms);
-    Assert.assertEquals(1, allocated1.size());
+    assertEquals(1, allocated1.size());
     allocated.addAll(allocated1);
     allocated.addAll(allocated1);
-    Assert.assertEquals(3, getContainerNodesNum(allocated));
+    assertEquals(3, getContainerNodesNum(allocated));
 
 
     // app1 asks for 1 anti-affinity containers for the same app. anti-affinity
     // app1 asks for 1 anti-affinity containers for the same app. anti-affinity
     // to tag_1_1/tag_1_2/tag_2_1/tag_2_2. With allocation_tag = tag_3
     // to tag_1_1/tag_1_2/tag_2_1/tag_2_2. With allocation_tag = tag_3
@@ -265,9 +273,9 @@ public class TestSchedulingRequestContainerAllocation {
         "tag_1_1", "tag_1_2", "tag_2_1", "tag_2_2");
         "tag_1_1", "tag_1_2", "tag_2_1", "tag_2_2");
 
 
     allocated1 = waitForAllocation(1, 3000, am1, nms);
     allocated1 = waitForAllocation(1, 3000, am1, nms);
-    Assert.assertEquals(1, allocated1.size());
+    assertEquals(1, allocated1.size());
     allocated.addAll(allocated1);
     allocated.addAll(allocated1);
-    Assert.assertEquals(4, getContainerNodesNum(allocated));
+    assertEquals(4, getContainerNodesNum(allocated));
 
 
     rm1.close();
     rm1.close();
   }
   }
@@ -278,8 +286,12 @@ public class TestSchedulingRequestContainerAllocation {
    * types, see more in TestPlacementConstraintsUtil.
    * types, see more in TestPlacementConstraintsUtil.
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(timeout = 30000L)
-  public void testInterAppAntiAffinity() throws Exception {
+  @Timeout(30)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testInterAppAntiAffinity(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocation(pPlacementConstraintHandler);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
 
 
     // inject node label manager
     // inject node label manager
@@ -320,8 +332,8 @@ public class TestSchedulingRequestContainerAllocation {
         Priority.newInstance(1), 1L, ImmutableSet.of("mapper"), "mapper");
         Priority.newInstance(1), 1L, ImmutableSet.of("mapper"), "mapper");
 
 
     List<Container> allocated = waitForAllocation(3, 3000, am1, nms);
     List<Container> allocated = waitForAllocation(3, 3000, am1, nms);
-    Assert.assertEquals(3, allocated.size());
-    Assert.assertEquals(3, getContainerNodesNum(allocated));
+    assertEquals(3, allocated.size());
+    assertEquals(3, getContainerNodesNum(allocated));
 
 
     System.out.println("Mappers on HOST0: "
     System.out.println("Mappers on HOST0: "
         + rmNodes[0].getAllocationTagsWithCount().get("mapper"));
         + rmNodes[0].getAllocationTagsWithCount().get("mapper"));
@@ -353,10 +365,10 @@ public class TestSchedulingRequestContainerAllocation {
         ImmutableSet.of("foo"), "mapper");
         ImmutableSet.of("foo"), "mapper");
 
 
     List<Container> allocated1 = waitForAllocation(3, 3000, am2, nms);
     List<Container> allocated1 = waitForAllocation(3, 3000, am2, nms);
-    Assert.assertEquals(3, allocated1.size());
-    Assert.assertEquals(1, getContainerNodesNum(allocated1));
+    assertEquals(3, allocated1.size());
+    assertEquals(1, getContainerNodesNum(allocated1));
     allocated.addAll(allocated1);
     allocated.addAll(allocated1);
-    Assert.assertEquals(4, getContainerNodesNum(allocated));
+    assertEquals(4, getContainerNodesNum(allocated));
 
 
 
 
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
@@ -364,7 +376,7 @@ public class TestSchedulingRequestContainerAllocation {
         am2.getApplicationAttemptId());
         am2.getApplicationAttemptId());
 
 
     // The allocated node should not have mapper tag.
     // The allocated node should not have mapper tag.
-    Assert.assertTrue(schedulerApp2.getLiveContainers()
+    assertTrue(schedulerApp2.getLiveContainers()
         .stream().allMatch(rmContainer -> {
         .stream().allMatch(rmContainer -> {
           // except the nm host
           // except the nm host
           if (!rmContainer.getContainer().getNodeId().equals(rmNodes[0])) {
           if (!rmContainer.getContainer().getNodeId().equals(rmNodes[0])) {
@@ -396,15 +408,18 @@ public class TestSchedulingRequestContainerAllocation {
 
 
 
 
     allocated1 = waitForAllocation(1, 3000, am3, nms);
     allocated1 = waitForAllocation(1, 3000, am3, nms);
-    Assert.assertEquals(1, allocated1.size());
+    assertEquals(1, allocated1.size());
     allocated.addAll(allocated1);
     allocated.addAll(allocated1);
-    Assert.assertEquals(4, getContainerNodesNum(allocated));
+    assertEquals(4, getContainerNodesNum(allocated));
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test
-  public void testSchedulingRequestDisabledByDefault() throws Exception {
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testSchedulingRequestDisabledByDefault(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocation(pPlacementConstraintHandler);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(
         new Configuration());
         new Configuration());
 
 
@@ -450,12 +465,16 @@ public class TestSchedulingRequestContainerAllocation {
     } catch (Exception e) {
     } catch (Exception e) {
       caughtException = true;
       caughtException = true;
     }
     }
-    Assert.assertTrue(caughtException);
+    assertTrue(caughtException);
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 30000L)
-  public void testSchedulingRequestWithNullConstraint() throws Exception {
+  @Timeout(30)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testSchedulingRequestWithNullConstraint(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocation(pPlacementConstraintHandler);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
 
 
     // inject node label manager
     // inject node label manager
@@ -504,7 +523,7 @@ public class TestSchedulingRequestContainerAllocation {
     am1.allocate(request);
     am1.allocate(request);
 
 
     List<Container> allocated = waitForAllocation(1, 3000, am1, nms);
     List<Container> allocated = waitForAllocation(1, 3000, am1, nms);
-    Assert.assertEquals(1, allocated.size());
+    assertEquals(1, allocated.size());
 
 
     // Send another request with null placement constraint,
     // Send another request with null placement constraint,
     // ensure there is no NPE while handling this request.
     // ensure there is no NPE while handling this request.
@@ -519,14 +538,17 @@ public class TestSchedulingRequestContainerAllocation {
     am1.allocate(request1);
     am1.allocate(request1);
 
 
     allocated = waitForAllocation(2, 3000, am1, nms);
     allocated = waitForAllocation(2, 3000, am1, nms);
-    Assert.assertEquals(2, allocated.size());
+    assertEquals(2, allocated.size());
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 30000L)
-  public void testInvalidSchedulingRequest() throws Exception {
-
+  @Timeout(30)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testInvalidSchedulingRequest(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocation(pPlacementConstraintHandler);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
     Configuration csConf = TestUtils.getConfigurationWithMultipleQueues(conf);
     MockRM rm1 = new MockRM(csConf) {
     MockRM rm1 = new MockRM(csConf) {
       @Override
       @Override
@@ -580,7 +602,7 @@ public class TestSchedulingRequestContainerAllocation {
         }
         }
       }, 500, 20000);
       }, 500, 20000);
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.fail("Failed to reject invalid scheduling request");
+      fail("Failed to reject invalid scheduling request");
     }
     }
     rm1.stop();
     rm1.stop();
   }
   }
@@ -649,8 +671,12 @@ public class TestSchedulingRequestContainerAllocation {
     return nodes.size();
     return nodes.size();
   }
   }
 
 
-  @Test(timeout = 30000L)
-  public void testInterAppCompositeConstraints() throws Exception {
+  @Timeout(30)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testInterAppCompositeConstraints(String pPlacementConstraintHandler)
+      throws Exception {
+    initTestSchedulingRequestContainerAllocation(pPlacementConstraintHandler);
     // This test both intra and inter app constraints.
     // This test both intra and inter app constraints.
     // Including simple affinity, anti-affinity, cardinality constraints,
     // Including simple affinity, anti-affinity, cardinality constraints,
     // and simple AND composite constraints.
     // and simple AND composite constraints.
@@ -682,9 +708,9 @@ public class TestSchedulingRequestContainerAllocation {
       List<Container> allocated = waitForAllocation(2, 3000, am1, nm1, nm2);
       List<Container> allocated = waitForAllocation(2, 3000, am1, nm1, nm2);
 
 
       // 2 containers allocated
       // 2 containers allocated
-      Assert.assertEquals(2, allocated.size());
+      assertEquals(2, allocated.size());
       // containers should be distributed on 2 different nodes
       // containers should be distributed on 2 different nodes
-      Assert.assertEquals(2, getContainerNodesNum(allocated));
+      assertEquals(2, getContainerNodesNum(allocated));
 
 
       // App1 (hbase)
       // App1 (hbase)
       // h1: hbase-rs(1), hbase-master(1)
       // h1: hbase-rs(1), hbase-master(1)
@@ -698,8 +724,8 @@ public class TestSchedulingRequestContainerAllocation {
               schedulingRequest(2, 4, 1, 1024, pc, "hbase-rs")));
               schedulingRequest(2, 4, 1, 1024, pc, "hbase-rs")));
       allocated = waitForAllocation(4, 3000, am1, nm1, nm2, nm3, nm4, nm5);
       allocated = waitForAllocation(4, 3000, am1, nm1, nm2, nm3, nm4, nm5);
 
 
-      Assert.assertEquals(4, allocated.size());
-      Assert.assertEquals(4, getContainerNodesNum(allocated));
+      assertEquals(4, allocated.size());
+      assertEquals(4, getContainerNodesNum(allocated));
 
 
       // App2 (web-server)
       // App2 (web-server)
       // Web server instance has 2 instance and non of them can be co-allocated
       // Web server instance has 2 instance and non of them can be co-allocated
@@ -722,19 +748,19 @@ public class TestSchedulingRequestContainerAllocation {
           ImmutableList.of(
           ImmutableList.of(
               schedulingRequest(1, 2, 1, 2048, pc, "ws-inst")));
               schedulingRequest(1, 2, 1, 2048, pc, "ws-inst")));
       allocated = waitForAllocation(2, 3000, am2, nm1, nm2, nm3, nm4, nm5);
       allocated = waitForAllocation(2, 3000, am2, nm1, nm2, nm3, nm4, nm5);
-      Assert.assertEquals(2, allocated.size());
-      Assert.assertEquals(2, getContainerNodesNum(allocated));
+      assertEquals(2, allocated.size());
+      assertEquals(2, getContainerNodesNum(allocated));
 
 
       ConcurrentMap<NodeId, RMNode> rmNodes = rm.getRMContext().getRMNodes();
       ConcurrentMap<NodeId, RMNode> rmNodes = rm.getRMContext().getRMNodes();
       for (Container c : allocated) {
       for (Container c : allocated) {
         RMNode rmNode = rmNodes.get(c.getNodeId());
         RMNode rmNode = rmNodes.get(c.getNodeId());
-        Assert.assertNotNull(rmNode);
-        Assert.assertTrue("If ws-inst is allocated to a node,"
-                + " this node should have inherited the ws-inst tag ",
-            rmNode.getAllocationTagsWithCount().get("ws-inst") == 1);
-        Assert.assertTrue("ws-inst should be co-allocated to "
-                + "hbase-master nodes",
-            rmNode.getAllocationTagsWithCount().get("hbase-master") == 1);
+        assertNotNull(rmNode);
+        assertTrue(rmNode.getAllocationTagsWithCount().get("ws-inst") == 1,
+            "If ws-inst is allocated to a node,"
+            + " this node should have inherited the ws-inst tag ");
+        assertTrue(rmNode.getAllocationTagsWithCount().get("hbase-master") == 1,
+            "ws-inst should be co-allocated to "
+            + "hbase-master nodes");
       }
       }
 
 
       // App3 (ws-servant)
       // App3 (ws-servant)
@@ -762,25 +788,29 @@ public class TestSchedulingRequestContainerAllocation {
       // total 6 containers can be allocated due to cardinality constraint
       // total 6 containers can be allocated due to cardinality constraint
       // each round, 2 containers can be allocated
       // each round, 2 containers can be allocated
       allocated = waitForAllocation(6, 10000, am3, nm1, nm2, nm3, nm4, nm5);
       allocated = waitForAllocation(6, 10000, am3, nm1, nm2, nm3, nm4, nm5);
-      Assert.assertEquals(6, allocated.size());
-      Assert.assertEquals(2, getContainerNodesNum(allocated));
+      assertEquals(6, allocated.size());
+      assertEquals(2, getContainerNodesNum(allocated));
 
 
       for (Container c : allocated) {
       for (Container c : allocated) {
         RMNode rmNode = rmNodes.get(c.getNodeId());
         RMNode rmNode = rmNodes.get(c.getNodeId());
-        Assert.assertNotNull(rmNode);
-        Assert.assertTrue("Node has ws-servant allocated must have 3 instances",
-            rmNode.getAllocationTagsWithCount().get("ws-servant") == 3);
-        Assert.assertTrue("Every ws-servant container should be co-allocated"
-                + " with ws-inst",
-            rmNode.getAllocationTagsWithCount().get("ws-inst") == 1);
+        assertNotNull(rmNode);
+        assertTrue(rmNode.getAllocationTagsWithCount().get("ws-servant") == 3,
+            "Node has ws-servant allocated must have 3 instances");
+        assertTrue(rmNode.getAllocationTagsWithCount().get("ws-inst") == 1,
+            "Every ws-servant container should be co-allocated"
+            + " with ws-inst");
       }
       }
     } finally {
     } finally {
       rm.stop();
       rm.stop();
     }
     }
   }
   }
 
 
-  @Test(timeout = 30000L)
-  public void testMultiAllocationTagsConstraints() throws Exception {
+  @Timeout(30)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testMultiAllocationTagsConstraints(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocation(pPlacementConstraintHandler);
     // This test simulates to use PC to avoid port conflicts
     // This test simulates to use PC to avoid port conflicts
 
 
     MockRM rm = new MockRM(conf);
     MockRM rm = new MockRM(conf);
@@ -814,9 +844,9 @@ public class TestSchedulingRequestContainerAllocation {
           am1, nm1, nm2, nm3, nm4, nm5);
           am1, nm1, nm2, nm3, nm4, nm5);
 
 
       // 2 containers allocated
       // 2 containers allocated
-      Assert.assertEquals(2, allocated.size());
+      assertEquals(2, allocated.size());
       // containers should be distributed on 2 different nodes
       // containers should be distributed on 2 different nodes
-      Assert.assertEquals(2, getContainerNodesNum(allocated));
+      assertEquals(2, getContainerNodesNum(allocated));
 
 
       // App1 uses ports: 6000
       // App1 uses ports: 6000
       String[] server2Ports = new String[] {"port_6000"};
       String[] server2Ports = new String[] {"port_6000"};
@@ -835,19 +865,19 @@ public class TestSchedulingRequestContainerAllocation {
           ImmutableList.of(
           ImmutableList.of(
               schedulingRequest(1, 3, 1, 1024, pc, server2Ports)));
               schedulingRequest(1, 3, 1, 1024, pc, server2Ports)));
       allocated = waitForAllocation(3, 3000, am2, nm1, nm2, nm3, nm4, nm5);
       allocated = waitForAllocation(3, 3000, am2, nm1, nm2, nm3, nm4, nm5);
-      Assert.assertEquals(3, allocated.size());
-      Assert.assertEquals(3, getContainerNodesNum(allocated));
+      assertEquals(3, allocated.size());
+      assertEquals(3, getContainerNodesNum(allocated));
 
 
       ConcurrentMap<NodeId, RMNode> rmNodes = rm.getRMContext().getRMNodes();
       ConcurrentMap<NodeId, RMNode> rmNodes = rm.getRMContext().getRMNodes();
       for (Container c : allocated) {
       for (Container c : allocated) {
         RMNode rmNode = rmNodes.get(c.getNodeId());
         RMNode rmNode = rmNodes.get(c.getNodeId());
-        Assert.assertNotNull(rmNode);
-        Assert.assertTrue("server2 should not co-allocate to server1 as"
-                + " they both need to use port 6000",
-            rmNode.getAllocationTagsWithCount().get("port_6000") == 1);
-        Assert.assertFalse(rmNode.getAllocationTagsWithCount()
+        assertNotNull(rmNode);
+        assertTrue(rmNode.getAllocationTagsWithCount().get("port_6000") == 1,
+            "server2 should not co-allocate to server1 as"
+            + " they both need to use port 6000");
+        assertFalse(rmNode.getAllocationTagsWithCount()
             .containsKey("port_7000"));
             .containsKey("port_7000"));
-        Assert.assertFalse(rmNode.getAllocationTagsWithCount()
+        assertFalse(rmNode.getAllocationTagsWithCount()
             .containsKey("port_8000"));
             .containsKey("port_8000"));
       }
       }
     } finally {
     } finally {
@@ -855,8 +885,12 @@ public class TestSchedulingRequestContainerAllocation {
     }
     }
   }
   }
 
 
-  @Test(timeout = 30000L)
-  public void testInterAppConstraintsWithNamespaces() throws Exception {
+  @Timeout(30)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testInterAppConstraintsWithNamespaces(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocation(pPlacementConstraintHandler);
     // This test verifies inter-app constraints with namespaces
     // This test verifies inter-app constraints with namespaces
     // not-self/app-id/app-tag
     // not-self/app-id/app-tag
     MockRM rm = new MockRM(conf);
     MockRM rm = new MockRM(conf);
@@ -898,8 +932,8 @@ public class TestSchedulingRequestContainerAllocation {
             allocated);
             allocated);
       }
       }
 
 
-      Assert.assertNotNull(app5Id);
-      Assert.assertEquals(3, getContainerNodesNum(allocMap.get(app5Id)));
+      assertNotNull(app5Id);
+      assertEquals(3, getContainerNodesNum(allocMap.get(app5Id)));
 
 
       // *** app-id
       // *** app-id
       // Submit another app, use app-id constraint against app5
       // Submit another app, use app-id constraint against app5
@@ -925,11 +959,9 @@ public class TestSchedulingRequestContainerAllocation {
       List<Container> app5Alloc = allocMap.get(app5Id);
       List<Container> app5Alloc = allocMap.get(app5Id);
       for (Container c : allocated) {
       for (Container c : allocated) {
         RMNode rmNode = rmNodes.get(c.getNodeId());
         RMNode rmNode = rmNodes.get(c.getNodeId());
-        Assert.assertNotNull(rmNode);
-        Assert.assertTrue("This app is affinity with app-id/app5/foo "
-                + "containers",
-            app5Alloc.stream().anyMatch(
-                c5 -> c5.getNodeId() == c.getNodeId()));
+        assertNotNull(rmNode);
+        assertTrue(app5Alloc.stream().anyMatch(c5 -> c5.getNodeId() == c.getNodeId()),
+            "This app is affinity with app-id/app5/foo containers");
       }
       }
 
 
       // *** app-tag
       // *** app-tag
@@ -949,11 +981,11 @@ public class TestSchedulingRequestContainerAllocation {
           ImmutableList.of(
           ImmutableList.of(
               schedulingRequest(1, 2, 1, 1024, pc, "foo")));
               schedulingRequest(1, 2, 1, 1024, pc, "foo")));
       allocated = waitForAllocation(2, 3000, am2, nm1, nm2, nm3, nm4, nm5);
       allocated = waitForAllocation(2, 3000, am2, nm1, nm2, nm3, nm4, nm5);
-      Assert.assertEquals(2, allocated.size());
+      assertEquals(2, allocated.size());
 
 
       // none of them can be allocated to nodes that has app5 foo containers
       // none of them can be allocated to nodes that has app5 foo containers
       for (Container c : app5Alloc) {
       for (Container c : app5Alloc) {
-        Assert.assertNotEquals(c.getNodeId(),
+        assertNotEquals(c.getNodeId(),
             allocated.iterator().next().getNodeId());
             allocated.iterator().next().getNodeId());
       }
       }
 
 
@@ -972,9 +1004,9 @@ public class TestSchedulingRequestContainerAllocation {
           ImmutableList.of(
           ImmutableList.of(
               schedulingRequest(1, 1, 1, 1024, pc, "foo")));
               schedulingRequest(1, 1, 1, 1024, pc, "foo")));
       allocated = waitForAllocation(1, 3000, am3, nm1, nm2, nm3, nm4, nm5);
       allocated = waitForAllocation(1, 3000, am3, nm1, nm2, nm3, nm4, nm5);
-      Assert.assertEquals(1, allocated.size());
+      assertEquals(1, allocated.size());
       // All 5 containers should be allocated
       // All 5 containers should be allocated
-      Assert.assertTrue(rmNodes.get(allocated.iterator().next().getNodeId())
+      assertTrue(rmNodes.get(allocated.iterator().next().getNodeId())
           .getAllocationTagsWithCount().get("foo") == 2);
           .getAllocationTagsWithCount().get("foo") == 2);
     } finally {
     } finally {
       rm.stop();
       rm.stop();

+ 42 - 25
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestSchedulingRequestContainerAllocationAsync.java

@@ -18,6 +18,8 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.Container;
@@ -35,12 +37,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsMana
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
 import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collection;
@@ -49,7 +48,6 @@ import java.util.List;
 /**
 /**
  * Test SchedulingRequest With Asynchronous Scheduling.
  * Test SchedulingRequest With Asynchronous Scheduling.
  */
  */
-@RunWith(Parameterized.class)
 public class TestSchedulingRequestContainerAllocationAsync {
 public class TestSchedulingRequestContainerAllocationAsync {
   private final int GB = 1024;
   private final int GB = 1024;
 
 
@@ -58,7 +56,6 @@ public class TestSchedulingRequestContainerAllocationAsync {
 
 
   RMNodeLabelsManager mgr;
   RMNodeLabelsManager mgr;
 
 
-  @Parameters
   public static Collection<Object[]> placementConstarintHandlers() {
   public static Collection<Object[]> placementConstarintHandlers() {
     Object[][] params = new Object[][] {
     Object[][] params = new Object[][] {
         {YarnConfiguration.PROCESSOR_RM_PLACEMENT_CONSTRAINTS_HANDLER},
         {YarnConfiguration.PROCESSOR_RM_PLACEMENT_CONSTRAINTS_HANDLER},
@@ -66,12 +63,12 @@ public class TestSchedulingRequestContainerAllocationAsync {
     return Arrays.asList(params);
     return Arrays.asList(params);
   }
   }
 
 
-  public TestSchedulingRequestContainerAllocationAsync(
-      String placementConstraintHandler) {
-    this.placementConstraintHandler = placementConstraintHandler;
+  private void initTestSchedulingRequestContainerAllocationAsync(
+      String pPlacementConstraintHandler) throws Exception {
+    this.placementConstraintHandler = pPlacementConstraintHandler;
+    setUp();
   }
   }
 
 
-  @Before
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -132,35 +129,55 @@ public class TestSchedulingRequestContainerAllocationAsync {
 
 
     List<Container> allocated = TestSchedulingRequestContainerAllocation.
     List<Container> allocated = TestSchedulingRequestContainerAllocation.
             waitForAllocation(nNMs, 6000, am1, nms);
             waitForAllocation(nNMs, 6000, am1, nms);
-    Assert.assertEquals(nNMs, allocated.size());
-    Assert.assertEquals(nNMs, TestSchedulingRequestContainerAllocation.
-            getContainerNodesNum(allocated));
+    assertEquals(nNMs, allocated.size());
+    assertEquals(nNMs, TestSchedulingRequestContainerAllocation.
+        getContainerNodesNum(allocated));
 
 
     rm1.close();
     rm1.close();
   }
   }
 
 
-  @Test(timeout = 300000)
-  public void testSingleThreadAsyncContainerAllocation() throws Exception {
+  @Timeout(value = 300)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testSingleThreadAsyncContainerAllocation(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocationAsync(pPlacementConstraintHandler);
     testIntraAppAntiAffinityAsync(1);
     testIntraAppAntiAffinityAsync(1);
   }
   }
 
 
-  @Test(timeout = 300000)
-  public void testTwoThreadsAsyncContainerAllocation() throws Exception {
+  @Timeout(value = 300)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testTwoThreadsAsyncContainerAllocation(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocationAsync(pPlacementConstraintHandler);
     testIntraAppAntiAffinityAsync(2);
     testIntraAppAntiAffinityAsync(2);
   }
   }
 
 
-  @Test(timeout = 300000)
-  public void testThreeThreadsAsyncContainerAllocation() throws Exception {
+  @Timeout(value = 300)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testThreeThreadsAsyncContainerAllocation(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocationAsync(pPlacementConstraintHandler);
     testIntraAppAntiAffinityAsync(3);
     testIntraAppAntiAffinityAsync(3);
   }
   }
 
 
-  @Test(timeout = 300000)
-  public void testFourThreadsAsyncContainerAllocation() throws Exception {
+  @Timeout(value = 300)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testFourThreadsAsyncContainerAllocation(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocationAsync(pPlacementConstraintHandler);
     testIntraAppAntiAffinityAsync(4);
     testIntraAppAntiAffinityAsync(4);
   }
   }
 
 
-  @Test(timeout = 300000)
-  public void testFiveThreadsAsyncContainerAllocation() throws Exception {
+  @Timeout(value = 300)
+  @ParameterizedTest
+  @MethodSource("placementConstarintHandlers")
+  public void testFiveThreadsAsyncContainerAllocation(
+      String pPlacementConstraintHandler) throws Exception {
+    initTestSchedulingRequestContainerAllocationAsync(pPlacementConstraintHandler);
     testIntraAppAntiAffinityAsync(5);
     testIntraAppAntiAffinityAsync(5);
   }
   }
 }
 }

+ 1 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestUniformQueueResourceCalculation.java

@@ -20,7 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 
 
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 

+ 10 - 11
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestUsersManager.java

@@ -21,7 +21,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.anyString;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
 import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
@@ -29,13 +29,13 @@ import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsMana
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 
 
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class TestUsersManager {
 public class TestUsersManager {
   private static final Resource CLUSTER_RESOURCE =
   private static final Resource CLUSTER_RESOURCE =
       Resource.newInstance(16384, 16);
       Resource.newInstance(16384, 16);
@@ -58,7 +58,7 @@ public class TestUsersManager {
   @Mock
   @Mock
   private QueueMetrics metrics;
   private QueueMetrics metrics;
 
 
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     usersManager = new UsersManager(metrics,
     usersManager = new UsersManager(metrics,
         lQueue,
         lQueue,
@@ -66,8 +66,6 @@ public class TestUsersManager {
         new DefaultResourceCalculator());
         new DefaultResourceCalculator());
 
 
     when(lQueue.getMinimumAllocation()).thenReturn(MINIMUM_ALLOCATION);
     when(lQueue.getMinimumAllocation()).thenReturn(MINIMUM_ALLOCATION);
-    when(lQueue.getEffectiveMaxCapacityDown(anyString(), any(Resource.class)))
-        .thenReturn(MAX_RESOURCE_LIMIT);
     when(labelMgr.getResourceByLabel(anyString(), any(Resource.class)))
     when(labelMgr.getResourceByLabel(anyString(), any(Resource.class)))
         .thenReturn(CLUSTER_RESOURCE);
         .thenReturn(CLUSTER_RESOURCE);
     usersManager.setUsageRatio(CommonNodeLabelsManager.NO_LABEL, 0.5f);
     usersManager.setUsageRatio(CommonNodeLabelsManager.NO_LABEL, 0.5f);
@@ -81,7 +79,8 @@ public class TestUsersManager {
   public void testComputeUserLimitWithZeroCapacityQueue() {
   public void testComputeUserLimitWithZeroCapacityQueue() {
     when(lQueue.getEffectiveCapacity(anyString()))
     when(lQueue.getEffectiveCapacity(anyString()))
         .thenReturn(Resources.none());
         .thenReturn(Resources.none());
-
+    when(lQueue.getEffectiveMaxCapacityDown(anyString(), any(Resource.class)))
+        .thenReturn(MAX_RESOURCE_LIMIT);
     checkLimit(MAX_RESOURCE_LIMIT);
     checkLimit(MAX_RESOURCE_LIMIT);
   }
   }
 
 
@@ -100,6 +99,6 @@ public class TestUsersManager {
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY,
         SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY,
         true);
         true);
 
 
-    assertEquals("User limit", expectedLimit, limit);
+    assertEquals(expectedLimit, limit, "User limit");
   }
   }
 }
 }

+ 14 - 11
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestWorkPreservingRMRestartForNodeLabel.java

@@ -47,20 +47,23 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnSched
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 public class TestWorkPreservingRMRestartForNodeLabel {
 public class TestWorkPreservingRMRestartForNodeLabel {
   private Configuration conf;
   private Configuration conf;
   private static final int GB = 1024; // 1024 MB
   private static final int GB = 1024; // 1024 MB
   
   
   RMNodeLabelsManager mgr;
   RMNodeLabelsManager mgr;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
     conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
@@ -82,8 +85,8 @@ public class TestWorkPreservingRMRestartForNodeLabel {
       MockRM rm, String labelExpression) {
       MockRM rm, String labelExpression) {
     RMContainer container =
     RMContainer container =
         rm.getRMContext().getScheduler().getRMContainer(containerId);
         rm.getRMContext().getScheduler().getRMContainer(containerId);
-    Assert.assertNotNull("Cannot find RMContainer=" + containerId, container);
-    Assert.assertEquals(labelExpression,
+    assertNotNull(container, "Cannot find RMContainer=" + containerId);
+    assertEquals(labelExpression,
         container.getNodeLabelExpression());
         container.getNodeLabelExpression());
   }
   }
   
   
@@ -113,14 +116,14 @@ public class TestWorkPreservingRMRestartForNodeLabel {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     FiCaSchedulerApp app =
     FiCaSchedulerApp app =
         cs.getSchedulerApplications().get(appId).getCurrentAppAttempt();
         cs.getSchedulerApplications().get(appId).getCurrentAppAttempt();
-    Assert.assertEquals(expectedMemUsage, app.getAppAttemptResourceUsage()
+    assertEquals(expectedMemUsage, app.getAppAttemptResourceUsage()
         .getUsed(partition).getMemorySize());
         .getUsed(partition).getMemorySize());
   }
   }
   
   
   private void checkQueueResourceUsage(String partition, String queueName, MockRM rm, int expectedMemUsage) {
   private void checkQueueResourceUsage(String partition, String queueName, MockRM rm, int expectedMemUsage) {
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
     CSQueue queue = cs.getQueue(queueName);
     CSQueue queue = cs.getQueue(queueName);
-    Assert.assertEquals(expectedMemUsage, queue.getQueueResourceUsage()
+    assertEquals(expectedMemUsage, queue.getQueueResourceUsage()
         .getUsed(partition).getMemorySize());
         .getUsed(partition).getMemorySize());
   }
   }
 
 
@@ -171,7 +174,7 @@ public class TestWorkPreservingRMRestartForNodeLabel {
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am1.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId =
     containerId =
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
         ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm1.waitForState(nm1, containerId,
+    assertTrue(rm1.waitForState(nm1, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkRMContainerLabelExpression(ContainerId.newContainerId(
     checkRMContainerLabelExpression(ContainerId.newContainerId(
         am1.getApplicationAttemptId(), 1), rm1, "x");
         am1.getApplicationAttemptId(), 1), rm1, "x");
@@ -194,7 +197,7 @@ public class TestWorkPreservingRMRestartForNodeLabel {
     // request a container.
     // request a container.
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am2.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm1.waitForState(nm2, containerId,
+    assertTrue(rm1.waitForState(nm2, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkRMContainerLabelExpression(ContainerId.newContainerId(
     checkRMContainerLabelExpression(ContainerId.newContainerId(
         am2.getApplicationAttemptId(), 1), rm1, "y");
         am2.getApplicationAttemptId(), 1), rm1, "y");
@@ -217,7 +220,7 @@ public class TestWorkPreservingRMRestartForNodeLabel {
     // request a container.
     // request a container.
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     am3.allocate("*", 1024, 1, new ArrayList<ContainerId>());
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
     containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2);
-    Assert.assertTrue(rm1.waitForState(nm3, containerId,
+    assertTrue(rm1.waitForState(nm3, containerId,
         RMContainerState.ALLOCATED));
         RMContainerState.ALLOCATED));
     checkRMContainerLabelExpression(ContainerId.newContainerId(
     checkRMContainerLabelExpression(ContainerId.newContainerId(
         am3.getApplicationAttemptId(), 1), rm1, "");
         am3.getApplicationAttemptId(), 1), rm1, "");

+ 7 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/ConfigurationStoreBaseTest.java

@@ -24,11 +24,11 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 /**
 /**
  * Base class for {@link YarnConfigurationStore} implementations.
  * Base class for {@link YarnConfigurationStore} implementations.
@@ -42,7 +42,7 @@ public abstract class ConfigurationStoreBaseTest {
 
 
   abstract YarnConfigurationStore createConfStore();
   abstract YarnConfigurationStore createConfStore();
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     this.conf = new Configuration();
     this.conf = new Configuration();
     this.conf.setClass(YarnConfiguration.RM_SCHEDULER,
     this.conf.setClass(YarnConfiguration.RM_SCHEDULER,
@@ -62,8 +62,8 @@ public abstract class ConfigurationStoreBaseTest {
 
 
     confStore.confirmMutation(prepareLogMutation("keyUpdate2", "valUpdate2"),
     confStore.confirmMutation(prepareLogMutation("keyUpdate2", "valUpdate2"),
         false);
         false);
-    assertNull("Configuration should not be updated",
-        confStore.retrieve().get("keyUpdate2"));
+    assertNull(confStore.retrieve().get("keyUpdate2"),
+        "Configuration should not be updated");
     confStore.close();
     confStore.close();
   }
   }
 
 

+ 6 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/PersistentConfigurationStoreBaseTest.java

@@ -19,13 +19,13 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf;
 
 
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.records.Version;
 import org.apache.hadoop.yarn.server.records.Version;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.LinkedList;
 import java.util.LinkedList;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assume.assumeFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
 
 
 /**
 /**
  * Base class for the persistent {@link YarnConfigurationStore}
  * Base class for the persistent {@link YarnConfigurationStore}
@@ -95,8 +95,8 @@ public abstract class PersistentConfigurationStoreBaseTest extends
 
 
   @Test
   @Test
   public void testMaxLogs() throws Exception {
   public void testMaxLogs() throws Exception {
-    assumeFalse("test should be skipped for TestFSSchedulerConfigurationStore",
-      this instanceof TestFSSchedulerConfigurationStore);
+    assumeFalse(this instanceof TestFSSchedulerConfigurationStore,
+        "test should be skipped for TestFSSchedulerConfigurationStore");
 
 
     conf.setLong(YarnConfiguration.RM_SCHEDCONF_MAX_LOGS, 2);
     conf.setLong(YarnConfiguration.RM_SCHEDCONF_MAX_LOGS, 2);
     confStore.initialize(conf, schedConf, rmContext);
     confStore.initialize(conf, schedConf, rmContext);

+ 7 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestConfigurationUpdateAssembler.java

@@ -22,17 +22,17 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.Capacity
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePath;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePath;
 import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo;
 import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo;
 import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo;
 import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Tests {@link ConfigurationUpdateAssembler}.
  * Tests {@link ConfigurationUpdateAssembler}.
@@ -62,7 +62,7 @@ public class TestConfigurationUpdateAssembler {
 
 
   private CapacitySchedulerConfiguration csConfig;
   private CapacitySchedulerConfiguration csConfig;
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     csConfig = crateInitialCSConfig();
     csConfig = crateInitialCSConfig();
   }
   }

+ 17 - 19
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestFSSchedulerConfigurationStore.java

@@ -31,15 +31,14 @@ import org.apache.hadoop.hdfs.HdfsConfiguration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.records.Version;
 import org.apache.hadoop.yarn.server.records.Version;
-import org.hamcrest.CoreMatchers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 
 
 /**
 /**
@@ -49,7 +48,7 @@ public class TestFSSchedulerConfigurationStore extends
     PersistentConfigurationStoreBaseTest {
     PersistentConfigurationStoreBaseTest {
   private File testSchedulerConfigurationDir;
   private File testSchedulerConfigurationDir;
 
 
-  @Before
+  @BeforeEach
   @Override
   @Override
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     super.setUp();
     super.setUp();
@@ -73,7 +72,7 @@ public class TestFSSchedulerConfigurationStore extends
     outputStream.close();
     outputStream.close();
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     FileUtils.deleteDirectory(testSchedulerConfigurationDir);
     FileUtils.deleteDirectory(testSchedulerConfigurationDir);
   }
   }
@@ -155,17 +154,16 @@ public class TestFSSchedulerConfigurationStore extends
     writeConf(persistedSchedConf);
     writeConf(persistedSchedConf);
     confStore.initialize(conf, conf, null);
     confStore.initialize(conf, conf, null);
     Configuration storedConfig = confStore.retrieve();
     Configuration storedConfig = confStore.retrieve();
-    assertEquals("Retrieved config should match the stored one", "a",
-        storedConfig.get("a"));
+    assertEquals("a", storedConfig.get("a"),
+        "Retrieved config should match the stored one");
     confStore.format();
     confStore.format();
     try {
     try {
       confStore.retrieve();
       confStore.retrieve();
       fail("Expected an IOException with message containing \"no capacity " +
       fail("Expected an IOException with message containing \"no capacity " +
           "scheduler file in\" to be thrown");
           "scheduler file in\" to be thrown");
     } catch (IOException e) {
     } catch (IOException e) {
-      assertThat("Exception message should contain the predefined string.",
-          e.getMessage(),
-          CoreMatchers.containsString("no capacity scheduler file in"));
+      assertThat(e.getMessage()).contains("no capacity scheduler file in").
+          as("Exception message should contain the predefined string.");
     }
     }
   }
   }
 
 
@@ -214,13 +212,13 @@ public class TestFSSchedulerConfigurationStore extends
   private void compareConfig(Configuration schedulerConf,
   private void compareConfig(Configuration schedulerConf,
                              Configuration storedConfig) {
                              Configuration storedConfig) {
     for (Map.Entry<String, String> entry : schedulerConf) {
     for (Map.Entry<String, String> entry : schedulerConf) {
-      assertEquals(entry.getKey(), schedulerConf.get(entry.getKey()),
-          storedConfig.get(entry.getKey()));
+      assertEquals(schedulerConf.get(entry.getKey()),
+          storedConfig.get(entry.getKey()), entry.getKey());
     }
     }
 
 
     for (Map.Entry<String, String> entry : storedConfig) {
     for (Map.Entry<String, String> entry : storedConfig) {
-      assertEquals(entry.getKey(), storedConfig.get(entry.getKey()),
-          schedulerConf.get(entry.getKey()));
+      assertEquals(storedConfig.get(entry.getKey()),
+          schedulerConf.get(entry.getKey()), entry.getKey());
     }
     }
   }
   }
 
 

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestInMemoryConfigurationStore.java

@@ -18,9 +18,9 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
 /**
  * Tests {@link InMemoryConfigurationStore}.
  * Tests {@link InMemoryConfigurationStore}.

+ 20 - 21
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestLeveldbConfigurationStore.java

@@ -31,8 +31,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.MutableConfigurat
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf.YarnConfigurationStore.LogMutation;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf.YarnConfigurationStore.LogMutation;
 import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo;
 import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.iq80.leveldb.DB;
 import org.iq80.leveldb.DB;
 import org.iq80.leveldb.DBIterator;
 import org.iq80.leveldb.DBIterator;
 
 
@@ -40,9 +40,7 @@ import java.io.File;
 import java.nio.charset.StandardCharsets;
 import java.nio.charset.StandardCharsets;
 import java.util.Map;
 import java.util.Map;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
 
 /**
 /**
  * Tests {@link LeveldbConfigurationStore}.
  * Tests {@link LeveldbConfigurationStore}.
@@ -57,7 +55,7 @@ public class TestLeveldbConfigurationStore extends
           System.getProperty("java.io.tmpdir")),
           System.getProperty("java.io.tmpdir")),
       TestLeveldbConfigurationStore.class.getName());
       TestLeveldbConfigurationStore.class.getName());
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     super.setUp();
     super.setUp();
     FileUtil.fullyDelete(TEST_DIR);
     FileUtil.fullyDelete(TEST_DIR);
@@ -66,21 +64,22 @@ public class TestLeveldbConfigurationStore extends
     conf.set(YarnConfiguration.RM_SCHEDCONF_STORE_PATH, TEST_DIR.toString());
     conf.set(YarnConfiguration.RM_SCHEDCONF_STORE_PATH, TEST_DIR.toString());
   }
   }
 
 
-  @Test(expected = YarnConfStoreVersionIncompatibleException.class)
+  @Test
   public void testIncompatibleVersion() throws Exception {
   public void testIncompatibleVersion() throws Exception {
-    try {
-      confStore.initialize(conf, schedConf, rmContext);
-
-      Version otherVersion = Version.newInstance(1, 1);
-      ((LeveldbConfigurationStore) confStore).storeVersion(otherVersion);
-
-      assertEquals("The configuration store should have stored the new" +
-              "version.", otherVersion,
-          confStore.getConfStoreVersion());
-      confStore.checkVersion();
-    } finally {
-      confStore.close();
-    }
+    assertThrows(YarnConfStoreVersionIncompatibleException.class, ()->{
+      try {
+        confStore.initialize(conf, schedConf, rmContext);
+
+        Version otherVersion = Version.newInstance(1, 1);
+        ((LeveldbConfigurationStore) confStore).storeVersion(otherVersion);
+
+        assertEquals(otherVersion, confStore.getConfStoreVersion(),
+            "The configuration store should have stored the new version.");
+        confStore.checkVersion();
+      } finally {
+        confStore.close();
+      }
+    });
   }
   }
 
 
   @Test
   @Test
@@ -102,7 +101,7 @@ public class TestLeveldbConfigurationStore extends
         break;
         break;
       }
       }
     }
     }
-    assertFalse("Audit Log is not disabled", logKeyPresent);
+    assertFalse(logKeyPresent, "Audit Log is not disabled");
     confStore.close();
     confStore.close();
   }
   }
 
 

+ 8 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java

@@ -33,16 +33,16 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePat
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf.YarnConfigurationStore.LogMutation;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf.YarnConfigurationStore.LogMutation;
 import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo;
 import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo;
 import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo;
 import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -61,7 +61,7 @@ public class TestMutableCSConfigurationProvider {
   private static final UserGroupInformation TEST_USER = UserGroupInformation
   private static final UserGroupInformation TEST_USER = UserGroupInformation
       .createUserForTesting("testUser", new String[] {});
       .createUserForTesting("testUser", new String[] {});
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     cs = mock(CapacityScheduler.class);
     cs = mock(CapacityScheduler.class);
     rmContext = mock(RMContext.class);
     rmContext = mock(RMContext.class);
@@ -142,9 +142,9 @@ public class TestMutableCSConfigurationProvider {
 
 
     log = confProvider.logAndApplyMutation(TEST_USER, updateInfo);
     log = confProvider.logAndApplyMutation(TEST_USER, updateInfo);
     confProvider.confirmPendingMutation(log, true);
     confProvider.confirmPendingMutation(log, true);
-    assertNull("Failed to remove config",
-        confProvider.loadConfiguration(conf)
-        .get("yarn.scheduler.capacity.root.a.testkey1"));
+    assertNull(confProvider.loadConfiguration(conf)
+        .get("yarn.scheduler.capacity.root.a.testkey1"),
+        "Failed to remove config");
     assertEquals("testval2", confProvider.loadConfiguration(conf)
     assertEquals("testval2", confProvider.loadConfiguration(conf)
         .get("yarn.scheduler.capacity.root.a.testkey2"));
         .get("yarn.scheduler.capacity.root.a.testkey2"));
   }
   }

+ 41 - 40
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestQueueCapacityConfigParser.java

@@ -18,6 +18,8 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 import org.apache.hadoop.util.Lists;
 import org.apache.hadoop.util.Lists;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
@@ -26,8 +28,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCap
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacityVector.ResourceUnitCapacityType;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacityVector.ResourceUnitCapacityType;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePath;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePath;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -78,11 +79,11 @@ public class TestQueueCapacityConfigParser {
     QueueCapacityVectorEntry memory = percentageCapacityVector.getResource(MEMORY_URI);
     QueueCapacityVectorEntry memory = percentageCapacityVector.getResource(MEMORY_URI);
     QueueCapacityVectorEntry vcore = percentageCapacityVector.getResource(VCORES_URI);
     QueueCapacityVectorEntry vcore = percentageCapacityVector.getResource(VCORES_URI);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.PERCENTAGE, memory.getVectorResourceType());
-    Assert.assertEquals(PERCENTAGE_VALUE, memory.getResourceValue(), EPSILON);
+    assertEquals(ResourceUnitCapacityType.PERCENTAGE, memory.getVectorResourceType());
+    assertEquals(PERCENTAGE_VALUE, memory.getResourceValue(), EPSILON);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.PERCENTAGE, vcore.getVectorResourceType());
-    Assert.assertEquals(PERCENTAGE_VALUE, vcore.getResourceValue(), EPSILON);
+    assertEquals(ResourceUnitCapacityType.PERCENTAGE, vcore.getVectorResourceType());
+    assertEquals(PERCENTAGE_VALUE, vcore.getResourceValue(), EPSILON);
 
 
     QueueCapacityVector rootCapacityVector =
     QueueCapacityVector rootCapacityVector =
         capacityConfigParser.parse(Float.toString(PERCENTAGE_VALUE), ROOT);
         capacityConfigParser.parse(Float.toString(PERCENTAGE_VALUE), ROOT);
@@ -90,11 +91,11 @@ public class TestQueueCapacityConfigParser {
     QueueCapacityVectorEntry memoryRoot = rootCapacityVector.getResource(MEMORY_URI);
     QueueCapacityVectorEntry memoryRoot = rootCapacityVector.getResource(MEMORY_URI);
     QueueCapacityVectorEntry vcoreRoot = rootCapacityVector.getResource(VCORES_URI);
     QueueCapacityVectorEntry vcoreRoot = rootCapacityVector.getResource(VCORES_URI);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.PERCENTAGE, memoryRoot.getVectorResourceType());
-    Assert.assertEquals(100f, memoryRoot.getResourceValue(), EPSILON);
+    assertEquals(ResourceUnitCapacityType.PERCENTAGE, memoryRoot.getVectorResourceType());
+    assertEquals(100f, memoryRoot.getResourceValue(), EPSILON);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.PERCENTAGE, vcoreRoot.getVectorResourceType());
-    Assert.assertEquals(100f, vcoreRoot.getResourceValue(), EPSILON);
+    assertEquals(ResourceUnitCapacityType.PERCENTAGE, vcoreRoot.getVectorResourceType());
+    assertEquals(100f, vcoreRoot.getResourceValue(), EPSILON);
   }
   }
 
 
   @Test
   @Test
@@ -105,11 +106,11 @@ public class TestQueueCapacityConfigParser {
     QueueCapacityVectorEntry memory = weightCapacityVector.getResource(MEMORY_URI);
     QueueCapacityVectorEntry memory = weightCapacityVector.getResource(MEMORY_URI);
     QueueCapacityVectorEntry vcore = weightCapacityVector.getResource(VCORES_URI);
     QueueCapacityVectorEntry vcore = weightCapacityVector.getResource(VCORES_URI);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.WEIGHT, memory.getVectorResourceType());
-    Assert.assertEquals(WEIGHT_VALUE, memory.getResourceValue(), EPSILON);
+    assertEquals(ResourceUnitCapacityType.WEIGHT, memory.getVectorResourceType());
+    assertEquals(WEIGHT_VALUE, memory.getResourceValue(), EPSILON);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.WEIGHT, vcore.getVectorResourceType());
-    Assert.assertEquals(WEIGHT_VALUE, vcore.getResourceValue(), EPSILON);
+    assertEquals(ResourceUnitCapacityType.WEIGHT, vcore.getVectorResourceType());
+    assertEquals(WEIGHT_VALUE, vcore.getResourceValue(), EPSILON);
   }
   }
 
 
   @Test
   @Test
@@ -123,26 +124,26 @@ public class TestQueueCapacityConfigParser {
     QueueCapacityVector absoluteCapacityVector = capacityConfigParser.parse(ABSOLUTE_RESOURCE,
     QueueCapacityVector absoluteCapacityVector = capacityConfigParser.parse(ABSOLUTE_RESOURCE,
         QUEUE_PATH);
         QUEUE_PATH);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.ABSOLUTE,
+    assertEquals(ResourceUnitCapacityType.ABSOLUTE,
         absoluteCapacityVector.getResource(MEMORY_URI).getVectorResourceType());
         absoluteCapacityVector.getResource(MEMORY_URI).getVectorResourceType());
-    Assert.assertEquals(12 * GB, absoluteCapacityVector.getResource(MEMORY_URI)
+    assertEquals(12 * GB, absoluteCapacityVector.getResource(MEMORY_URI)
         .getResourceValue(), EPSILON);
         .getResourceValue(), EPSILON);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.ABSOLUTE,
+    assertEquals(ResourceUnitCapacityType.ABSOLUTE,
         absoluteCapacityVector.getResource(VCORES_URI).getVectorResourceType());
         absoluteCapacityVector.getResource(VCORES_URI).getVectorResourceType());
-    Assert.assertEquals(VCORE_ABSOLUTE, absoluteCapacityVector.getResource(VCORES_URI)
+    assertEquals(VCORE_ABSOLUTE, absoluteCapacityVector.getResource(VCORES_URI)
         .getResourceValue(), EPSILON);
         .getResourceValue(), EPSILON);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.ABSOLUTE,
+    assertEquals(ResourceUnitCapacityType.ABSOLUTE,
         absoluteCapacityVector.getResource(GPU_URI).getVectorResourceType());
         absoluteCapacityVector.getResource(GPU_URI).getVectorResourceType());
-    Assert.assertEquals(GPU_ABSOLUTE, absoluteCapacityVector.getResource(GPU_URI)
+    assertEquals(GPU_ABSOLUTE, absoluteCapacityVector.getResource(GPU_URI)
         .getResourceValue(), EPSILON);
         .getResourceValue(), EPSILON);
 
 
     QueueCapacityVector withoutGpuVector = capacityConfigParser
     QueueCapacityVector withoutGpuVector = capacityConfigParser
         .parse(ABSOLUTE_RESOURCE_MEMORY_VCORE, QUEUE_PATH);
         .parse(ABSOLUTE_RESOURCE_MEMORY_VCORE, QUEUE_PATH);
 
 
-    Assert.assertEquals(3, withoutGpuVector.getResourceCount());
-    Assert.assertEquals(0f, withoutGpuVector.getResource(GPU_URI).getResourceValue(), EPSILON);
+    assertEquals(3, withoutGpuVector.getResourceCount());
+    assertEquals(0f, withoutGpuVector.getResource(GPU_URI).getResourceValue(), EPSILON);
   }
   }
 
 
   @Test
   @Test
@@ -154,27 +155,27 @@ public class TestQueueCapacityConfigParser {
     QueueCapacityVector mixedCapacityVector =
     QueueCapacityVector mixedCapacityVector =
         capacityConfigParser.parse(MIXED_RESOURCE, QUEUE_PATH);
         capacityConfigParser.parse(MIXED_RESOURCE, QUEUE_PATH);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.ABSOLUTE,
+    assertEquals(ResourceUnitCapacityType.ABSOLUTE,
         mixedCapacityVector.getResource(MEMORY_URI).getVectorResourceType());
         mixedCapacityVector.getResource(MEMORY_URI).getVectorResourceType());
-    Assert.assertEquals(MEMORY_MIXED, mixedCapacityVector.getResource(MEMORY_URI)
+    assertEquals(MEMORY_MIXED, mixedCapacityVector.getResource(MEMORY_URI)
         .getResourceValue(), EPSILON);
         .getResourceValue(), EPSILON);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.PERCENTAGE,
+    assertEquals(ResourceUnitCapacityType.PERCENTAGE,
         mixedCapacityVector.getResource(VCORES_URI).getVectorResourceType());
         mixedCapacityVector.getResource(VCORES_URI).getVectorResourceType());
-    Assert.assertEquals(PERCENTAGE_VALUE,
+    assertEquals(PERCENTAGE_VALUE,
         mixedCapacityVector.getResource(VCORES_URI).getResourceValue(), EPSILON);
         mixedCapacityVector.getResource(VCORES_URI).getResourceValue(), EPSILON);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.WEIGHT,
+    assertEquals(ResourceUnitCapacityType.WEIGHT,
         mixedCapacityVector.getResource(GPU_URI).getVectorResourceType());
         mixedCapacityVector.getResource(GPU_URI).getVectorResourceType());
-    Assert.assertEquals(WEIGHT_VALUE,
+    assertEquals(WEIGHT_VALUE,
         mixedCapacityVector.getResource(GPU_URI).getResourceValue(), EPSILON);
         mixedCapacityVector.getResource(GPU_URI).getResourceValue(), EPSILON);
 
 
     // Test undefined capacity type default value
     // Test undefined capacity type default value
     QueueCapacityVector mixedCapacityVectorWithGpuUndefined =
     QueueCapacityVector mixedCapacityVectorWithGpuUndefined =
         capacityConfigParser.parse(ABSOLUTE_RESOURCE_MEMORY_VCORE, QUEUE_PATH);
         capacityConfigParser.parse(ABSOLUTE_RESOURCE_MEMORY_VCORE, QUEUE_PATH);
-    Assert.assertEquals(ResourceUnitCapacityType.ABSOLUTE,
+    assertEquals(ResourceUnitCapacityType.ABSOLUTE,
         mixedCapacityVectorWithGpuUndefined.getResource(MEMORY_URI).getVectorResourceType());
         mixedCapacityVectorWithGpuUndefined.getResource(MEMORY_URI).getVectorResourceType());
-    Assert.assertEquals(0, mixedCapacityVectorWithGpuUndefined.getResource(GPU_URI)
+    assertEquals(0, mixedCapacityVectorWithGpuUndefined.getResource(GPU_URI)
         .getResourceValue(), EPSILON);
         .getResourceValue(), EPSILON);
 
 
   }
   }
@@ -185,37 +186,37 @@ public class TestQueueCapacityConfigParser {
         capacityConfigParser.parse(NONEXISTINGSUFFIX, QUEUE_PATH);
         capacityConfigParser.parse(NONEXISTINGSUFFIX, QUEUE_PATH);
     List<QueueCapacityVectorEntry> entriesWithInvalidSuffix =
     List<QueueCapacityVectorEntry> entriesWithInvalidSuffix =
         Lists.newArrayList(capacityVectorWithInvalidSuffix.iterator());
         Lists.newArrayList(capacityVectorWithInvalidSuffix.iterator());
-    Assert.assertEquals(0, entriesWithInvalidSuffix.size());
+    assertEquals(0, entriesWithInvalidSuffix.size());
 
 
     QueueCapacityVector invalidDelimiterCapacityVector =
     QueueCapacityVector invalidDelimiterCapacityVector =
         capacityConfigParser.parse(INVALID_CAPACITY_FORMAT, QUEUE_PATH);
         capacityConfigParser.parse(INVALID_CAPACITY_FORMAT, QUEUE_PATH);
     List<QueueCapacityVectorEntry> invalidDelimiterEntries =
     List<QueueCapacityVectorEntry> invalidDelimiterEntries =
         Lists.newArrayList(invalidDelimiterCapacityVector.iterator());
         Lists.newArrayList(invalidDelimiterCapacityVector.iterator());
-    Assert.assertEquals(0, invalidDelimiterEntries.size());
+    assertEquals(0, invalidDelimiterEntries.size());
 
 
     QueueCapacityVector invalidCapacityVector =
     QueueCapacityVector invalidCapacityVector =
         capacityConfigParser.parse(INVALID_CAPACITY_BRACKET, QUEUE_PATH);
         capacityConfigParser.parse(INVALID_CAPACITY_BRACKET, QUEUE_PATH);
     List<QueueCapacityVectorEntry> resources =
     List<QueueCapacityVectorEntry> resources =
         Lists.newArrayList(invalidCapacityVector.iterator());
         Lists.newArrayList(invalidCapacityVector.iterator());
-    Assert.assertEquals(0, resources.size());
+    assertEquals(0, resources.size());
 
 
     QueueCapacityVector emptyBracketCapacityVector =
     QueueCapacityVector emptyBracketCapacityVector =
         capacityConfigParser.parse(EMPTY_BRACKET, QUEUE_PATH);
         capacityConfigParser.parse(EMPTY_BRACKET, QUEUE_PATH);
     List<QueueCapacityVectorEntry> emptyEntries =
     List<QueueCapacityVectorEntry> emptyEntries =
         Lists.newArrayList(emptyBracketCapacityVector.iterator());
         Lists.newArrayList(emptyBracketCapacityVector.iterator());
-    Assert.assertEquals(0, emptyEntries.size());
+    assertEquals(0, emptyEntries.size());
 
 
     QueueCapacityVector emptyCapacity =
     QueueCapacityVector emptyCapacity =
         capacityConfigParser.parse("", QUEUE_PATH);
         capacityConfigParser.parse("", QUEUE_PATH);
     List<QueueCapacityVectorEntry> emptyResources =
     List<QueueCapacityVectorEntry> emptyResources =
         Lists.newArrayList(emptyCapacity.iterator());
         Lists.newArrayList(emptyCapacity.iterator());
-    Assert.assertEquals(emptyResources.size(), 0);
+    assertEquals(emptyResources.size(), 0);
 
 
     QueueCapacityVector nonSetCapacity =
     QueueCapacityVector nonSetCapacity =
         capacityConfigParser.parse(null, QUEUE_PATH);
         capacityConfigParser.parse(null, QUEUE_PATH);
     List<QueueCapacityVectorEntry> nonSetResources =
     List<QueueCapacityVectorEntry> nonSetResources =
         Lists.newArrayList(nonSetCapacity.iterator());
         Lists.newArrayList(nonSetCapacity.iterator());
-    Assert.assertEquals(nonSetResources.size(), 0);
+    assertEquals(nonSetResources.size(), 0);
   }
   }
 
 
   @Test
   @Test
@@ -226,10 +227,10 @@ public class TestQueueCapacityConfigParser {
     QueueCapacityVectorEntry memory = weightCapacityVector.getResource(MEMORY_URI);
     QueueCapacityVectorEntry memory = weightCapacityVector.getResource(MEMORY_URI);
     QueueCapacityVectorEntry vcore = weightCapacityVector.getResource(VCORES_URI);
     QueueCapacityVectorEntry vcore = weightCapacityVector.getResource(VCORES_URI);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.ABSOLUTE, memory.getVectorResourceType());
-    Assert.assertEquals(0, memory.getResourceValue(), EPSILON);
+    assertEquals(ResourceUnitCapacityType.ABSOLUTE, memory.getVectorResourceType());
+    assertEquals(0, memory.getResourceValue(), EPSILON);
 
 
-    Assert.assertEquals(ResourceUnitCapacityType.ABSOLUTE, vcore.getVectorResourceType());
-    Assert.assertEquals(0, vcore.getResourceValue(), EPSILON);
+    assertEquals(ResourceUnitCapacityType.ABSOLUTE, vcore.getVectorResourceType());
+    assertEquals(0, vcore.getResourceValue(), EPSILON);
   }
   }
 }
 }

文件差异内容过多而无法显示
+ 95 - 86
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestZKConfigurationStore.java


+ 67 - 52
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/placement/TestMappingRuleCreator.java

@@ -18,8 +18,6 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placement;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placement;
 
 
-import static org.junit.Assert.assertEquals;
-
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
@@ -33,9 +31,12 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placemen
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placement.schema.Rule.Policy;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placement.schema.Rule.Policy;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placement.schema.Rule.Type;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placement.schema.Rule.Type;
 import org.assertj.core.util.Sets;
 import org.assertj.core.util.Sets;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestMappingRuleCreator {
 public class TestMappingRuleCreator {
   private static final String MATCH_ALL = "*";
   private static final String MATCH_ALL = "*";
@@ -53,10 +54,7 @@ public class TestMappingRuleCreator {
   private MappingRulesDescription description;
   private MappingRulesDescription description;
   private Rule rule;
   private Rule rule;
 
 
-  @org.junit.Rule
-  public ExpectedException expected = ExpectedException.none();
-
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     ruleCreator = new MappingRuleCreator();
     ruleCreator = new MappingRuleCreator();
     prepareMappingRuleDescription();
     prepareMappingRuleDescription();
@@ -106,13 +104,18 @@ public class TestMappingRuleCreator {
 
 
   @Test
   @Test
   public void testAllGroupMatcherFailsDueToMatchString() {
   public void testAllGroupMatcherFailsDueToMatchString() {
-    rule.setType(Type.GROUP);
 
 
-    expected.expect(IllegalArgumentException.class);
-    expected.expectMessage("Cannot match '*' for groups");
 
 
-    // fails because "*" is not applicable to group type
-    ruleCreator.getMappingRules(description);
+    IllegalArgumentException illegalArgumentException =
+        assertThrows(IllegalArgumentException.class, () -> {
+          rule.setType(Type.GROUP);
+          // fails because "*" is not applicable to group type
+          ruleCreator.getMappingRules(description);
+        });
+
+    assertTrue(illegalArgumentException.getMessage().
+        contains("Cannot match '*' for groups"));
+
   }
   }
 
 
   @Test
   @Test
@@ -166,18 +169,19 @@ public class TestMappingRuleCreator {
     rule.setValue("root.users.default");
     rule.setValue("root.users.default");
 
 
     verifyNoPlacementOccurs();
     verifyNoPlacementOccurs();
-    assertEquals("Default queue", "root.users.default",
-        variableContext.get("%default"));
+    assertEquals("root.users.default",
+        variableContext.get("%default"), "Default queue");
   }
   }
 
 
   @Test
   @Test
   public void testSetDefaultRuleWithMissingQueue() {
   public void testSetDefaultRuleWithMissingQueue() {
-    rule.setPolicy(Policy.SET_DEFAULT_QUEUE);
-
-    expected.expect(IllegalArgumentException.class);
-    expected.expectMessage("default queue is undefined");
+    IllegalArgumentException illegalArgumentException =
+        assertThrows(IllegalArgumentException.class, () -> {
+          rule.setPolicy(Policy.SET_DEFAULT_QUEUE);
+          ruleCreator.getMappingRules(description);
+        });
 
 
-    ruleCreator.getMappingRules(description);
+    assertTrue(illegalArgumentException.getMessage().contains("default queue is undefined"));
   }
   }
 
 
   @Test
   @Test
@@ -262,12 +266,14 @@ public class TestMappingRuleCreator {
 
 
   @Test
   @Test
   public void testCustomRuleWithMissingQueue() {
   public void testCustomRuleWithMissingQueue() {
-    rule.setPolicy(Policy.CUSTOM);
+    IllegalArgumentException illegalArgumentException =
+        assertThrows(IllegalArgumentException.class, () -> {
+          rule.setPolicy(Policy.CUSTOM);
+          ruleCreator.getMappingRules(description);
+        });
 
 
-    expected.expect(IllegalArgumentException.class);
-    expected.expectMessage("custom queue is undefined");
+    assertTrue(illegalArgumentException.getMessage().contains("custom queue is undefined"));
 
 
-    ruleCreator.getMappingRules(description);
   }
   }
 
 
   @Test
   @Test
@@ -356,8 +362,8 @@ public class TestMappingRuleCreator {
     List<MappingRule> rules = ruleCreator.getMappingRules(description);
     List<MappingRule> rules = ruleCreator.getMappingRules(description);
     MappingRule mpr = rules.get(0);
     MappingRule mpr = rules.get(0);
 
 
-    assertEquals("Fallback result",
-        expectedType, mpr.getFallback().getResult());
+    assertEquals(expectedType, mpr.getFallback().getResult(),
+        "Fallback result");
   }
   }
 
 
   @Test
   @Test
@@ -365,48 +371,57 @@ public class TestMappingRuleCreator {
     rule.setFallbackResult(null);
     rule.setFallbackResult(null);
     List<MappingRule> rules = ruleCreator.getMappingRules(description);
     List<MappingRule> rules = ruleCreator.getMappingRules(description);
     MappingRule mpr = rules.get(0);
     MappingRule mpr = rules.get(0);
-    assertEquals("Fallback result", MappingRuleResultType.SKIP,
-        mpr.getFallback().getResult());
+    assertEquals(MappingRuleResultType.SKIP,
+        mpr.getFallback().getResult(), "Fallback result");
   }
   }
 
 
   @Test
   @Test
   public void testTypeUnset() {
   public void testTypeUnset() {
-    rule.setType(null);
+    IllegalArgumentException illegalArgumentException =
+        assertThrows(IllegalArgumentException.class, () -> {
+          rule.setType(null);
+          ruleCreator.getMappingRules(description);
+        });
 
 
-    expected.expect(IllegalArgumentException.class);
-    expected.expectMessage("Rule type is undefined");
-
-    ruleCreator.getMappingRules(description);
+    assertTrue(illegalArgumentException.getMessage().contains("Rule type is undefined"));
   }
   }
 
 
   @Test
   @Test
   public void testMatchesUnset() {
   public void testMatchesUnset() {
-    rule.setMatches(null);
 
 
-    expected.expect(IllegalArgumentException.class);
-    expected.expectMessage("Match string is undefined");
+    IllegalArgumentException illegalArgumentException =
+        assertThrows(IllegalArgumentException.class, ()->{
+          rule.setMatches(null);
+          ruleCreator.getMappingRules(description);
+        });
+
+    assertTrue(illegalArgumentException.getMessage().contains("Match string is undefined"));
 
 
-    ruleCreator.getMappingRules(description);
   }
   }
 
 
   @Test
   @Test
   public void testMatchesEmpty() {
   public void testMatchesEmpty() {
-    rule.setMatches("");
 
 
-    expected.expect(IllegalArgumentException.class);
-    expected.expectMessage("Match string is empty");
+    IllegalArgumentException illegalArgumentException =
+        assertThrows(IllegalArgumentException.class, ()->{
+          rule.setMatches("");
+          ruleCreator.getMappingRules(description);
+        });
 
 
-    ruleCreator.getMappingRules(description);
+    assertTrue(illegalArgumentException.getMessage().contains("Match string is empty"));
   }
   }
 
 
   @Test
   @Test
   public void testPolicyUnset() {
   public void testPolicyUnset() {
     rule.setPolicy(null);
     rule.setPolicy(null);
 
 
-    expected.expect(IllegalArgumentException.class);
-    expected.expectMessage("Rule policy is undefined");
+    IllegalArgumentException illegalArgumentException =
+        assertThrows(IllegalArgumentException.class, ()->{
+          rule.setPolicy(null);
+          ruleCreator.getMappingRules(description);
+        });
 
 
-    ruleCreator.getMappingRules(description);
+    assertTrue(illegalArgumentException.getMessage().contains("Rule policy is undefined"));
   }
   }
 
 
   private void prepareMappingRuleDescription() {
   private void prepareMappingRuleDescription() {
@@ -449,22 +464,22 @@ public class TestMappingRuleCreator {
   private void verifyPlacement(MappingRuleResultType expectedResultType,
   private void verifyPlacement(MappingRuleResultType expectedResultType,
       String expectedQueue, boolean allowCreate) {
       String expectedQueue, boolean allowCreate) {
     List<MappingRule> rules = ruleCreator.getMappingRules(description);
     List<MappingRule> rules = ruleCreator.getMappingRules(description);
-    assertEquals("Number of rules", 1, rules.size());
+    assertEquals(1, rules.size(), "Number of rules");
     MappingRule mpr = rules.get(0);
     MappingRule mpr = rules.get(0);
     MappingRuleResult result = mpr.evaluate(variableContext);
     MappingRuleResult result = mpr.evaluate(variableContext);
 
 
-    assertEquals("Create flag", allowCreate, result.isCreateAllowed());
+    assertEquals(allowCreate, result.isCreateAllowed(), "Create flag");
 
 
     if (expectedResultType != null) {
     if (expectedResultType != null) {
-      assertEquals("Mapping rule result",
-          expectedResultType, result.getResult());
+      assertEquals(expectedResultType, result.getResult(),
+          "Mapping rule result");
     } else {
     } else {
-      assertEquals("Mapping rule result",
-          MappingRuleResultType.SKIP, result.getResult());
+      assertEquals(MappingRuleResultType.SKIP, result.getResult(),
+          "Mapping rule result");
     }
     }
 
 
     if (expectedQueue != null) {
     if (expectedQueue != null) {
-      assertEquals("Evaluated queue", expectedQueue, result.getQueue());
+      assertEquals(expectedQueue, result.getQueue(), "Evaluated queue");
     }
     }
   }
   }
 }
 }

+ 10 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/placement/converter/TestLegacyMappingRuleToJson.java

@@ -17,11 +17,13 @@
  */
  */
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placement.converter;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placement.converter;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import org.apache.hadoop.yarn.server.resourcemanager.placement.csmappingrule.MappingRule;
 import org.apache.hadoop.yarn.server.resourcemanager.placement.csmappingrule.MappingRule;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Collection;
@@ -64,21 +66,21 @@ public class TestLegacyMappingRuleToJson {
     List<MappingRule> jsonRules = conf.getMappingRules();
     List<MappingRule> jsonRules = conf.getMappingRules();
 
 
     //Sanity check
     //Sanity check
-    assertEquals("Number of rules should mach",
-        legacyRules.size(), jsonRules.size());
+    assertEquals(legacyRules.size(), jsonRules.size(),
+        "Number of rules should mach");
 
 
     //We expect ALL rules to match no matter if it was parsed from legacy format
     //We expect ALL rules to match no matter if it was parsed from legacy format
     //or from JSON
     //or from JSON
     for (int i = 0; i < legacyRules.size(); i++) {
     for (int i = 0; i < legacyRules.size(); i++) {
       assertEquals(
       assertEquals(
-          "Rule #" + i + " should match",
           legacyRules.get(i).toString(),
           legacyRules.get(i).toString(),
-          jsonRules.get(i).toString());
+          jsonRules.get(i).toString(),
+          "Rule #" + i + " should match");
 
 
       assertEquals(
       assertEquals(
-          "Rule #" + i + " fallback should match",
           legacyRules.get(i).getFallback().toString(),
           legacyRules.get(i).getFallback().toString(),
-          jsonRules.get(i).getFallback().toString());
+          jsonRules.get(i).getFallback().toString(),
+          "Rule #" + i + " fallback should match");
     }
     }
 
 
   }
   }

+ 3 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/policy/TestPriorityUtilizationQueueOrderingPolicy.java

@@ -25,8 +25,7 @@ import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueResourceQuotas;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueResourceQuotas;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacities;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacities;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.HashSet;
@@ -37,6 +36,7 @@ import java.util.Collections;
 
 
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.ThreadLocalRandom;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
@@ -75,7 +75,7 @@ public class TestPriorityUtilizationQueueOrderingPolicy {
     int i = 0;
     int i = 0;
     while (iter.hasNext()) {
     while (iter.hasNext()) {
       CSQueue q = iter.next();
       CSQueue q = iter.next();
-      Assert.assertEquals(expectedOrder[i], q.getQueuePath());
+      assertEquals(expectedOrder[i], q.getQueuePath());
       i++;
       i++;
     }
     }
 
 

+ 3 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/queuemanagement/TestDeactivatedLeafQueuesByLabel.java

@@ -16,9 +16,10 @@
 
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.queuemanagement;
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.queuemanagement;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
-import static org.junit.Assert.*;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.spy;
 
 
 public class TestDeactivatedLeafQueuesByLabel {
 public class TestDeactivatedLeafQueuesByLabel {

部分文件因为文件数量过多而无法显示