Skip to content

Commit 659d9a8

Browse files
tomicoolersusheelgupta7
authored andcommitted
YARN-11645. Order the queues by queuePath in json assert tests. (#6432)
1 parent 92e475f commit 659d9a8

File tree

43 files changed

+27702
-27602
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+27702
-27602
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.Collection;
2727

2828
import org.codehaus.jettison.json.JSONObject;
29+
import org.junit.AfterClass;
2930
import org.junit.Test;
3031

3132
import org.apache.hadoop.conf.Configuration;
@@ -43,8 +44,10 @@
4344
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.assertJsonResponse;
4445
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.assertJsonType;
4546
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.assertXmlResponse;
47+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.backupSchedulerConfigFileInTarget;
4648
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createRM;
4749
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createWebAppDescriptor;
50+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.restoreSchedulerConfigFileInTarget;
4851
import static org.junit.Assert.assertEquals;
4952

5053
@RunWith(Parameterized.class)
@@ -60,6 +63,12 @@ public static Collection<Boolean> getParameters() {
6063
public TestRMWebServicesCapacitySched(boolean legacyQueueMode) {
6164
super(createWebAppDescriptor());
6265
this.legacyQueueMode = legacyQueueMode;
66+
backupSchedulerConfigFileInTarget();
67+
}
68+
69+
@AfterClass
70+
public static void afterClass() {
71+
restoreSchedulerConfigFileInTarget();
6372
}
6473

6574
@Test

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySchedDynamicConfig.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.HashMap;
2525
import java.util.Map;
2626

27+
import org.junit.AfterClass;
2728
import org.junit.Test;
2829

2930
import org.apache.hadoop.conf.Configuration;
@@ -39,10 +40,12 @@
3940
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfigGeneratorForTest.createConfiguration;
4041
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
4142
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.assertJsonResponse;
43+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.backupSchedulerConfigFileInTarget;
4244
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createMutableRM;
4345
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createWebAppDescriptor;
4446
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.getExpectedResourceFile;
4547
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.reinitialize;
48+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.restoreSchedulerConfigFileInTarget;
4649
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.runTest;
4750
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.sendRequest;
4851
import static org.assertj.core.api.Assertions.fail;
@@ -72,6 +75,12 @@ public static Collection<Boolean> getParameters() {
7275
public TestRMWebServicesCapacitySchedDynamicConfig(boolean legacyQueueMode) {
7376
super(createWebAppDescriptor());
7477
this.legacyQueueMode = legacyQueueMode;
78+
backupSchedulerConfigFileInTarget();
79+
}
80+
81+
@AfterClass
82+
public static void afterClass() {
83+
restoreSchedulerConfigFileInTarget();
7584
}
7685

7786
@Test

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySchedLegacyQueueCreation.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import javax.ws.rs.core.MediaType;
2626

2727
import com.sun.jersey.api.client.ClientResponse;
28+
29+
import org.junit.AfterClass;
2830
import org.junit.Test;
2931

3032
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
@@ -38,8 +40,10 @@
3840
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfigGeneratorForTest.createConfiguration;
3941
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
4042
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.assertJsonResponse;
43+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.backupSchedulerConfigFileInTarget;
4144
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createMutableRM;
4245
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createWebAppDescriptor;
46+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.restoreSchedulerConfigFileInTarget;
4347

4448
@RunWith(Parameterized.class)
4549
public class TestRMWebServicesCapacitySchedLegacyQueueCreation extends
@@ -55,6 +59,12 @@ public static Collection<Boolean> getParameters() {
5559
public TestRMWebServicesCapacitySchedLegacyQueueCreation(boolean legacyQueueMode) {
5660
super(createWebAppDescriptor());
5761
this.legacyQueueMode = legacyQueueMode;
62+
backupSchedulerConfigFileInTarget();
63+
}
64+
65+
@AfterClass
66+
public static void afterClass() {
67+
restoreSchedulerConfigFileInTarget();
5868
}
5969

6070
@Test

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySchedulerMixedMode.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323

2424
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
2525
import org.apache.hadoop.yarn.webapp.JerseyTestBase;
26+
import org.junit.AfterClass;
2627
import org.junit.Test;
2728

2829
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfigGeneratorForTest.createConfiguration;
30+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.backupSchedulerConfigFileInTarget;
2931
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createRM;
3032
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createWebAppDescriptor;
33+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.restoreSchedulerConfigFileInTarget;
3134
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.runTest;
3235

3336
/**
@@ -47,6 +50,12 @@ public class TestRMWebServicesCapacitySchedulerMixedMode extends JerseyTestBase
4750

4851
public TestRMWebServicesCapacitySchedulerMixedMode() {
4952
super(createWebAppDescriptor());
53+
backupSchedulerConfigFileInTarget();
54+
}
55+
56+
@AfterClass
57+
public static void afterClass() {
58+
restoreSchedulerConfigFileInTarget();
5059
}
5160

5261

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesConfigurationMutation.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@
5050
import org.codehaus.jettison.json.JSONException;
5151
import org.codehaus.jettison.json.JSONObject;
5252
import org.junit.After;
53+
import org.junit.AfterClass;
5354
import org.junit.Before;
55+
import org.junit.BeforeClass;
5456
import org.junit.Test;
5557
import org.slf4j.Logger;
5658
import org.slf4j.LoggerFactory;
5759

5860
import javax.ws.rs.core.MediaType;
5961
import javax.ws.rs.core.Response.Status;
6062

61-
import java.io.File;
6263
import java.io.FileOutputStream;
6364
import java.io.IOException;
6465
import java.util.HashMap;
@@ -67,6 +68,9 @@
6768
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.ACCESSIBLE_NODE_LABELS;
6869
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.CAPACITY;
6970
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_CAPACITY;
71+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.getCapacitySchedulerConfigFileInTarget;
72+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.backupSchedulerConfigFileInTarget;
73+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.restoreSchedulerConfigFileInTarget;
7074
import static org.apache.hadoop.yarn.webapp.util.YarnWebServiceUtils.toJson;
7175
import static org.junit.Assert.assertEquals;
7276
import static org.junit.Assert.assertNull;
@@ -80,11 +84,6 @@
8084
public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
8185
private static final Logger LOG = LoggerFactory
8286
.getLogger(TestRMWebServicesConfigurationMutation.class);
83-
84-
private static final File CONF_FILE = new File(new File("target",
85-
"test-classes"), YarnConfiguration.CS_CONFIGURATION_FILE);
86-
private static final File OLD_CONF_FILE = new File(new File("target",
87-
"test-classes"), YarnConfiguration.CS_CONFIGURATION_FILE + ".tmp");
8887
private static final String LABEL_1 = "label1";
8988
public static final QueuePath ROOT = new QueuePath("root");
9089
public static final QueuePath ROOT_A = new QueuePath("root", "a");
@@ -95,6 +94,16 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
9594
private static CapacitySchedulerConfiguration csConf;
9695
private static YarnConfiguration conf;
9796

97+
@BeforeClass
98+
public static void beforeClass() {
99+
backupSchedulerConfigFileInTarget();
100+
}
101+
102+
@AfterClass
103+
public static void afterClass() {
104+
restoreSchedulerConfigFileInTarget();
105+
}
106+
98107
private static class WebServletModule extends ServletModule {
99108
@Override
100109
protected void configureServlets() {
@@ -117,12 +126,7 @@ protected void configureServlets() {
117126
YarnConfiguration.MEMORY_CONFIGURATION_STORE);
118127
conf.set(YarnConfiguration.YARN_ADMIN_ACL, userName);
119128
try {
120-
if (CONF_FILE.exists()) {
121-
if (!CONF_FILE.renameTo(OLD_CONF_FILE)) {
122-
throw new RuntimeException("Failed to rename conf file");
123-
}
124-
}
125-
FileOutputStream out = new FileOutputStream(CONF_FILE);
129+
FileOutputStream out = new FileOutputStream(getCapacitySchedulerConfigFileInTarget());
126130
csConf.writeXml(out);
127131
out.close();
128132
} catch (IOException e) {
@@ -1070,10 +1074,6 @@ public void tearDown() throws Exception {
10701074
if (rm != null) {
10711075
rm.stop();
10721076
}
1073-
CONF_FILE.delete();
1074-
if (!OLD_CONF_FILE.renameTo(CONF_FILE)) {
1075-
throw new RuntimeException("Failed to re-copy old configuration file");
1076-
}
10771077
super.tearDown();
10781078
}
10791079
}

0 commit comments

Comments
 (0)