diff --git a/appveyor.yml b/appveyor.yml index 34776b06c..122d48cf7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,8 +17,8 @@ init: install: - rmdir c:\go /s /q - - appveyor DownloadFile https://storage.googleapis.com/golang/go1.8.1.windows-amd64.msi - - msiexec /i go1.8.1.windows-amd64.msi /q + - appveyor DownloadFile https://storage.googleapis.com/golang/go1.8.3.windows-amd64.msi + - msiexec /i go1.8.3.windows-amd64.msi /q - go version - go env - appveyor DownloadFile http://sourceforge.netcologne.de/project/gnuwin32/tar/1.13-1/tar-1.13-1-bin.zip -FileName tar.zip diff --git a/src/restic/backend/swift/swift_test.go b/src/restic/backend/swift/swift_test.go index e09ba9e61..c2d1cc14b 100644 --- a/src/restic/backend/swift/swift_test.go +++ b/src/restic/backend/swift/swift_test.go @@ -20,8 +20,8 @@ func newSwiftTestSuite(t testing.TB) *test.Suite { // do not use excessive data MinimalData: true, - // wait for removals for at least 20s - WaitForDelayedRemoval: 20 * time.Second, + // wait for removals for at least 60s + WaitForDelayedRemoval: 60 * time.Second, // NewConfig returns a config for a new temporary backend that will be used in tests. NewConfig: func() (interface{}, error) { diff --git a/src/restic/backend/test/tests.go b/src/restic/backend/test/tests.go index 3b9450c8f..504f65097 100644 --- a/src/restic/backend/test/tests.go +++ b/src/restic/backend/test/tests.go @@ -330,7 +330,7 @@ func (s *Suite) TestSave(t *testing.T) { t.Fatal(err) } - err = delayedRemove(t, b, h, s.WaitForDelayedRemoval) + err = delayedRemove(t, b, s.WaitForDelayedRemoval, h) if err != nil { t.Fatalf("error removing item: %+v", err) } @@ -435,28 +435,39 @@ func testLoad(b restic.Backend, h restic.Handle, length int, offset int64) error return err } -func delayedRemove(t testing.TB, be restic.Backend, h restic.Handle, maxwait time.Duration) error { +func delayedRemove(t testing.TB, be restic.Backend, maxwait time.Duration, handles ...restic.Handle) error { // Some backend (swift, I'm looking at you) may implement delayed // removal of data. Let's wait a bit if this happens. - err := be.Remove(context.TODO(), h) - if err != nil { - return err - } - start := time.Now() - attempt := 0 - for time.Since(start) <= maxwait { - found, err := be.Test(context.TODO(), h) + for _, h := range handles { + err := be.Remove(context.TODO(), h) if err != nil { return err } + } - if !found { - break + for _, h := range handles { + start := time.Now() + attempt := 0 + var found bool + var err error + for time.Since(start) <= maxwait { + found, err = be.Test(context.TODO(), h) + if err != nil { + return err + } + + if !found { + break + } + + time.Sleep(2 * time.Second) + attempt++ } - time.Sleep(500 * time.Millisecond) - attempt++ + if found { + t.Fatalf("removed blob %v still present after %v (%d attempts)", h, time.Since(start), attempt) + } } return nil @@ -552,7 +563,7 @@ func (s *Suite) TestBackend(t *testing.T) { test.Assert(t, err != nil, "expected error for %v, got %v", h, err) // remove and recreate - err = delayedRemove(t, b, h, s.WaitForDelayedRemoval) + err = delayedRemove(t, b, s.WaitForDelayedRemoval, h) test.OK(t, err) // test that the blob is gone @@ -587,6 +598,7 @@ func (s *Suite) TestBackend(t *testing.T) { // remove content if requested if test.TestCleanupTempDirs { + var handles []restic.Handle for _, ts := range testStrings { id, err := restic.ParseID(ts.id) test.OK(t, err) @@ -597,12 +609,10 @@ func (s *Suite) TestBackend(t *testing.T) { test.OK(t, err) test.Assert(t, found, fmt.Sprintf("id %q not found", id)) - test.OK(t, delayedRemove(t, b, h, s.WaitForDelayedRemoval)) - - found, err = b.Test(context.TODO(), h) - test.OK(t, err) - test.Assert(t, !found, fmt.Sprintf("id %q found after removal", id)) + handles = append(handles, h) } + + test.OK(t, delayedRemove(t, b, s.WaitForDelayedRemoval, handles...)) } } }