Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

test(storage): improve object cleanup #8262

Merged
merged 4 commits into from
Jul 18, 2023

Conversation

tritone
Copy link
Contributor

@tritone tritone commented Jul 13, 2023

Use the test helper mustDeleteObject function and make it resilient to transient failures. Also switch to using t.Helper and t.Cleanup when possible for test helper funcs.

We should probably move other tests to do this at some point; could be a small fixit project.

Fixes #8259

Use the test helper mustDeleteObject function and make it resilient
to transient failures.

We should probably move other tests to do this at some point; could
be a small fixit project.

Fixes googleapis#8259
@tritone tritone requested review from a team as code owners July 13, 2023 20:49
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: storage Issues related to the Cloud Storage API. labels Jul 13, 2023
if apiErr.HTTPCode() == 404 || apiErr.GRPCStatus().Code() == codes.NotFound {
return
}
}
h.t.Fatalf("%s: delete object %s from bucket %s: %v", loc(), o.ObjectName(), o.BucketName(), err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're in here, maybe we should also update this to use t.Helper() instead of manually calling loc()? Maybe that change could be made as part of the fixit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went ahead and just did this and got rid of loc()

@@ -272,7 +272,9 @@ func multiTransportTest(ctx context.Context, t *testing.T,
opts ...option.ClientOption) {
for transport, client := range initTransportClients(ctx, t, opts...) {
t.Run(transport, func(t *testing.T) {
defer client.Close()
t.Cleanup(func() {
client.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, turns out this is necessary b/c defer calls run before t.Cleanup calls :)

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jul 18, 2023
@tritone tritone added the automerge Merge the pull request once unit tests and other checks pass. label Jul 18, 2023
@gcf-merge-on-green gcf-merge-on-green bot merged commit cd07570 into googleapis:main Jul 18, 2023
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jul 18, 2023
@tritone tritone deleted the test-object-cleanup branch July 19, 2023 16:44
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
api: storage Issues related to the Cloud Storage API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

storage: TestIntegration_Copy failed
2 participants