@@ -174,7 +174,6 @@ def init_table_id(self):
174174 base_id = f"{ base_id } -async"
175175 return base_id
176176
177-
178177 def _make_client (self ):
179178 project = os .getenv ("GOOGLE_CLOUD_PROJECT" ) or None
180179 return CrossSync .DataClient (project = project )
@@ -1338,7 +1337,7 @@ async def test_execute_metadata_on_empty_response(
13381337 SqlType .Bytes (), SqlType .Int64 ()
13391338 )
13401339
1341- @pytest .mark .order (' last' )
1340+ @pytest .mark .order (" last" )
13421341 class TestExportedMetrics (SystemTestRunner ):
13431342 """
13441343 Checks to make sure metrics were exported by tests
@@ -1361,36 +1360,42 @@ def time_interval(self, start_timestamp):
13611360 LOOKBACK_MINUTES = os .getenv ("LOOKBACK_MINUTES" )
13621361 if LOOKBACK_MINUTES is not None :
13631362 print (f"running with LOOKBACK_MINUTES={ LOOKBACK_MINUTES } " )
1364- start_timestamp = start_timestamp - datetime .timedelta (minutes = int (LOOKBACK_MINUTES ))
1363+ start_timestamp = start_timestamp - datetime .timedelta (
1364+ minutes = int (LOOKBACK_MINUTES )
1365+ )
13651366 return {"start_time" : start_timestamp , "end_time" : end_time }
13661367
1367-
1368- @pytest .mark .parametrize ("metric,methods" , [
1369- ("attempt_latencies" , [m .value for m in OperationType ]),
1370- ("operation_latencies" , [m .value for m in OperationType ]),
1371- ("retry_count" , [m .value for m in OperationType ]),
1372- ("first_response_latencies" , [OperationType .READ_ROWS ]),
1373- ("server_latencies" , [m .value for m in OperationType ]),
1374- ("connectivity_error_count" , [m .value for m in OperationType ]),
1375- ("application_blocking_latencies" , [OperationType .READ_ROWS ]),
1376- ])
1377- @retry .Retry (
1378- predicate = retry .if_exception_type (AssertionError )
1368+ @pytest .mark .parametrize (
1369+ "metric,methods" ,
1370+ [
1371+ ("attempt_latencies" , [m .value for m in OperationType ]),
1372+ ("operation_latencies" , [m .value for m in OperationType ]),
1373+ ("retry_count" , [m .value for m in OperationType ]),
1374+ ("first_response_latencies" , [OperationType .READ_ROWS ]),
1375+ ("server_latencies" , [m .value for m in OperationType ]),
1376+ ("connectivity_error_count" , [m .value for m in OperationType ]),
1377+ ("application_blocking_latencies" , [OperationType .READ_ROWS ]),
1378+ ],
13791379 )
1380- def test_metric_existence (self , client , table_id , metrics_client , time_interval , metric , methods ):
1380+ @retry .Retry (predicate = retry .if_exception_type (AssertionError ))
1381+ def test_metric_existence (
1382+ self , client , table_id , metrics_client , time_interval , metric , methods
1383+ ):
13811384 """
13821385 Checks existence of each metric in Cloud Monitoring
13831386 """
13841387 for m in methods :
13851388 metric_filter = (
1386- f'metric.type = "bigtable.googleapis.com/client/{ metric } " ' +
1387- f'AND metric.labels.client_name = "python-bigtable/{ client ._client_version ()} " ' +
1388- f'AND resource.labels.table = "{ table_id } " '
1389+ f'metric.type = "bigtable.googleapis.com/client/{ metric } " '
1390+ + f'AND metric.labels.client_name = "python-bigtable/{ client ._client_version ()} " '
1391+ + f'AND resource.labels.table = "{ table_id } " '
1392+ )
1393+ results = list (
1394+ metrics_client .list_time_series (
1395+ name = f"projects/{ client .project } " ,
1396+ filter = metric_filter ,
1397+ interval = time_interval ,
1398+ view = 0 ,
1399+ )
13891400 )
1390- results = list (metrics_client .list_time_series (
1391- name = f"projects/{ client .project } " ,
1392- filter = metric_filter ,
1393- interval = time_interval ,
1394- view = 0 ,
1395- ))
1396- assert len (results ) > 0 , f"No data found for { metric } { m } "
1401+ assert len (results ) > 0 , f"No data found for { metric } { m } "
0 commit comments