From 2203766f7761731baa256129ab35025ef0c21c83 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 14 Sep 2015 21:01:25 +0100 Subject: [PATCH] Retry listing in tests to work around eventual consistency --- fstest/fstest.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fstest/fstest.go b/fstest/fstest.go index 74aefb5be..e3d0be2f1 100644 --- a/fstest/fstest.go +++ b/fstest/fstest.go @@ -117,7 +117,19 @@ func (is *Items) Done(t *testing.T) { func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, precision time.Duration) { is := NewItems(items) 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 { t.Errorf("Unexpected nil in List()") continue