WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit b44d2d6

Browse files
committed
tests_macos_gitlab_arm64 flakiness: extend go build isolation in pkgconfigusage (#43773)
### What does this PR do? Add `GOCACHE` isolation to `TestAll` in `pkg/linters/components/pkgconfigusage` to reduce test timeouts on macOS CI runners. ### Motivation The test still times out occasionally ([example in `main`](http://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/1267508733/viewer#L2040)) after 3 minutes on macOS Gitlab runners when running with `-p 12 -parallel 12`, despite previous tentative fix (#43207) which added `GOPRIVATE=*` and `GOPROXY=off`. `analysistest.Run` internally runs `go build` commands to verify the Go toolchain works. When multiple tests run concurrently with the same shared `GOCACHE`, they can deadlock in Go's process management layer (see golang/go#59657). ### Changes Added per-test isolated `GOCACHE` directory using `t.TempDir()`, following the same approach as PR #39687 which fixed a similar timeout issue in `comp/core/secrets/impl/fetch_secret_test.go`. ### Describe how you validated your changes Verified locally with `go test -v -race -count=20 -parallel 12 -timeout 600s`. ### Additional Notes Prior art include: - #39518 - #39687 - #43207 - #43627 💡 `-mod=vendor` could be also factored out through a future PR should the problem manifest itself again after the present change is merged.
1 parent 15fd09a commit b44d2d6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pkg/linters/components/pkgconfigusage/pkgconfigusage_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ import (
1010
"path/filepath"
1111
"testing"
1212

13+
"github.com/DataDog/datadog-agent/pkg/util/testutil"
1314
"github.com/stretchr/testify/assert"
1415
"golang.org/x/tools/go/analysis/analysistest"
1516
)
1617

1718
func TestAll(t *testing.T) {
1819
// Set environment variables to prevent go commands from accessing
1920
// the module cache concurrently, which can cause timeouts on macOS.
21+
t.Setenv("GOCACHE", t.TempDir())
2022
t.Setenv("GOPRIVATE", "*")
2123
t.Setenv("GOPROXY", "off")
2224

0 commit comments

Comments
 (0)