@@ -277,6 +277,28 @@ def test_query_options(self):
277277 d = self .client .query_metric (MetricType .Gauge , 'test.query.gauge.1' , start = (t - 1000 ))
278278 self .assertEqual (1 , len (d ))
279279
280+ def test_stats_queries (self ):
281+ self .client .create_metric_definition (MetricType .Gauge , 'test.buckets.1' , units = 'bytes' , env = 'unittest' )
282+ self .client .create_metric_definition (MetricType .Gauge , 'test.buckets.2' , units = 'bytes' , env = 'unittest' )
283+
284+ t = time_millis ()
285+ dps = []
286+
287+ for i in range (0 , 10 ):
288+ t = t - 1000
289+ val = 1.45 * i
290+ dps .append (create_datapoint (val , timestamp = t ))
291+
292+ self .client .put (create_metric (MetricType .Gauge , 'test.buckets.1' , dps ))
293+ self .client .put (create_metric (MetricType .Gauge , 'test.buckets.2' , [create_datapoint (2.4 )]))
294+
295+ # Read single stats bucket
296+ bp = self .client .query_metric_stats (MetricType .Gauge , 'test.buckets.1' , buckets = 1 , tags = create_tags_filter (units = 'bytes' , env = 'unittest' ), percentiles = create_percentiles_filter (90.0 , 99.0 ))
297+
298+ self .assertEqual (1 , len (bp ), "Only one bucket was requested" )
299+ self .assertEqual (10 , bp [0 ]['samples' ])
300+ self .assertEqual (2 , len (bp [0 ]['percentiles' ]))
301+
280302 def test_tenant_changing (self ):
281303 self .client .create_metric_definition (MetricType .Availability , 'test.tenant.avail.1' )
282304 # Fetch metrics and check that it did appear
0 commit comments