mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 03:18:55 +00:00
mount: only start next test after mount command cleanup is complete
The test did not wait for the mount command to fully shutdown all running goroutines. This caused the go race detector to report a data race related to lock refreshes. ================== WARNING: DATA RACE Write at 0x0000021bdfdb by goroutine 667: github.com/restic/restic/internal/backend/retry.TestFastRetries() /restic/restic/internal/backend/retry/testing.go:7 +0x18f github.com/restic/restic/cmd/restic.withTestEnvironment() /restic/restic/cmd/restic/integration_helpers_test.go:175 +0x183 github.com/restic/restic/cmd/restic.TestMountSameTimestamps() /restic/restic/cmd/restic/integration_fuse_test.go:202 +0xac testing.tRunner() /usr/lib/go/src/testing/testing.go:1446 +0x216 testing.(*T).Run.func1() /usr/lib/go/src/testing/testing.go:1493 +0x47 Previous read at 0x0000021bdfdb by goroutine 609: github.com/restic/restic/internal/backend/retry.(*Backend).retry() /restic/restic/internal/backend/retry/backend_retry.go:72 +0x9e github.com/restic/restic/internal/backend/retry.(*Backend).Remove() /restic/restic/internal/backend/retry/backend_retry.go:149 +0x17d github.com/restic/restic/internal/cache.(*Backend).Remove() /restic/restic/internal/cache/backend.go:38 +0x11d github.com/restic/restic/internal/restic.(*Lock).Unlock() /restic/restic/internal/restic/lock.go:190 +0x249 github.com/restic/restic/cmd/restic.refreshLocks.func1() /restic/restic/cmd/restic/lock.go:86 +0xae runtime.deferreturn() /usr/lib/go/src/runtime/panic.go:476 +0x32 github.com/restic/restic/cmd/restic.lockRepository.func2() /restic/restic/cmd/restic/lock.go:61 +0x71 [...] Goroutine 609 (finished) created at: github.com/restic/restic/cmd/restic.lockRepository() /restic/restic/cmd/restic/lock.go:61 +0x488 github.com/restic/restic/cmd/restic.lockRepo() /restic/restic/cmd/restic/lock.go:25 +0x219 github.com/restic/restic/cmd/restic.runMount() /restic/restic/cmd/restic/cmd_mount.go:126 +0x1f8 github.com/restic/restic/cmd/restic.testRunMount() /restic/restic/cmd/restic/integration_fuse_test.go:61 +0x1ce github.com/restic/restic/cmd/restic.checkSnapshots.func1() /restic/restic/cmd/restic/integration_fuse_test.go:90 +0x124 ==================
This commit is contained in:
parent
32c9667990
commit
dc060356c2
@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -54,7 +55,8 @@ func waitForMount(t testing.TB, dir string) {
|
||||
t.Errorf("subdir %q of dir %s never appeared", mountTestSubdir, dir)
|
||||
}
|
||||
|
||||
func testRunMount(t testing.TB, gopts GlobalOptions, dir string) {
|
||||
func testRunMount(t testing.TB, gopts GlobalOptions, dir string, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
opts := MountOptions{
|
||||
TimeTemplate: time.RFC3339,
|
||||
}
|
||||
@ -87,8 +89,11 @@ func listSnapshots(t testing.TB, dir string) []string {
|
||||
func checkSnapshots(t testing.TB, global GlobalOptions, repo *repository.Repository, mountpoint, repodir string, snapshotIDs restic.IDs, expectedSnapshotsInFuseDir int) {
|
||||
t.Logf("checking for %d snapshots: %v", len(snapshotIDs), snapshotIDs)
|
||||
|
||||
go testRunMount(t, global, mountpoint)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go testRunMount(t, global, mountpoint, &wg)
|
||||
waitForMount(t, mountpoint)
|
||||
defer wg.Wait()
|
||||
defer testRunUmount(t, global, mountpoint)
|
||||
|
||||
if !snapshotsDirExists(t, mountpoint) {
|
||||
|
Loading…
Reference in New Issue
Block a user