Skip to content

Flaky TestSnapshotSummary#testFileSizeSummaryWithDVs caused by generateContentLength returning 0 #16542

@lilei1128

Description

@lilei1128

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:

  1. addedSize accumulates to 0 in UpdateMetrics.addedFile()
  2. SnapshotSummary.addTo() skips writing the "added-files-size" field due to the guard setIf(addedSize > 0, builder, ADDED_FILE_SIZE_PROP, addedSize)
  3. The snapshot summary ends up with 18 fields instead of the expected 19
  4. assertThat(summary2).hasSize(19) fails

Failure Output

Image

Fix

Change generateContentLength() in FileGenerationUtil to guarantee a positive value:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions