Skip to content

Commit

Permalink
Merge pull request #1680 from tseaver/logging-system_tests-sink_creat…
Browse files Browse the repository at this point in the history
…e_pubsub_topic

Add system test for 'Sink.create' using a Pubsub topic
  • Loading branch information
tseaver committed Mar 31, 2016
2 parents c3d0977 + 1800393 commit b16e272
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions system_tests/logging_.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
DEFAULT_DESCRIPTION = 'System testing'
BUCKET_NAME = 'gcloud-python-system-testing-%d' % (_MILLIS,)
DATASET_NAME = 'system_testing_dataset_%d' % (_MILLIS,)
TOPIC_NAME = 'gcloud-python-system-testing-%d' % (_MILLIS,)


class Config(object):
Expand Down Expand Up @@ -225,6 +226,28 @@ def test_create_sink_storage_bucket(self):
self.to_delete.append(sink)
self.assertTrue(sink.exists())

def test_create_sink_pubsub_topic(self):
from gcloud import pubsub

# Create the destination topic, and set up the IAM policy to allow
# Cloud Logging to write into it.
pubsub_client = pubsub.Client()
topic = pubsub_client.topic(TOPIC_NAME)
topic.create()
self.to_delete.append(topic)
policy = topic.get_iam_policy()
policy.owners.add(policy.group('cloud-logs@google.com'))
topic.set_iam_policy(policy)

TOPIC_URI = 'pubsub.googleapis.com/%s' % (topic.full_name,)

sink = Config.CLIENT.sink(
DEFAULT_SINK_NAME, DEFAULT_FILTER, TOPIC_URI)
self.assertFalse(sink.exists())
sink.create()
self.to_delete.append(sink)
self.assertTrue(sink.exists())

def _init_bigquery_dataset(self):
from gcloud import bigquery
from gcloud.bigquery.dataset import AccessGrant
Expand Down

0 comments on commit b16e272

Please sign in to comment.