From 61c2939a5351757f67a14858362d3ab3e4925219 Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Fri, 15 Aug 2025 05:40:32 +0000 Subject: [PATCH] ci: add `paralleltestctx` to lint/go --- Makefile | 1 + agent/agent_test.go | 3 +-- agent/agentcontainers/containers_dockercli_test.go | 4 +++- coderd/telemetry/telemetry_test.go | 2 +- coderd/workspaceapps/db_test.go | 2 ++ coderd/workspaces_test.go | 1 + enterprise/coderd/schedule/template_test.go | 1 + enterprise/wsproxy/wsproxy_test.go | 1 + 8 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index bd3f04a4874cd..9040a891700e1 100644 --- a/Makefile +++ b/Makefile @@ -576,6 +576,7 @@ lint/go: ./scripts/check_codersdk_imports.sh linter_ver=$(shell egrep -o 'GOLANGCI_LINT_VERSION=\S+' dogfood/coder/Dockerfile | cut -d '=' -f 2) go run github.com/golangci/golangci-lint/cmd/golangci-lint@v$$linter_ver run + go run github.com/coder/paralleltestctx/cmd/paralleltestctx@v0.0.1 -custom-funcs="testutil.Context" ./... .PHONY: lint/go lint/examples: diff --git a/agent/agent_test.go b/agent/agent_test.go index 15c653d56ad62..8593123ef7aca 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -456,8 +456,6 @@ func TestAgent_GitSSH(t *testing.T) { func TestAgent_SessionTTYShell(t *testing.T) { t.Parallel() - ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) - t.Cleanup(cancel) if runtime.GOOS == "windows" { // This might be our implementation, or ConPTY itself. // It's difficult to find extensive tests for it, so @@ -468,6 +466,7 @@ func TestAgent_SessionTTYShell(t *testing.T) { for _, port := range sshPorts { t.Run(fmt.Sprintf("(%d)", port), func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) session := setupSSHSessionOnPort(t, agentsdk.Manifest{}, codersdk.ServiceBannerConfig{}, nil, port) command := "sh" diff --git a/agent/agentcontainers/containers_dockercli_test.go b/agent/agentcontainers/containers_dockercli_test.go index c69110a757bc7..3c299e353858d 100644 --- a/agent/agentcontainers/containers_dockercli_test.go +++ b/agent/agentcontainers/containers_dockercli_test.go @@ -55,11 +55,11 @@ func TestIntegrationDockerCLI(t *testing.T) { }, testutil.WaitShort, testutil.IntervalSlow, "Container did not start in time") dcli := agentcontainers.NewDockerCLI(agentexec.DefaultExecer) - ctx := testutil.Context(t, testutil.WaitMedium) // Longer timeout for multiple subtests containerName := strings.TrimPrefix(ct.Container.Name, "/") t.Run("DetectArchitecture", func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) arch, err := dcli.DetectArchitecture(ctx, containerName) require.NoError(t, err, "DetectArchitecture failed") @@ -71,6 +71,7 @@ func TestIntegrationDockerCLI(t *testing.T) { t.Run("Copy", func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) want := "Help, I'm trapped!" tempFile := filepath.Join(t.TempDir(), "test-file.txt") @@ -90,6 +91,7 @@ func TestIntegrationDockerCLI(t *testing.T) { t.Run("ExecAs", func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) // Test ExecAs without specifying user (should use container's default). want := "root" diff --git a/coderd/telemetry/telemetry_test.go b/coderd/telemetry/telemetry_test.go index ac836317b680e..63bdc12870cb3 100644 --- a/coderd/telemetry/telemetry_test.go +++ b/coderd/telemetry/telemetry_test.go @@ -403,7 +403,6 @@ func TestTelemetryItem(t *testing.T) { func TestPrebuiltWorkspacesTelemetry(t *testing.T) { t.Parallel() - ctx := testutil.Context(t, testutil.WaitMedium) db, _ := dbtestutil.NewDB(t) cases := []struct { @@ -435,6 +434,7 @@ func TestPrebuiltWorkspacesTelemetry(t *testing.T) { for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) deployment, snapshot := collectSnapshot(ctx, t, db, func(opts telemetry.Options) telemetry.Options { opts.Database = tc.storeFn(db) diff --git a/coderd/workspaceapps/db_test.go b/coderd/workspaceapps/db_test.go index d9862ab1f9db9..22669d568b0e1 100644 --- a/coderd/workspaceapps/db_test.go +++ b/coderd/workspaceapps/db_test.go @@ -255,6 +255,7 @@ func Test_ResolveRequest(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) // Try resolving a request for each app as the owner, without a // token, then use the token to resolve each app. @@ -589,6 +590,7 @@ func Test_ResolveRequest(t *testing.T) { t.Run("TokenDoesNotMatchRequest", func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) badToken := workspaceapps.SignedToken{ Request: (workspaceapps.Request{ diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index 90a7c87d41041..443098036af62 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -1800,6 +1800,7 @@ func TestWorkspaceFilter(t *testing.T) { for _, c := range testCases { t.Run(c.Name, func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) workspaces, err := client.Workspaces(ctx, c.Filter) require.NoError(t, err, "fetch workspaces") diff --git a/enterprise/coderd/schedule/template_test.go b/enterprise/coderd/schedule/template_test.go index feafbd54b31bb..2eb13b4eb3554 100644 --- a/enterprise/coderd/schedule/template_test.go +++ b/enterprise/coderd/schedule/template_test.go @@ -222,6 +222,7 @@ func TestTemplateUpdateBuildDeadlines(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) user := quietUser if c.noQuietHours { diff --git a/enterprise/wsproxy/wsproxy_test.go b/enterprise/wsproxy/wsproxy_test.go index b49dfd6c1ceaa..ab6ef7f992377 100644 --- a/enterprise/wsproxy/wsproxy_test.go +++ b/enterprise/wsproxy/wsproxy_test.go @@ -290,6 +290,7 @@ resourceLoop: t.Run(r.RegionName, func(t *testing.T) { t.Parallel() + ctx := testutil.Context(t, testutil.WaitShort) derpMap := &tailcfg.DERPMap{ Regions: map[int]*tailcfg.DERPRegion{