jojochuang commented on code in PR #8884:
URL: https://github.com/apache/ozone/pull/8884#discussion_r2246153253
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java:
##########
@@ -224,12 +225,44 @@ public void write(int b) throws IOException {
doCallRealMethod().when(omDbCheckpointServletMock).getSstBackupDir();
}
- @Test
- void testContentsOfTarballWithSnapshot() throws Exception {
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testTarballBatching(boolean includeSnapshots) throws Exception {
String volumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
String bucketName = "buck" + RandomStringUtils.secure().nextNumeric(5);
AtomicReference<DBCheckpoint> realCheckpoint = new AtomicReference<>();
- setupClusterAndMocks(volumeName, bucketName, realCheckpoint);
+ setupClusterAndMocks(volumeName, bucketName, realCheckpoint,
includeSnapshots);
+ long maxFileSizeLimit = 4096;
+
om.getConfiguration().setLong(OZONE_OM_RATIS_SNAPSHOT_MAX_TOTAL_SST_SIZE_KEY,
maxFileSizeLimit);
+ // Get the tarball.
+ omDbCheckpointServletMock.doGet(requestMock, responseMock);
+ String testDirName = folder.resolve("testDir").toString();
+ String newDbDirName = testDirName + OM_KEY_PREFIX + OM_DB_NAME;
+ File newDbDir = new File(newDbDirName);
+ assertTrue(newDbDir.mkdirs());
+ FileUtil.unTar(tempFile, newDbDir);
+ long totalSize;
+ try (Stream<Path> list = Files.list(newDbDir.toPath())) {
+ totalSize = list.mapToLong(path -> path.toFile().length()).sum();
+ }
+ boolean obtainedFilesUnderMaxLimit = totalSize < maxFileSizeLimit;
+ if (!includeSnapshots) {
+ // If includeSnapshotData flag is set to false , it always sends all data
+ // in one batch and doesn't respect the max size config. This is how
Recon
+ // uses it today.
+ assertFalse(obtainedFilesUnderMaxLimit);
+ } else {
+ assertTrue(obtainedFilesUnderMaxLimit);
+ }
Review Comment:
Can simplify as:
```suggestion
assertEquals(includeSnapshots, totalSize < maxFileSizeLimit);
```
--
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]