Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit de131c7

Browse files
authored
Delete SD integ test metric descriptors (#770)
1 parent cde62c5 commit de131c7

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

tests/system/stats/stackdriver/stackdriver_stats_test.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,26 @@ def setUp(self):
6666
patcher.start()
6767
self.addCleanup(patcher.stop)
6868

69+
def tearDown(self):
70+
suffix = str(os.getgid())
71+
72+
cli = monitoring_v3.MetricServiceClient()
73+
for md in cli.list_metric_descriptors('projects/{}'.format(PROJECT)):
74+
if "OpenCensus" in md.name and suffix in md.name:
75+
try:
76+
cli.delete_metric_descriptor(md.name)
77+
except Exception:
78+
pass
79+
6980
def test_stats_record_sync(self):
70-
# We are using sufix in order to prevent cached objects
71-
sufix = str(os.getgid())
81+
# We are using suffix in order to prevent cached objects
82+
suffix = str(os.getgid())
7283

73-
tag_key = "SampleKeySyncTest%s" % sufix
74-
measure_name = "SampleMeasureNameSyncTest%s" % sufix
75-
measure_description = "SampleDescriptionSyncTest%s" % sufix
76-
view_name = "SampleViewNameSyncTest%s" % sufix
77-
view_description = "SampleViewDescriptionSyncTest%s" % sufix
84+
tag_key = "SampleKeySyncTest%s" % suffix
85+
measure_name = "SampleMeasureNameSyncTest%s" % suffix
86+
measure_description = "SampleDescriptionSyncTest%s" % suffix
87+
view_name = "SampleViewNameSyncTest%s" % suffix
88+
view_description = "SampleViewDescriptionSyncTest%s" % suffix
7889

7990
FRONTEND_KEY = tag_key_module.TagKey(tag_key)
8091
VIDEO_SIZE_MEASURE = measure_module.MeasureInt(
@@ -119,14 +130,14 @@ def test_stats_record_sync(self):
119130
self.check_sd_md(exporter, view_description)
120131

121132
def test_stats_record_async(self):
122-
# We are using sufix in order to prevent cached objects
123-
sufix = str(os.getpid())
124-
125-
tag_key = "SampleKeyAsyncTest%s" % sufix
126-
measure_name = "SampleMeasureNameAsyncTest%s" % sufix
127-
measure_description = "SampleDescriptionAsyncTest%s" % sufix
128-
view_name = "SampleViewNameAsyncTest%s" % sufix
129-
view_description = "SampleViewDescriptionAsyncTest%s" % sufix
133+
# We are using suffix in order to prevent cached objects
134+
suffix = str(os.getpid())
135+
136+
tag_key = "SampleKeyAsyncTest%s" % suffix
137+
measure_name = "SampleMeasureNameAsyncTest%s" % suffix
138+
measure_description = "SampleDescriptionAsyncTest%s" % suffix
139+
view_name = "SampleViewNameAsyncTest%s" % suffix
140+
view_description = "SampleViewDescriptionAsyncTest%s" % suffix
130141

131142
FRONTEND_KEY_ASYNC = tag_key_module.TagKey(tag_key)
132143
VIDEO_SIZE_MEASURE_ASYNC = measure_module.MeasureInt(

0 commit comments

Comments
 (0)