smengcl commented on code in PR #3618:
URL: https://github.com/apache/ozone/pull/3618#discussion_r929295815


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMultiTenantManagerImpl.java:
##########
@@ -98,9 +88,35 @@ public void setUp() throws IOException {
         .thenReturn(ozoneConfiguration);
 
     tenantManager = new OMMultiTenantManagerImpl(ozoneManager, conf);
-    assertEquals(1, tenantManager.getTenantCache().size());
-    assertEquals(1, tenantManager.getTenantCache().get(TENANT_ID)
-        .getAccessIdInfoMap().size());
+  }
+
+  /**
+   * Tests rebuilding the tenant cache on restart.
+   */
+  @Test
+  public void testReloadCache() throws IOException {
+    // Create a tenant with multiple users.
+    CachedTenantState expectedTenant2State = createTenant("tenant2");
+    assignUserToTenant(expectedTenant2State, "access2", "user2", false, false);
+    assignUserToTenant(expectedTenant2State, "access3", "user2", true, false);
+    assignUserToTenant(expectedTenant2State, "access4", "user2", true, true);
+
+    // Create a tenant with no users.
+    CachedTenantState expectedTenant3State = createTenant("tenant3");
+
+    // Reload the cache as part of new object creation.
+    OMMultiTenantManagerImpl tenantManager2 =
+        new OMMultiTenantManagerImpl(ozoneManager, conf);
+    // Check that the cache was restored correctly.
+    // Setup created a tenant in addition to the ones created for this test.
+    assertEquals(3, tenantManager2.getTenantCache().size());
+    // Check tenant2
+    assertEquals(expectedTenant2State, tenantManager.getTenantCache()
+        .get("tenant2"));

Review Comment:
   nvm. included.



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMultiTenantManagerImpl.java:
##########
@@ -98,9 +88,35 @@ public void setUp() throws IOException {
         .thenReturn(ozoneConfiguration);
 
     tenantManager = new OMMultiTenantManagerImpl(ozoneManager, conf);
-    assertEquals(1, tenantManager.getTenantCache().size());
-    assertEquals(1, tenantManager.getTenantCache().get(TENANT_ID)
-        .getAccessIdInfoMap().size());
+  }
+
+  /**
+   * Tests rebuilding the tenant cache on restart.
+   */
+  @Test
+  public void testReloadCache() throws IOException {
+    // Create a tenant with multiple users.
+    CachedTenantState expectedTenant2State = createTenant("tenant2");
+    assignUserToTenant(expectedTenant2State, "access2", "user2", false, false);
+    assignUserToTenant(expectedTenant2State, "access3", "user2", true, false);
+    assignUserToTenant(expectedTenant2State, "access4", "user2", true, true);
+
+    // Create a tenant with no users.
+    CachedTenantState expectedTenant3State = createTenant("tenant3");
+
+    // Reload the cache as part of new object creation.
+    OMMultiTenantManagerImpl tenantManager2 =
+        new OMMultiTenantManagerImpl(ozoneManager, conf);
+    // Check that the cache was restored correctly.
+    // Setup created a tenant in addition to the ones created for this test.
+    assertEquals(3, tenantManager2.getTenantCache().size());
+    // Check tenant2
+    assertEquals(expectedTenant2State, tenantManager.getTenantCache()
+        .get("tenant2"));
+    // Check tenant3
+    assertEquals(expectedTenant3State, tenantManager.getTenantCache()
+        .get("tenant3"));

Review Comment:
   nvm. included



-- 
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