From 64233ca0a7880c47c19b85eb64691ede3550153a Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 7 Apr 2023 19:43:00 +0200 Subject: [PATCH 1/2] lock: Improve debug logging in the test --- cmd/restic/lock_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/restic/lock_test.go b/cmd/restic/lock_test.go index c074f15a6..242252f42 100644 --- a/cmd/restic/lock_test.go +++ b/cmd/restic/lock_test.go @@ -136,7 +136,9 @@ type loggingBackend struct { 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) + err := b.Backend.Save(ctx, h, rd) + b.t.Logf("save finished %v @ %v", h, time.Now()) + return err } func TestLockSuccessfulRefresh(t *testing.T) { @@ -161,7 +163,8 @@ func TestLockSuccessfulRefresh(t *testing.T) { select { case <-wrappedCtx.Done(): - t.Fatal("lock refresh failed") + // don't call t.Fatal to allow the lock to be properly cleaned up + t.Error("lock refresh failed", time.Now()) case <-time.After(2 * refreshabilityTimeout): // expected lock refresh to work } From cf1cc1fb72b11343915d7a900fd0b43ea5b3a1e8 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 7 Apr 2023 19:51:31 +0200 Subject: [PATCH 2/2] lock: Print stacktrace if TestLockSuccessfulRefresh fails --- cmd/restic/lock_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/restic/lock_test.go b/cmd/restic/lock_test.go index 242252f42..fd3af0724 100644 --- a/cmd/restic/lock_test.go +++ b/cmd/restic/lock_test.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "runtime" "testing" "time" @@ -165,6 +166,13 @@ func TestLockSuccessfulRefresh(t *testing.T) { case <-wrappedCtx.Done(): // don't call t.Fatal to allow the lock to be properly cleaned up t.Error("lock refresh failed", time.Now()) + + // Dump full stacktrace + buf := make([]byte, 1024*1024) + n := runtime.Stack(buf, true) + buf = buf[:n] + t.Log(string(buf)) + case <-time.After(2 * refreshabilityTimeout): // expected lock refresh to work }