YARN-2201. Made TestRMWebServicesAppsModification be independent of the changes on yarn-default.xml. Contributed by Varun Vasudev.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1606285 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
739b135dcc
commit
55a0aa0bad
|
@ -299,6 +299,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
YARN-2104. Scheduler queue filter failed to work because index of queue
|
YARN-2104. Scheduler queue filter failed to work because index of queue
|
||||||
column changed. (Wangda Tan via jlowe)
|
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
|
Release 2.4.1 - 2014-06-23
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
@ -49,6 +50,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
|
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.RMApp;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
|
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.capacity.CapacitySchedulerConfiguration;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager;
|
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.AppState;
|
||||||
|
@ -93,6 +95,8 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
private Injector injector;
|
private Injector injector;
|
||||||
private String webserviceUserName = "testuser";
|
private String webserviceUserName = "testuser";
|
||||||
|
|
||||||
|
private boolean setAuthFilter = false;
|
||||||
|
|
||||||
public class GuiceServletConfig extends GuiceServletContextListener {
|
public class GuiceServletConfig extends GuiceServletContextListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -131,7 +135,6 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
|
|
||||||
private class TestServletModule extends ServletModule {
|
private class TestServletModule extends ServletModule {
|
||||||
public Configuration conf = new Configuration();
|
public Configuration conf = new Configuration();
|
||||||
boolean setAuthFilter = false;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureServlets() {
|
protected void configureServlets() {
|
||||||
|
@ -157,6 +160,7 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
return Guice.createInjector(new TestServletModule() {
|
return Guice.createInjector(new TestServletModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configureServlets() {
|
protected void configureServlets() {
|
||||||
|
setAuthFilter = false;
|
||||||
super.configureServlets();
|
super.configureServlets();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -204,8 +208,8 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAuthorizationEnabled() {
|
private boolean isAuthenticationEnabled() {
|
||||||
return rm.getConfig().getBoolean(YarnConfiguration.YARN_ACL_ENABLE, false);
|
return setAuthFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebResource constructWebResource(WebResource r, String... paths) {
|
private WebResource constructWebResource(WebResource r, String... paths) {
|
||||||
|
@ -213,7 +217,7 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
for (String path : paths) {
|
for (String path : paths) {
|
||||||
rt = rt.path(path);
|
rt = rt.path(path);
|
||||||
}
|
}
|
||||||
if (isAuthorizationEnabled()) {
|
if (isAuthenticationEnabled()) {
|
||||||
rt = rt.queryParam("user.name", webserviceUserName);
|
rt = rt.queryParam("user.name", webserviceUserName);
|
||||||
}
|
}
|
||||||
return rt;
|
return rt;
|
||||||
|
@ -280,7 +284,7 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
"state").entity(entity, contentType).accept(mediaType)
|
"state").entity(entity, contentType).accept(mediaType)
|
||||||
.put(ClientResponse.class);
|
.put(ClientResponse.class);
|
||||||
|
|
||||||
if (!isAuthorizationEnabled()) {
|
if (!isAuthenticationEnabled()) {
|
||||||
assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
|
assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -295,7 +299,7 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
response.getHeaders().getFirst(HttpHeaders.LOCATION);
|
response.getHeaders().getFirst(HttpHeaders.LOCATION);
|
||||||
Client c = Client.create();
|
Client c = Client.create();
|
||||||
WebResource tmp = c.resource(locationHeaderValue);
|
WebResource tmp = c.resource(locationHeaderValue);
|
||||||
if (isAuthorizationEnabled()) {
|
if (isAuthenticationEnabled()) {
|
||||||
tmp = tmp.queryParam("user.name", webserviceUserName);
|
tmp = tmp.queryParam("user.name", webserviceUserName);
|
||||||
}
|
}
|
||||||
response = tmp.get(ClientResponse.class);
|
response = tmp.get(ClientResponse.class);
|
||||||
|
@ -361,7 +365,7 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
.entity(entity, contentType).accept(mediaType)
|
.entity(entity, contentType).accept(mediaType)
|
||||||
.put(ClientResponse.class);
|
.put(ClientResponse.class);
|
||||||
|
|
||||||
if (!isAuthorizationEnabled()) {
|
if (!isAuthenticationEnabled()) {
|
||||||
assertEquals(Status.UNAUTHORIZED,
|
assertEquals(Status.UNAUTHORIZED,
|
||||||
response.getClientResponseStatus());
|
response.getClientResponseStatus());
|
||||||
continue;
|
continue;
|
||||||
|
@ -426,6 +430,11 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
@Test(timeout = 30000)
|
@Test(timeout = 30000)
|
||||||
public void testSingleAppKillUnauthorized() throws Exception {
|
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
|
// default root queue allows anyone to have admin acl
|
||||||
CapacitySchedulerConfiguration csconf =
|
CapacitySchedulerConfiguration csconf =
|
||||||
new CapacitySchedulerConfiguration();
|
new CapacitySchedulerConfiguration();
|
||||||
|
@ -452,7 +461,7 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
.constructWebResource("apps", app.getApplicationId().toString(),
|
.constructWebResource("apps", app.getApplicationId().toString(),
|
||||||
"state").accept(mediaType)
|
"state").accept(mediaType)
|
||||||
.entity(info, MediaType.APPLICATION_XML).put(ClientResponse.class);
|
.entity(info, MediaType.APPLICATION_XML).put(ClientResponse.class);
|
||||||
if (!isAuthorizationEnabled()) {
|
if (!isAuthenticationEnabled()) {
|
||||||
assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
|
assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
|
||||||
} else {
|
} else {
|
||||||
assertEquals(Status.FORBIDDEN, response.getClientResponseStatus());
|
assertEquals(Status.FORBIDDEN, response.getClientResponseStatus());
|
||||||
|
@ -475,7 +484,7 @@ public class TestRMWebServicesAppsModification extends JerseyTest {
|
||||||
this.constructWebResource("apps", testAppId, "state")
|
this.constructWebResource("apps", testAppId, "state")
|
||||||
.accept(MediaType.APPLICATION_XML)
|
.accept(MediaType.APPLICATION_XML)
|
||||||
.entity(info, MediaType.APPLICATION_XML).put(ClientResponse.class);
|
.entity(info, MediaType.APPLICATION_XML).put(ClientResponse.class);
|
||||||
if (!isAuthorizationEnabled()) {
|
if (!isAuthenticationEnabled()) {
|
||||||
assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
|
assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue