Copilot commented on code in PR #11666:
URL: https://github.com/apache/ozone/pull/11666#discussion_r4338242510


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMultiTenantManagerImpl.java:
##########
@@ -114,6 +121,16 @@ public void testReloadCache() throws IOException {
 
   }
 
+  @Test
+  public void testReloadCacheWithNoTenants() throws IOException {
+    omMetadataManager.getTenantAccessIdTable().delete("seed-accessId1");
+    omMetadataManager.getTenantStateTable().delete(TENANT_ID);
+
+    OMMultiTenantManagerImpl emptyTenantManager = new 
OMMultiTenantManagerImpl(ozoneManager, conf);
+    assertThat(emptyTenantManager.getTenantCache()).isEmpty();
+    verify(omMetrics).setNumTenants(0);

Review Comment:
   This assertion only checks that `setNumTenants(0)` was called at least once, 
but it doesn’t validate that the *final* value after the reload is 0 
(especially if other `setNumTenants(...)` calls happen during setup/other 
operations in the same test). To make the intent explicit, consider capturing 
the argument values (via an ArgumentCaptor) and asserting the last one is 0, or 
reset the mock right before constructing `emptyTenantManager`.



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMultiTenantManagerImpl.java:
##########
@@ -102,6 +108,7 @@ public void testReloadCache() throws IOException {
     // Reload the cache as part of new object creation.
     OMMultiTenantManagerImpl tenantManager2 =
         new OMMultiTenantManagerImpl(ozoneManager, conf);
+    verify(omMetrics).setNumTenants(3);

Review Comment:
   These verifications don’t enforce call count or ordering, so the test can 
pass even if `setNumTenants(...)` is invoked multiple times or out of sequence. 
Consider using `InOrder` to assert `setNumTenants(1)` happens before 
constructing `tenantManager2` and `setNumTenants(3)` happens after, and/or use 
`times(1)` to make the expectation strict.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to