goiri commented on code in PR #5131: URL: https://github.com/apache/hadoop/pull/5131#discussion_r1039696785
########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/TestZookeeperFederationStateStore.java: ########## @@ -171,38 +203,293 @@ public void testMetricsInited() throws Exception { MetricsRecords.assertMetric(record, "UpdateReservationHomeSubClusterNumOps", expectOps); } - @Test(expected = NotImplementedException.class) + @Test public void testStoreNewMasterKey() throws Exception { - super.testStoreNewMasterKey(); + + // Manually create a DelegationKey, + // and call the interface storeNewMasterKey to write the data to zk. + DelegationKey key = new DelegationKey(1234, Time.now() + 60 * 60, "keyBytes".getBytes()); + RouterMasterKey paramRouterMasterKey = RouterMasterKey.newInstance(key.getKeyId(), + ByteBuffer.wrap(key.getEncodedKey()), key.getExpiryDate()); + FederationStateStore stateStore = this.getStateStore(); + + assertTrue(stateStore instanceof ZookeeperFederationStateStore); + + // Compare the data returned by the storeNewMasterKey + // interface with the data queried by zk, and ensure that the data is consistent. + RouterMasterKeyRequest routerMasterKeyRequest = + RouterMasterKeyRequest.newInstance(paramRouterMasterKey); + RouterMasterKeyResponse response = stateStore.storeNewMasterKey(routerMasterKeyRequest); + assertNotNull(response); + RouterMasterKey respRouterMasterKey = response.getRouterMasterKey(); + assertNotNull(respRouterMasterKey); + + // Get Data From zk. + String nodeName = ROUTER_RM_DELEGATION_KEY_PREFIX + key.getKeyId(); + String nodePath = ZNODE_MASTER_KEY_PREFIX + nodeName; + RouterMasterKey zkRouterMasterKey = getRouterMasterKeyFromZK(nodePath); + + assertNotNull(zkRouterMasterKey); + assertEquals(paramRouterMasterKey, respRouterMasterKey); + assertEquals(paramRouterMasterKey, zkRouterMasterKey); + assertEquals(zkRouterMasterKey, respRouterMasterKey); } - @Test(expected = NotImplementedException.class) + @Test public void testGetMasterKeyByDelegationKey() throws YarnException, IOException { - super.testGetMasterKeyByDelegationKey(); + + // Manually create a DelegationKey, + // and call the interface storeNewMasterKey to write the data to zk. + DelegationKey key = new DelegationKey(5678, Time.now() + 60 * 60, "keyBytes".getBytes()); + RouterMasterKey paramRouterMasterKey = RouterMasterKey.newInstance(key.getKeyId(), + ByteBuffer.wrap(key.getEncodedKey()), key.getExpiryDate()); + FederationStateStore stateStore = this.getStateStore(); + + assertTrue(stateStore instanceof ZookeeperFederationStateStore); Review Comment: Can we use the super method and have a function to check these things we do in every method? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org