Skip to content

Commit

Permalink
tests: skip some system tests for mtls testing (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Nov 23, 2020
1 parent 6a46b46 commit 85242c0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/system/test_system.py
Expand Up @@ -14,6 +14,8 @@

import datetime
import logging
import os
import pytest
import unittest

from google.api_core.exceptions import BadGateway
Expand Down Expand Up @@ -81,12 +83,21 @@ class Config(object):
"""

CLIENT = None
use_mtls = os.environ.get("GOOGLE_API_USE_MTLS_ENDPOINT", "never")


def setUpModule():
Config.CLIENT = client.Client()


# Skip the test cases using bigquery, storage and pubsub clients for mTLS testing.
# Bigquery and storage uses http which doesn't have mTLS support, pubsub doesn't
# have mTLS fix released yet.
skip_for_mtls = pytest.mark.skipif(
Config.use_mtls == "always", reason="Skip the test case for mTLS testing"
)


class TestLogging(unittest.TestCase):

JSON_PAYLOAD = {
Expand Down Expand Up @@ -408,6 +419,7 @@ def _init_storage_bucket(self):

return BUCKET_URI

@skip_for_mtls
def test_create_sink_storage_bucket(self):
uri = self._init_storage_bucket()
SINK_NAME = "test-create-sink-bucket%s" % (_RESOURCE_ID,)
Expand All @@ -421,6 +433,7 @@ def test_create_sink_storage_bucket(self):
self.to_delete.append(sink)
self.assertTrue(sink.exists())

@skip_for_mtls
def test_create_sink_pubsub_topic(self):
from google.cloud import pubsub_v1

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

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

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

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

@skip_for_mtls
def test_update_sink(self):
SINK_NAME = "test-update-sink%s" % (_RESOURCE_ID,)
retry = RetryErrors((Conflict, ServiceUnavailable), max_tries=10)
Expand Down

0 comments on commit 85242c0

Please sign in to comment.