From 93fb3b4b9cbc63e65d590676a5a318d555a25904 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Tue, 23 Oct 2018 12:49:15 -0500 Subject: [PATCH] YARN-8904. TestRMDelegationTokens can fail in testRMDTMasterKeyStateOnRollingMasterKey. Contributed by Wilfred Spiegelenburg --- .../security/TestRMDelegationTokens.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestRMDelegationTokens.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestRMDelegationTokens.java index 2c52377995..aae86b0bd5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestRMDelegationTokens.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestRMDelegationTokens.java @@ -97,7 +97,17 @@ public void testRMDTMasterKeyStateOnRollingMasterKey() throws Exception { RMDelegationTokenSecretManager dtSecretManager = rm1.getRMContext().getRMDelegationTokenSecretManager(); // assert all master keys are saved - Assert.assertEquals(dtSecretManager.getAllMasterKeys(), rmDTMasterKeyState); + dtSecretManager.getAllMasterKeys().forEach(managerKey -> { + int keyId = managerKey.getKeyId(); + boolean found = false; + for (DelegationKey stateKey: rmDTMasterKeyState) { + if (stateKey.getKeyId() == keyId) { + found = true; + break; + } + } + Assert.assertTrue("Master key not found: " + keyId, found); + }); // request to generate a RMDelegationToken GetDelegationTokenRequest request = mock(GetDelegationTokenRequest.class);