forked from TrueCloudLab/rclone
Retry listing in tests to work around eventual consistency
This commit is contained in:
parent
235cbe0e57
commit
2203766f77
1 changed files with 13 additions and 1 deletions
|
@ -117,7 +117,19 @@ func (is *Items) Done(t *testing.T) {
|
||||||
func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, precision time.Duration) {
|
func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, precision time.Duration) {
|
||||||
is := NewItems(items)
|
is := NewItems(items)
|
||||||
oldErrors := fs.Stats.GetErrors()
|
oldErrors := fs.Stats.GetErrors()
|
||||||
for obj := range f.List() {
|
var objs []fs.Object
|
||||||
|
for i := 1; i <= 5; i++ {
|
||||||
|
objs = nil
|
||||||
|
for obj := range f.List() {
|
||||||
|
objs = append(objs, obj)
|
||||||
|
}
|
||||||
|
if len(objs) == len(items) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
t.Logf("Sleeping for 1 second for list eventual consistency: %d/5", i)
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
|
for _, obj := range objs {
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
t.Errorf("Unexpected nil in List()")
|
t.Errorf("Unexpected nil in List()")
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Reference in a new issue