|
@@ -1363,6 +1363,38 @@ public class TestRMAppAttemptTransitions {
|
|
|
Assert.assertNull(token);
|
|
|
}
|
|
|
|
|
|
+ // this is to test master key is saved in the secret manager only after
|
|
|
+ // attempt is launched and in secure-mode
|
|
|
+ @Test
|
|
|
+ public void testApplicationAttemptMasterKey() throws Exception {
|
|
|
+ Container amContainer = allocateApplicationAttempt();
|
|
|
+ ApplicationAttemptId appid = applicationAttempt.getAppAttemptId();
|
|
|
+ boolean isMasterKeyExisted = false;
|
|
|
+
|
|
|
+ // before attempt is launched, can not get MasterKey
|
|
|
+ isMasterKeyExisted = clientToAMTokenManager.hasMasterKey(appid);
|
|
|
+ Assert.assertFalse(isMasterKeyExisted);
|
|
|
+
|
|
|
+ launchApplicationAttempt(amContainer);
|
|
|
+ // after attempt is launched and in secure mode, can get MasterKey
|
|
|
+ isMasterKeyExisted = clientToAMTokenManager.hasMasterKey(appid);
|
|
|
+ if (isSecurityEnabled) {
|
|
|
+ Assert.assertTrue(isMasterKeyExisted);
|
|
|
+ Assert.assertNotNull(clientToAMTokenManager.getMasterKey(appid));
|
|
|
+ } else {
|
|
|
+ Assert.assertFalse(isMasterKeyExisted);
|
|
|
+ }
|
|
|
+
|
|
|
+ applicationAttempt.handle(new RMAppAttemptEvent(applicationAttempt
|
|
|
+ .getAppAttemptId(), RMAppAttemptEventType.KILL));
|
|
|
+ assertEquals(YarnApplicationAttemptState.LAUNCHED,
|
|
|
+ applicationAttempt.createApplicationAttemptState());
|
|
|
+ sendAttemptUpdateSavedEvent(applicationAttempt);
|
|
|
+ // after attempt is killed, can not get MasterKey
|
|
|
+ isMasterKeyExisted = clientToAMTokenManager.hasMasterKey(appid);
|
|
|
+ Assert.assertFalse(isMasterKeyExisted);
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testFailedToFailed() {
|
|
|
// create a failed attempt.
|