Skip to content
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
27 changes: 27 additions & 0 deletions system_tests/logging_.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
DEFAULT_FILTER = 'logName:syslog AND severity>=INFO'
DEFAULT_DESCRIPTION = 'System testing'
BUCKET_NAME = 'gcloud-python-system-testing-%d' % (_MILLIS,)
DATASET_NAME = 'system_testing_dataset_%d' % (_MILLIS,)


class Config(object):
Expand Down Expand Up @@ -148,3 +149,29 @@ def test_create_sink_storage_bucket(self):
sink.create()
self.to_delete.append(sink)
self.assertTrue(sink.exists())

def test_create_sink_bigquery_dataset(self):
from gcloud import bigquery
from gcloud.bigquery.dataset import AccessGrant
DATASET_URI = 'bigquery.googleapis.com/projects/%s/datasets/%s' % (
Config.CLIENT.project, DATASET_NAME,)

This comment was marked as spam.


# Create the destination dataset, and set up the ACL to allow
# Cloud Logging to write into it.
bigquery_client = bigquery.Client()
dataset = bigquery_client.dataset(DATASET_NAME)
dataset.create()
self.to_delete.append(dataset)
dataset.reload()
grants = dataset.access_grants
grants.append(AccessGrant(
'WRITER', 'groupByEmail', 'cloud-logs@google.com'))
dataset.access_grants = grants
dataset.update()

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