Skip to content

Commit

Permalink
tests: add retry conf test cases for conditionally idempotent operati…
Browse files Browse the repository at this point in the history
…ons with no preconditions (#566)

This adds test cases to the retry strategy conformance tests:

- Scenario 3 - for conditionally idempotent operations with retryable error codes, libraries **don't** retry when preconditions are absent
- Add test schema for scenario 3 and align json file with [conformance-tests/retry_tests.json](https://github.com/googleapis/conformance-tests/blob/master/storage/v1/retry_tests.json)
  • Loading branch information
cojenco authored Sep 2, 2021
1 parent 57cf3a1 commit 3a489ad
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 216 deletions.
267 changes: 52 additions & 215 deletions tests/conformance/retry_strategy_test_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,247 +2,84 @@
"retryStrategyTests": [
{
"id": 1,
"description": "always idempotent",
"description": "always_idempotent",
"cases": [
{
"instructions": [
"return-503",
"return-503"
]
"instructions": ["return-503", "return-503"]
}
],
"methods": [
{
"name": "storage.bucket_acl.get",
"resources": [
"BUCKET"
]
},
{
"name": "storage.bucket_acl.list",
"resources": [
"BUCKET"
]
},
{
"name": "storage.buckets.delete",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.buckets.get",
"resources": [
"BUCKET"
]
},
{
"name": "storage.buckets.getIamPolicy",
"resources": [
"BUCKET"
]
},
{
"name": "storage.buckets.insert",
"resources": []
},
{
"name": "storage.buckets.list",
"resources": [
"BUCKET"
]
},
{
"name": "storage.buckets.lockRetentionPolicy",
"resources": [
"BUCKET"
]
},
{
"name": "storage.buckets.testIamPermissions",
"resources": [
"BUCKET"
]
},
{
"name": "storage.default_object_acl.get",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.default_object_acl.list",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.hmacKey.delete",
"resources": []
},
{
"name": "storage.hmacKey.get",
"resources": []
},
{
"name": "storage.hmacKey.list",
"resources": []
},
{
"name": "storage.notifications.delete",
"resources": [
"BUCKET",
"NOTIFICATION"
]
},
{
"name": "storage.notifications.get",
"resources": [
"BUCKET",
"NOTIFICATION"
]
},
{
"name": "storage.notifications.list",
"resources": [
"BUCKET",
"NOTIFICATION"
]
},
{
"name": "storage.object_acl.get",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.object_acl.list",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.objects.get",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.objects.list",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.serviceaccount.get",
"resources": []
}
{"name": "storage.bucket_acl.get", "resources": ["BUCKET"]},
{"name": "storage.bucket_acl.list", "resources": ["BUCKET"]},
{"name": "storage.buckets.delete", "resources": ["BUCKET"]},
{"name": "storage.buckets.get", "resources": ["BUCKET"]},
{"name": "storage.buckets.getIamPolicy", "resources": ["BUCKET"]},
{"name": "storage.buckets.insert", "resources": []},
{"name": "storage.buckets.list", "resources": ["BUCKET"]},
{"name": "storage.buckets.lockRetentionPolicy", "resources": ["BUCKET"]},
{"name": "storage.buckets.testIamPermissions", "resources": ["BUCKET"]},
{"name": "storage.default_object_acl.get", "resources": ["BUCKET"]},
{"name": "storage.default_object_acl.list", "resources": ["BUCKET"]},
{"name": "storage.hmacKey.delete", "resources": ["HMAC_KEY"]},
{"name": "storage.hmacKey.get", "resources": ["HMAC_KEY"]},
{"name": "storage.hmacKey.list", "resources": ["HMAC_KEY"]},
{"name": "storage.notifications.delete", "resources": ["BUCKET", "NOTIFICATION"]},
{"name": "storage.notifications.get", "resources": ["BUCKET", "NOTIFICATION"]},
{"name": "storage.notifications.list", "resources": ["BUCKET", "NOTIFICATION"]},
{"name": "storage.object_acl.get", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.object_acl.list", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.get", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.list", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.serviceaccount.get", "resources": []}
],
"preconditionProvided": false,
"expectSuccess": true
},
{
"id": 2,
"description": "conditionally idempotent retries when precondition is present",
"description": "conditionally_idempotent_retries_when_precondition_is_present",
"cases": [
{
"instructions": [
"return-503",
"return-503"
]
"instructions": ["return-503", "return-503"]
}
],
"methods": [
{
"name": "storage.buckets.patch",
"resources": [
"BUCKET"
]
},
{
"name": "storage.buckets.setIamPolicy",
"resources": [
"BUCKET"
]
},
{
"name": "storage.buckets.update",
"resources": [
"BUCKET"
]
},
{
"name": "storage.hmacKey.update",
"resources": []
},
{
"name": "storage.objects.compose",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.objects.copy",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.objects.delete",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.objects.insert",
"resources": [
"BUCKET"
]
},
{
"name": "storage.objects.patch",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.objects.rewrite",
"resources": [
"BUCKET",
"OBJECT"
]
},
{
"name": "storage.objects.update",
"resources": [
"BUCKET",
"OBJECT"
]
}
{"name": "storage.buckets.patch", "resources": ["BUCKET"]},
{"name": "storage.buckets.setIamPolicy", "resources": ["BUCKET"]},
{"name": "storage.buckets.update", "resources": ["BUCKET"]},
{"name": "storage.hmacKey.update", "resources": ["HMAC_KEY"]},
{"name": "storage.objects.compose", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.copy", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.delete", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.insert", "resources": ["BUCKET"]},
{"name": "storage.objects.patch", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.rewrite", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.update", "resources": ["BUCKET", "OBJECT"]}
],
"preconditionProvided": true,
"expectSuccess": true
},
{
"id": 3,
"description": "conditionally idempotent no retries when precondition is absent",
"description": "conditionally_idempotent_no_retries_when_precondition_is_absent",
"cases": [
{
"instructions": []
"instructions": ["return-503"]
}
],
"methods": [],
"methods": [
{"name": "storage.buckets.patch", "resources": ["BUCKET"]},
{"name": "storage.buckets.setIamPolicy", "resources": ["BUCKET"]},
{"name": "storage.buckets.update", "resources": ["BUCKET"]},
{"name": "storage.hmacKey.update", "resources": ["HMAC_KEY"]},
{"name": "storage.objects.compose", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.copy", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.delete", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.insert", "resources": ["BUCKET"]},
{"name": "storage.objects.patch", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.rewrite", "resources": ["BUCKET", "OBJECT"]},
{"name": "storage.objects.update", "resources": ["BUCKET", "OBJECT"]}
],
"preconditionProvided": false,
"expectSuccess": false
},
Expand Down
2 changes: 1 addition & 1 deletion tests/conformance/test_conformance.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def bucket(client):
@pytest.fixture
def object(client, bucket):
blob = client.bucket(bucket.name).blob(uuid.uuid4().hex)
blob.upload_from_string(_STRING_CONTENT, checksum="crc32c")
blob.upload_from_string(_STRING_CONTENT)
blob.reload()
yield blob
try:
Expand Down

0 comments on commit 3a489ad

Please sign in to comment.