YARN-10321. Break down TestUserGroupMappingPlacementRule#testMapping into test scenarios

Contributed by Szilard Nemeth. Reviewed by Gergely Pollak.
This commit is contained in:
Prabhu Joseph 2020-06-22 12:47:46 +05:30 committed by Prabhu Joseph
parent 17ffcab5f6
commit ce1008fe61
2 changed files with 284 additions and 214 deletions

View File

@ -141,7 +141,7 @@ private ApplicationPlacementContext getPlacementForUser(String user)
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Creating placement context for user {} using " +
"static user static mapping", user);
"current user static mapping", user);
}
return getPlacementContext(mapping);
}
@ -173,7 +173,7 @@ private ApplicationPlacementContext getPlacementForUser(String user)
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Creating placement context for user {} using " +
"static user static mapping", user);
"current user static mapping", user);
}
return getPlacementContext(mapping);
}

View File

@ -169,7 +169,7 @@ public void testSecondaryGroupMapping() throws YarnException {
}
@Test
public void testNullGroupMapping() throws YarnException {
public void testNullGroupMapping() {
conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
NullGroupsMapping.class, GroupMappingServiceProvider.class);
try {
@ -190,9 +190,7 @@ public void testNullGroupMapping() throws YarnException {
}
@Test
public void testMapping() throws YarnException {
//if a mapping rule defines no parent, we cannot expect auto creation,
// so we must provide already existing queues
public void testSimpleUserMappingToSpecificQueue() throws YarnException {
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
.queueMapping(QueueMappingBuilder.create()
@ -203,6 +201,10 @@ public void testMapping() throws YarnException {
.inputUser("a")
.expectedQueue("a")
.build());
}
@Test
public void testSimpleGroupMappingToSpecificQueue() throws YarnException {
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
.queueMapping(QueueMappingBuilder.create()
@ -213,6 +215,10 @@ public void testMapping() throws YarnException {
.inputUser("a")
.expectedQueue("a")
.build());
}
@Test
public void testUserMappingToSpecificQueueForEachUser() throws YarnException {
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
.queueMapping(QueueMappingBuilder.create()
@ -223,6 +229,10 @@ public void testMapping() throws YarnException {
.inputUser("a")
.expectedQueue("b")
.build());
}
@Test
public void testUserMappingToQueueNamedAsUsername() throws YarnException {
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
.queueMapping(QueueMappingBuilder.create()
@ -233,6 +243,10 @@ public void testMapping() throws YarnException {
.inputUser("a")
.expectedQueue("a")
.build());
}
@Test
public void testUserMappingToQueueNamedGroupOfTheUser() throws YarnException {
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
.queueMapping(QueueMappingBuilder.create()
@ -244,6 +258,11 @@ public void testMapping() throws YarnException {
.expectedQueue("agroup")
.expectedParentQueue("root")
.build());
}
@Test
public void testUserMappingToQueueNamedAsUsernameWithPrimaryGroupAsParentQueue()
throws YarnException {
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
.queueMapping(QueueMappingBuilder.create()
@ -256,6 +275,11 @@ public void testMapping() throws YarnException {
.expectedQueue("a")
.expectedParentQueue("root.agroup")
.build());
}
@Test
public void testUserMappingToQueueNamedAsUsernameWithSecondaryGroupAsParentQueue()
throws YarnException {
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
.queueMapping(QueueMappingBuilder.create()
@ -268,6 +292,10 @@ public void testMapping() throws YarnException {
.expectedQueue("b")
.expectedParentQueue("root.bsubgroup2")
.build());
}
@Test
public void testGroupMappingToStaticQueue() throws YarnException {
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
.queueMapping(QueueMappingBuilder.create()
@ -278,8 +306,11 @@ public void testMapping() throws YarnException {
.inputUser("a")
.expectedQueue("a")
.build());
}
// "agroup" queue exists
@Test
public void testUserMappingToQueueNamedAsGroupNameWithRootAsParentQueue()
throws YarnException {
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
.queueMapping(QueueMappingBuilder.create()
@ -292,7 +323,11 @@ public void testMapping() throws YarnException {
.expectedQueue("agroup")
.expectedParentQueue("root")
.build());
}
@Test
public void testUserMappingToPrimaryGroupQueueDoesNotExistUnmanagedParent()
throws YarnException {
// "abcgroup" queue doesn't exist, %primary_group queue, not managed parent
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
@ -305,7 +340,11 @@ public void testMapping() throws YarnException {
.inputUser("abc")
.expectedQueue("default")
.build());
}
@Test
public void testUserMappingToPrimaryGroupQueueDoesNotExistManagedParent()
throws YarnException {
// "abcgroup" queue doesn't exist, %primary_group queue, managed parent
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
@ -319,7 +358,11 @@ public void testMapping() throws YarnException {
.expectedQueue("abcgroup")
.expectedParentQueue("root.managedParent")
.build());
}
@Test
public void testUserMappingToSecondaryGroupQueueDoesNotExist()
throws YarnException {
// "abcgroup" queue doesn't exist, %secondary_group queue
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
@ -332,7 +375,11 @@ public void testMapping() throws YarnException {
.inputUser("abc")
.expectedQueue("default")
.build());
}
@Test
public void testUserMappingToSecondaryGroupQueueUnderParent()
throws YarnException {
// "asubgroup2" queue exists, %secondary_group queue
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
@ -346,7 +393,11 @@ public void testMapping() throws YarnException {
.expectedQueue("asubgroup2")
.expectedParentQueue("root")
.build());
}
@Test
public void testUserMappingToSpecifiedQueueOverwritesInputQueueFromMapping()
throws YarnException {
// specify overwritten, and see if user specified a queue, and it will be
// overridden
verifyQueueMapping(
@ -361,7 +412,10 @@ public void testMapping() throws YarnException {
.expectedQueue("a")
.overwrite(true)
.build());
}
@Test
public void testUserMappingToExplicitlySpecifiedQueue() throws YarnException {
// if overwritten not specified, it should be which user specified
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
@ -374,7 +428,11 @@ public void testMapping() throws YarnException {
.inputQueue("b")
.expectedQueue("b")
.build());
}
@Test
public void testGroupMappingToExplicitlySpecifiedQueue()
throws YarnException {
// if overwritten not specified, it should be which user specified
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
@ -388,7 +446,11 @@ public void testMapping() throws YarnException {
.inputQueue("a")
.expectedQueue("a")
.build());
}
@Test
public void testGroupMappingToSpecifiedQueueOverwritesInputQueueFromMapping()
throws YarnException {
// if overwritten not specified, it should be which user specified
verifyQueueMapping(
QueueMappingTestDataBuilder.create()
@ -403,7 +465,11 @@ public void testMapping() throws YarnException {
.expectedQueue("b")
.overwrite(true)
.build());
}
@Test
public void testGroupMappingToSpecifiedQueueUnderAGivenParentQueue()
throws YarnException {
// If user specific queue is enabled for a specified group under a given
// parent queue
verifyQueueMapping(
@ -417,7 +483,11 @@ public void testMapping() throws YarnException {
.inputUser("a")
.expectedQueue("a")
.build());
}
@Test
public void testGroupMappingToSpecifiedQueueWithoutParentQueue()
throws YarnException {
// If user specific queue is enabled for a specified group without parent
// queue
verifyQueueMapping(