Skip to content

Avoid random generator races in concurrent Storage tests - #7305

Merged
JinmingHu (Jinming-Hu) merged 2 commits into
mainfrom
stgxx_fix_concurrent_test_random_races
Aug 10, 2026
Merged

Avoid random generator races in concurrent Storage tests#7305
JinmingHu (Jinming-Hu) merged 2 commits into
mainfrom
stgxx_fix_concurrent_test_random_races

Conversation

@Jinming-Hu

@Jinming-Hu JinmingHu (Jinming-Hu) commented Aug 8, 2026

Copy link
Copy Markdown
Member

Purpose

Avoid calling StorageTest random helpers from concurrent test workers. These helpers are explicitly not thread-safe and can generate conflicting local filenames or resource names under load.

Changes

  • Generate concurrent download filenames before launching workers in Blobs, Data Lake, and File Shares tests.
  • Generate structured-message blob names before launching Blob workers.
  • Use deterministic per-worker names in the disabled Data Lake pagination stress test.

Validation

  • Built azure-storage-blobs-test, azure-storage-files-datalake-test, and azure-storage-files-shares-test in Release.
  • Passed 3 consecutive LIVE iterations of:
    • BlockBlobClientTest.ConcurrentDownload_LIVEONLY_
    • BlockBlobClientTest.StructuredMessageTest_Concurrent_LIVEONLY_
    • DataLakeFileClientTest.ConcurrentDownload_LIVEONLY_
    • FileShareFileClientTest.ConcurrentDownload_LIVEONLY_
  • The disabled Data Lake pagination stress test was compile-validated only because it requires a special AAD app without RBAC permissions.

Generate resource names on the test thread before launching async work so StorageTest's non-thread-safe random helpers are not called concurrently.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Storage Storage Service (Queues, Blobs, Files) label Aug 8, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
9 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@Jinming-Hu

Copy link
Copy Markdown
Member Author

/azp run cpp - storage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
9 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Azure Storage unit tests to avoid calling non-thread-safe StorageTest random helpers from concurrent worker threads, preventing filename/blob-name collisions and race conditions during stress/concurrency runs.

Changes:

  • Pre-generate per-worker download-to-file temporary filenames on the main thread before launching std::async workers (Blobs, Data Lake, File Shares).
  • Pre-generate structured-message blob names before launching concurrent blob workers.
  • Replace per-thread RandomString() file naming with deterministic workerIndex-fileIndex naming in the disabled Data Lake pagination stress test.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp Passes a pre-generated temp filename into the async download-to-file worker to avoid thread-unsafe random calls.
sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.cpp Uses deterministic per-worker/per-file names to avoid concurrent RandomString() usage in a disabled stress test.
sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.cpp Moves temp filename generation out of the async worker by passing it as an argument.
sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp Moves temp filename and structured-message blob-name generation out of concurrent workers to avoid random-helper races.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Jinming-Hu
JinmingHu (Jinming-Hu) merged commit 6aafc66 into main Aug 10, 2026
44 checks passed
@Jinming-Hu
JinmingHu (Jinming-Hu) deleted the stgxx_fix_concurrent_test_random_races branch August 10, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storage Storage Service (Queues, Blobs, Files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants