|
@@ -25,6 +25,7 @@ import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.PrintWriter;
|
|
|
+import java.security.AccessControlException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
@@ -200,7 +201,8 @@ public class TestRMAdminService {
|
|
|
rm.adminService.getAccessControlList().getAclString().trim();
|
|
|
|
|
|
Assert.assertTrue(!aclStringAfter.equals(aclStringBefore));
|
|
|
- Assert.assertEquals(aclStringAfter, "world:anyone:rwcda");
|
|
|
+ Assert.assertEquals(aclStringAfter, "world:anyone:rwcda,"
|
|
|
+ + UserGroupInformation.getCurrentUser().getShortUserName());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -685,7 +687,8 @@ public class TestRMAdminService {
|
|
|
String aclStringAfter =
|
|
|
resourceManager.adminService.getAccessControlList()
|
|
|
.getAclString().trim();
|
|
|
- Assert.assertEquals(aclStringAfter, "world:anyone:rwcda");
|
|
|
+ Assert.assertEquals(aclStringAfter, "world:anyone:rwcda,"
|
|
|
+ + UserGroupInformation.getCurrentUser().getShortUserName());
|
|
|
|
|
|
// validate values for queue configuration
|
|
|
CapacityScheduler cs =
|
|
@@ -751,6 +754,47 @@ public class TestRMAdminService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /* For verifying fix for YARN-3804 */
|
|
|
+ @Test
|
|
|
+ public void testRefreshAclWithDaemonUser() throws Exception {
|
|
|
+ String daemonUser =
|
|
|
+ UserGroupInformation.getCurrentUser().getShortUserName();
|
|
|
+ configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
|
|
+ "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
|
|
+
|
|
|
+ uploadDefaultConfiguration();
|
|
|
+ YarnConfiguration yarnConf = new YarnConfiguration();
|
|
|
+ yarnConf.set(YarnConfiguration.YARN_ADMIN_ACL, daemonUser + "xyz");
|
|
|
+ uploadConfiguration(yarnConf, "yarn-site.xml");
|
|
|
+
|
|
|
+ try {
|
|
|
+ rm = new MockRM(configuration);
|
|
|
+ rm.init(configuration);
|
|
|
+ rm.start();
|
|
|
+ } catch(Exception ex) {
|
|
|
+ fail("Should not get any exceptions");
|
|
|
+ }
|
|
|
+
|
|
|
+ Assert.assertEquals(daemonUser + "xyz," + daemonUser,
|
|
|
+ rm.adminService.getAccessControlList().getAclString().trim());
|
|
|
+
|
|
|
+ yarnConf = new YarnConfiguration();
|
|
|
+ yarnConf.set(YarnConfiguration.YARN_ADMIN_ACL, daemonUser + "abc");
|
|
|
+ uploadConfiguration(yarnConf, "yarn-site.xml");
|
|
|
+ try {
|
|
|
+ rm.adminService.refreshAdminAcls(RefreshAdminAclsRequest.newInstance());
|
|
|
+ } catch (YarnException e) {
|
|
|
+ if (e.getCause() != null &&
|
|
|
+ e.getCause() instanceof AccessControlException) {
|
|
|
+ fail("Refresh should not have failed due to incorrect ACL");
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+
|
|
|
+ Assert.assertEquals(daemonUser + "abc," + daemonUser,
|
|
|
+ rm.adminService.getAccessControlList().getAclString().trim());
|
|
|
+ }
|
|
|
+
|
|
|
private String writeConfigurationXML(Configuration conf, String confXMLName)
|
|
|
throws IOException {
|
|
|
DataOutputStream output = null;
|