Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b772454
initial tests for retry strategy conformance tests implementation
cojenco Apr 30, 2021
c78011e
revise helper methods to interact with Retry Test API
cojenco May 3, 2021
09b8903
add helper to delete retry test
cojenco May 4, 2021
2845731
handle exceptions in helper methods
cojenco May 4, 2021
e615dc9
remove try except
cojenco May 5, 2021
b7c6b4a
change payload key to instructions to align emulator change
cojenco May 19, 2021
489643f
rename and revise to loop through each case and method
cojenco May 19, 2021
c6c3fff
wip populate resources to conf tests
cojenco May 19, 2021
6281e70
add logic to populate fixture resources
cojenco May 20, 2021
c595aa5
add helper method to populate fixture hmacy key
cojenco May 20, 2021
294b084
revise endpoints and 2 clients
cojenco May 20, 2021
7e8bd06
add assertions to testdata scenarios
cojenco May 20, 2021
d4ed764
add logic for preconditions wip
cojenco May 20, 2021
b59c39d
add mapping scenarios and formatting for readability
cojenco May 21, 2021
cca0c65
add library methods to method invocation mapping and json
cojenco May 21, 2021
dcb2f09
lint
cojenco May 21, 2021
5b33dc2
refactor using **kwargs
cojenco May 25, 2021
11d9ee1
remove unused module and fix lint
cojenco May 25, 2021
70c6501
Merge branch 'master' into retry-conf-tests
cojenco May 25, 2021
ee61aab
handle misused arguments following style guide
cojenco May 25, 2021
694ae33
handle unused arguments
cojenco May 25, 2021
e9cf5b1
wip: add library methods to mapping and json
cojenco May 26, 2021
ffe7183
add client_options to resource populating client
cojenco May 27, 2021
cba9d13
log warnings and revise try except blocks
cojenco May 27, 2021
15567c2
update schema for S1 and S2
cojenco Jun 1, 2021
e7a7e34
Merge branch 'master' into retry-conf-tests
cojenco Jun 1, 2021
952769b
fix lint and mark error
cojenco Jun 1, 2021
6c31f01
move retry conformance tests to separate folder
cojenco Jun 1, 2021
cf092fc
update noxfile
cojenco Jun 1, 2021
95a3cc8
relocate conformance tests
cojenco Jun 1, 2021
90b586d
add S1 S2 tests and delete json file
cojenco Jun 3, 2021
0e051fe
lint and clean comments
cojenco Jun 3, 2021
b121df3
add S2 object library methods
cojenco Jun 4, 2021
ca5ab24
Merge branch 'master' into retry-conf-tests
cojenco Jun 8, 2021
996534b
Merge branch 'master' into retry-conf-tests
cojenco Jun 10, 2021
77e79cc
address comments
cojenco Jun 10, 2021
f49b30f
change test parametrization to separate test cases and address comments
cojenco Jun 11, 2021
de3ee4b
add assertion message and display library method name
cojenco Jun 17, 2021
9717daf
Merge branch 'master' into retry-conf-tests
cojenco Jun 18, 2021
9f123f5
Merge branch 'retry-conf-tests' of github.com:googleapis/python-stora…
cojenco Jun 18, 2021
b4096a2
add multiple lib methods and revise assertion message
cojenco Jun 18, 2021
e49a9d2
add S2 entry library methods after emulator fix
cojenco Jun 23, 2021
9483381
Merge branch 'master' into retry-conf-tests
cojenco Jun 23, 2021
fb24d47
Merge branch 'retry-conf-tests' of github.com:googleapis/python-stora…
cojenco Jun 23, 2021
8fe60c1
Merge branch 'master' into retry-conf-tests
cojenco Jun 25, 2021
90a0438
address comments
cojenco Jun 26, 2021
0a6de71
Merge branch 'master' into retry-conf-tests
cojenco Jun 30, 2021
05fc261
revise test case structure using python globals
cojenco Jul 12, 2021
083f61a
Merge branch 'master' into retry-conf-tests
cojenco Jul 12, 2021
d70b44b
revise library methods naming to start with class name
cojenco Jul 12, 2021
0e8a111
unify library method signatures
cojenco Jul 13, 2021
efc75cc
cleanup code
cojenco Jul 13, 2021
1ff387c
use pytest fixtures to populate resources
cojenco Jul 14, 2021
53b9f7d
Merge branch 'master' into retry-conf-tests
cojenco Jul 14, 2021
cfe0168
Merge branch 'master' of github.com:googleapis/python-storage into re…
cojenco Jul 28, 2021
994a2f6
address comments and update docstrings
cojenco Jul 28, 2021
f35cced
address comments. change to use anonymous credentials
cojenco Aug 6, 2021
f0586e3
Merge branch 'master' into retry-conf-tests
cojenco Aug 6, 2021
eb8b9bf
Merge branch 'master' into retry-conf-tests
cojenco Aug 18, 2021
0b52219
update descriptions
cojenco Aug 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
DEFAULT_PYTHON_VERSION = "3.8"
SYSTEM_TEST_PYTHON_VERSIONS = ["2.7", "3.8"]
UNIT_TEST_PYTHON_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"]
CONFORMANCE_TEST_PYTHON_VERSIONS = ["3.8"]

