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:
Tamas Domok 2021-10-07 16:21:05 +02:00 committed by GitHub
parent e103c83765
commit 5535d66fb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 17 deletions

View File

@ -26,16 +26,18 @@ import org.junit.Assert;
import java.util.Set;
public class CapacitySchedulerTestBase {
protected final int GB = 1024;
public final class CapacitySchedulerTestUtilities {
public static final int GB = 1024;
@SuppressWarnings("unchecked")
protected <E> Set<E> toSet(E... elements) {
Set<E> set = Sets.newHashSet(elements);
return set;
private CapacitySchedulerTestUtilities() {
}
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) {
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
CSQueue queue = cs.getQueue(queueName);
@ -47,7 +49,7 @@ public class CapacitySchedulerTestBase {
}
protected void checkPendingResourceGreaterThanZero(MockRM rm, String queueName,
public static void checkPendingResourceGreaterThanZero(MockRM rm, String queueName,
String label) {
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
CSQueue queue = cs.getQueue(queueName);
@ -56,7 +58,7 @@ public class CapacitySchedulerTestBase {
.getMemorySize() > 0);
}
protected void waitforNMRegistered(ResourceScheduler scheduler, int nodecount,
public static void waitforNMRegistered(ResourceScheduler scheduler, int nodecount,
int timesec) throws InterruptedException {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timesec * 1000) {

View File

@ -42,6 +42,11 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.C
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.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.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION;
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION_MB;
@ -222,7 +227,7 @@ import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
public class TestCapacityScheduler extends CapacitySchedulerTestBase {
public class TestCapacityScheduler {
private static final Logger LOG =
LoggerFactory.getLogger(TestCapacityScheduler.class);
private final static ContainerUpdates NULL_UPDATE_REQUESTS =

View File

@ -18,6 +18,9 @@
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.HashSet;
import java.util.Iterator;
@ -53,7 +56,7 @@ import org.junit.Test;
/**
* Test class for Multi Node scheduling related tests.
*/
public class TestCapacitySchedulerMultiNodes extends CapacitySchedulerTestBase {
public class TestCapacitySchedulerMultiNodes {
private static final Logger LOG = LoggerFactory
.getLogger(TestCapacitySchedulerMultiNodes.class);

View File

@ -18,6 +18,7 @@
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.assertNotEquals;
@ -52,8 +53,7 @@ import org.junit.Test;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
public class TestCapacitySchedulerMultiNodesWithPreemption
extends CapacitySchedulerTestBase {
public class TestCapacitySchedulerMultiNodesWithPreemption {
private static final Log LOG = LogFactory
.getLog(TestCapacitySchedulerMultiNodesWithPreemption.class);

View File

@ -18,6 +18,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.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.ImmutableSet;
import org.apache.hadoop.conf.Configuration;
@ -45,8 +49,7 @@ import java.util.Arrays;
/**
* Test class for verifying Scheduling requests in CS.
*/
public class TestCapacitySchedulerSchedulingRequestUpdate
extends CapacitySchedulerTestBase {
public class TestCapacitySchedulerSchedulingRequestUpdate {
@Test
public void testBasicPendingResourceUpdate() throws Exception {
Configuration conf = TestUtils.getConfigurationWithQueueLabels(

View File

@ -53,8 +53,7 @@ import org.junit.Test;
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
public class TestCapacitySchedulerWorkflowPriorityMapping
extends CapacitySchedulerTestBase {
public class TestCapacitySchedulerWorkflowPriorityMapping {
private MockRM mockRM = null;
private static void setWorkFlowPriorityMappings(