Skip to content

Commit

Permalink
test(storage): add retry to ACL tests that rely on eventual consisten…
Browse files Browse the repository at this point in the history
…cy (#8313)

This adds retry in the PredefinedACLs integration test that relies on eventual consistency

Fixes #7653
  • Loading branch information
cojenco authored Jul 26, 2023
1 parent 4a23c37 commit 954fb0b
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions storage/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit 954fb0b

Please sign in to comment.