Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.
Open
Show file tree
Hide file tree
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
33 changes: 17 additions & 16 deletions test/python/monitoring/monitoring.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""System tests for monitoring."""
from __future__ import print_function


from google.cloud.gapic.monitoring.v3 import group_service_client
Expand All @@ -20,37 +21,37 @@ def testGroupCollection():
group = group_pb2.Group(display_name='displayName', filter='resource.type = gce_instance')
createdGroup = api.create_group(projectName, group)

print "New group created: \n%s\n" % createdGroup
print("New group created: \n%s\n" % createdGroup)

groupName = createdGroup.name
groupToUpdate = group_pb2.Group(name=groupName, display_name='displayName2', filter='resource.type = gce_instance')
updatedGroup = api.update_group(groupToUpdate)
print "Group updated: \n%s\n" % updatedGroup
print("Group updated: \n%s\n" % updatedGroup)

# group id is the last segment in the returned group name.
groupId = updatedGroup.name[createdGroup.name.rfind('/')+1:]
api = group_service_client.GroupServiceClient()
name = api.group_path(PROJECT_ID, groupId)
response = api.get_group(name)
print "Group fetched: \n%s\n" % response
print("Group fetched: \n%s\n" % response)

print "List groups:\n"
print("List groups:\n")
for group in api.list_groups(name):
# process element
print(group)

print "List group members:\n"
print("List group members:\n")
name = api.group_path(PROJECT_ID, groupId)
for member in api.list_group_members(name=name, interval=common_pb2.TimeInterval(end_time=timestamp_pb2.Timestamp(seconds=1475262206))):
print(member)

print "Delete groups:\n"
print("Delete groups:\n")
name = api.group_path(PROJECT_ID, groupId)
api.delete_group(name)
try:
response = api.get_group(name)
except:
print "Expect error here since the group should have been deleted"
print("Expect error here since the group should have been deleted")


def testMetricCollection():
Expand All @@ -60,20 +61,20 @@ def testMetricCollection():

metric_descriptor = api_metric_pb2.MetricDescriptor(type=custom_metric_type, metric_kind=enums.MetricDescriptor.MetricKind.GAUGE, value_type=enums.MetricDescriptor.ValueType.BOOL)
response = api.create_metric_descriptor(name, metric_descriptor)
print "Metric created: \n%s\n" % response
print("Metric created: \n%s\n" % response)

name = api.metric_descriptor_path_path(PROJECT_ID, custom_metric_type)
response = api.get_metric_descriptor(name)
print "Metric fetched: \n%s\n" % response
print("Metric fetched: \n%s\n" % response)

print "List metrics:"
print("List metrics:")
name = api.project_path(PROJECT_ID)
# Iterate over all results
for metric in api.list_metric_descriptors(name):
# process element
print metric
print(metric)

print "delete metric:"
print("delete metric:")
name = api.metric_descriptor_path_path(PROJECT_ID, custom_metric_type)
api.delete_metric_descriptor(name)

Expand All @@ -94,22 +95,22 @@ def testTimeseriesCollection():
view = enums.ListTimeSeriesRequest.TimeSeriesView.FULL
for element in api.list_time_series(name, filter_, interval, view):
# process element
print element
print(element)


def testMonitoredResourceCollection():
api = metric_service_client.MetricServiceClient()
name = api.project_path(PROJECT_ID)

print "List monitored reourses:"
print("List monitored reourses:")
# Iterate over all results
for element in api.list_monitored_resource_descriptors(name):
# process element
print element
print(element)

name = api.monitored_resource_descriptor_path(PROJECT_ID, 'uptime_url')
response = api.get_monitored_resource_descriptor(name)
print "Get monitored resource\n%s" % response
print("Get monitored resource\n%s" % response)


testGroupCollection()
Expand Down
3 changes: 2 additions & 1 deletion test/python/speech/speech.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from google.cloud.gapic.speech.v1beta1 import enums
from google.cloud.gapic.speech.v1beta1 import speech_client
from google.cloud.proto.speech.v1beta1 import cloud_speech_pb2 as types
Expand All @@ -17,7 +18,7 @@ def test_sync_recognize():
audio = types.RecognitionAudio(uri=INPUT_URI)
response = api.sync_recognize(config, audio)

print response
print(response)

def test_async_recognize():
def callback(operation_future):
Expand Down
15 changes: 8 additions & 7 deletions test/python/trace/trace.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from google.cloud.gapic.trace.v1 import enums
from google.cloud.gapic.trace.v1 import trace_service_api
from google.devtools.cloudtrace.v1 import trace_pb2
Expand Down Expand Up @@ -28,23 +29,23 @@
trace = trace_pb2.Trace(project_id=PROJECT_ID, trace_id=id, spans=[span])
traces = trace_pb2.Traces(traces=[trace])

print 'testing patch'
print('testing patch')
api.patch_traces(PROJECT_ID, traces)
print 'patched'
print('patched')

# 1 second seems to be sufficient to avoid race condition
time.sleep(1)

print 'testing get'
print('testing get')
get_response = api.get_trace(PROJECT_ID, id)
print 'got trace: {}'.format(get_response)
print('got trace: {}'.format(get_response))

print 'testing list'
print('testing list')
list_response = api.list_traces(PROJECT_ID)
print 'listed traces:'
print('listed traces:')
i = 0
for trace in list_response:
if i > 10:
break
i += 1
print '> {}'.format(trace)
print('> {}'.format(trace))
3 changes: 2 additions & 1 deletion test/python/vision/vision.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functional test for Google Cloud Vision API."""
from __future__ import print_function

from google.cloud.gapic.vision.v1.image_annotator_client import ImageAnnotatorClient
from google.cloud.grpc.vision.v1 import image_annotator_pb2
Expand All @@ -19,4 +20,4 @@
requests = [request]
response = api.batch_annotate_images(requests)

print response.__str__
print(response.__str__)