2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 11:28:54 +00:00

Merge pull request #2579 from MichaelEischer/fix-flaky-archiver-test

Fix flaky TestArchiverAbortEarlyOnError
This commit is contained in:
rawtaz 2020-02-15 01:29:37 +01:00 committed by GitHub
commit ecdf49679e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1856,7 +1856,7 @@ func TestArchiverAbortEarlyOnError(t *testing.T) {
var tests = []struct { var tests = []struct {
src TestDir src TestDir
wantOpen map[string]uint wantOpen map[string]uint
failAfter uint // error after so many files have been saved to the repo failAfter uint // error after so many blobs have been saved to the repo
err error err error
}{ }{
{ {
@ -1876,26 +1876,29 @@ func TestArchiverAbortEarlyOnError(t *testing.T) {
{ {
src: TestDir{ src: TestDir{
"dir": TestDir{ "dir": TestDir{
"file1": TestFile{Content: string(restictest.Random(3, 4*1024*1024))}, "file1": TestFile{Content: string(restictest.Random(1, 1024))},
"file2": TestFile{Content: string(restictest.Random(3, 4*1024*1024))}, "file2": TestFile{Content: string(restictest.Random(2, 1024))},
"file3": TestFile{Content: string(restictest.Random(3, 4*1024*1024))}, "file3": TestFile{Content: string(restictest.Random(3, 1024))},
"file4": TestFile{Content: string(restictest.Random(3, 4*1024*1024))}, "file4": TestFile{Content: string(restictest.Random(4, 1024))},
"file5": TestFile{Content: string(restictest.Random(3, 4*1024*1024))}, "file5": TestFile{Content: string(restictest.Random(5, 1024))},
"file6": TestFile{Content: string(restictest.Random(3, 4*1024*1024))}, "file6": TestFile{Content: string(restictest.Random(6, 1024))},
"file7": TestFile{Content: string(restictest.Random(3, 4*1024*1024))}, "file7": TestFile{Content: string(restictest.Random(7, 1024))},
"file8": TestFile{Content: string(restictest.Random(3, 4*1024*1024))}, "file8": TestFile{Content: string(restictest.Random(8, 1024))},
"file9": TestFile{Content: string(restictest.Random(3, 4*1024*1024))}, "file9": TestFile{Content: string(restictest.Random(9, 1024))},
}, },
}, },
wantOpen: map[string]uint{ wantOpen: map[string]uint{
filepath.FromSlash("dir/file1"): 1, filepath.FromSlash("dir/file1"): 1,
filepath.FromSlash("dir/file2"): 1, filepath.FromSlash("dir/file2"): 1,
filepath.FromSlash("dir/file3"): 1, filepath.FromSlash("dir/file3"): 1,
filepath.FromSlash("dir/file4"): 1,
filepath.FromSlash("dir/file7"): 0, filepath.FromSlash("dir/file7"): 0,
filepath.FromSlash("dir/file8"): 0, filepath.FromSlash("dir/file8"): 0,
filepath.FromSlash("dir/file9"): 0, filepath.FromSlash("dir/file9"): 0,
}, },
failAfter: 5, // fails four to six files were opened as the FileReadConcurrency allows for
// two queued files
failAfter: 4,
err: testErr, err: testErr,
}, },
} }
@ -1926,7 +1929,10 @@ func TestArchiverAbortEarlyOnError(t *testing.T) {
err: test.err, err: test.err,
} }
arch := New(testRepo, testFS, Options{}) // at most two files may be queued
arch := New(testRepo, testFS, Options{
FileReadConcurrency: 2,
})
_, _, err := arch.Snapshot(ctx, []string{"."}, SnapshotOptions{Time: time.Now()}) _, _, err := arch.Snapshot(ctx, []string{"."}, SnapshotOptions{Time: time.Now()})
if errors.Cause(err) != test.err { if errors.Cause(err) != test.err {