-
Notifications
You must be signed in to change notification settings - Fork 0
fix(Storage): Prevent collisions in object context tests #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,16 +128,16 @@ public void PartialResponses() | |
| [Fact] | ||
| public void ListObjectsMatchingContextKeyValuePair() | ||
| { | ||
| string contextKey = "A\u00F1\u03A9\U0001F680"; | ||
| string contextValue = "Ab\u00F1\u03A9\U0001F680"; | ||
| string contextKey = "A\u00F1\u03A9\U0001F683"; | ||
| string contextValue = "Ab\u00F1\u03A9\U0001F683"; | ||
|
Comment on lines
+131
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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> | ||
| { | ||
| { contextKey, new ObjectCustomContextPayload { Value = contextValue } } | ||
|
|
||
| }; | ||
| var destination = new Object | ||
| { | ||
| Bucket = _fixture.ReadBucket, | ||
| Bucket = _fixture.SingleVersionBucket, | ||
| Name = IdGenerator.FromGuid(), | ||
| Contexts = new Object.ContextsData { Custom = custom } | ||
| }; | ||
|
|
@@ -146,7 +146,7 @@ public void ListObjectsMatchingContextKeyValuePair() | |
| _fixture.Client.UploadObject(destination, source); | ||
| string filter = $@"contexts.""{contextKey}""=""{contextValue}"""; | ||
| var options = new ListObjectsOptions { Filter = filter }; | ||
| var objects = _fixture.Client.ListObjects(_fixture.ReadBucket, options: options).ToList(); | ||
| var objects = _fixture.Client.ListObjects(_fixture.SingleVersionBucket, options: options).ToList(); | ||
| var obj = Assert.Single(objects); | ||
| var fetchedContext = Assert.Single(obj.Contexts.Custom); | ||
| Assert.Equal(contextKey, fetchedContext.Key); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ public void ClearAllObjectContexts() | |
| var client = _fixture.Client; | ||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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()}" } } |
||
| }; | ||
|
|
||
| var destination = new Object | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.