diff --git a/storage/integration_test.go b/storage/integration_test.go index 02ab34bd860..e4ce8f87e9c 100644 --- a/storage/integration_test.go +++ b/storage/integration_test.go @@ -3016,8 +3016,8 @@ func TestIntegration_RequesterPays(t *testing.T) { } else if err == nil && !test.expectSuccess { t.Errorf("%s: got unexpected success\n\t\t%s", desc, printTestCase()) } else if !test.expectSuccess && test.wantErrorCode != 0 && errCode(err) != test.wantErrorCode { - t.Errorf("%s: mismatched errors; %s\n\t\twant error code: %d\n\t\tgot error: %v\n", - desc, printTestCase(), test.wantErrorCode, err) + t.Errorf("%s: mismatched errors; want error code: %d, got error: %v \n\t\t%s\n", + desc, test.wantErrorCode, err, printTestCase()) } } @@ -3029,9 +3029,7 @@ func TestIntegration_RequesterPays(t *testing.T) { if err := requesterPaysBucket.ACL().Set(ctx, ACLEntity("user-"+otherUserEmail), RoleOwner); err != nil { t.Fatalf("set ACL: %v", err) } - t.Cleanup(func() { - h.mustDeleteBucket(requesterPaysBucket) - }) + t.Cleanup(func() { h.mustDeleteBucket(requesterPaysBucket) }) // Make sure the object exists, so we don't get confused by ErrObjectNotExist. // The later write we perform may fail so we always write to the object as the user @@ -3057,17 +3055,7 @@ func TestIntegration_RequesterPays(t *testing.T) { } } - // Object operations (except for delete) - checkforErrors("write object", writeObject(ctx, bucket.Object(objectName), "text/plain", []byte("hello"))) - _, err = readObject(ctx, bucket.Object(objectName)) - checkforErrors("read object", err) - _, err = bucket.Object(objectName).Attrs(ctx) - checkforErrors("get object attrs", err) - _, err = bucket.Object(objectName).Update(ctx, ObjectAttrsToUpdate{ContentLanguage: "en"}) - checkforErrors("update object", err) - // Bucket ACL operations - // We interleave buckets to get around the rate limit entity := ACLEntity("domain-google.com") checkforErrors("bucket acl set", bucket.ACL().Set(ctx, entity, RoleReader)) @@ -3075,6 +3063,25 @@ func TestIntegration_RequesterPays(t *testing.T) { checkforErrors("bucket acl list", err) checkforErrors("bucket acl delete", bucket.ACL().Delete(ctx, entity)) + // Object operations (except for delete) + // Retry to account for propagation delay to objects in metadata update + // (we updated the metadata to add the otherUserEmail as owner on the bucket) + o := bucket.Object(objectName) + ctxWithTimeout, cancel := context.WithTimeout(ctx, time.Second*10) + defer cancel() + // Only retry when we expect success to avoid retrying for 10 seconds + // when we know it will fail + if test.expectSuccess { + o = o.Retryer(WithErrorFunc(retryOnTransient400and403)) + } + checkforErrors("write object", writeObject(ctxWithTimeout, o, "text/plain", []byte("hello"))) + _, err = readObject(ctx, bucket.Object(objectName)) + checkforErrors("read object", err) + _, err = bucket.Object(objectName).Attrs(ctx) + checkforErrors("get object attrs", err) + _, err = bucket.Object(objectName).Update(ctx, ObjectAttrsToUpdate{ContentLanguage: "en"}) + checkforErrors("update object", err) + // Object ACL operations checkforErrors("object acl set", bucket.Object(objectName).ACL().Set(ctx, entity, RoleReader)) _, err = bucket.Object(objectName).ACL().List(ctx)