1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-24 08:44:52 +00:00

Merge pull request #4068 from MichaelEischer/debug-lock-refresh-test

Add more debug logging to `TestLockSuccessfulRefresh`
This commit is contained in:
Michael Eischer 2022-12-03 17:38:21 +01:00 committed by GitHub
commit 78ea69082a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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