From f9b541072a2256fcf00074e830d50b9e81904473 Mon Sep 17 00:00:00 2001 From: sergeyb Date: Thu, 3 Dec 2026 21:13:33 +0000 Subject: [PATCH] test(changeprovider): disable git auto-maintenance in the git provider fixture The git provider fixture builds four repositories under one t.TempDir: a bare remote, a work clone, the provider's bare copy (copy.git, fetched into by every provider.Get) and, in one test, an orphan clone. Tests commit, push and fetch into them and read results back right before returning. Latent race: those writes can make git start a detached background maintenance run (auto gc / geometric repack) in the repository. The detached process can still be writing under the directory when t.TempDir cleanup removes it, so cleanup fails intermittently. The provider's copy.git is the most exposed, since a fetch into it is usually the last write. Every repository in the fixture now sets maintenance.auto=false, so git does not start auto-maintenance in any of them. copy.git is created as a bare repository up front so the setting is in place before Provision, which keeps an existing repository and only adds the remote and fetches. Test-only change. Co-Authored-By: Claude Sonnet 5.5 --- .../extension/changeprovider/git/provider_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/submitqueue/extension/changeprovider/git/provider_test.go b/submitqueue/extension/changeprovider/git/provider_test.go index 021222862..33b78299f 100644 --- a/submitqueue/extension/changeprovider/git/provider_test.go +++ b/submitqueue/extension/changeprovider/git/provider_test.go @@ -62,18 +62,25 @@ func newFixture(t *testing.T) *fixture { work: filepath.Join(root, "work"), } + // Every repository in this fixture disables auto-maintenance so cleanup cannot race a background repack. f.run("", "init", "--bare", "-b", "main", f.remote) + f.run(f.remote, "config", "maintenance.auto", "false") f.run("", "clone", f.remote, f.work) f.run(f.work, "config", "user.name", "Test") f.run(f.work, "config", "user.email", "test@example.invalid") + f.run(f.work, "config", "maintenance.auto", "false") f.write("seed.txt", "seed\n") f.run(f.work, "add", ".") f.run(f.work, "commit", "-m", "seed") f.run(f.work, "push", "origin", "main") + copyPath := filepath.Join(root, "copy.git") + f.run("", "init", "--bare", "-b", "main", copyPath) + f.run(copyPath, "config", "maintenance.auto", "false") + repo, err := gitrepo.NewRepo(gitrepo.RepoConfig{ Git: git, - Path: filepath.Join(root, "copy.git"), + Path: copyPath, RemoteURL: f.remote, Target: "main", }) @@ -300,6 +307,7 @@ func TestGet_UnrelatedHistoryIsAnError(t *testing.T) { f.run("", "clone", f.remote, orphan) f.run(orphan, "config", "user.name", "Test") f.run(orphan, "config", "user.email", "test@example.invalid") + f.run(orphan, "config", "maintenance.auto", "false") f.run(orphan, "checkout", "--orphan", "feature/orphan") f.run(orphan, "rm", "-rf", ".") require.NoError(t, os.WriteFile(filepath.Join(orphan, "alone.txt"), []byte("alone\n"), 0o644))