ChenSammi commented on code in PR #6530:
URL: https://github.com/apache/ozone/pull/6530#discussion_r1584245787
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestOpenKeyCleanupService.java:
##########
@@ -257,7 +257,51 @@ public void testIgnoreExpiredRecoverhsyncKeys() throws
Exception {
waitForOpenKeyCleanup(true, BucketLayout.FILE_SYSTEM_OPTIMIZED);
// 2 keys should still remain in openKey table
- assertEquals(2, getOpenKeyInfo(BucketLayout.FILE_SYSTEM_OPTIMIZED).size());
+ assertEquals(2, getKeyInfo(BucketLayout.FILE_SYSTEM_OPTIMIZED,
true).size());
+ }
+
+ @Test
+ public void testCommitExpiredHsyncKeys() throws Exception {
+ OpenKeyCleanupService openKeyCleanupService =
+ (OpenKeyCleanupService) keyManager.getOpenKeyCleanupService();
+
+ openKeyCleanupService.suspend();
+ // wait for submitted tasks to complete
+ Thread.sleep(SERVICE_INTERVAL);
+
+ int keyCount = 10;
+ Pipeline pipeline = Pipeline.newBuilder()
+ .setState(Pipeline.PipelineState.OPEN)
+ .setId(PipelineID.randomId())
+ .setReplicationConfig(
+
StandaloneReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE))
+ .setNodes(new ArrayList<>())
+ .build();
+
+
when(om.getScmClient().getContainerClient().getContainerWithPipeline(anyLong()))
+ .thenReturn(new
ContainerWithPipeline(Mockito.mock(ContainerInfo.class), pipeline));
+
+ // Create 5 keys with directories
+ createOpenKeys(keyCount / 2, true, BucketLayout.FILE_SYSTEM_OPTIMIZED,
false, true);
+ // Create 5 keys without directory
+ createOpenKeys(keyCount / 2, true, BucketLayout.FILE_SYSTEM_OPTIMIZED,
false, false);
+
+ // wait for open keys to expire
+ Thread.sleep(EXPIRE_THRESHOLD_MS);
+
+ // 10 keys should be returned after hard limit period
+ assertEquals(keyCount, getExpiredOpenKeys(true,
BucketLayout.FILE_SYSTEM_OPTIMIZED));
+ assertExpiredOpenKeys(false, true,
+ BucketLayout.FILE_SYSTEM_OPTIMIZED);
+
+ openKeyCleanupService.resume();
+
+ // keys should be recovered and there should not be any expired key pending
+ waitForOpenKeyCleanup(true, BucketLayout.FILE_SYSTEM_OPTIMIZED);
+
+ List<OmKeyInfo> lstKeyInfo =
getKeyInfo(BucketLayout.FILE_SYSTEM_OPTIMIZED, false);
Review Comment:
lstKeyInfo -> listKeyInfo ?
--
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]