diff --git a/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 b/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 index a03993515c..84405192dd 100644 --- a/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 +++ b/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 @@ -34,11 +34,9 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.PriorityQueue; import java.util.Set; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CyclicBarrier; @@ -52,7 +50,6 @@ import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.TokenIdentifier; import org.apache.hadoop.test.GenericTestUtils; -import org.apache.hadoop.util.Time; import org.apache.hadoop.yarn.LocalConfigurationProvider; import org.apache.hadoop.yarn.api.ApplicationMasterProtocol; import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest; @@ -157,12 +154,8 @@ import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator; import org.apache.hadoop.yarn.util.resource.Resources; -import org.apache.log4j.Level; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; import org.junit.After; import org.junit.Assert; -import org.junit.Assume; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -1055,13 +1048,16 @@ null, new RMContainerTokenSecretManager(conf), @Test public void testCapacitySchedulerInfo() throws Exception { QueueInfo queueInfo = resourceManager.getResourceScheduler().getQueueInfo("a", true, true); - Assert.assertEquals(queueInfo.getQueueName(), "a"); - Assert.assertEquals(queueInfo.getChildQueues().size(), 2); + Assert.assertEquals("Queue Name should be a", "a", + queueInfo.getQueueName()); + Assert.assertEquals("Child Queues size should be 2", 2, + queueInfo.getChildQueues().size()); List userACLInfo = resourceManager.getResourceScheduler().getQueueUserAclInfo(); Assert.assertNotNull(userACLInfo); for (QueueUserACLInfo queueUserACLInfo : userACLInfo) { - Assert.assertEquals(getQueueCount(userACLInfo, queueUserACLInfo.getQueueName()), 1); + Assert.assertEquals(1, getQueueCount(userACLInfo, + queueUserACLInfo.getQueueName())); } } @@ -3054,8 +3050,8 @@ public void testRefreshQueuesMaxAllocationRefreshLarger() throws Exception { CSQueue rootQueue = cs.getRootQueue(); CSQueue queueA = findQueue(rootQueue, A); CSQueue queueA1 = findQueue(queueA, A1); - assertEquals("queue max allocation", ((LeafQueue) queueA1) - .getMaximumAllocation().getMemorySize(), 4096); + assertEquals("queue max allocation", 4096, ((LeafQueue) queueA1) + .getMaximumAllocation().getMemorySize()); setMaxAllocMb(conf, A1, 6144); setMaxAllocVcores(conf, A1, 3); @@ -3868,12 +3864,16 @@ public void testDefaultNodeLabelExpressionQueueConfig() throws Exception { cs.start(); QueueInfo queueInfoA = cs.getQueueInfo("a", true, false); - Assert.assertEquals(queueInfoA.getQueueName(), "a"); - Assert.assertEquals(queueInfoA.getDefaultNodeLabelExpression(), "x"); + Assert.assertEquals("Queue Name should be a", "a", + queueInfoA.getQueueName()); + Assert.assertEquals("Default Node Label Expression should be x", "x", + queueInfoA.getDefaultNodeLabelExpression()); QueueInfo queueInfoB = cs.getQueueInfo("b", true, false); - Assert.assertEquals(queueInfoB.getQueueName(), "b"); - Assert.assertEquals(queueInfoB.getDefaultNodeLabelExpression(), "y"); + Assert.assertEquals("Queue Name should be b", "b", + queueInfoB.getQueueName()); + Assert.assertEquals("Default Node Label Expression should be y", "y", + queueInfoB.getDefaultNodeLabelExpression()); } @Test(timeout = 60000) @@ -4147,20 +4147,26 @@ public void handle(Event event) { Resource usedResource = resourceManager.getResourceScheduler() .getSchedulerNode(nm_0.getNodeId()).getAllocatedResource(); - Assert.assertEquals(usedResource.getMemorySize(), 1 * GB); - Assert.assertEquals(usedResource.getVirtualCores(), 1); + 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()); // Check total resource of scheduler node is also changed to 1 GB 1 core Resource totalResource = resourceManager.getResourceScheduler() .getSchedulerNode(nm_0.getNodeId()).getTotalResource(); - Assert.assertEquals(totalResource.getMemorySize(), 1 * GB); - Assert.assertEquals(totalResource.getVirtualCores(), 1); + 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()); // Check the available resource is 0/0 Resource availableResource = resourceManager.getResourceScheduler() .getSchedulerNode(nm_0.getNodeId()).getUnallocatedResource(); - Assert.assertEquals(availableResource.getMemorySize(), 0); - Assert.assertEquals(availableResource.getVirtualCores(), 0); + Assert.assertEquals("Available Resource Memory Size should be 0", 0, + availableResource.getMemorySize()); + Assert.assertEquals("Available Resource Memory Size should be 0", 0, + availableResource.getVirtualCores()); } @Test @@ -4709,7 +4715,7 @@ null, new RMContainerTokenSecretManager(conf), String targetQueue = "b1"; CSQueue b1 = cs.getQueue(targetQueue); - Assert.assertEquals(b1.getState(), QueueState.RUNNING); + Assert.assertEquals(QueueState.RUNNING, b1.getState()); // test if we can convert a leaf queue which is in RUNNING state conf = new CapacitySchedulerConfiguration(); @@ -4727,7 +4733,7 @@ null, new RMContainerTokenSecretManager(conf), setupQueueConfiguration(conf); conf.set("yarn.scheduler.capacity.root.b.b1.state", "STOPPED"); cs.reinitialize(conf, mockContext); - Assert.assertEquals(b1.getState(), QueueState.STOPPED); + Assert.assertEquals(QueueState.STOPPED, b1.getState()); // test if we can convert a leaf queue which is in STOPPED state conf = new CapacitySchedulerConfiguration(); @@ -4740,7 +4746,7 @@ null, new RMContainerTokenSecretManager(conf), } b1 = cs.getQueue(targetQueue); Assert.assertTrue(b1 instanceof ParentQueue); - Assert.assertEquals(b1.getState(), QueueState.RUNNING); + Assert.assertEquals(QueueState.RUNNING, b1.getState()); Assert.assertTrue(!b1.getChildQueues().isEmpty()); }