TestSnapshotSummary#testFileSizeSummaryWithDVs is a flaky test that fails intermittently in CI.
FileGenerationUtil.generateContentLength() uses random().nextInt(10_000), which can return 0 with a probability of 1/10,000.
When a DV's contentSizeInBytes is 0:
addedSize accumulates to 0 in UpdateMetrics.addedFile()
SnapshotSummary.addTo() skips writing the "added-files-size" field due to the guard setIf(addedSize > 0, builder, ADDED_FILE_SIZE_PROP, addedSize)
- The snapshot summary ends up with 18 fields instead of the expected 19
assertThat(summary2).hasSize(19) fails
Failure Output
Fix
Change generateContentLength() in FileGenerationUtil to guarantee a positive value:
TestSnapshotSummary#testFileSizeSummaryWithDVsis a flaky test that fails intermittently in CI.FileGenerationUtil.generateContentLength()usesrandom().nextInt(10_000), which can return 0 with a probability of 1/10,000.When a DV's
contentSizeInBytesis 0:addedSizeaccumulates to 0 inUpdateMetrics.addedFile()SnapshotSummary.addTo()skips writing the"added-files-size"field due to the guardsetIf(addedSize > 0, builder, ADDED_FILE_SIZE_PROP, addedSize)assertThat(summary2).hasSize(19)failsFailure Output
Fix
Change
generateContentLength()inFileGenerationUtilto guarantee a positive value: