From e3416c30017c6c624cd236e6b826e7a1ff6c3880 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Sun, 18 Oct 2026 12:25:45 -0600 Subject: [PATCH] test(workspace): stabilize Windows provider update tests Replace the hard-coded 5s/10s/3s update deadlines shared by the provider-update preservation fixtures with a single 60s hang guard, since tight wall-clock deadlines flake under slow Windows -race CI. Drop -race from the Windows provider-update test run: it intermittently crashes net/http server teardown during goroutine stack shrink/copy on windows/amd64 (golang/go#77975, #77955, #78041), still reproducing on go1.26.9. pkg/workspace and pkg/provider keep -race coverage via the Unit Tests job on ubuntu-latest and macos-latest. --- hack/provider_update_ci/discovery.go | 7 ++++++- hack/provider_update_ci/main_test.go | 6 +++--- pkg/workspace/provider_update_extended_test.go | 4 +++- pkg/workspace/provider_update_prepared_test.go | 10 +++++----- pkg/workspace/provider_update_preservation_test.go | 3 +-- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/hack/provider_update_ci/discovery.go b/hack/provider_update_ci/discovery.go index 88b0992f10..6c45399ea5 100644 --- a/hack/provider_update_ci/discovery.go +++ b/hack/provider_update_ci/discovery.go @@ -6,8 +6,13 @@ import ( "os/exec" ) +// providerTestCommand omits -race: the Go runtime crashes intermittently on +// windows/amd64 under -race during goroutine stack shrink/copy (observed in +// net/http server teardown; matches golang/go#77975, #77955, #78041, still +// reproducing on go1.26.9). pkg/workspace and pkg/provider keep -race +// coverage on ubuntu-latest and macos-latest via the Unit Tests job. func providerTestCommand(selection string) *exec.Cmd { - args := []string{"test", "-race", "-json", "-count=1", "-timeout", windowsTestTimeout} + args := []string{"test", "-json", "-count=1", "-timeout", windowsTestTimeout} args = append(args, providerUpdatePackages...) args = append(args, selection, providerUpdateRunPattern) return exec.Command("go", args...) diff --git a/hack/provider_update_ci/main_test.go b/hack/provider_update_ci/main_test.go index 3ac2beb376..624ccb93ab 100644 --- a/hack/provider_update_ci/main_test.go +++ b/hack/provider_update_ci/main_test.go @@ -74,12 +74,12 @@ func isFakeGoInvocation(path string) bool { } func isExpectedGoCommand(args []string) bool { - if len(args) != 10 || (args[8] != "-run" && args[8] != "-list") { + if len(args) != 9 || (args[7] != "-run" && args[7] != "-list") { return false } expected := []string{ - "test", "-race", "-json", "-count=1", "-timeout", "10m", - providerUpdatePackages[0], providerUpdatePackages[1], args[8], providerUpdateRunPattern, + "test", "-json", "-count=1", "-timeout", "10m", + providerUpdatePackages[0], providerUpdatePackages[1], args[7], providerUpdateRunPattern, } return equalStrings(args, expected) } diff --git a/pkg/workspace/provider_update_extended_test.go b/pkg/workspace/provider_update_extended_test.go index a468cf5032..c48abce5d9 100644 --- a/pkg/workspace/provider_update_extended_test.go +++ b/pkg/workspace/provider_update_extended_test.go @@ -42,6 +42,8 @@ const ( updateCurrentLink = "current" updateMiddleLink = "middle" updateEntryLink = "entry" + // updateTestHangGuard is a hang-safety bound, not a target duration. + updateTestHangGuard = 60 * time.Second ) type preservationFixture struct { @@ -174,7 +176,7 @@ func (f *preservationFixture) update(binaries map[string][]*provider.ProviderBin } raw, err := json.Marshal(replacement) require.NoError(f.t, err) - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), updateTestHangGuard) defer cancel() _, err = updateProvider( ctx, diff --git a/pkg/workspace/provider_update_prepared_test.go b/pkg/workspace/provider_update_prepared_test.go index cf2aeeed7b..b2b233df3b 100644 --- a/pkg/workspace/provider_update_prepared_test.go +++ b/pkg/workspace/provider_update_prepared_test.go @@ -776,7 +776,7 @@ func TestProviderUpdateCachedReplacement(t *testing.T) { binaries := map[string][]*provider.ProviderBinary{ updateRuntimeKey: {updateTestBinary(server.URL+"/runtime", content)}, } - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), updateTestHangGuard) defer cancel() _, err := provider.DownloadBinaries(ctx, binaries, t.TempDir()) require.NoError(t, err) @@ -812,7 +812,7 @@ func TestProviderUpdateCachedArchiveReplacement(t *testing.T) { binary := updateTestBinary(server.URL+"/provider.tgz", content) binary.ArchivePath = updateRuntimeName binaries := map[string][]*provider.ProviderBinary{updateRuntimeKey: {binary}} - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), updateTestHangGuard) defer cancel() _, err := provider.DownloadBinaries(ctx, binaries, t.TempDir()) require.NoError(t, err) @@ -1186,7 +1186,7 @@ func warmProviderUpdateCache( server *httptest.Server, ) { t.Helper() - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), updateTestHangGuard) defer cancel() _, err := provider.DownloadBinaries(ctx, binaries, t.TempDir()) require.NoError(t, err) @@ -1295,7 +1295,7 @@ func TestProviderUpdateNestedAndLeafAliasOfflineCache(t *testing.T) { binary := updateTestBinary(server.URL+"/nested-alias.tar", content) binary.ArchivePath = a.selected binaries := map[string][]*provider.ProviderBinary{updateRuntimeKey: {binary}} - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), updateTestHangGuard) defer cancel() _, err := provider.DownloadBinaries(ctx, binaries, t.TempDir()) require.NoError(t, err) @@ -1384,7 +1384,7 @@ func TestProviderUpdateAncestorRootAliasOfflineCache(t *testing.T) { binary := updateTestBinary(server.URL+"/ancestor-root.tar", content) binary.ArchivePath = selected binaries := map[string][]*provider.ProviderBinary{updateRuntimeKey: {binary}} - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), updateTestHangGuard) defer cancel() _, err := provider.DownloadBinaries(ctx, binaries, t.TempDir()) require.NoError(t, err) diff --git a/pkg/workspace/provider_update_preservation_test.go b/pkg/workspace/provider_update_preservation_test.go index b02742dd4d..d57c590c99 100644 --- a/pkg/workspace/provider_update_preservation_test.go +++ b/pkg/workspace/provider_update_preservation_test.go @@ -12,7 +12,6 @@ import ( "runtime" "sync/atomic" "testing" - "time" "github.com/devsy-org/devsy/pkg/config" "github.com/devsy-org/devsy/pkg/provider" @@ -47,7 +46,7 @@ func TestProviderUpdateFailedDownloadPreservesExisting(t *testing.T) { } raw, err := json.Marshal(replacement) require.NoError(t, err) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), updateTestHangGuard) defer cancel() _, err = updateProvider(ctx, ProviderParams{ DevsyConfig: f.config,