@@ -97,6 +97,35 @@ async def target(self, client, table_id, instance_id, handler):
9797 table ._metrics .add_handler (handler )
9898 yield table
9999
100+ @CrossSync .pytest
101+ async def test_sample_row_keys (self , target , temp_rows , handler , cluster_config ):
102+ await target .sample_row_keys ()
103+ # validate counts
104+ assert len (handler .completed_operations ) == 1
105+ assert len (handler .completed_attempts ) == 1
106+ assert len (handler .cancelled_operations ) == 0
107+ # validate operation
108+ operation = handler .completed_operations [0 ]
109+ assert isinstance (operation , CompletedOperationMetric )
110+ assert operation .final_status .value [0 ] == 0
111+ assert operation .is_streaming is False
112+ assert operation .op_type .value == "SampleRowKeys"
113+ assert len (operation .completed_attempts ) == 1
114+ assert operation .completed_attempts [0 ] == handler .completed_attempts [0 ]
115+ assert operation .cluster_id == next (iter (cluster_config .keys ()))
116+ assert operation .zone == cluster_config [operation .cluster_id ].location .split ("/" )[- 1 ]
117+ assert operation .duration_ns > 0 and operation .duration_ns < 1e9
118+ assert operation .first_response_latency_ns is None # populated for read_rows only
119+ assert operation .flow_throttling_time_ns == 0
120+ # validate attempt
121+ attempt = handler .completed_attempts [0 ]
122+ assert attempt .duration_ns > 0 and attempt .duration_ns < operation .duration_ns
123+ assert attempt .end_status .value [0 ] == 0
124+ assert attempt .backoff_before_attempt_ns == 0
125+ assert attempt .gfe_latency_ns > 0 and attempt .gfe_latency_ns < attempt .duration_ns
126+ assert attempt .application_blocking_time_ns == 0
127+ assert attempt .grpc_throttling_time_ns == 0 # TODO: confirm
128+
100129 @CrossSync .pytest
101130 async def test_read_modify_write (self , target , temp_rows , handler , cluster_config ):
102131 from google .cloud .bigtable .data .read_modify_write_rules import IncrementRule
0 commit comments