Skip to content

fix(storage): resolve race conditions in archived generation tests - #3341

Merged
krishnamd-jkp merged 2 commits into
GoogleCloudPlatform:mainfrom
mahendra-google:fix/file-archived-generation-tests-flakes
Aug 18, 2026
Merged

krishnamd-jkp merged 2 commits into
GoogleCloudPlatform:mainfrom
mahendra-google:fix/file-archived-generation-tests-flakes

Conversation

@mahendra-google

Copy link
Copy Markdown
Contributor

This PR provides a fix to the issue and
resolves the test flakiness observed in the archived generation tests (such as CopyFileArchivedGenerationTest , ListFileArchivedGenerationTest and DeleteFileArchivedGenerationTest).

Previously, these tests were failing intermittently with 404 No such object or assertion errors (Expected: 2, Actual: 1).

Because the tests were creating, deleting objects immediately after enabling versioning on the bucket, GCS had not always propagated the versioning state, resulting in objects being permanently deleted instead of archived.

This PR removes bucket versioning toggling from generation tests and introduces BucketNameVersioned (shared versioned bucket) in the StorageFixture and utilized shared versioned bucket across all generation tests eliminating race conditions.

Introduce a pre-configured versioned bucket in the StorageFixture to eliminate
GCS metadata propagation delays and utilized shared versioned bucket across all generation tests
@mahendra-google
mahendra-google requested review from a team as code owners August 4, 2026 08:57
@product-auto-label product-auto-label Bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Aug 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors several integration tests—specifically CopyFileArchivedGenerationTest, DeleteFileArchivedGenerationTest, and ListFileArchivedGenerationTest—to use a shared, pre-configured versioned bucket (BucketNameVersioned) from the test fixture, eliminating the need to repeatedly enable and disable versioning within individual tests. It also cleans up unused sample variables and standardizes object name generation. The review feedback correctly identifies a performance issue in DeleteFileArchivedGenerationTest.cs where an IEnumerable is enumerated multiple times, causing redundant HTTP requests, and suggests materializing the sequence to avoid this.

Comment thread storage/api/Storage.Samples.Tests/DeleteFileArchivedGenerationTest.cs Outdated
Comment thread storage/api/Storage.Samples.Tests/ListFileArchivedGenerationTest.cs Outdated
Comment thread storage/api/Storage.Samples.Tests/CopyFileArchivedGenerationTest.cs Outdated
@krishnamd-jkp krishnamd-jkp added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 18, 2026
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 18, 2026
@krishnamd-jkp
krishnamd-jkp merged commit 068dbd0 into GoogleCloudPlatform:main Aug 18, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants