From 321a358ff1b77b9bcdca549e25a2adf8b6dca770 Mon Sep 17 00:00:00 2001 From: Cathy Ouyang Date: Fri, 21 Jul 2023 15:04:30 -0700 Subject: [PATCH] test(storage): add retry to ACL tests that rely on eventual consistency --- storage/integration_test.go | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/storage/integration_test.go b/storage/integration_test.go index 63242a54fac8..bca8951c5980 100644 --- a/storage/integration_test.go +++ b/storage/integration_test.go @@ -3985,11 +3985,38 @@ func TestIntegration_PredefinedACLs(t *testing.T) { w.PredefinedACL = "authenticatedRead" h.mustWrite(w, []byte("hello")) defer h.mustDeleteObject(obj) - if acl, want := w.Attrs().ACL, userOwner; !containsACLRule(acl, want) { - t.Fatalf("Object.ACL: expected acl to contain: %+v, got acl: %+v", want, acl) + var acl []ACLRule + err := retry(ctx, func() error { + attrs, err := obj.Attrs(ctx) + if err != nil { + return fmt.Errorf("Object.Attrs: object metadata get failed: %v", err) + } + acl = attrs.ACL + return nil + }, func() error { + if want := userOwner; !containsACLRule(acl, want) { + return fmt.Errorf("Object.ACL: expected acl to contain: %+v, got acl: %+v", want, acl) + } + return nil + }) + if err != nil { + t.Fatal(err) } - if acl, want := w.Attrs().ACL, authenticatedRead; !containsACLRule(acl, want) { - t.Fatalf("Object.ACL: expected acl to contain: %+v, got acl: %+v", want, acl) + err = retry(ctx, func() error { + attrs, err := obj.Attrs(ctx) + if err != nil { + return fmt.Errorf("Object.Attrs: object metadata get failed: %v", err) + } + acl = attrs.ACL + return nil + }, func() error { + if want := authenticatedRead; !containsACLRule(acl, want) { + return fmt.Errorf("Object.ACL: expected acl to contain: %+v, got acl: %+v", want, acl) + } + return nil + }) + if err != nil { + t.Fatal(err) } // Object update @@ -4005,7 +4032,7 @@ func TestIntegration_PredefinedACLs(t *testing.T) { dst := bkt.Object("dst") copier := dst.CopierFrom(obj) copier.PredefinedACL = "publicRead" - oattrs, err := copier.Run(ctx) + oattrs, err = copier.Run(ctx) if err != nil { t.Fatal(err) }