Skip to content

tests: harden 'extra table' cleanup vs. 403 #362

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

Merged
merged 2 commits into from
Oct 26, 2021
Merged
Changes from all commits
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
7 changes: 6 additions & 1 deletion tests/system/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import pytest
import sqlalchemy

from google.api_core import exceptions
from google.cloud import bigquery
import test_utils.prefixer
import test_utils.retry

from sqlalchemy_bigquery import BigQueryDialect

Expand Down Expand Up @@ -128,7 +130,10 @@ def bigquery_regional_dataset(bigquery_client, bigquery_schema):
@pytest.fixture(autouse=True)
def cleanup_extra_tables(bigquery_client, bigquery_dataset):
common = "sample", "sample_one_row", "sample_view", "sample_dml_empty"
for table in bigquery_client.list_tables(bigquery_dataset):
# Back-end may raise 403 for a dataset not ready yet.
retry_403 = test_utils.retry.RetryErrors(exceptions.Forbidden)
tables = retry_403(bigquery_client.list_tables)(bigquery_dataset)
for table in tables:
if table.table_id not in common:
bigquery_client.delete_table(table)

Expand Down