[ 
https://issues.apache.org/jira/browse/YARN-11350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17643379#comment-17643379
 ] 

ASF GitHub Bot commented on YARN-11350:
---------------------------------------

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?





> [Federation] Router Support DelegationToken With ZK
> ---------------------------------------------------
>
>                 Key: YARN-11350
>                 URL: https://issues.apache.org/jira/browse/YARN-11350
>             Project: Hadoop YARN
>          Issue Type: Sub-task
>          Components: federation, router
>    Affects Versions: 3.4.0
>            Reporter: Shilun Fan
>            Assignee: Shilun Fan
>            Priority: Major
>              Labels: pull-request-available
>
> [Federation] Router Support DelegationToken With 
> ZookeeperFederationStateStore.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org

Reply via email to