Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa3dbcd

Browse files
authored
chore: addt.Parallel() to speed up tests (#184)
This makes the test suite run in under a minute, compared to severalminutes per run before.
1 parentc440681 commitaa3dbcd

17 files changed

+36
-7
lines changed

‎.golangci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@ linters:
1818
-makezero
1919
-misspell
2020
-nilerr
21+
-paralleltest
2122
-predeclared
2223
-staticcheck
2324
-unconvert
2425
-unparam
2526
-unused
2627
-usetesting
28+
29+
linters-settings:
30+
paralleltest:
31+
# Terraform acceptance subtests all share a Coder instance, and cannot run
32+
# in parallel.
33+
ignore-missing-subtests:true

‎Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ fmt:
44
go fmt ./...
55
terraform fmt -recursive
66

7-
vet:
8-
go vet ./...
7+
lint:
8+
golangci-lint run ./...
99

1010
gen:
1111
go generate ./...

‎integration/integration_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
// - Runs the `main.tf` specified in the given test directory against the Coder deployment
2323
// - Asserts the state of the deployment via `codersdk`.
2424
funcTestIntegration(t*testing.T) {
25+
t.Parallel()
2526
ifos.Getenv("TF_ACC")=="1" {
2627
t.Skip("Skipping integration tests during tf acceptance tests")
2728
}
@@ -145,6 +146,8 @@ func TestIntegration(t *testing.T) {
145146
},
146147
} {
147148
t.Run(tt.name,func(t*testing.T) {
149+
t.Parallel()
150+
148151
client:=StartCoder(ctx,t,tt.name,true)
149152
wd,err:=os.Getwd()
150153
require.NoError(t,err)

‎internal/provider/group_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
funcTestAccGroupDataSource(t*testing.T) {
19+
t.Parallel()
1920
ifos.Getenv("TF_ACC")=="" {
2021
t.Skip("Acceptance tests are disabled.")
2122
}

‎internal/provider/group_resource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
funcTestAccGroupResource(t*testing.T) {
19+
t.Parallel()
1920
ifos.Getenv("TF_ACC")=="" {
2021
t.Skip("Acceptance tests are disabled.")
2122
}
@@ -133,6 +134,7 @@ func TestAccGroupResource(t *testing.T) {
133134
}
134135

135136
funcTestAccGroupResourceAGPL(t*testing.T) {
137+
t.Parallel()
136138
ifos.Getenv("TF_ACC")=="" {
137139
t.Skip("Acceptance tests are disabled.")
138140
}

‎internal/provider/license_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
)
1414

1515
funcTestAccLicenseResource(t*testing.T) {
16+
t.Parallel()
1617
ifos.Getenv("TF_ACC")=="" {
1718
t.Skip("Acceptance tests are disabled.")
1819
}

‎internal/provider/organization_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
funcTestAccOrganizationDataSource(t*testing.T) {
19+
t.Parallel()
1920
ifos.Getenv("TF_ACC")=="" {
2021
t.Skip("Acceptance tests are disabled.")
2122
}

‎internal/provider/organization_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
)
2020

2121
funcTestAccOrganizationResource(t*testing.T) {
22+
t.Parallel()
2223
ifos.Getenv("TF_ACC")=="" {
2324
t.Skip("Acceptance tests are disabled.")
2425
}

‎internal/provider/organization_sync_settings_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
)
1919

2020
funcTestAccOrganizationSyncSettingsResource(t*testing.T) {
21+
t.Parallel()
2122
ifos.Getenv("TF_ACC")=="" {
2223
t.Skip("Acceptance tests are disabled.")
2324
}

‎internal/provider/provider_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServe
1616
}
1717

1818
functestAccPreCheck(t*testing.T) {
19+
t.Helper()
1920
// You can add code here to run prior to any test case execution, for example assertions
2021
// about the appropriate environment variables being set are common to see in a pre-check
2122
// function.

‎internal/provider/provisioner_key_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
)
1919

2020
funcTestAccProvisionerKeyResource(t*testing.T) {
21+
t.Parallel()
2122
ifos.Getenv("TF_ACC")=="" {
2223
t.Skip("Acceptance tests are disabled.")
2324
}

‎internal/provider/template_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
)
2121

2222
funcTestAccTemplateDataSource(t*testing.T) {
23+
t.Parallel()
2324
ifos.Getenv("TF_ACC")=="" {
2425
t.Skip("Acceptance tests are disabled.")
2526
}

‎internal/provider/template_resource_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
)
2424

2525
funcTestAccTemplateResource(t*testing.T) {
26+
t.Parallel()
2627
ifos.Getenv("TF_ACC")=="" {
2728
t.Skip("Acceptance tests are disabled.")
2829
}
@@ -637,6 +638,7 @@ func TestAccTemplateResource(t *testing.T) {
637638
}
638639

639640
funcTestAccTemplateResourceEnterprise(t*testing.T) {
641+
t.Parallel()
640642
ifos.Getenv("TF_ACC")=="" {
641643
t.Skip("Acceptance tests are disabled.")
642644
}
@@ -782,6 +784,7 @@ func TestAccTemplateResourceEnterprise(t *testing.T) {
782784
}
783785

784786
funcTestAccTemplateResourceAGPL(t*testing.T) {
787+
t.Parallel()
785788
ifos.Getenv("TF_ACC")=="" {
786789
t.Skip("Acceptance tests are disabled.")
787790
}
@@ -875,6 +878,7 @@ func TestAccTemplateResourceAGPL(t *testing.T) {
875878
}
876879

877880
funcTestAccTemplateResourceVariables(t*testing.T) {
881+
t.Parallel()
878882
cfg:=`
879883
provider coderd {
880884
url = %q
@@ -1137,6 +1141,7 @@ func testAccCheckNumTemplateVersions(ctx context.Context, client *codersdk.Clien
11371141
}
11381142

11391143
funcTestReconcileVersionIDs(t*testing.T) {
1144+
t.Parallel()
11401145
aUUID:=uuid.New()
11411146
bUUID:=uuid.New()
11421147
cases:= []struct {
@@ -1507,6 +1512,8 @@ func TestReconcileVersionIDs(t *testing.T) {
15071512
for_,c:=rangecases {
15081513
c:=c
15091514
t.Run(c.Name,func(t*testing.T) {
1515+
t.Parallel()
1516+
15101517
diag:=c.planVersions.reconcileVersionIDs(c.inputState,c.configVersions,c.cfgHasActiveVersion)
15111518
ifc.expectError {
15121519
require.True(t,diag.HasError())

‎internal/provider/user_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
funcTestAccUserDataSource(t*testing.T) {
19+
t.Parallel()
1920
ifos.Getenv("TF_ACC")=="" {
2021
t.Skip("Acceptance tests are disabled.")
2122
}

‎internal/provider/user_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
)
1515

1616
funcTestAccUserResource(t*testing.T) {
17+
t.Parallel()
1718
ifos.Getenv("TF_ACC")=="" {
1819
t.Skip("Acceptance tests are disabled.")
1920
}

‎internal/provider/uuid_internal_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ func TestUUIDTypeValueFromTerraform(t *testing.T) {
5151
test:=test
5252
t.Run(test.name,func(t*testing.T) {
5353
t.Parallel()
54-
ctx:=context.Background()
5554

55+
ctx:=context.Background()
5656
actual,err:=uuidType.ValueFromTerraform(UUIDType,ctx,test.input)
5757
require.NoError(t,err)
58-
5958
require.Equal(t,test.expected,actual)
6059
})
6160
}
@@ -86,10 +85,9 @@ func TestUUIDToStringValue(t *testing.T) {
8685
name,test:=name,test
8786
t.Run(name,func(t*testing.T) {
8887
t.Parallel()
89-
ctx:=context.Background()
9088

89+
ctx:=context.Background()
9190
s,_:=test.uuid.ToStringValue(ctx)
92-
9391
require.Equal(t,test.expected,s)
9492
})
9593
}

‎internal/provider/workspace_proxy_resource_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
funcTestAccWorkspaceProxyResource(t*testing.T) {
18+
t.Parallel()
1819
ifos.Getenv("TF_ACC")=="" {
1920
t.Skip("Acceptance tests are disabled.")
2021
}
@@ -56,11 +57,12 @@ func TestAccWorkspaceProxyResource(t *testing.T) {
5657
}
5758

5859
funcTestAccWorkspaceProxyResourceAGPL(t*testing.T) {
60+
t.Parallel()
5961
ifos.Getenv("TF_ACC")=="" {
6062
t.Skip("Acceptance tests are disabled.")
6163
}
6264
ctx:=context.Background()
63-
client:=integration.StartCoder(ctx,t,"ws_proxy_acc",false)
65+
client:=integration.StartCoder(ctx,t,"ws_proxy_acc_agpl",false)
6466

6567
cfg1:=testAccWorkspaceProxyResourceConfig{
6668
URL:client.URL.String(),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp