2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-05 12:57:53 +00:00

Merge pull request #4285 from MichaelEischer/debug-lock-refresh-failures

lock: Improve debug logging in the test
This commit is contained in:
Michael Eischer 2023-04-07 20:06:15 +02:00 committed by GitHub
commit 8afc117aa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"runtime"
"testing" "testing"
"time" "time"
@ -136,7 +137,9 @@ type loggingBackend struct {
func (b *loggingBackend) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) error { func (b *loggingBackend) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) error {
b.t.Logf("save %v @ %v", h, time.Now()) 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) { func TestLockSuccessfulRefresh(t *testing.T) {
@ -161,7 +164,15 @@ func TestLockSuccessfulRefresh(t *testing.T) {
select { select {
case <-wrappedCtx.Done(): 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())
// 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): case <-time.After(2 * refreshabilityTimeout):
// expected lock refresh to work // expected lock refresh to work
} }