ci: add Linux race detector test phase - #9910
ci: add Linux race detector test phase#9910Richard Park (richardpark-msft) wants to merge 10 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
…`go test -race`. - Also, moving the test into the 'linux' build job since it's already setup properly to run tests.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new -race CI step will likely fail on Linux due to CGO_ENABLED=0 in the Linux matrix, and there are test-helper locking changes that can introduce potential deadlocks.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 1
New issues introduced by this change (4)
| Severity | Finding |
|---|---|
eng/pipelines/templates/jobs/build-cli.yml — This Linux-only go test -race step will likely fail in the release pipeline because the Linux… |
|
cli/azd/pkg/grpcbroker/message_broker_test.go — Send holds sim.mu while sending on the channel. If the channel buffer fills, this can block… |
|
cli/azd/pkg/ux/internal/input_test.go — With the stdin pipe removal, this test may run against a real TTY stdin. In that case ReadInput… |
|
cli/azd/pkg/extensions/extension.go — The comment above ensureInit still refers to init, which is confusing/misleading now that the… |
What changed in this PR
This PR adds a Linux-only CI phase to run go test -race to proactively catch concurrency issues, and includes a handful of code/test adjustments aimed at making existing components more race-safe and panic-safe under the new checks.
Changes:
- Add a Linux-only Azure Pipelines step to run
go test -race -short ./.... - Make extension initialization concurrency-safe via
sync.Once, with accompanying concurrency tests. - Ensure
async.RunWithProgress*always closes progress and waits for the observer goroutine even when the work function panics, and add coverage for that behavior.
| File | Description |
|---|---|
| eng/pipelines/templates/jobs/build-cli.yml | Adds a Linux-only go test -race step to CI. |
| eng/pipelines/release-cli.yml | Updates path filters so template changes trigger the pipeline. |
| cli/azd/pkg/ux/internal/input_test.go | Adjusts cancellation test setup around stdin handling. |
| cli/azd/pkg/grpcbroker/message_broker_test.go | Changes simulated stream send locking behavior in tests. |
| cli/azd/pkg/extensions/runner_test.go | Updates runner tests to assert on initialized fields rather than a removed flag. |
| cli/azd/pkg/extensions/extension.go | Switches initialization from a boolean flag to sync.Once. |
| cli/azd/pkg/extensions/extension_test.go | Adds a concurrent initialization test. |
| cli/azd/pkg/async/progress.go | Uses defer to guarantee cleanup and observer completion on panic/return. |
| cli/azd/pkg/async/progress_test.go | Adds a test validating RunWithProgress behavior on panic. |
Suppressed comments (1)
cli/azd/pkg/grpcbroker/message_broker_test.go:106
- Same issue as client-side:
Sendkeepssim.mulocked while performing a potentially blocking channel send, which can deadlock withClose()or other operations that need the mutex.
s.sim.mu.Lock()
defer s.sim.mu.Unlock()
if s.sim.closed {
return io.EOF
}
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…em to be optionally passed in via InputConfig.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The PR trigger does not include the job template containing the new race-test phase.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
eng/pipelines/release-cli.yml — Include the race-test job template in PR triggers |
Issues resolved since last review (4)
| Severity | Finding |
|---|---|
cli/azd/pkg/extensions/extension.go — The comment above ensureInit still refers to init, which is confusing/misleading now that the… View resolved comment |
|
cli/azd/pkg/ux/internal/input_test.go — With the stdin pipe removal, this test may run against a real TTY stdin. In that case ReadInput… View resolved comment |
|
cli/azd/pkg/grpcbroker/message_broker_test.go — Send holds sim.mu while sending on the channel. If the channel buffer fills, this can block… View resolved comment |
|
eng/pipelines/templates/jobs/build-cli.yml — This Linux-only go test -race step will likely fail in the release pipeline because the Linux… View resolved comment |
Previously missed findings (1)
In code that hasn't changed since last review
cli/azd/pkg/extensions/extension_test.go:176
- The repository's Go 1.26 guidance requires
WaitGroup.Goinstead of the manualAdd/go/Donepattern (cli/azd/AGENTS.md:353). Using it here also removes the bookkeeping that can drift when this test is extended.
# Conflicts: # cli/azd/pkg/extensions/extension.go
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The PR trigger omits the modified build job template, leaving future edits to the race phase unvalidated.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
cli/azd/pkg/extensions/extension_test.go — Use WaitGroup.Go for the concurrent test |
Pre-existing issues (1)
| Severity | Finding |
|---|---|
eng/pipelines/release-cli.yml — Include the race-test job template in PR triggers View comment |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The PR path filter does not trigger validation for future changes to the race-test job template.
Review tier: Balanced
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
eng/pipelines/release-cli.yml — Include the race-test job template in PR triggers View comment |
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
cli/azd/pkg/extensions/extension_test.go — Use WaitGroup.Go for the concurrent test View resolved comment |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The race-test integration and associated concurrency fixes are consistent and adequately covered.
Review tier: Balanced
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
eng/pipelines/release-cli.yml — Include the race-test job template in PR triggers View comment |
…issue for it - it's a bit complicated to fix, not something I want to tackle as part of this (much simpler) PR!
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
A newly added Go comment exceeds the enforced 125-character line limit.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
cli/azd/pkg/ux/internal/input_cancellation_norace_test.go — Wrap this comment below the Go line-length limit |
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
eng/pipelines/release-cli.yml — Include the race-test job template in PR triggers View resolved comment |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The race phase and supporting concurrency fixes are consistent and adequately tested.
Review tier: Balanced
Findings: None
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
cli/azd/pkg/ux/internal/input_cancellation_norace_test.go — Wrap this comment below the Go line-length limit View resolved comment |



Add a phase to our tests that runs
go test -race, so we can start making sure our concurrency code is correct. I ran into a few concurrency bugs as I was building out the layers PR, and this would have caught some of them.NOTE:
-racerequires us to have a c compiler, so sticking with Linux only for now. Cursory examination shows that we don't have a ton of platform specific code that would be affected here, but eventually we can look into doing this on Windows, and Mac.This actually showed a deeper issue than what we should address in this PR, filed here: #9995