From 73b0ba9ecea4a1d74956a140cacd565552b802c9 Mon Sep 17 00:00:00 2001 From: Chris Kleinknecht Date: Tue, 20 Aug 2019 15:50:03 -0700 Subject: [PATCH] Delete SD integ test metric descriptors --- .../stackdriver/stackdriver_stats_test.py | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/system/stats/stackdriver/stackdriver_stats_test.py b/tests/system/stats/stackdriver/stackdriver_stats_test.py index 59857b7d6..a18291b37 100644 --- a/tests/system/stats/stackdriver/stackdriver_stats_test.py +++ b/tests/system/stats/stackdriver/stackdriver_stats_test.py @@ -66,15 +66,26 @@ def setUp(self): patcher.start() self.addCleanup(patcher.stop) + def tearDown(self): + suffix = str(os.getgid()) + + cli = monitoring_v3.MetricServiceClient() + for md in cli.list_metric_descriptors('projects/{}'.format(PROJECT)): + if "OpenCensus" in md.name and suffix in md.name: + try: + cli.delete_metric_descriptor(md.name) + except Exception: + pass + def test_stats_record_sync(self): - # We are using sufix in order to prevent cached objects - sufix = str(os.getgid()) + # We are using suffix in order to prevent cached objects + suffix = str(os.getgid()) - tag_key = "SampleKeySyncTest%s" % sufix - measure_name = "SampleMeasureNameSyncTest%s" % sufix - measure_description = "SampleDescriptionSyncTest%s" % sufix - view_name = "SampleViewNameSyncTest%s" % sufix - view_description = "SampleViewDescriptionSyncTest%s" % sufix + tag_key = "SampleKeySyncTest%s" % suffix + measure_name = "SampleMeasureNameSyncTest%s" % suffix + measure_description = "SampleDescriptionSyncTest%s" % suffix + view_name = "SampleViewNameSyncTest%s" % suffix + view_description = "SampleViewDescriptionSyncTest%s" % suffix FRONTEND_KEY = tag_key_module.TagKey(tag_key) VIDEO_SIZE_MEASURE = measure_module.MeasureInt( @@ -119,14 +130,14 @@ def test_stats_record_sync(self): self.check_sd_md(exporter, view_description) def test_stats_record_async(self): - # We are using sufix in order to prevent cached objects - sufix = str(os.getpid()) - - tag_key = "SampleKeyAsyncTest%s" % sufix - measure_name = "SampleMeasureNameAsyncTest%s" % sufix - measure_description = "SampleDescriptionAsyncTest%s" % sufix - view_name = "SampleViewNameAsyncTest%s" % sufix - view_description = "SampleViewDescriptionAsyncTest%s" % sufix + # We are using suffix in order to prevent cached objects + suffix = str(os.getpid()) + + tag_key = "SampleKeyAsyncTest%s" % suffix + measure_name = "SampleMeasureNameAsyncTest%s" % suffix + measure_description = "SampleDescriptionAsyncTest%s" % suffix + view_name = "SampleViewNameAsyncTest%s" % suffix + view_description = "SampleViewDescriptionAsyncTest%s" % suffix FRONTEND_KEY_ASYNC = tag_key_module.TagKey(tag_key) VIDEO_SIZE_MEASURE_ASYNC = measure_module.MeasureInt(