From 6b5d6b9f2c93e7ca24f7b83eb6ac716b3c62f10b Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 3 Dec 2022 12:05:38 +0100 Subject: [PATCH] Add more debug logging to TestLockSuccessfulRefresh The test fails from time to time. Add some more logging to hopefully get an idea where things go wrong. --- cmd/restic/lock_test.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/restic/lock_test.go b/cmd/restic/lock_test.go index a70d32897..c074f15a6 100644 --- a/cmd/restic/lock_test.go +++ b/cmd/restic/lock_test.go @@ -129,11 +129,26 @@ func TestLockFailedRefresh(t *testing.T) { unlockRepo(lock) } +type loggingBackend struct { + restic.Backend + t *testing.T +} + +func (b *loggingBackend) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) error { + b.t.Logf("save %v @ %v", h, time.Now()) + return b.Backend.Save(ctx, h, rd) +} + func TestLockSuccessfulRefresh(t *testing.T) { - repo, cleanup, _ := openTestRepo(t, nil) + repo, cleanup, _ := openTestRepo(t, func(r restic.Backend) (restic.Backend, error) { + return &loggingBackend{ + Backend: r, + t: t, + }, nil + }) defer cleanup() - t.Log("test for successful lock refresh") + t.Logf("test for successful lock refresh %v", time.Now()) // reduce locking intervals to be suitable for testing ri, rt := refreshInterval, refreshabilityTimeout refreshInterval = 40 * time.Millisecond