forked from TrueCloudLab/restic
Reduce lock timeout to zero
This commit is contained in:
parent
eb6e3ba8b3
commit
88d0f24ce7
2 changed files with 9 additions and 1 deletions
|
@ -43,6 +43,7 @@ func parseIDsFromReader(t testing.TB, rd io.Reader) restic.IDs {
|
||||||
|
|
||||||
func cmdInit(t testing.TB, global GlobalOptions) {
|
func cmdInit(t testing.TB, global GlobalOptions) {
|
||||||
repository.TestUseLowSecurityKDFParameters(t)
|
repository.TestUseLowSecurityKDFParameters(t)
|
||||||
|
restic.TestSetLockTimeout(t, 0)
|
||||||
|
|
||||||
cmd := &CmdInit{global: &global}
|
cmd := &CmdInit{global: &global}
|
||||||
OK(t, cmd.Execute(nil))
|
OK(t, cmd.Execute(nil))
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"os/user"
|
"os/user"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -68,7 +69,13 @@ func NewExclusiveLock(repo Repository) (*Lock, error) {
|
||||||
return newLock(repo, true)
|
return newLock(repo, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const waitBeforeLockCheck = 200 * time.Millisecond
|
var waitBeforeLockCheck = 200 * time.Millisecond
|
||||||
|
|
||||||
|
// TestSetLockTimeout can be used to reduce the lock wait timeout for tests.
|
||||||
|
func TestSetLockTimeout(t testing.TB, d time.Duration) {
|
||||||
|
t.Logf("setting lock timeout to %v", d)
|
||||||
|
waitBeforeLockCheck = d
|
||||||
|
}
|
||||||
|
|
||||||
func newLock(repo Repository, excl bool) (*Lock, error) {
|
func newLock(repo Repository, excl bool) (*Lock, error) {
|
||||||
lock := &Lock{
|
lock := &Lock{
|
||||||
|
|
Loading…
Reference in a new issue