@@ -554,7 +554,13 @@ def test_create_grpc_error(self):
554554
555555 api .create_database .assert_called_once_with (
556556 request = expected_request ,
557- metadata = [("google-cloud-resource-prefix" , database .name )],
557+ metadata = [
558+ ("google-cloud-resource-prefix" , database .name ),
559+ (
560+ "x-goog-spanner-request-id" ,
561+ f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .1.1" ,
562+ ),
563+ ],
558564 )
559565
560566 def test_create_already_exists (self ):
@@ -702,7 +708,7 @@ def test_create_success_w_encryption_config_dict(self):
702708 ("google-cloud-resource-prefix" , database .name ),
703709 (
704710 "x-goog-spanner-request-id" ,
705- f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .1.0 .1" ,
711+ f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database . _channel_id } .1 .1" ,
706712 ),
707713 ],
708714 )
@@ -743,7 +749,7 @@ def test_create_success_w_proto_descriptors(self):
743749 ("google-cloud-resource-prefix" , database .name ),
744750 (
745751 "x-goog-spanner-request-id" ,
746- f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .1.0 .1" ,
752+ f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database . _channel_id } .1 .1" ,
747753 ),
748754 ],
749755 )
@@ -1339,21 +1345,10 @@ def _execute_partitioned_dml_helper(
13391345 )
13401346
13411347 if retried :
1342- api .execute_streaming_sql .assert_any_call (
1343- request = expected_request ,
1344- metadata = [
1345- ("google-cloud-resource-prefix" , database .name ),
1346- ("x-goog-spanner-route-to-leader" , "true" ),
1347- (
1348- "x-goog-spanner-request-id" ,
1349- f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .4.1" ,
1350- ),
1351- ],
1352- )
13531348 expected_retry_transaction = TransactionSelector (
13541349 id = self .RETRY_TRANSACTION_ID
13551350 )
1356- expected_request = ExecuteSqlRequest (
1351+ expected_request_with_retry = ExecuteSqlRequest (
13571352 session = self .SESSION_NAME ,
13581353 sql = dml ,
13591354 transaction = expected_retry_transaction ,
@@ -1362,14 +1357,35 @@ def _execute_partitioned_dml_helper(
13621357 query_options = expected_query_options ,
13631358 request_options = expected_request_options ,
13641359 )
1365- api .execute_streaming_sql .assert_called_with (
1366- request = expected_request ,
1367- metadata = [
1368- ("google-cloud-resource-prefix" , database .name ),
1369- ("x-goog-spanner-route-to-leader" , "true" ),
1370- (
1371- "x-goog-spanner-request-id" ,
1372- f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .6.1" ,
1360+
1361+ print ("expected_request" , expected_request )
1362+ print (
1363+ "\033 [34marg_list" , api .execute_streaming_sql .call_args_list , "\033 [00m"
1364+ )
1365+ self .assertEqual (
1366+ api .execute_streaming_sql .call_args_list ,
1367+ [
1368+ mock .call (
1369+ request = expected_request ,
1370+ metadata = [
1371+ ("google-cloud-resource-prefix" , database .name ),
1372+ ("x-goog-spanner-route-to-leader" , "true" ),
1373+ (
1374+ "x-goog-spanner-request-id" ,
1375+ f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .2.1" ,
1376+ ),
1377+ ],
1378+ ),
1379+ mock .call (
1380+ request = expected_request_with_retry ,
1381+ metadata = [
1382+ ("google-cloud-resource-prefix" , database .name ),
1383+ ("x-goog-spanner-route-to-leader" , "true" ),
1384+ (
1385+ "x-goog-spanner-request-id" ,
1386+ f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .4.1" ,
1387+ ),
1388+ ],
13731389 ),
13741390 ],
13751391 )
@@ -2051,10 +2067,6 @@ def test_context_mgr_success(self):
20512067 metadata = [
20522068 ("google-cloud-resource-prefix" , database .name ),
20532069 ("x-goog-spanner-route-to-leader" , "true" ),
2054- (
2055- "x-goog-spanner-request-id" ,
2056- f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .1.1" ,
2057- ),
20582070 ],
20592071 )
20602072
@@ -2102,10 +2114,6 @@ def test_context_mgr_w_commit_stats_success(self):
21022114 metadata = [
21032115 ("google-cloud-resource-prefix" , database .name ),
21042116 ("x-goog-spanner-route-to-leader" , "true" ),
2105- (
2106- "x-goog-spanner-request-id" ,
2107- f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .1.1" ,
2108- ),
21092117 ],
21102118 )
21112119
0 commit comments