YARN-6878. TestCapacityScheduler.testDefaultNodeLabelExpressionQueueConfig() has the args to assertEqual() in the wrong order

(Contributed by Sen Zhao via Daniel Templeton)
This commit is contained in:
Daniel Templeton 2017-09-22 23:52:29 +02:00
parent 8d29bf57ca
commit 164a063e74
1 changed files with 31 additions and 25 deletions

View File

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