Skip to content

Commit 85242c0

Browse files
tests: skip some system tests for mtls testing (#105)
1 parent 6a46b46 commit 85242c0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/system/test_system.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import datetime
1616
import logging
17+
import os
18+
import pytest
1719
import unittest
1820

1921
from google.api_core.exceptions import BadGateway
@@ -81,12 +83,21 @@ class Config(object):
8183
"""
8284

8385
CLIENT = None
86+
use_mtls = os.environ.get("GOOGLE_API_USE_MTLS_ENDPOINT", "never")
8487

8588

8689
def setUpModule():
8790
Config.CLIENT = client.Client()
8891

8992

93+
# Skip the test cases using bigquery, storage and pubsub clients for mTLS testing.
94+
# Bigquery and storage uses http which doesn't have mTLS support, pubsub doesn't
95+
# have mTLS fix released yet.
96+
skip_for_mtls = pytest.mark.skipif(
97+
Config.use_mtls == "always", reason="Skip the test case for mTLS testing"
98+
)
99+
100+
90101
class TestLogging(unittest.TestCase):
91102

92103
JSON_PAYLOAD = {
@@ -408,6 +419,7 @@ def _init_storage_bucket(self):
408419

409420
return BUCKET_URI
410421

422+
@skip_for_mtls
411423
def test_create_sink_storage_bucket(self):
412424
uri = self._init_storage_bucket()
413425
SINK_NAME = "test-create-sink-bucket%s" % (_RESOURCE_ID,)
@@ -421,6 +433,7 @@ def test_create_sink_storage_bucket(self):
421433
self.to_delete.append(sink)
422434
self.assertTrue(sink.exists())
423435

436+
@skip_for_mtls
424437
def test_create_sink_pubsub_topic(self):
425438
from google.cloud import pubsub_v1
426439

@@ -474,6 +487,7 @@ def _init_bigquery_dataset(self):
474487
bigquery_client.update_dataset(dataset, ["access_entries"])
475488
return dataset_uri
476489

490+
@skip_for_mtls
477491
def test_create_sink_bigquery_dataset(self):
478492
SINK_NAME = "test-create-sink-dataset%s" % (_RESOURCE_ID,)
479493
retry = RetryErrors((Conflict, ServiceUnavailable), max_tries=10)
@@ -486,6 +500,7 @@ def test_create_sink_bigquery_dataset(self):
486500
self.to_delete.append(sink)
487501
self.assertTrue(sink.exists())
488502

503+
@skip_for_mtls
489504
def test_list_sinks(self):
490505
SINK_NAME = "test-list-sinks%s" % (_RESOURCE_ID,)
491506
uri = self._init_storage_bucket()
@@ -504,6 +519,7 @@ def test_list_sinks(self):
504519
after_names = set(after.name for after in after_sinks)
505520
self.assertTrue(sink.name in after_names)
506521

522+
@skip_for_mtls
507523
def test_reload_sink(self):
508524
SINK_NAME = "test-reload-sink%s" % (_RESOURCE_ID,)
509525
retry = RetryErrors((Conflict, ServiceUnavailable), max_tries=10)
@@ -520,6 +536,7 @@ def test_reload_sink(self):
520536
self.assertEqual(sink.filter_, DEFAULT_FILTER)
521537
self.assertEqual(sink.destination, uri)
522538

539+
@skip_for_mtls
523540
def test_update_sink(self):
524541
SINK_NAME = "test-update-sink%s" % (_RESOURCE_ID,)
525542
retry = RetryErrors((Conflict, ServiceUnavailable), max_tries=10)

0 commit comments

Comments
 (0)