Repository navigation
test(enterprise): run the Terraform workspace tag tests in parallel - #33018
Merged
Merged
Conversation
TestWorkspaceTagsTerraform ran its 20 real Terraform builds one after another, because it set TF_CLI_CONFIG_FILE with t.Setenv, and a test that calls t.Setenv cannot run in parallel. It took about 70 of the package's 120 seconds. NewExternalProvisionerDaemonTerraform now takes the Terraform CLI config path and gives it to the provisioner, which already passes it to Terraform. TestWorkspaceTagsTerraform, its subtests, and TestWorkspaceTemplateParamsChange use that and call t.Parallel.
sreya
approved these changes
Dec 6, 2026
kylecarbs
marked this pull request as ready for review
December 6, 2026 08:13
kylecarbs
had a problem deploying
to
docs-preview
December 6, 2026 08:13 — with
GitHub Actions
Failure
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TestWorkspaceTagsTerraformran its 20 real Terraform builds one after another. It setTF_CLI_CONFIG_FILEwitht.Setenv, and a test that callst.Setenvcannot run in parallel.coderdenttest.NewExternalProvisionerDaemonTerraformnow takes the Terraform CLI config path and setsterraform.ServeOptions.CliConfigPath, which the provisioner already passes to Terraform.TestWorkspaceTagsTerraform, its subtests, andTestWorkspaceTemplateParamsChange(which used the samet.Setenv) pass the path that way and callt.Parallel().enterprise/coderdtest binary,mainat 9023596 against this branch (12 cores, local Postgres 17,-tags=testsmallbatch -test.parallel=8, two runs each, 1,229 tests passed in every run):mainTotal CPU goes up by about 10% because up to eight Terraform builds now run at once and each one takes longer than it did alone (about 7 s against 3.5 s). The package used 3 of 12 cores before and uses 7 now.
CI on this PR passed on Linux, macOS, Windows, and with
-race. Windows has no provider cache, so there each build downloads the provider from the registry, now several at a time. I did not measure the gain on CI runners:enterprise/coderdtook 69.5 s in this PR's Linux job against 212.5 s in the last full run (#33011), but this run served most other packages from the test cache, so the two are not comparable.Decision log
Why a parameter.
NewExternalProvisionerDaemonTerraformhas three callers. A required parameter makes each one state its choice; the scale test passes""and keeps Terraform's default config. An options struct seemed too much for one field.The config still takes effect. With
HTTPS_PROXYpointed at a closed port, so that the registry is unreachable,TestWorkspaceTemplateParamsChangeandTestWorkspaceTagsTerraform/{tag_param,no_tags}pass on this branch. A plainterraform initof the same provider block fails under that proxy setting. So the builds use the provider mirror named in the config file.Isolation between parallel builds. Each provisioner daemon already has its own
CachePathand work directory (t.TempDir()), so parallel builds do not share a plugin cache. They only read the provider mirror. The CLI config file lives in the persistent cache directory, not in a test's temporary directory, so it is still there when the parallel subtests run after the parent function returns.Flake check. The two tests passed 6 times in a row at
-test.parallel=8and twice at-test.parallel=16(32 results per run).Checks run locally.
golangci-linton./enterprise/coderd/...and./enterprise/scaletest/prebuilds/...,paralleltestctxon./enterprise/...,make lint/go/new-code lint/emdash, and the fullenterprise/coderdpackage four times.enterprise/scaletest/prebuildswas compiled and vetted, not run.This PR was generated by Coder Agents on behalf of @kylecarbs.