fix(Storage): Prevent collisions in object context tests#13
fix(Storage): Prevent collisions in object context tests#13mahendra-google wants to merge 1 commit into
Conversation
Update copy, list, and patch object tests to utilize unique context keys and values. This ensures isolation during test execution on single-version buckets and prevents cross-test interference.
There was a problem hiding this comment.
Code Review
This pull request updates several integration tests by modifying hardcoded Unicode characters in object context keys and values. Additionally, the ListObjectsMatchingContextKeyValuePair test was updated to use SingleVersionBucket instead of ReadBucket. The review feedback suggests further improving test isolation by appending dynamic unique identifiers to the context keys and values to prevent potential collisions during concurrent test runs.
| string contextKey = "A\u00F1\u03A9\U0001F681"; | ||
| string contextValue = "Ab\u00F1\u03A9\U0001F681"; |
There was a problem hiding this comment.
While changing the Unicode character reduces the immediate collision risk between tests, hardcoding these values still leaves the tests vulnerable to collisions if multiple test runs occur simultaneously against the same bucket (e.g., in a CI environment). To ensure true isolation and prevent flakiness, consider appending a unique identifier to the keys and values.
string contextKey = $"A\u00F1\u03A9\U0001F681-{IdGenerator.FromGuid()}";
string contextValue = $"Ab\u00F1\u03A9\U0001F681-{IdGenerator.FromGuid()}";| string contextKey = "A\u00F1\u03A9\U0001F683"; | ||
| string contextValue = "Ab\u00F1\u03A9\U0001F683"; |
There was a problem hiding this comment.
Using a dynamic suffix for the context key and value ensures that this test remains isolated even when multiple instances of the test suite run concurrently against the same shared bucket resources.
string contextKey = $"A\u00F1\u03A9\U0001F683-{IdGenerator.FromGuid()}";
string contextValue = $"Ab\u00F1\u03A9\U0001F683-{IdGenerator.FromGuid()}";| var custom = new Dictionary<string, ObjectCustomContextPayload> | ||
| { | ||
| { "A\u00F1\u03A9\U0001F680", new ObjectCustomContextPayload { Value = "Ab\u00F1\u03A9\U0001F680" } } | ||
| { "A\u00F1\u03A9\U0001F682", new ObjectCustomContextPayload { Value = "Ab\u00F1\u03A9\U0001F682" } } |
There was a problem hiding this comment.
Hardcoding the context key and value here still poses a risk of collision during concurrent test execution. Using dynamic values with a unique identifier would provide better isolation and reliability.
{ $"A\u00F1\u03A9\U0001F682-{IdGenerator.FromGuid()}", new ObjectCustomContextPayload { Value = $"Ab\u00F1\u03A9\U0001F682-{IdGenerator.FromGuid()}" } }
Update copy, list, and patch object tests to utilize unique context keys and values. This ensures isolation during test execution on single-version buckets and prevents cross-test interference.