GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Consolidate retry logic by tseaver · Pull Request #2050 · googleapis/google-cloud-python

Conversation

@tseaver

@tseaver tseaver commented Aug 3, 2016

Copy link
Copy Markdown
Contributor

Toward #2042.

This PR tries to rationalize the retries in our system tests into three types:

  • Retry methods which raise particular exceptions (the class @daspecster implemented already)
  • Retry methods until the result passes a predicate (generalizing the backoff stuff in logging_).
  • Retry methods until a predicate on the instance's __self__ passes (e.g., until job.state == "done").

The PR adds classes for each of these categories, and attempts to use them where appropriate, replacing manual time.sleep() calls and existing "backoff" functions / loops.

It also tweaks the tox -e system-tests runner to attempt all system test modules, even if one fails, and tries to run them in order from least to most flake.

BTW, cannot figure out how to get the translate tests to run at all, and there is one of the error_reporting tests which blows up at me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tseaver tseaver added the testing label Aug 3, 2016
@tseaver tseaver assigned daspecster and dhermes Aug 3, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 3, 2016
This was referenced Aug 3, 2016
Adopt common timeout/retry/backoff strategy for system tests. #1619
Closed
Investigate novel pub/sub system test failures #1085
Closed
Investigate novel bigquery system test failures #1104
Closed
@daspecster

daspecster commented Aug 3, 2016

Copy link
Copy Markdown
Contributor

@tseaver nice! Did you happen to try this on any of the pubsub failures? I tried retrying them last night but they still failed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Aug 3, 2016

Copy link
Copy Markdown
Contributor

Lint failure

system_tests/retry.py:163:9: E301 expected 1 blank line, found 0
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes
dhermes reviewed Aug 3, 2016
View reviewed changes
Comment thread system_tests/attempt_system_tests.py Outdated
from run_system_test import run_module_tests


MODULES = (

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Aug 3, 2016

Copy link
Copy Markdown
Contributor

Really great work!

How did you decide which flaky test cases to target?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Aug 4, 2016

Copy link
Copy Markdown
Contributor Author

@dhermes Thanks! I was tackling those which fail routinely, first on my box and then on Travis. I imagine we haven't whacked the last mole yet.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes
dhermes reviewed Aug 4, 2016
View reviewed changes
Comment thread system_tests/retry.py Outdated
:param logger: Logger to use. If None, print.
"""
def __init__(self, instance_predicate,
max_tries=MAX_TRIES, delay=1, backoff=BACKOFF, logger=None):

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tseaver added 2 commits August 4, 2016 15:10
@tseaver
Rename 'Retry' -> 'RetryErrors'.
f6f4b65
Better indicates its purpose relative to other retry implementations.

Rename 'tries' -> 'max_tries' for clarity.

Also, rework the exponential backoff bits to make a little clearer.
@tseaver
Add an 'error_predicate' to 'RetryErrors'.
6a70a90
Allows choosing to retry caught exceptions based on exception attributes.

Use the new predicate feature for Bigtable retry/backoff:  we want to
retry only gRCP 'AbortionErrors' which have a status code of
'UNAVAILABLE'.
tseaver added 14 commits August 4, 2016 15:10
@tseaver
Add 'retry.RetryResult'.
a04edfd
Permits retrying a method call until it returns the expected result,
e.g. until the newly-created 'Widget' shows up in the 'list_widgets'
API call (eventual consistency).
@tseaver
Add 'retry.RetryInstanceState'.
8cc3c49
Permits retrying a method call until it its instance is in a given state,
e.g. until a job is 'done'.
@tseaver
Add retries for 'test_list_{topics,subscriptions}'.
d6f0793
@tseaver
Move away from decorating wrapper functions.
4979112
The imperative form is cleaner.
@tseaver
Add retry for eventually-orphaned subscription.
dd68fa3
@tseaver
Add retries for '{sink,metric}.create' when setting up 'reload'/'upda…
0c0b314
…te':

The back end may raise a transient Conflict because the instance created
by the previous testcase is not-dead-yet.
@tseaver
Order system test suites by flakiness.
d0bc55d
@tseaver
Attempt *all* system test modules, even after one fails.
c938074
@tseaver
Lint fixups.
d4985da
@tseaver
Add comment explaining ordering of test modules.
530edcb
@tseaver
Fix comment, number of tries to ensure 90 seconds.
2ae304f
Addresses:
#2050 (comment)
@tseaver
Typo.
60a5a74
Addresses:
#2050 (comment)
@tseaver
Avoid double-casting execption to string.
40cd346
Addresses:
#2050 (comment)
@tseaver
Use module-scope constants for defaults.
7b955bf
Addresses:
#2050 (comment)
@tseaver

tseaver commented Aug 7, 2016

Copy link
Copy Markdown
Contributor Author

@dhermes Any remaining issues? I think we disagree about the third RetryInstanceState class: should we ask @jgeewax to be the tie-breaker? I believe @daspecster is mostly offline through the end of next wee,.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Aug 8, 2016

Copy link
Copy Markdown
Contributor

My argument for a tie-breaker: fewer classes is better 😀

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Aug 8, 2016

Copy link
Copy Markdown
Contributor Author

Mine: the third class makes the intent clearer: I still have to puzzle out exactly how your examples work every time I look at them.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tseaver added 2 commits August 8, 2016 14:08
@tseaver
Address EC issues in storage.
00d42d8
See reports 4) an 7) in:
#1100
@tseaver
Wait longer for orphaned subscription to have topic==None.
9f499ae
@dhermes

dhermes commented Aug 9, 2016

Copy link
Copy Markdown
Contributor

LGTM. Let's get this merged before it gets stale

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver
tseaver merged commit eab9cd6 into googleapis:master Aug 9, 2016
@tseaver
tseaver deleted the consolidate-retry-logic branch August 9, 2016 18:39
This was referenced Aug 9, 2016
Consolidate backoff code in system tests #2042
Closed
Flaky System Tests #1796
Closed
@dhermes dhermes mentioned this pull request Sep 19, 2016
Cut 0.19.0 release. #2270
Merged
@theacodes theacodes unassigned daspecster and dhermes Sep 28, 2018
parthea pushed a commit that referenced this pull request Nov 24, 2025
@daniel-sanche
chore: fix AwaitableMock test coverage (#2050)
b1f8440
parthea pushed a commit that referenced this pull request Mar 6, 2026
@leahecole
chore: two fixit fixes (#2050)
1a678b9
parthea pushed a commit that referenced this pull request Apr 1, 2026
@release-please
chore(main): release 2.19.0 (#2050)
1be9635
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement. testing

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@tseaver @daspecster @dhermes @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.