YARN-7308. TestApplicationACLs fails with FairScheduler (rkanter)
This commit is contained in:
parent
4540ffd15f
commit
8a61525928
|
@ -89,7 +89,8 @@ public abstract class ParameterizedSchedulerTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureFairScheduler(YarnConfiguration conf) throws IOException {
|
protected void configureFairScheduler(YarnConfiguration conf)
|
||||||
|
throws IOException {
|
||||||
// Disable queueMaxAMShare limitation for fair scheduler
|
// Disable queueMaxAMShare limitation for fair scheduler
|
||||||
PrintWriter out = new PrintWriter(new FileWriter(FS_ALLOC_FILE));
|
PrintWriter out = new PrintWriter(new FileWriter(FS_ALLOC_FILE));
|
||||||
out.println("<?xml version=\"1.0\"?>");
|
out.println("<?xml version=\"1.0\"?>");
|
||||||
|
|
|
@ -22,7 +22,10 @@ import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.security.PrivilegedExceptionAction;
|
import java.security.PrivilegedExceptionAction;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -30,6 +33,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
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.scheduler.fair.FairScheduler;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairSchedulerConfiguration;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -57,19 +63,17 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.factories.RecordFactory;
|
import org.apache.hadoop.yarn.factories.RecordFactory;
|
||||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||||
import org.apache.hadoop.yarn.ipc.YarnRPC;
|
import org.apache.hadoop.yarn.ipc.YarnRPC;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore;
|
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreFactory;
|
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStoreFactory;
|
||||||
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.ResourceScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager;
|
import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager;
|
||||||
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
||||||
import org.junit.AfterClass;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
public class TestApplicationACLs {
|
public class TestApplicationACLs extends ParameterizedSchedulerTestBase {
|
||||||
|
|
||||||
private static final String APP_OWNER = "owner";
|
private static final String APP_OWNER = "owner";
|
||||||
private static final String FRIEND = "friend";
|
private static final String FRIEND = "friend";
|
||||||
|
@ -82,27 +86,34 @@ public class TestApplicationACLs {
|
||||||
|
|
||||||
private static final Log LOG = LogFactory.getLog(TestApplicationACLs.class);
|
private static final Log LOG = LogFactory.getLog(TestApplicationACLs.class);
|
||||||
|
|
||||||
static MockRM resourceManager;
|
private MockRM resourceManager;
|
||||||
static Configuration conf = new YarnConfiguration();
|
private Configuration conf;
|
||||||
final static YarnRPC rpc = YarnRPC.create(conf);
|
private YarnRPC rpc;
|
||||||
final static InetSocketAddress rmAddress = conf.getSocketAddr(
|
private InetSocketAddress rmAddress;
|
||||||
YarnConfiguration.RM_ADDRESS,
|
private ApplicationClientProtocol rmClient;
|
||||||
YarnConfiguration.DEFAULT_RM_ADDRESS,
|
private RecordFactory recordFactory;
|
||||||
YarnConfiguration.DEFAULT_RM_PORT);
|
private boolean isQueueUser;
|
||||||
private static ApplicationClientProtocol rmClient;
|
|
||||||
|
|
||||||
private static RecordFactory recordFactory = RecordFactoryProvider
|
public TestApplicationACLs(SchedulerType type) throws IOException {
|
||||||
.getRecordFactory(conf);
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isQueueUser = false;
|
@Before
|
||||||
|
public void setup() throws InterruptedException, IOException {
|
||||||
@BeforeClass
|
conf = getConf();
|
||||||
public static void setup() throws InterruptedException, IOException {
|
rpc = YarnRPC.create(conf);
|
||||||
RMStateStore store = RMStateStoreFactory.getStore(conf);
|
rmAddress = conf.getSocketAddr(
|
||||||
|
YarnConfiguration.RM_ADDRESS,
|
||||||
|
YarnConfiguration.DEFAULT_RM_ADDRESS,
|
||||||
|
YarnConfiguration.DEFAULT_RM_PORT);
|
||||||
|
RMStateStoreFactory.getStore(conf);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
||||||
AccessControlList adminACL = new AccessControlList("");
|
AccessControlList adminACL = new AccessControlList("");
|
||||||
adminACL.addGroup(SUPER_GROUP);
|
adminACL.addGroup(SUPER_GROUP);
|
||||||
conf.set(YarnConfiguration.YARN_ADMIN_ACL, adminACL.getAclString());
|
conf.set(YarnConfiguration.YARN_ADMIN_ACL, adminACL.getAclString());
|
||||||
|
recordFactory = RecordFactoryProvider
|
||||||
|
.getRecordFactory(conf);
|
||||||
|
isQueueUser = false;
|
||||||
|
|
||||||
resourceManager = new MockRM(conf) {
|
resourceManager = new MockRM(conf) {
|
||||||
|
|
||||||
|
@ -161,13 +172,36 @@ public class TestApplicationACLs {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@After
|
||||||
public static void tearDown() {
|
public void tearDown() {
|
||||||
if(resourceManager != null) {
|
if(resourceManager != null) {
|
||||||
resourceManager.stop();
|
resourceManager.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureFairScheduler(YarnConfiguration conf)
|
||||||
|
throws IOException {
|
||||||
|
final String testDir = new File(System.getProperty("test.build.data",
|
||||||
|
"/tmp")).getAbsolutePath();
|
||||||
|
final String allocFile = new File(testDir, "test-queues.xml")
|
||||||
|
.getAbsolutePath();
|
||||||
|
PrintWriter out = new PrintWriter(new FileWriter(allocFile));
|
||||||
|
out.println("<?xml version=\"1.0\"?>");
|
||||||
|
out.println("<allocations>");
|
||||||
|
out.println("<queue name=\"root\" >");
|
||||||
|
out.println(" <queue name=\"default\">");
|
||||||
|
out.println(" </queue>");
|
||||||
|
out.println("</queue>");
|
||||||
|
out.println("<queuePlacementPolicy>");
|
||||||
|
out.println(" <rule name=\"specified\" create=\"false\" />");
|
||||||
|
out.println(" <rule name=\"reject\" />");
|
||||||
|
out.println("</queuePlacementPolicy>");
|
||||||
|
out.println("</allocations>");
|
||||||
|
out.close();
|
||||||
|
conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, allocFile);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplicationACLs() throws Exception {
|
public void testApplicationACLs() throws Exception {
|
||||||
|
|
||||||
|
@ -207,6 +241,10 @@ public class TestApplicationACLs {
|
||||||
Resource resource = BuilderUtils.newResource(1024, 1);
|
Resource resource = BuilderUtils.newResource(1024, 1);
|
||||||
context.setResource(resource);
|
context.setResource(resource);
|
||||||
amContainer.setApplicationACLs(acls);
|
amContainer.setApplicationACLs(acls);
|
||||||
|
if (conf.get(YarnConfiguration.RM_SCHEDULER)
|
||||||
|
.equals(FairScheduler.class.getName())) {
|
||||||
|
context.setQueue("root.default");
|
||||||
|
}
|
||||||
context.setAMContainerSpec(amContainer);
|
context.setAMContainerSpec(amContainer);
|
||||||
submitRequest.setApplicationSubmissionContext(context);
|
submitRequest.setApplicationSubmissionContext(context);
|
||||||
rmClient.submitApplication(submitRequest);
|
rmClient.submitApplication(submitRequest);
|
||||||
|
@ -424,8 +462,14 @@ public class TestApplicationACLs {
|
||||||
GetApplicationReportResponse applicationReport =
|
GetApplicationReportResponse applicationReport =
|
||||||
rmClient.getApplicationReport(appReportRequest);
|
rmClient.getApplicationReport(appReportRequest);
|
||||||
ApplicationReport appReport = applicationReport.getApplicationReport();
|
ApplicationReport appReport = applicationReport.getApplicationReport();
|
||||||
Assert.assertTrue(appReport.getDiagnostics()
|
if (conf.get(YarnConfiguration.RM_SCHEDULER)
|
||||||
.contains("submitted by user owner to unknown queue: InvalidQueue"));
|
.equals(FairScheduler.class.getName())) {
|
||||||
|
Assert.assertTrue(appReport.getDiagnostics()
|
||||||
|
.contains("Application rejected by queue placement policy"));
|
||||||
|
} else {
|
||||||
|
Assert.assertTrue(appReport.getDiagnostics()
|
||||||
|
.contains("submitted by user owner to unknown queue: InvalidQueue"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyAdministerQueueUserAccess() throws Exception {
|
private void verifyAdministerQueueUserAccess() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue