Skip to content
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

tests: add retry conformance test framework and test always idempotent operations #450

Merged
merged 60 commits into from Aug 19, 2021

Conversation

cojenco
Copy link
Contributor

@cojenco cojenco commented May 25, 2021

Retry strategies are included in the client library when it's safe to do so. These retry strategies are complex and need automated integration tests to ensure they work and continue to work in the future.

This adds retry strategy conformance tests that are expected to run against a local GCS API emulator and validate correct behavior around retryable errors, idempotency considerations and preconditions. This PR includes the tests and schema json for:

  • Scenario 1 - Libraries retry all idempotent operations for retriable error codes
  • Scenario 2 - For conditionally idempotent operations with retryable error codes, libraries retry when precondition is present

Tests are loaded by the json directly. An individual test case is generated for each scenario ID, instruction set, method, and method_invocation_mapping_library_method). Test names are displayed as test-S{scenario_id}-{method}-{client-library-method-name}, for example, test-S1-storage.buckets.insert-bucket_create

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/python-storage API. label May 25, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 25, 2021
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
@cojenco cojenco requested a review from tritone July 14, 2021 20:31
Copy link
Contributor

@andrewsg andrewsg left a comment

Choose a reason for hiding this comment

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

Great work so far!

tests/conformance/test_conformance.py Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
notification,
hmac_key,
)
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why catch and log this instead of just letting the exception bubble up and have pytest deal with it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Catching the exception here helps verify whether or not the test ran successfully, with a variable success_results. success_results is compared against expect_success from the schema.

For test scenarios 3 and 4, the tests are expected to fail, hence why we're catching the exception.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see-- would the test logs be filled with all these exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep the exceptions here are caught and logged.

@cojenco cojenco requested a review from andrewsg July 28, 2021 23:53
Copy link
Contributor

@tritone tritone left a comment

Choose a reason for hiding this comment

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

Couple nits and questions, otherwise LGTM! This is looking so much cleaner, thank you for all your work!

noxfile.py Outdated Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Show resolved Hide resolved
tests/conformance/test_conformance.py Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
notification,
hmac_key,
)
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

I see-- would the test logs be filled with all these exceptions?

tests/conformance/test_conformance.py Outdated Show resolved Hide resolved
tests/conformance/test_conformance.py Show resolved Hide resolved
@cojenco cojenco requested a review from tritone August 6, 2021 20:50
Copy link
Contributor

@andrewsg andrewsg left a comment

Choose a reason for hiding this comment

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

Looks great. The conformance test idea has come a long way thanks in part to this implementation and review. Good stuff.

tests/conformance/test_conformance.py Show resolved Hide resolved
@cojenco cojenco changed the title tests: add retry conformance tests [WIP] tests: add retry conformance test framework and test always idempotent operations Aug 19, 2021
@cojenco cojenco merged commit bd72f5d into master Aug 19, 2021
@cojenco cojenco deleted the retry-conf-tests branch August 19, 2021 00:52
cojenco added a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
…t operations (googleapis#450)

* initial tests for retry strategy conformance tests implementation

* revise helper methods to interact with Retry Test API

* add helper to delete retry test

* handle exceptions in helper methods

* remove try except

* change payload key to instructions to align emulator change

* rename and revise to loop through each case and method

* wip populate resources to conf tests

* add logic to populate fixture resources

* add helper method to populate fixture hmacy key

* revise endpoints and 2 clients

* add assertions to testdata scenarios

* add logic for preconditions wip

* add mapping scenarios and formatting for readability

* add library methods to method invocation mapping and json

* lint

* refactor using **kwargs

* remove unused module and fix lint

* handle misused arguments following style guide

* handle unused arguments

* wip: add library methods to mapping and json

* add client_options to resource populating client

* log warnings and revise try except blocks

* update schema for S1 and S2

* fix lint and mark error

* move retry conformance tests to separate folder

* update noxfile

* relocate conformance tests

* add S1 S2 tests and delete json file

* lint and clean comments

* add S2 object library methods

* address comments

* change test parametrization to separate test cases and address comments

* add assertion message and display library method name

* add multiple lib methods and revise assertion message

* add S2 entry library methods after emulator fix

* address comments

* revise test case structure using python globals

* revise library methods naming to start with class name

* unify library method signatures

* cleanup code

* use pytest fixtures to populate resources

* address comments and update docstrings

* address comments. change to use anonymous credentials

* update descriptions
cojenco added a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
…t operations (googleapis#450)

* initial tests for retry strategy conformance tests implementation

* revise helper methods to interact with Retry Test API

* add helper to delete retry test

* handle exceptions in helper methods

* remove try except

* change payload key to instructions to align emulator change

* rename and revise to loop through each case and method

* wip populate resources to conf tests

* add logic to populate fixture resources

* add helper method to populate fixture hmacy key

* revise endpoints and 2 clients

* add assertions to testdata scenarios

* add logic for preconditions wip

* add mapping scenarios and formatting for readability

* add library methods to method invocation mapping and json

* lint

* refactor using **kwargs

* remove unused module and fix lint

* handle misused arguments following style guide

* handle unused arguments

* wip: add library methods to mapping and json

* add client_options to resource populating client

* log warnings and revise try except blocks

* update schema for S1 and S2

* fix lint and mark error

* move retry conformance tests to separate folder

* update noxfile

* relocate conformance tests

* add S1 S2 tests and delete json file

* lint and clean comments

* add S2 object library methods

* address comments

* change test parametrization to separate test cases and address comments

* add assertion message and display library method name

* add multiple lib methods and revise assertion message

* add S2 entry library methods after emulator fix

* address comments

* revise test case structure using python globals

* revise library methods naming to start with class name

* unify library method signatures

* cleanup code

* use pytest fixtures to populate resources

* address comments and update docstrings

* address comments. change to use anonymous credentials

* update descriptions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants