ArafatKhan2198 commented on code in PR #4876:
URL: https://github.com/apache/ozone/pull/4876#discussion_r1229458607
##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestContainerEndpoint.java:
##########
@@ -1296,16 +1366,115 @@ public void testGetContainerInsightsNonOMContainers()
}
});
Response containerInsights =
- containerEndpoint.getContainerMisMatchInsights();
+ containerEndpoint.getContainerMisMatchInsights(10, 0, "OM");
+ Map<String, Object> response =
+ (Map<String, Object>) containerInsights.getEntity();
List<ContainerDiscrepancyInfo> containerDiscrepancyInfoList =
- (List<ContainerDiscrepancyInfo>) containerInsights.getEntity();
+ (List<ContainerDiscrepancyInfo>) response.get(
+ "containerDiscrepancyInfo");
ContainerDiscrepancyInfo containerDiscrepancyInfo =
containerDiscrepancyInfoList.get(0);
assertEquals(2, containerDiscrepancyInfo.getContainerID());
assertEquals(1, containerDiscrepancyInfoList.size());
assertEquals("SCM", containerDiscrepancyInfo.getExistsAt());
}
+ @Test
+ public void testGetContainerInsightsNonOMContainersWithPrevKey()
+ throws IOException, TimeoutException {
+ putContainerInfos(5);
+ List<ContainerKeyPrefix> deletedContainerKeyList =
+ reconContainerMetadataManager.getKeyPrefixesForContainer(2).entrySet()
+ .stream().map(entry ->
entry.getKey()).collect(Collectors.toList());
+ deletedContainerKeyList.forEach((ContainerKeyPrefix key) -> {
+ try (RDBBatchOperation rdbBatchOperation = new RDBBatchOperation()) {
+ reconContainerMetadataManager.batchDeleteContainerMapping(
+ rdbBatchOperation, key);
+ reconContainerMetadataManager.commitBatchOperation(rdbBatchOperation);
+ } catch (IOException e) {
+ LOG.error("Unable to write Container Key Prefix data in Recon DB.", e);
+ }
+ });
+
+ // Set prevKey and limit
+ long prevKey = 2;
+ int limit = 3;
+
+ Response containerInsights =
+ containerEndpoint.getContainerMisMatchInsights(limit, prevKey, "OM");
+ Map<String, Object> response =
+ (Map<String, Object>) containerInsights.getEntity();
+ List<ContainerDiscrepancyInfo> containerDiscrepancyInfoList =
+ (List<ContainerDiscrepancyInfo>) response.get(
+ "containerDiscrepancyInfo");
+
+ // Check the first two ContainerDiscrepancyInfo objects in the response
+ assertEquals(3, containerDiscrepancyInfoList.size());
+
+ ContainerDiscrepancyInfo containerDiscrepancyInfo1 =
+ containerDiscrepancyInfoList.get(0);
+ assertEquals(3, containerDiscrepancyInfo1.getContainerID());
+ assertEquals("SCM", containerDiscrepancyInfo1.getExistsAt());
+
+ ContainerDiscrepancyInfo containerDiscrepancyInfo2 =
+ containerDiscrepancyInfoList.get(1);
+ assertEquals(4, containerDiscrepancyInfo2.getContainerID());
+ assertEquals("SCM", containerDiscrepancyInfo2.getExistsAt());
+ }
Review Comment:
I have already implemented it for the test method
`testGetContainerInsightsNonSCMContainersWithPrevKey` which should make sure it
works for others as well, do you want me to impelemnt it for each and every
test 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: [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]