Skip to content

fix(cli): scope context per subtest to fix flake test in prebuilt workspace delete #18872

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

Merged
merged 1 commit into from
Jul 15, 2025

Conversation

ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented Jul 15, 2025

Description

This PR fixes a flaky test in TestDelete/Prebuilt_workspace_delete_permissions: coder/internal#764

Previously, all subtests used the same context created at the top level. Since the subtests run in parallel, they could run for too long and cause the shared context to expire. This sometimes led to context deadline exceeded errors, especially during the testutil.Eventually check for running prebuilt workspaces.

The fix is to create a fresh context per subtest, ensuring they are isolated and not prematurely cancelled due to other subtests' durations.

@ssncferreira ssncferreira changed the title fix(cli): flake test in prebuilt workspace delete by scoping context per subtest fix(cli): scope context per subtest to fix flake test in prebuilt workspace delete Jul 15, 2025
Copy link
Member

@ethanndickson ethanndickson left a comment

Choose a reason for hiding this comment

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

👍 - shoutout spike's blog post on this topic: https://coder.com/blog/go-testing-contexts-and-t-parallel

@ssncferreira ssncferreira merged commit f1eec2d into main Jul 15, 2025
34 checks passed
@ssncferreira ssncferreira deleted the ssncferreira/fix-flake-cli-prebuilt-delete-ctx branch July 15, 2025 09:21
@github-actions github-actions bot locked and limited conversation to collaborators Jul 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants