diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index 047fb55dcd..a67ff27617 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -45,6 +45,9 @@ Release 2.7.0 - UNRELEASED
BUG FIXES
+ YARN-2254. TestRMWebServicesAppsModification should run against both
+ CS and FS. (Zhihai Xu via kasha)
+
Release 2.6.0 - UNRELEASED
INCOMPATIBLE CHANGES
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesAppsModification.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesAppsModification.java
index 875c83c2fa..1812bab4a4 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesAppsModification.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesAppsModification.java
@@ -67,6 +67,8 @@
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairSchedulerConfiguration;
import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppState;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo;
@@ -117,6 +119,11 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
private boolean setAuthFilter = false;
+ private static final String TEST_DIR = new File(System.getProperty(
+ "test.build.data", "/tmp")).getAbsolutePath();
+ private static final String FS_ALLOC_FILE = new File(TEST_DIR,
+ "test-fs-queues.xml").getAbsolutePath();
+
public static class GuiceServletConfig extends GuiceServletContextListener {
@Override
@@ -153,11 +160,14 @@ protected Properties getConfiguration(String configPrefix,
}
- private class TestServletModule extends ServletModule {
+ private abstract class TestServletModule extends ServletModule {
public Configuration conf = new Configuration();
+ public abstract void configureScheduler();
+
@Override
protected void configureServlets() {
+ configureScheduler();
bind(JAXBContextResolver.class);
bind(RMWebServices.class);
bind(GenericExceptionHandler.class);
@@ -176,8 +186,39 @@ protected void configureServlets() {
}
}
- private Injector getNoAuthInjector() {
- return Guice.createInjector(new TestServletModule() {
+ private class CapTestServletModule extends TestServletModule {
+ @Override
+ public void configureScheduler() {
+ conf.set("yarn.resourcemanager.scheduler.class",
+ CapacityScheduler.class.getName());
+ }
+ }
+
+ private class FairTestServletModule extends TestServletModule {
+ @Override
+ public void configureScheduler() {
+ try {
+ PrintWriter out = new PrintWriter(new FileWriter(FS_ALLOC_FILE));
+ out.println("");
+ out.println("");
+ out.println("");
+ out.println(" someuser ");
+ out.println(" ");
+ out.println(" someuser ");
+ out.println(" ");
+ out.println("");
+ out.println("");
+ out.close();
+ } catch(IOException e) {
+ }
+ conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, FS_ALLOC_FILE);
+ conf.set("yarn.resourcemanager.scheduler.class",
+ FairScheduler.class.getName());
+ }
+ }
+
+ private Injector getNoAuthInjectorCap() {
+ return Guice.createInjector(new CapTestServletModule() {
@Override
protected void configureServlets() {
setAuthFilter = false;
@@ -186,8 +227,32 @@ protected void configureServlets() {
});
}
- private Injector getSimpleAuthInjector() {
- return Guice.createInjector(new TestServletModule() {
+ private Injector getSimpleAuthInjectorCap() {
+ return Guice.createInjector(new CapTestServletModule() {
+ @Override
+ protected void configureServlets() {
+ setAuthFilter = true;
+ conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
+ // set the admin acls otherwise all users are considered admins
+ // and we can't test authorization
+ conf.setStrings(YarnConfiguration.YARN_ADMIN_ACL, "testuser1");
+ super.configureServlets();
+ }
+ });
+ }
+
+ private Injector getNoAuthInjectorFair() {
+ return Guice.createInjector(new FairTestServletModule() {
+ @Override
+ protected void configureServlets() {
+ setAuthFilter = false;
+ super.configureServlets();
+ }
+ });
+ }
+
+ private Injector getSimpleAuthInjectorFair() {
+ return Guice.createInjector(new FairTestServletModule() {
@Override
protected void configureServlets() {
setAuthFilter = true;
@@ -202,7 +267,7 @@ protected void configureServlets() {
@Parameters
public static Collection