forked from TrueCloudLab/restic
backend tests: Delay listing for swift backend
This commit is contained in:
parent
98ae7b1210
commit
eb7fc12e01
1 changed files with 16 additions and 6 deletions
|
@ -453,6 +453,21 @@ func delayedRemove(b restic.Backend, h restic.Handle) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func delayedList(t testing.TB, b restic.Backend, tpe restic.FileType, max int) restic.IDs {
|
||||||
|
list := restic.NewIDSet()
|
||||||
|
for i := 0; i < max; i++ {
|
||||||
|
for s := range b.List(context.TODO(), tpe) {
|
||||||
|
id := restic.TestParseID(s)
|
||||||
|
list.Insert(id)
|
||||||
|
}
|
||||||
|
if len(list) < max {
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.List()
|
||||||
|
}
|
||||||
|
|
||||||
// TestBackend tests all functions of the backend.
|
// TestBackend tests all functions of the backend.
|
||||||
func (s *Suite) TestBackend(t *testing.T) {
|
func (s *Suite) TestBackend(t *testing.T) {
|
||||||
b := s.open(t)
|
b := s.open(t)
|
||||||
|
@ -548,12 +563,7 @@ func (s *Suite) TestBackend(t *testing.T) {
|
||||||
IDs = append(IDs, id)
|
IDs = append(IDs, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
list := restic.IDs{}
|
list := delayedList(t, b, tpe, len(IDs))
|
||||||
|
|
||||||
for s := range b.List(context.TODO(), tpe) {
|
|
||||||
list = append(list, restic.TestParseID(s))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(IDs) != len(list) {
|
if len(IDs) != len(list) {
|
||||||
t.Fatalf("wrong number of IDs returned: want %d, got %d", len(IDs), len(list))
|
t.Fatalf("wrong number of IDs returned: want %d, got %d", len(IDs), len(list))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue