-
Notifications
You must be signed in to change notification settings - Fork 567
feat(storage): Add retry conformance test #18230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(storage): Add retry conformance test #18230
Conversation
c8bba11 to
c10217e
Compare
af1f30d to
1262e47
Compare
e558204 to
2e60107
Compare
2e60107 to
fe58b5d
Compare
e7a0dd5 to
5331212
Compare
c597c25 to
61c96a4
Compare
61c96a4 to
361c371
Compare
af561fa to
5686331
Compare
3297f9c to
b64fa30
Compare
790e0a3 to
b88be1b
Compare
…orted, remove broken-stream and reset-connection tests
10a3309 to
25c4c16
Compare
google-cloud-storage/Rakefile
Outdated
| end | ||
| end | ||
|
|
||
| #Conformance Tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add space here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
google-cloud-storage/conformance/v1/proto/google/cloud/conformance/storage/v1/tests.proto
Show resolved
Hide resolved
google-cloud-storage/test/google/cloud/storage/retry/conformance_test.rb
Outdated
Show resolved
Hide resolved
|
|
||
| success_result = true | ||
| begin | ||
| run_retry_test test_id, lib_func, scenario["preconditionProvided"], method.resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why scenario["preconditionProvided"] & not scenario.preconditionProvided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No specific reason. Since it was a JSON key, I used the string
| # The Retry Test API in the testbench is used to run the retry conformance tests. It offers a | ||
| # mechanism to describe more complex | ||
| # retry scenarios while sending a single, constant header through all the HTTP requests from a | ||
| # test program. The Retry Test API can be accessed by adding the path "/retry-test" to the host. # See also: https://github.com/googleapis/storage-testbench |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limit to 80 characters. # See also.... can move to next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| object = resources[:object] | ||
| object_2 = bucket.create_file StringIO.new(CONF_TEST_FILE_CONTENT), "my-test-file-2" | ||
| destination = "new-composite-object" | ||
| if _preconditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
underscored variable used.
| def self.delete_file client, _preconditions, **resources | ||
| bucket = resources[:bucket] | ||
| object = resources[:object] | ||
| if _preconditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. underscored variable
| def self.patch_file client, _preconditions, **resources | ||
| bucket = resources[:bucket] | ||
| object = resources[:object] | ||
| if _preconditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
| def self.rewrite_file client, _preconditions, **resources | ||
| bucket = resources[:bucket] | ||
| object = resources[:object] | ||
| if _preconditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here
google-cloud-storage/Rakefile
Outdated
| end | ||
| end | ||
|
|
||
| #Conformance Tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
google-cloud-storage/conformance/v1/proto/google/cloud/conformance/storage/v1/tests.proto
Show resolved
Hide resolved
google-cloud-storage/test/google/cloud/storage/retry/conformance_test.rb
Outdated
Show resolved
Hide resolved
| end | ||
|
|
||
| def self.insert_bucket client, _preconditions, **resources | ||
| bucket_name = "new_bucket" + Time.now.to_i.to_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. It's best to append some random digits to prevent this.
|
|
||
| def self.bucket_acl_public client, _preconditions, **resources | ||
| bucket = resources[:bucket] | ||
| if _preconditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
|
|
||
| def self.insert_object client, _preconditions, **resources | ||
| bucket = resources[:bucket] | ||
| file = StringIO.new CONF_TEST_FILE_CONTENT * 1024 * 1024 # 1MB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this is actually 1024 * 1024 * CONF_TEST_FILE_CONTENT.size which is 12MB rather than 1MB. Just making sure that's what you intend for this object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's indeed 12 MB.
We needed a use case where we're doing multi chunk upload. The default chunk size is 8MB, so needed an input bigger than that.
shivgautam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
dazuma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tritone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great, very clear and well factored. I know this was a big effort so thank you @bajajneha27 !
| ## Running the tests | ||
|
|
||
| The conformance tests are included in the ordinary unit test suite. In the `google-cloud-storage` directory, run `rake test`. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the emulator need to be launched separately in order to run the tests? If so worth noting how to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does. Updated README to include that. Thanks.
|
|
||
| def self.get | ||
| { | ||
| "storage.bucket_acl.list" => [:list_bucket_acls], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could you sort these by resource / alphabetically? Otherwise it's a bit difficult to see all of what's implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Updated it alphabetically.
| "storage.buckets.setIamPolicy" => [:set_bucket_policy], | ||
| "storage.hmacKey.update" => [:update_hmac_key], | ||
| "storage.resumable.upload" => [ | ||
| :blob_upload_from_string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I notice that I think these still need to be implemented, correct? Fine to do it in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented them as part of storage.objects.insert . If we need to implement more varieties of it, can be done in separate PR.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
bundle exec rake ciin the gem subdirectory.closes: b/228274210