Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,16 @@ public String toString() {
.append(" and snapshot: ")
.append(getLaterSnapshotName())
.append(LINE_SEPARATOR);
for (DiffReportEntry entry : getDiffList()) {
str.append(entry.toString()).append(LINE_SEPARATOR);
}
if (StringUtils.isNotEmpty(token)) {
str.append("Next token: ")
.append(token)
.append(LINE_SEPARATOR);
if (!getDiffList().isEmpty()) {
for (DiffReportEntry entry : getDiffList()) {
str.append(entry.toString()).append(LINE_SEPARATOR);
}
if (StringUtils.isNotEmpty(token)) {
str.append("Next token: ")
.append(token);
}
} else {
str.append("No diff or no more diff for the request parameters.");
}
return str.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,14 @@ public void testSnapDiff() throws Exception {
SnapshotDiffReport.DiffType.MODIFY, key3)
);
assertEquals(expectedDiffList, diff5.getDiffList());

IOException ioException = assertThrows(IOException.class,
() -> store.snapshotDiff(volume, bucket, snap6,
snap7, "3", 0, forceFullSnapshotDiff, disableNativeDiff));
assertThat(ioException.getMessage(), containsString("Index (given: 3) " +
"should be a number >= 0 and < totalDiffEntries: 2. Page size " +
"(given: 1000) should be a positive number > 0."));

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,12 @@ SnapshotDiffReportOzone createPageResponse(
final int index,
final int pageSize
) throws IOException {
if (index < 0 || pageSize <= 0) {
throw new IllegalArgumentException(String.format(
"Index should be a number >= 0. Given index %d. Page size " +
"should be a positive number > 0. Given page size is %d",
index, pageSize));
if (index < 0 || index > snapDiffJob.getTotalDiffEntries()
|| pageSize <= 0) {
throw new IOException(String.format(
"Index (given: %d) should be a number >= 0 and < totalDiffEntries: " +
"%d. Page size (given: %d) should be a positive number > 0.",
index, snapDiffJob.getTotalDiffEntries(), pageSize));
}

OFSPath path = getSnapshotRootPath(volumeName, bucketName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ private DiffReportEntry getTestDiffEntry(String jobId,
* objectId Map of diff keys to be checked with their corresponding key names.
*/
@ParameterizedTest
@CsvSource({"0,10,1000", "1,10,8", "1000,1000,10", "-1,1000,10000",
@CsvSource({"0,10,1000", "1,10,8", "10,1000,10", "-1,1000,10000",
"1,0,1000", "1,-1,1000"})
public void testCreatePageResponse(int startIdx,
int pageSize,
Expand Down Expand Up @@ -933,7 +933,7 @@ public void testCreatePageResponse(int startIdx,
codecRegistry.asRawData(snapshotDiffJob2));

if (pageSize <= 0 || startIdx < 0) {
Assertions.assertThrows(IllegalArgumentException.class,
Assertions.assertThrows(IOException.class,
() -> snapshotDiffManager.createPageResponse(snapshotDiffJob, "vol",
"buck", "fs", "ts", startIdx, pageSize));
return;
Expand Down