From 88ad267bd5fdf9a654a4c3d117a51f2f425214e6 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Fri, 21 Feb 2025 16:23:44 +0000 Subject: [PATCH 1/4] add `t.Parallel()` everywhere --- .golangci.yml | 1 + integration/integration_test.go | 1 + internal/provider/group_data_source_test.go | 1 + internal/provider/group_resource_test.go | 2 ++ internal/provider/license_resource_test.go | 1 + internal/provider/organization_data_source_test.go | 1 + internal/provider/organization_resource_test.go | 1 + .../provider/organization_sync_settings_resource_test.go | 1 + internal/provider/provider_test.go | 1 + internal/provider/provisioner_key_resource_test.go | 1 + internal/provider/template_data_source_test.go | 1 + internal/provider/template_resource_test.go | 5 +++++ internal/provider/user_data_source_test.go | 1 + internal/provider/user_resource_test.go | 1 + internal/provider/uuid_internal_test.go | 2 -- internal/provider/workspace_proxy_resource_test.go | 2 ++ 16 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 98eed9e..5e4c54f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,6 +18,7 @@ linters: - makezero - misspell - nilerr + - paralleltest - predeclared - staticcheck - unconvert diff --git a/integration/integration_test.go b/integration/integration_test.go index aeb90a5..f1937b6 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -22,6 +22,7 @@ import ( // - Runs the `main.tf` specified in the given test directory against the Coder deployment // - Asserts the state of the deployment via `codersdk`. func TestIntegration(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "1" { t.Skip("Skipping integration tests during tf acceptance tests") } diff --git a/internal/provider/group_data_source_test.go b/internal/provider/group_data_source_test.go index 5a081af..6581343 100644 --- a/internal/provider/group_data_source_test.go +++ b/internal/provider/group_data_source_test.go @@ -16,6 +16,7 @@ import ( ) func TestAccGroupDataSource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/group_resource_test.go b/internal/provider/group_resource_test.go index 865851a..090e504 100644 --- a/internal/provider/group_resource_test.go +++ b/internal/provider/group_resource_test.go @@ -16,6 +16,7 @@ import ( ) func TestAccGroupResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -133,6 +134,7 @@ func TestAccGroupResource(t *testing.T) { } func TestAccGroupResourceAGPL(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/license_resource_test.go b/internal/provider/license_resource_test.go index 9a4abc7..fe124cd 100644 --- a/internal/provider/license_resource_test.go +++ b/internal/provider/license_resource_test.go @@ -13,6 +13,7 @@ import ( ) func TestAccLicenseResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/organization_data_source_test.go b/internal/provider/organization_data_source_test.go index c7bb982..9eb9c86 100644 --- a/internal/provider/organization_data_source_test.go +++ b/internal/provider/organization_data_source_test.go @@ -16,6 +16,7 @@ import ( ) func TestAccOrganizationDataSource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/organization_resource_test.go b/internal/provider/organization_resource_test.go index 0a755c4..6afb076 100644 --- a/internal/provider/organization_resource_test.go +++ b/internal/provider/organization_resource_test.go @@ -19,6 +19,7 @@ import ( ) func TestAccOrganizationResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/organization_sync_settings_resource_test.go b/internal/provider/organization_sync_settings_resource_test.go index 66f7b81..0d55b71 100644 --- a/internal/provider/organization_sync_settings_resource_test.go +++ b/internal/provider/organization_sync_settings_resource_test.go @@ -18,6 +18,7 @@ import ( ) func TestAccOrganizationSyncSettingsResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 2f8b921..cc9fba6 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -16,6 +16,7 @@ var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServe } func testAccPreCheck(t *testing.T) { + t.Parallel() // You can add code here to run prior to any test case execution, for example assertions // about the appropriate environment variables being set are common to see in a pre-check // function. diff --git a/internal/provider/provisioner_key_resource_test.go b/internal/provider/provisioner_key_resource_test.go index 9c89647..7b05568 100644 --- a/internal/provider/provisioner_key_resource_test.go +++ b/internal/provider/provisioner_key_resource_test.go @@ -18,6 +18,7 @@ import ( ) func TestAccProvisionerKeyResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/template_data_source_test.go b/internal/provider/template_data_source_test.go index f6759b3..564e12f 100644 --- a/internal/provider/template_data_source_test.go +++ b/internal/provider/template_data_source_test.go @@ -20,6 +20,7 @@ import ( ) func TestAccTemplateDataSource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/template_resource_test.go b/internal/provider/template_resource_test.go index 5bb1e3b..f5ff8bb 100644 --- a/internal/provider/template_resource_test.go +++ b/internal/provider/template_resource_test.go @@ -23,6 +23,7 @@ import ( ) func TestAccTemplateResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -637,6 +638,7 @@ func TestAccTemplateResource(t *testing.T) { } func TestAccTemplateResourceEnterprise(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -782,6 +784,7 @@ func TestAccTemplateResourceEnterprise(t *testing.T) { } func TestAccTemplateResourceAGPL(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -875,6 +878,7 @@ func TestAccTemplateResourceAGPL(t *testing.T) { } func TestAccTemplateResourceVariables(t *testing.T) { + t.Parallel() cfg := ` provider coderd { url = %q @@ -1137,6 +1141,7 @@ func testAccCheckNumTemplateVersions(ctx context.Context, client *codersdk.Clien } func TestReconcileVersionIDs(t *testing.T) { + t.Parallel() aUUID := uuid.New() bUUID := uuid.New() cases := []struct { diff --git a/internal/provider/user_data_source_test.go b/internal/provider/user_data_source_test.go index 6a9309f..695ae27 100644 --- a/internal/provider/user_data_source_test.go +++ b/internal/provider/user_data_source_test.go @@ -16,6 +16,7 @@ import ( ) func TestAccUserDataSource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/user_resource_test.go b/internal/provider/user_resource_test.go index b9c6bb7..dd515d9 100644 --- a/internal/provider/user_resource_test.go +++ b/internal/provider/user_resource_test.go @@ -14,6 +14,7 @@ import ( ) func TestAccUserResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/uuid_internal_test.go b/internal/provider/uuid_internal_test.go index 697d9c3..f4a2034 100644 --- a/internal/provider/uuid_internal_test.go +++ b/internal/provider/uuid_internal_test.go @@ -50,7 +50,6 @@ func TestUUIDTypeValueFromTerraform(t *testing.T) { for _, test := range tests { test := test t.Run(test.name, func(t *testing.T) { - t.Parallel() ctx := context.Background() actual, err := uuidType.ValueFromTerraform(UUIDType, ctx, test.input) @@ -85,7 +84,6 @@ func TestUUIDToStringValue(t *testing.T) { for name, test := range tests { name, test := name, test t.Run(name, func(t *testing.T) { - t.Parallel() ctx := context.Background() s, _ := test.uuid.ToStringValue(ctx) diff --git a/internal/provider/workspace_proxy_resource_test.go b/internal/provider/workspace_proxy_resource_test.go index 88d7013..641d1d9 100644 --- a/internal/provider/workspace_proxy_resource_test.go +++ b/internal/provider/workspace_proxy_resource_test.go @@ -15,6 +15,7 @@ import ( ) func TestAccWorkspaceProxyResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -56,6 +57,7 @@ func TestAccWorkspaceProxyResource(t *testing.T) { } func TestAccWorkspaceProxyResourceAGPL(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } From 88ae71ddf78a9e26beb9c8e5ec961e143302c33b Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Fri, 21 Feb 2025 19:22:52 +0000 Subject: [PATCH 2/4] fmt --- internal/provider/provider_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index cc9fba6..7dab7ff 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -16,7 +16,7 @@ var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServe } func testAccPreCheck(t *testing.T) { - t.Parallel() + t.Helper() // You can add code here to run prior to any test case execution, for example assertions // about the appropriate environment variables being set are common to see in a pre-check // function. From e05d30b696cbd65b81a6d6552d86173649868dcc Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Fri, 21 Feb 2025 22:48:47 +0000 Subject: [PATCH 3/4] couple bits --- .golangci.yml | 6 ++++++ Makefile | 4 ++-- integration/integration_test.go | 2 ++ internal/provider/template_resource_test.go | 2 ++ internal/provider/uuid_internal_test.go | 8 ++++---- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 5e4c54f..7efde44 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -25,3 +25,9 @@ linters: - unparam - unused - usetesting + +linters-settings: + paralleltest: + # Terraform acceptance subtests all share a Coder instance, and cannot run + # in parallel. + ignore-missing-subtests: true diff --git a/Makefile b/Makefile index e26660e..faf8f49 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,8 @@ fmt: go fmt ./... terraform fmt -recursive -vet: - go vet ./... +lint: + golangci-lint run ./... gen: go generate ./... diff --git a/integration/integration_test.go b/integration/integration_test.go index f1937b6..2ed60eb 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -146,6 +146,8 @@ func TestIntegration(t *testing.T) { }, } { t.Run(tt.name, func(t *testing.T) { + t.Parallel() + client := StartCoder(ctx, t, tt.name, true) wd, err := os.Getwd() require.NoError(t, err) diff --git a/internal/provider/template_resource_test.go b/internal/provider/template_resource_test.go index f5ff8bb..0cc0015 100644 --- a/internal/provider/template_resource_test.go +++ b/internal/provider/template_resource_test.go @@ -1512,6 +1512,8 @@ func TestReconcileVersionIDs(t *testing.T) { for _, c := range cases { c := c t.Run(c.Name, func(t *testing.T) { + t.Parallel() + diag := c.planVersions.reconcileVersionIDs(c.inputState, c.configVersions, c.cfgHasActiveVersion) if c.expectError { require.True(t, diag.HasError()) diff --git a/internal/provider/uuid_internal_test.go b/internal/provider/uuid_internal_test.go index f4a2034..ff9fd32 100644 --- a/internal/provider/uuid_internal_test.go +++ b/internal/provider/uuid_internal_test.go @@ -50,11 +50,11 @@ func TestUUIDTypeValueFromTerraform(t *testing.T) { for _, test := range tests { test := test t.Run(test.name, func(t *testing.T) { - ctx := context.Background() + t.Parallel() + ctx := context.Background() actual, err := uuidType.ValueFromTerraform(UUIDType, ctx, test.input) require.NoError(t, err) - require.Equal(t, test.expected, actual) }) } @@ -84,10 +84,10 @@ func TestUUIDToStringValue(t *testing.T) { for name, test := range tests { name, test := name, test t.Run(name, func(t *testing.T) { - ctx := context.Background() + t.Parallel() + ctx := context.Background() s, _ := test.uuid.ToStringValue(ctx) - require.Equal(t, test.expected, s) }) } From cc5e221635ba6543184c9a8d54ef028ba3de59d1 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Fri, 21 Feb 2025 22:58:16 +0000 Subject: [PATCH 4/4] fix duplicate container name --- internal/provider/workspace_proxy_resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/provider/workspace_proxy_resource_test.go b/internal/provider/workspace_proxy_resource_test.go index 641d1d9..9626e83 100644 --- a/internal/provider/workspace_proxy_resource_test.go +++ b/internal/provider/workspace_proxy_resource_test.go @@ -62,7 +62,7 @@ func TestAccWorkspaceProxyResourceAGPL(t *testing.T) { t.Skip("Acceptance tests are disabled.") } ctx := context.Background() - client := integration.StartCoder(ctx, t, "ws_proxy_acc", false) + client := integration.StartCoder(ctx, t, "ws_proxy_acc_agpl", false) cfg1 := testAccWorkspaceProxyResourceConfig{ URL: client.URL.String(),