ArafatKhan2198 commented on code in PR #12208:
URL: https://github.com/apache/ozone/pull/12208#discussion_r4810318570
##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestNSSummaryTaskWithLegacy.java:
##########
@@ -389,6 +392,44 @@ public void testProcessDirDeleteRename() throws
IOException {
// after renaming dir1, check its new name
assertEquals(DIR_ONE_RENAME, nsSummaryForDir1.getDirName());
}
+
+ /**
+ * An update of a directory key (for example an ACL change) is an UPDATE
event whose old and new
+ * values are the same directory, and must not change the totals of its
ancestors.
+ */
+ @Test
+ public void testProcessDirKeyUpdateKeepsAncestorTotals() throws
IOException {
+ // rebuild the summaries from the DB, without the event batch processed
+ getReconNamespaceSummaryManager().clearNSSummaryTable();
+ nSSummaryTaskWithLegacy.reprocessWithLegacy(getReconOMMetadataManager());
+
Review Comment:
Would it be cleaner to move this test outside the nested TestProcess class?
We could avoid processing the unrelated event batch and then clearing and
rebuilding the namespace summary again.
##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestNSSummaryTaskWithLegacy.java:
##########
@@ -389,6 +392,44 @@ public void testProcessDirDeleteRename() throws
IOException {
// after renaming dir1, check its new name
assertEquals(DIR_ONE_RENAME, nsSummaryForDir1.getDirName());
}
+
+ /**
+ * An update of a directory key (for example an ACL change) is an UPDATE
event whose old and new
+ * values are the same directory, and must not change the totals of its
ancestors.
+ */
+ @Test
+ public void testProcessDirKeyUpdateKeepsAncestorTotals() throws
IOException {
+ // rebuild the summaries from the DB, without the event batch processed
+ getReconNamespaceSummaryManager().clearNSSummaryTable();
+ nSSummaryTaskWithLegacy.reprocessWithLegacy(getReconOMMetadataManager());
+
+ String dirTwoKey = DIR_ONE + OM_KEY_PREFIX + DIR_TWO + OM_KEY_PREFIX;
+ OMDBUpdateEvent updateEvent = new
OMDBUpdateEvent.OMUpdateEventBuilder<String, OmKeyInfo>()
+ .setKey(OM_KEY_PREFIX + VOL + OM_KEY_PREFIX + BUCKET_ONE +
OM_KEY_PREFIX + dirTwoKey)
+ .setValue(buildOmDirKeyInfo(VOL, BUCKET_ONE, dirTwoKey, DIR_TWO,
DIR_TWO_OBJECT_ID))
+ .setOldValue(buildOmDirKeyInfo(VOL, BUCKET_ONE, dirTwoKey, DIR_TWO,
DIR_TWO_OBJECT_ID))
+ .setAction(OMDBUpdateEvent.OMDBUpdateAction.UPDATE)
+
.setTable(getOmMetadataManager().getKeyTable(getBucketLayout()).getName())
+ .build();
+ ProcessResult result = nSSummaryTaskWithLegacy.processWithLegacy(
+ new OMUpdateEventBatch(Collections.singletonList(updateEvent), 0L),
0);
+ assertTrue(result.success());
+
+ NSSummary nsSummaryForDir2 =
getReconNamespaceSummaryManager().getNSSummary(DIR_TWO_OBJECT_ID);
+ assertEquals(DIR_ONE_OBJECT_ID, nsSummaryForDir2.getParentId());
+
+ NSSummary nsSummaryForDir1 =
getReconNamespaceSummaryManager().getNSSummary(DIR_ONE_OBJECT_ID);
+ dirOneAns.clear();
+ dirOneAns.add(DIR_TWO_OBJECT_ID);
+ dirOneAns.add(DIR_THREE_OBJECT_ID);
+ assertEquals(dirOneAns, nsSummaryForDir1.getChildDir());
+ assertEquals(1, nsSummaryForDir1.getNumOfFiles());
+ assertEquals(KEY_THREE_SIZE, nsSummaryForDir1.getSizeOfFiles());
+
+ NSSummary nsSummaryForBucket =
getReconNamespaceSummaryManager().getNSSummary(BUCKET_ONE_OBJECT_ID);
+ assertEquals(2, nsSummaryForBucket.getNumOfFiles());
+ assertEquals(KEY_ONE_SIZE + KEY_THREE_SIZE,
nsSummaryForBucket.getSizeOfFiles());
Review Comment:
Could we also verify the replicated size here and for the parent directory?
Both the delete and put handlers update the replicated size, so it would be
good to ensure that remains unchanged as well.
##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestNSSummaryTaskWithLegacy.java:
##########
@@ -389,6 +392,44 @@ public void testProcessDirDeleteRename() throws
IOException {
// after renaming dir1, check its new name
assertEquals(DIR_ONE_RENAME, nsSummaryForDir1.getDirName());
}
+
+ /**
+ * An update of a directory key (for example an ACL change) is an UPDATE
event whose old and new
+ * values are the same directory, and must not change the totals of its
ancestors.
+ */
+ @Test
+ public void testProcessDirKeyUpdateKeepsAncestorTotals() throws
IOException {
+ // rebuild the summaries from the DB, without the event batch processed
+ getReconNamespaceSummaryManager().clearNSSummaryTable();
+ nSSummaryTaskWithLegacy.reprocessWithLegacy(getReconOMMetadataManager());
Review Comment:
Could we also assert that the reprocessing was successful before proceeding
with the UPDATE event?
--
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]