_DEFAULT_STORAGE_HOST = "https://storage.googleapis.com"

CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()

Expand Down Expand Up @@ -148,6 +151,37 @@ def system(session):
session.run("py.test", "--quiet", system_test_folder_path, *session.posargs)


@nox.session(python=CONFORMANCE_TEST_PYTHON_VERSIONS)
def conftest_retry(session):
"""Run the retry conformance test suite."""
conformance_test_path = os.path.join("tests", "conformance.py")
conformance_test_folder_path = os.path.join("tests", "conformance")

# Environment check: Only run tests if the STORAGE_EMULATOR_HOST is set.
if (
os.environ.get("STORAGE_EMULATOR_HOST", _DEFAULT_STORAGE_HOST)
== _DEFAULT_STORAGE_HOST
):
session.skip("Set STORAGE_EMULATOR_HOST to run, skipping")

conformance_test_exists = os.path.exists(conformance_test_path)
conformance_test_folder_exists = os.path.exists(conformance_test_folder_path)
# Environment check: only run tests if found.
if not conformance_test_exists and not conformance_test_folder_exists:
session.skip("Conformance tests were not found")

session.install("pytest",)
session.install("-e", ".")

# Run py.test against the conformance tests.
if conformance_test_exists:
session.run("py.test", "--quiet", conformance_test_path, *session.posargs)
if conformance_test_folder_exists:
session.run(
"py.test", "--quiet", conformance_test_folder_path, *session.posargs
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def cover(session):
"""Run the final coverage report.
Expand Down
24 changes: 24 additions & 0 deletions tests/conformance/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import io
import json
import os


def _read_local_json(json_file):
here = os.path.dirname(__file__)
json_path = os.path.abspath(os.path.join(here, json_file))
with io.open(json_path, "r", encoding="utf-8-sig") as fileobj:
return json.load(fileobj)
262 changes: 262 additions & 0 deletions tests/conformance/retry_strategy_test_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
{
"retryStrategyTests": [
{
"id": 1,
"description": "always idempotent",
"cases": [
{
"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.lockRententionPolicy",
"resources": [
"BUCKET"
]
},
{
"name": "storage.buckets.testIamPermission",
"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": []
}
],
"preconditionProvided": false,
"expectSuccess": true
},
{
"id": 2,
"description": "conditionally idempotent retries when precondition is present",
"cases": [
{
"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"
]
}
],
"preconditionProvided": true,
"expectSuccess": true
},
{
"id": 3,
"description": "conditionally idempotent no retries when precondition is absent",
"cases": [
{
"instructions": []
}
],
"methods": [],
"preconditionProvided": false,
"expectSuccess": false
},
{
"id": 4,
"description": "non idempotent",
"cases": [
{
"instructions": []
}
],
"methods": [],
"preconditionProvided": false,
"expectSuccess": false
}
]
}
Loading