2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-10 15:21:03 +00:00

archiver: Fix flaky TestArchiverAbortEarlyOnError

Saving the blobs of a file by now happens asynchronously to the
processing in the FileSaver. Thus we have to account for the blobs
queued for saving.
This commit is contained in:
Michael Eischer 2022-12-02 20:07:34 +01:00
parent fa20a78bb6
commit a9972dbe7d

View File

@ -2001,6 +2001,7 @@ func TestArchiverAbortEarlyOnError(t *testing.T) {
{ {
src: TestDir{ src: TestDir{
"dir": TestDir{ "dir": TestDir{
"file0": TestFile{Content: string(restictest.Random(0, 1024))},
"file1": TestFile{Content: string(restictest.Random(1, 1024))}, "file1": TestFile{Content: string(restictest.Random(1, 1024))},
"file2": TestFile{Content: string(restictest.Random(2, 1024))}, "file2": TestFile{Content: string(restictest.Random(2, 1024))},
"file3": TestFile{Content: string(restictest.Random(3, 1024))}, "file3": TestFile{Content: string(restictest.Random(3, 1024))},
@ -2013,15 +2014,15 @@ func TestArchiverAbortEarlyOnError(t *testing.T) {
}, },
}, },
wantOpen: map[string]uint{ wantOpen: map[string]uint{
filepath.FromSlash("dir/file0"): 1,
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/file8"): 0, filepath.FromSlash("dir/file8"): 0,
filepath.FromSlash("dir/file9"): 0, filepath.FromSlash("dir/file9"): 0,
}, },
// fails four to six files were opened as the FileReadConcurrency allows for // fails after four to seven files were opened, as the ReadConcurrency allows for
// two queued files // two queued files and SaveBlobConcurrency for one blob queued for saving.
failAfter: 4, failAfter: 4,
err: testErr, err: testErr,
}, },
@ -2055,7 +2056,8 @@ func TestArchiverAbortEarlyOnError(t *testing.T) {
// at most two files may be queued // at most two files may be queued
arch := New(testRepo, testFS, Options{ arch := New(testRepo, testFS, Options{
ReadConcurrency: 2, ReadConcurrency: 2,
SaveBlobConcurrency: 1,
}) })
_, _, err := arch.Snapshot(ctx, []string{"."}, SnapshotOptions{Time: time.Now()}) _, _, err := arch.Snapshot(ctx, []string{"."}, SnapshotOptions{Time: time.Now()})