Skip to content

test flake: TestNoGeneratedPolicyReachesTheStagingBucket walks dist/ while TestReleaseBuildLeavesTheTreeClean creates and removes it #1334

Closed

Description

@scttfrdmn

make check failed once on an unmodified tree, on the branch for spawn#1225/#1226/#1205 at 121e3d5, with this:

--- FAIL: TestNoGeneratedPolicyReachesTheStagingBucket (0.05s)
    staging_scan_test.go:92: lstat ../../dist: no such file or directory
FAIL	github.com/spore-host/spawn/pkg/taskiam

Running the test again on its own passed (go test -count=1 -run TestNoGeneratedPolicyReachesTheStagingBucket ./pkg/taskiam/). There was no dist/ in the checkout either before or after.

I think this is a cross-package race, but I worked it out from the code and haven't reproduced it on purpose:

  • TestReleaseBuildLeavesTheTreeClean (release_tree_clean_test.go, root package) creates files at the real dist/ paths it discovers from .goreleaser.yaml (line 204 MkdirAll, 207 WriteFile). It removes them in t.Cleanup (line 210 RemoveAll).
  • TestNoGeneratedPolicyReachesTheStagingBucket (pkg/taskiam/staging_scan_test.go) runs filepath.Walk("../..") over the same checkout, and go test ./... runs the two packages in parallel. Its skip list is .git, node_modules, vendor, testdata, which leaves out dist, so it reads the root, sees dist, and then the Lstat fails once the root test has removed it. Its walk callback returns werr, which turns that into a test failure.

The other repo-walking tests already skip dist: bot_principal_test.go:129, cmd/spored_unit_test.go:46, cmd/spored_unit_nnp_test.go:45 and no_hardcoded_account_subdomain_test.go:55.

Possible fixes:

  • Add "dist" to the taskiam walk's skip list. This is the minimal change, and dist/ holds build output, not source.
  • Or have the walk ignore fs.ErrNotExist for entries that vanish mid-walk.

The first is narrower. Either way, the root cause is that a test writes into the shared checkout, and any other tree-walking test could hit the same race.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions