Skip to content

Commit f46e730

Browse files
committed
YARN-10692. Do not extend from CapacitySchedulerTestBase when not needed.
Change-Id: I7ff0b0977585798f9772f167adfe6a24e52d9737
1 parent 783e480 commit f46e730

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@
2626

2727
import java.util.Set;
2828

29-
public class CapacitySchedulerTestBase {
30-
protected final int GB = 1024;
29+
public final class CapacitySchedulerTestUtilities {
30+
public static final int GB = 1024;
31+
32+
private CapacitySchedulerTestUtilities() {
33+
}
3134

3235
@SuppressWarnings("unchecked")
33-
protected <E> Set<E> toSet(E... elements) {
34-
Set<E> set = Sets.newHashSet(elements);
35-
return set;
36+
public static <E> Set<E> toSet(E... elements) {
37+
return Sets.newHashSet(elements);
3638
}
3739

38-
protected void checkPendingResource(MockRM rm, String queueName, int memory,
40+
public static void checkPendingResource(MockRM rm, String queueName, int memory,
3941
String label) {
4042
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
4143
CSQueue queue = cs.getQueue(queueName);
@@ -47,7 +49,7 @@ protected void checkPendingResource(MockRM rm, String queueName, int memory,
4749
}
4850

4951

50-
protected void checkPendingResourceGreaterThanZero(MockRM rm, String queueName,
52+
public static void checkPendingResourceGreaterThanZero(MockRM rm, String queueName,
5153
String label) {
5254
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
5355
CSQueue queue = cs.getQueue(queueName);
@@ -56,7 +58,7 @@ protected void checkPendingResourceGreaterThanZero(MockRM rm, String queueName,
5658
.getMemorySize() > 0);
5759
}
5860

59-
protected void waitforNMRegistered(ResourceScheduler scheduler, int nodecount,
61+
public static void waitforNMRegistered(ResourceScheduler scheduler, int nodecount,
6062
int timesec) throws InterruptedException {
6163
long start = System.currentTimeMillis();
6264
while (System.currentTimeMillis() - start < timesec * 1000) {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfigurationWithB1AsParentQueue;
4343
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfigurationWithoutB;
4444
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfigurationWithoutB1;
45+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
46+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.checkPendingResource;
47+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.checkPendingResourceGreaterThanZero;
48+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.toSet;
49+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.waitforNMRegistered;
4550
import static org.assertj.core.api.Assertions.assertThat;
4651
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION;
4752
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION_MB;
@@ -222,7 +227,7 @@
222227
import org.mockito.invocation.InvocationOnMock;
223228
import org.mockito.stubbing.Answer;
224229

225-
public class TestCapacityScheduler extends CapacitySchedulerTestBase {
230+
public class TestCapacityScheduler {
226231
private static final Logger LOG =
227232
LoggerFactory.getLogger(TestCapacityScheduler.class);
228233
private final static ContainerUpdates NULL_UPDATE_REQUESTS =

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
2020

21+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
22+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.waitforNMRegistered;
23+
2124
import java.util.ArrayList;
2225
import java.util.HashSet;
2326
import java.util.Iterator;
@@ -53,7 +56,7 @@
5356
/**
5457
* Test class for Multi Node scheduling related tests.
5558
*/
56-
public class TestCapacitySchedulerMultiNodes extends CapacitySchedulerTestBase {
59+
public class TestCapacitySchedulerMultiNodes {
5760

5861
private static final Logger LOG = LoggerFactory
5962
.getLogger(TestCapacitySchedulerMultiNodes.class);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
2020

21+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
2122
import static org.junit.Assert.assertEquals;
2223
import static org.junit.Assert.assertNotEquals;
2324

@@ -52,8 +53,7 @@
5253
import java.util.concurrent.atomic.AtomicBoolean;
5354
import java.util.concurrent.atomic.AtomicReference;
5455

55-
public class TestCapacitySchedulerMultiNodesWithPreemption
56-
extends CapacitySchedulerTestBase {
56+
public class TestCapacitySchedulerMultiNodesWithPreemption {
5757

5858
private static final Log LOG = LogFactory
5959
.getLog(TestCapacitySchedulerMultiNodesWithPreemption.class);

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
2020

21+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
22+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.checkPendingResource;
23+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.toSet;
24+
2125
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
2226
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
2327
import org.apache.hadoop.conf.Configuration;
@@ -45,8 +49,7 @@
4549
/**
4650
* Test class for verifying Scheduling requests in CS.
4751
*/
48-
public class TestCapacitySchedulerSchedulingRequestUpdate
49-
extends CapacitySchedulerTestBase {
52+
public class TestCapacitySchedulerSchedulingRequestUpdate {
5053
@Test
5154
public void testBasicPendingResourceUpdate() throws Exception {
5255
Configuration conf = TestUtils.getConfigurationWithQueueLabels(

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
5454
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
5555

56-
public class TestCapacitySchedulerWorkflowPriorityMapping
57-
extends CapacitySchedulerTestBase {
56+
public class TestCapacitySchedulerWorkflowPriorityMapping {
5857
private MockRM mockRM = null;
5958

6059
private static void setWorkFlowPriorityMappings(

0 commit comments

Comments
 (0)