YARN-10692. Do not extend from CapacitySchedulerTestBase when not needed. Contributed by Tamas Domok
Co-authored-by: Tamas Domok <tdomok@cloudera.com>
This commit is contained in:
parent
e103c83765
commit
5535d66fb5
@ -26,16 +26,18 @@
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class CapacitySchedulerTestBase {
|
public final class CapacitySchedulerTestUtilities {
|
||||||
protected final int GB = 1024;
|
public static final int GB = 1024;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
private CapacitySchedulerTestUtilities() {
|
||||||
protected <E> Set<E> toSet(E... elements) {
|
|
||||||
Set<E> set = Sets.newHashSet(elements);
|
|
||||||
return set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkPendingResource(MockRM rm, String queueName, int memory,
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <E> Set<E> toSet(E... elements) {
|
||||||
|
return Sets.newHashSet(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkPendingResource(MockRM rm, String queueName, int memory,
|
||||||
String label) {
|
String label) {
|
||||||
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
|
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
|
||||||
CSQueue queue = cs.getQueue(queueName);
|
CSQueue queue = cs.getQueue(queueName);
|
||||||
@ -47,7 +49,7 @@ protected void checkPendingResource(MockRM rm, String queueName, int memory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void checkPendingResourceGreaterThanZero(MockRM rm, String queueName,
|
public static void checkPendingResourceGreaterThanZero(MockRM rm, String queueName,
|
||||||
String label) {
|
String label) {
|
||||||
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
|
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
|
||||||
CSQueue queue = cs.getQueue(queueName);
|
CSQueue queue = cs.getQueue(queueName);
|
||||||
@ -56,7 +58,7 @@ protected void checkPendingResourceGreaterThanZero(MockRM rm, String queueName,
|
|||||||
.getMemorySize() > 0);
|
.getMemorySize() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitforNMRegistered(ResourceScheduler scheduler, int nodecount,
|
public static void waitforNMRegistered(ResourceScheduler scheduler, int nodecount,
|
||||||
int timesec) throws InterruptedException {
|
int timesec) throws InterruptedException {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
while (System.currentTimeMillis() - start < timesec * 1000) {
|
while (System.currentTimeMillis() - start < timesec * 1000) {
|
@ -42,6 +42,11 @@
|
|||||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfigurationWithB1AsParentQueue;
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfigurationWithB1AsParentQueue;
|
||||||
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.checkPendingResource;
|
||||||
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.checkPendingResourceGreaterThanZero;
|
||||||
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.toSet;
|
||||||
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.waitforNMRegistered;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION;
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION;
|
||||||
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;
|
||||||
@ -222,7 +227,7 @@
|
|||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
public class TestCapacityScheduler extends CapacitySchedulerTestBase {
|
public class TestCapacityScheduler {
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
LoggerFactory.getLogger(TestCapacityScheduler.class);
|
LoggerFactory.getLogger(TestCapacityScheduler.class);
|
||||||
private final static ContainerUpdates NULL_UPDATE_REQUESTS =
|
private final static ContainerUpdates NULL_UPDATE_REQUESTS =
|
||||||
|
@ -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.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
|
||||||
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.waitforNMRegistered;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -53,7 +56,7 @@
|
|||||||
/**
|
/**
|
||||||
* Test class for Multi Node scheduling related tests.
|
* Test class for Multi Node scheduling related tests.
|
||||||
*/
|
*/
|
||||||
public class TestCapacitySchedulerMultiNodes extends CapacitySchedulerTestBase {
|
public class TestCapacitySchedulerMultiNodes {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory
|
private static final Logger LOG = LoggerFactory
|
||||||
.getLogger(TestCapacitySchedulerMultiNodes.class);
|
.getLogger(TestCapacitySchedulerMultiNodes.class);
|
||||||
|
@ -18,6 +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.CapacitySchedulerTestUtilities.GB;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
|
||||||
@ -52,8 +53,7 @@
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class TestCapacitySchedulerMultiNodesWithPreemption
|
public class TestCapacitySchedulerMultiNodesWithPreemption {
|
||||||
extends CapacitySchedulerTestBase {
|
|
||||||
|
|
||||||
private static final Log LOG = LogFactory
|
private static final Log LOG = LogFactory
|
||||||
.getLog(TestCapacitySchedulerMultiNodesWithPreemption.class);
|
.getLog(TestCapacitySchedulerMultiNodesWithPreemption.class);
|
||||||
|
@ -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.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
|
||||||
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.checkPendingResource;
|
||||||
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.toSet;
|
||||||
|
|
||||||
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 org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
@ -45,8 +49,7 @@
|
|||||||
/**
|
/**
|
||||||
* Test class for verifying Scheduling requests in CS.
|
* Test class for verifying Scheduling requests in CS.
|
||||||
*/
|
*/
|
||||||
public class TestCapacitySchedulerSchedulingRequestUpdate
|
public class TestCapacitySchedulerSchedulingRequestUpdate {
|
||||||
extends CapacitySchedulerTestBase {
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicPendingResourceUpdate() throws Exception {
|
public void testBasicPendingResourceUpdate() throws Exception {
|
||||||
Configuration conf = TestUtils.getConfigurationWithQueueLabels(
|
Configuration conf = TestUtils.getConfigurationWithQueueLabels(
|
||||||
|
@ -53,8 +53,7 @@
|
|||||||
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;
|
||||||
|
|
||||||
public class TestCapacitySchedulerWorkflowPriorityMapping
|
public class TestCapacitySchedulerWorkflowPriorityMapping {
|
||||||
extends CapacitySchedulerTestBase {
|
|
||||||
private MockRM mockRM = null;
|
private MockRM mockRM = null;
|
||||||
|
|
||||||
private static void setWorkFlowPriorityMappings(
|
private static void setWorkFlowPriorityMappings(
|
||||||
|
Loading…
Reference in New Issue
Block a user