Skip to content

ci: add Linux race detector test phase - #9910

Open
Richard Park (richardpark-msft) wants to merge 10 commits into
Azure:mainfrom
richardpark-msft:rp-add-race-ci-phase
Open

ci: add Linux race detector test phase#9910
Richard Park (richardpark-msft) wants to merge 10 commits into
Azure:mainfrom
richardpark-msft:rp-add-race-ci-phase

Conversation

@richardpark-msft

@richardpark-msft Richard Park (richardpark-msft) commented Sep 8, 2026

Copy link
Copy Markdown
Member

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: -race requires 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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
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.

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.

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 High severity · 2 Medium severity · 1 Low severity

New issues introduced by this change (4)
Severity Finding
High severity eng/​pipelines/​templates/​jobs/​build-cli.yml — This Linux-only go test -race step will likely fail in the release pipeline because the Linux…
Medium severity cli/​azd/​pkg/​grpcbroker/​message_broker_test.goSend holds sim.mu while sending on the channel. If the channel buffer fills, this can block…
Medium severity 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
Low severity 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: Send keeps sim.mu locked while performing a potentially blocking channel send, which can deadlock with Close() 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.

Comment thread eng/pipelines/templates/jobs/build-cli.yml
Comment thread cli/azd/pkg/grpcbroker/message_broker_test.go
Comment thread cli/azd/pkg/ux/internal/input_test.go Outdated
Comment thread cli/azd/pkg/extensions/extension.go Outdated
ripark and others added 2 commits September 8, 2026 18:38
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…em to be optionally passed in via InputConfig.

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.

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 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity eng/​pipelines/​release-cli.yml — Include the race-test job template in PR triggers
Issues resolved since last review (4)
Severity Finding
Low severity cli/​azd/​pkg/​extensions/​extension.go — The comment above ensureInit still refers to init, which is confusing/misleading now that the… View resolved comment
Medium severity 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 ReadInputView resolved comment
Medium severity cli/​azd/​pkg/​grpcbroker/​message_broker_test.goSend holds sim.mu while sending on the channel. If the channel buffer fills, this can block… View resolved comment
High severity 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.Go instead of the manual Add/go/Done pattern (cli/azd/AGENTS.md:353). Using it here also removes the bookkeeping that can drift when this test is extended.

Comment thread eng/pipelines/release-cli.yml

@vhvb1989 Victor Vazquez (vhvb1989) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

💖

# Conflicts:
#	cli/azd/pkg/extensions/extension.go
Copilot AI review requested due to automatic review settings September 10, 2026 22:13
@richardpark-msft Richard Park (richardpark-msft) added the skip-governance Skip PR governance checks label Sep 10, 2026

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.

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 Medium severity · 1 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity cli/​azd/​pkg/​extensions/​extension_test.go — Use WaitGroup.Go for the concurrent test
Pre-existing issues (1)
Severity Finding
Medium severity eng/​pipelines/​release-cli.yml — Include the race-test job template in PR triggers View comment

Comment thread cli/azd/pkg/extensions/extension_test.go

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.

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 Medium severity

Pre-existing issues (1)
Severity Finding
Medium severity eng/​pipelines/​release-cli.yml — Include the race-test job template in PR triggers View comment
Issues resolved since last review (1)
Severity Finding
Low severity cli/​azd/​pkg/​extensions/​extension_test.go — Use WaitGroup.Go for the concurrent test View resolved comment

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.

Copilot review overview

🟢 Approval recommended

The race-test integration and associated concurrency fixes are consistent and adequately covered.

Review tier: Balanced
Findings: 1 Medium severity

Pre-existing issues (1)
Severity Finding
Medium severity 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!

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.

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 High severity

New issues introduced by this change (1)
Severity Finding
High severity 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
Medium severity eng/​pipelines/​release-cli.yml — Include the race-test job template in PR triggers View resolved comment

Comment thread cli/azd/pkg/ux/internal/input_cancellation_norace_test.go Outdated

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.

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
High severity cli/​azd/​pkg/​ux/​internal/​input_cancellation_norace_test.go — Wrap this comment below the Go line-length limit View resolved comment

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.

Copilot review overview

🟢 Approval recommended

The race phase and supporting concurrency fixes are coherent, tested, and leave the known terminal cancellation defect explicitly tracked.

Review tier: Balanced
Findings: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-governance Skip PR governance checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants