From 0ce4a857e668095b555789301498b8bad94e3edd Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 30 Mar 2026 17:26:43 -0700 Subject: [PATCH] test: add dcache stabilisation check after FUSE git reset After git reset --hard on a FUSE mount, the kernel dcache can transiently show the directory then drop it moments later. Add a 1-second stabilisation delay and re-verification in resetToCommitWithRecovery and tryPullFromCommit so that recovery retries if the entry vanishes in that window. --- test/fuse_integration/git_operations_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/fuse_integration/git_operations_test.go b/test/fuse_integration/git_operations_test.go index 2aae86c89..50328d000 100644 --- a/test/fuse_integration/git_operations_test.go +++ b/test/fuse_integration/git_operations_test.go @@ -442,6 +442,20 @@ func resetToCommitWithRecovery(t *testing.T, bareRepo, localClone, mountClone, c } continue } + // The kernel dcache can drop the FUSE entry moments after a + // successful check. Wait briefly and re-verify to confirm the + // directory has stabilised before returning to the caller. + time.Sleep(1 * time.Second) + refreshDirEntry(t, mountClone) + if _, err := tryGitCommand(mountClone, "rev-parse", "HEAD"); err != nil { + lastErr = fmt.Errorf("post-reset stabilisation check failed: %w", err) + if attempt < maxAttempts { + t.Logf("reset recovery attempt %d: %v — removing clone for re-create", attempt, lastErr) + os.RemoveAll(mountClone) + time.Sleep(2 * time.Second) + } + continue + } return } require.NoError(t, lastErr, "git reset --hard %s failed after %d recovery attempts", commit, maxAttempts) @@ -469,6 +483,10 @@ func tryPullFromCommit(t *testing.T, bareRepo, localClone, cloneDir, fromCommit } refreshDirEntry(t, cloneDir) + // Let the dcache stabilise before proceeding. + time.Sleep(1 * time.Second) + refreshDirEntry(t, cloneDir) + head, err := tryGitCommand(cloneDir, "rev-parse", "HEAD") if err != nil { return fmt.Errorf("rev-parse after reset: %w", err)