storage: add retry to TestIntegration_BucketPolicyOnly
This introduces a retry to account for propagation delay in
metadata update that has been causing flakes.
Fixes #1480
Change-Id: Ic8cddb438472d229cfbc70c6c7322fb7ed3adf06
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/47977
Reviewed-by: Jean de Klerk <deklerk@google.com>
diff --git a/storage/integration_test.go b/storage/integration_test.go
index 96f88d3..f90e625 100644
--- a/storage/integration_test.go
+++ b/storage/integration_test.go
@@ -370,8 +370,6 @@
}
func TestIntegration_BucketPolicyOnly(t *testing.T) {
- t.Skip("https://github.com/googleapis/google-cloud-go/issues/1480")
-
ctx := context.Background()
client := testConfig(ctx, t)
defer client.Close()
@@ -425,15 +423,27 @@
}
// Check that the object ACLs are the same.
- acls, err := o.ACL().List(ctx)
- if err != nil {
- t.Fatalf("object ACL list failed: %v", err)
+ // The update to BucketPolicyOnly may be delayed in propagation, so retry
+ // for up to 11 seconds before failing.
+ timeout := time.After(11 * time.Second)
+ var acls []ACLRule
+ for {
+ select {
+ case <-timeout:
+ t.Fatalf("object ACL list failed: %v", err)
+ default:
+ }
+ acls, err = o.ACL().List(ctx)
+ if err == nil {
+ // Check that ACL rules contain custom ACL from above.
+ if !containsACL(acls, aclEntity, RoleReader) {
+ t.Fatalf("expected ACLs %v to include custom ACL entity %v", acls, aclEntity)
+ }
+ break
+ }
+ time.Sleep(200 * time.Millisecond)
}
- // Check that ACL rules contain custom ACL from above.
- if !containsACL(acls, aclEntity, RoleReader) {
- t.Fatalf("expected ACLs %v to include custom ACL entity %v", acls, aclEntity)
- }
}
func TestIntegration_UniformBucketLevelAccess(t *testing.T) {