mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 22:27:35 +00:00
Merge pull request #3923 from MichaelEischer/fix-flaky-cache-test
cache: fix flaky TestFileSaveConcurrent on windows
This commit is contained in:
commit
ef58ddd7b1
16
internal/cache/file_test.go
vendored
16
internal/cache/file_test.go
vendored
@ -6,6 +6,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -204,7 +205,22 @@ func TestFileLoad(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simulate multiple processes writing to a cache, using goroutines.
|
// Simulate multiple processes writing to a cache, using goroutines.
|
||||||
|
//
|
||||||
|
// The possibility of sharing a cache between multiple concurrent restic
|
||||||
|
// processes isn't guaranteed in the docs and doesn't always work on Windows, hence the
|
||||||
|
// check on GOOS. Cache sharing is considered a "nice to have" on POSIX, for now.
|
||||||
|
//
|
||||||
|
// The cache first creates a temporary file and then renames it to its final name.
|
||||||
|
// On Windows renaming internally creates a file handle with a shareMode which
|
||||||
|
// includes FILE_SHARE_DELETE. The Go runtime opens files without FILE_SHARE_DELETE,
|
||||||
|
// thus Open(fn) will fail until the file handle used for renaming was closed.
|
||||||
|
// See https://devblogs.microsoft.com/oldnewthing/20211022-00/?p=105822
|
||||||
|
// for hints on how to fix this properly.
|
||||||
func TestFileSaveConcurrent(t *testing.T) {
|
func TestFileSaveConcurrent(t *testing.T) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
t.Skip("may not work due to FILE_SHARE_DELETE issue")
|
||||||
|
}
|
||||||
|
|
||||||
const nproc = 40
|
const nproc = 40
|
||||||
|
|
||||||
c, cleanup := TestNewCache(t)
|
c, cleanup := TestNewCache(t)
|
||||||
|
Loading…
Reference in New Issue
Block a user