Skip to content

Commit

Permalink
fix: skip some system tests for mtls testing
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Dec 17, 2020
1 parent cef5d4a commit c0753e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/system/v1/conftest.py
Expand Up @@ -33,9 +33,20 @@ def project_id():


@pytest.fixture(scope="session")
def credentials():
def use_mtls():
return "always" == os.environ.get("GOOGLE_API_USE_MTLS_ENDPOINT", "never")


@pytest.fixture(scope="session")
def credentials(use_mtls):
import google.auth
from google.oauth2 import service_account

if use_mtls:
# mTLS test uses user credentials instead of service account credentials
creds, _ = google.auth.default()
return creds

# NOTE: the test config in noxfile checks that the env variable is indeed set
filename = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
return service_account.Credentials.from_service_account_file(filename)
Expand Down
17 changes: 17 additions & 0 deletions tests/system/v1/test_reader_v1.py
Expand Up @@ -18,6 +18,7 @@
import copy
import datetime as dt
import decimal
import os
import re

import pytest
Expand All @@ -27,6 +28,14 @@
from google.cloud.bigquery_storage import types


# Skip the test cases using bigquery client for mTLS testing since it
# doesn't have mTLS support yet.
skip_for_mtls = pytest.mark.skipif(
"always" == os.environ.get("GOOGLE_API_USE_MTLS_ENDPOINT", "never"),
reason="Skip the test case for mTLS testing",
)


def _to_bq_table_ref(table_name_string, partition_suffix=""):
"""Converts protobuf table reference to bigquery table reference.
Expand Down Expand Up @@ -107,6 +116,7 @@ def test_read_rows_as_rows_full_table(
assert len(rows) > 0


@skip_for_mtls
@pytest.mark.parametrize(
"data_format", ((types.DataFormat.AVRO), (types.DataFormat.ARROW))
)
Expand All @@ -129,6 +139,7 @@ def test_basic_nonfiltered_read(client, project_id, table_with_data_ref, data_fo
assert len(rows) == 5 # all table rows


@skip_for_mtls
def test_filtered_rows_read(client, project_id, table_with_data_ref):
read_session = types.ReadSession()
read_session.table = table_with_data_ref
Expand All @@ -149,6 +160,7 @@ def test_filtered_rows_read(client, project_id, table_with_data_ref):
assert len(rows) == 2


@skip_for_mtls
@pytest.mark.parametrize(
"data_format", ((types.DataFormat.AVRO), (types.DataFormat.ARROW))
)
Expand All @@ -175,6 +187,7 @@ def test_column_selection_read(client, project_id, table_with_data_ref, data_for
assert sorted(row.keys()) == ["age", "first_name"]


@skip_for_mtls
def test_snapshot(client, project_id, table_with_data_ref, bq_client):
before_new_data = types.Timestamp()
before_new_data.GetCurrentTime()
Expand Down Expand Up @@ -213,6 +226,7 @@ def test_snapshot(client, project_id, table_with_data_ref, bq_client):
assert "NewGuy" not in row["first_name"] # no new records


@skip_for_mtls
def test_column_partitioned_table(
client, project_id, col_partition_table_ref, bq_client
):
Expand Down Expand Up @@ -256,6 +270,7 @@ def test_column_partitioned_table(
assert row["description"] in expected_descriptions


@skip_for_mtls
@pytest.mark.parametrize(
"data_format", ((types.DataFormat.AVRO), (types.DataFormat.ARROW))
)
Expand Down Expand Up @@ -316,6 +331,7 @@ def test_ingestion_time_partitioned_table(
assert actual_items == expected_items


@skip_for_mtls
@pytest.mark.parametrize(
"data_format", ((types.DataFormat.AVRO), (types.DataFormat.ARROW))
)
Expand Down Expand Up @@ -421,6 +437,7 @@ def test_decoding_data_types(
assert expected_pattern.match(str(rows[0]["datetime_field"]))


@skip_for_mtls
@pytest.mark.parametrize(
"data_format", ((types.DataFormat.AVRO), (types.DataFormat.ARROW))
)
Expand Down

0 comments on commit c0753e4

Please sign in to comment.