Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fix cover for retry.py
  • Loading branch information
tswast committed Feb 21, 2025
commit 189f559fd22114d7315272088b9d1a655fbfbb9c
1 change: 0 additions & 1 deletion google/cloud/bigquery/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def _query_job_insert_should_retry(exc):
# doesn't actually exist and try again. We can't add 404 to the default
# job_retry because that happens for errors like "this table does not
# exist", which probably won't resolve with a retry.

if isinstance(exc, exceptions.RetryError):
exc = exc.cause

Expand Down
17 changes: 10 additions & 7 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5414,9 +5414,14 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_retries_404_and_query
creds = _make_credentials()
http = object()
client = self._make_one(project=self.PROJECT, credentials=creds, _http=http)

# We're mocking QueryJob._begin, so that the connection should only get
# jobs.get requests.
job_create_error = google.api_core.exceptions.Conflict("Job already exists.")
job_begin_patcher = mock.patch.object(
bqjob.QueryJob, "_begin", side_effect=job_create_error
)
conn = client._connection = make_connection(
# We're mocking QueryJob._begin, so this is only going to be
# jobs.get requests and responses.
google.api_core.exceptions.NotFound("we lost your job again, sorry"),
{
"jobReference": {
Expand All @@ -5428,10 +5433,8 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_retries_404_and_query
)

# Choose a small deadline so the 404 retries give up.
retry = google.cloud.bigquery.retry.DEFAULT_RETRY.with_deadline(1)
job_create_error = google.api_core.exceptions.Conflict("Job already exists.")
job_begin_patcher = mock.patch.object(
bqjob.QueryJob, "_begin", side_effect=job_create_error
retry = (
google.cloud.bigquery.retry._DEFAULT_GET_JOB_CONFLICT_RETRY.with_deadline(1)
)
job_id_patcher = mock.patch.object(
google.cloud.bigquery._job_helpers,
Expand All @@ -5447,7 +5450,7 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_retries_404_and_query
with freezegun.freeze_time(
"2025-01-01 00:00:00",
# 10x the retry deadline to guarantee a timeout.
auto_tick_seconds=100,
auto_tick_seconds=10,
), job_begin_patcher, job_id_patcher, retry_patcher:
# If get job request fails there does exist a job
# with this ID already, retry 404 until we get it (or fails for a
Expand Down