diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 58e394bf53..ef0111f09d 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -299,6 +299,9 @@ Release 2.5.0 - UNRELEASED YARN-2104. Scheduler queue filter failed to work because index of queue column changed. (Wangda Tan via jlowe) + YARN-2201. Made TestRMWebServicesAppsModification be independent of the + changes on yarn-default.xml. (Varun Vasudev via zjshen) + Release 2.4.1 - 2014-06-23 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 7cbf125ec5..76281d47b8 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 @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; import java.io.IOException; import java.io.StringReader; @@ -49,6 +50,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; 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.security.QueueACLsManager; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppState; @@ -93,6 +95,8 @@ public class TestRMWebServicesAppsModification extends JerseyTest { private Injector injector; private String webserviceUserName = "testuser"; + private boolean setAuthFilter = false; + public class GuiceServletConfig extends GuiceServletContextListener { @Override @@ -131,7 +135,6 @@ protected Properties getConfiguration(String configPrefix, private class TestServletModule extends ServletModule { public Configuration conf = new Configuration(); - boolean setAuthFilter = false; @Override protected void configureServlets() { @@ -157,6 +160,7 @@ private Injector getNoAuthInjector() { return Guice.createInjector(new TestServletModule() { @Override protected void configureServlets() { + setAuthFilter = false; super.configureServlets(); } }); @@ -204,8 +208,8 @@ public TestRMWebServicesAppsModification(int run) { } } - private boolean isAuthorizationEnabled() { - return rm.getConfig().getBoolean(YarnConfiguration.YARN_ACL_ENABLE, false); + private boolean isAuthenticationEnabled() { + return setAuthFilter; } private WebResource constructWebResource(WebResource r, String... paths) { @@ -213,7 +217,7 @@ private WebResource constructWebResource(WebResource r, String... paths) { for (String path : paths) { rt = rt.path(path); } - if (isAuthorizationEnabled()) { + if (isAuthenticationEnabled()) { rt = rt.queryParam("user.name", webserviceUserName); } return rt; @@ -280,7 +284,7 @@ public void testSingleAppKill() throws Exception { "state").entity(entity, contentType).accept(mediaType) .put(ClientResponse.class); - if (!isAuthorizationEnabled()) { + if (!isAuthenticationEnabled()) { assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus()); continue; } @@ -295,7 +299,7 @@ public void testSingleAppKill() throws Exception { response.getHeaders().getFirst(HttpHeaders.LOCATION); Client c = Client.create(); WebResource tmp = c.resource(locationHeaderValue); - if (isAuthorizationEnabled()) { + if (isAuthenticationEnabled()) { tmp = tmp.queryParam("user.name", webserviceUserName); } response = tmp.get(ClientResponse.class); @@ -361,7 +365,7 @@ public void testSingleAppKillInvalidState() throws Exception { .entity(entity, contentType).accept(mediaType) .put(ClientResponse.class); - if (!isAuthorizationEnabled()) { + if (!isAuthenticationEnabled()) { assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus()); continue; @@ -426,6 +430,11 @@ protected static void verifyAppStateXML(ClientResponse response, @Test(timeout = 30000) public void testSingleAppKillUnauthorized() throws Exception { + boolean isCapacityScheduler = + rm.getResourceScheduler() instanceof CapacityScheduler; + assumeTrue("Currently this test is only supported on CapacityScheduler", + isCapacityScheduler); + // default root queue allows anyone to have admin acl CapacitySchedulerConfiguration csconf = new CapacitySchedulerConfiguration(); @@ -452,7 +461,7 @@ public void testSingleAppKillUnauthorized() throws Exception { .constructWebResource("apps", app.getApplicationId().toString(), "state").accept(mediaType) .entity(info, MediaType.APPLICATION_XML).put(ClientResponse.class); - if (!isAuthorizationEnabled()) { + if (!isAuthenticationEnabled()) { assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus()); } else { assertEquals(Status.FORBIDDEN, response.getClientResponseStatus()); @@ -475,7 +484,7 @@ public void testSingleAppKillInvalidId() throws Exception { this.constructWebResource("apps", testAppId, "state") .accept(MediaType.APPLICATION_XML) .entity(info, MediaType.APPLICATION_XML).put(ClientResponse.class); - if (!isAuthorizationEnabled()) { + if (!isAuthenticationEnabled()) { assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus()); continue; }