@@ -1055,6 +1055,62 @@ test_get_transaction_opts (void)
1055
1055
mock_server_destroy (server );
1056
1056
}
1057
1057
1058
+ static void
1059
+ test_max_commit_time_ms_is_reset (void * ctx )
1060
+ {
1061
+ mock_rs_t * rs ;
1062
+ mongoc_uri_t * uri = NULL ;
1063
+ mongoc_client_t * client = NULL ;
1064
+ mongoc_transaction_opt_t * txn_opts = NULL ;
1065
+ mongoc_session_opt_t * session_opts = NULL ;
1066
+ mongoc_client_session_t * session = NULL ;
1067
+ bson_error_t error ;
1068
+ bool r ;
1069
+
1070
+ rs = mock_rs_with_autoismaster (WIRE_VERSION_4_2 ,
1071
+ true /* has primary */ ,
1072
+ 2 /* secondaries */ ,
1073
+ 0 /* arbiters */ );
1074
+
1075
+ mock_rs_run (rs );
1076
+ uri = mongoc_uri_copy (mock_rs_get_uri (rs ));
1077
+
1078
+ client = mongoc_client_new_from_uri (uri );
1079
+ BSON_ASSERT (client );
1080
+
1081
+ txn_opts = mongoc_transaction_opts_new ();
1082
+ session_opts = mongoc_session_opts_new ();
1083
+
1084
+ session = mongoc_client_start_session (client , session_opts , & error );
1085
+ ASSERT_OR_PRINT (session , error );
1086
+
1087
+ mongoc_transaction_opts_set_max_commit_time_ms (txn_opts , 1 );
1088
+
1089
+ r = mongoc_client_session_start_transaction (session , txn_opts , & error );
1090
+ ASSERT_OR_PRINT (r , error );
1091
+ BSON_ASSERT (1 == session -> txn .opts .max_commit_time_ms );
1092
+
1093
+ r = mongoc_client_session_abort_transaction (session , & error );
1094
+ ASSERT_OR_PRINT (r , error );
1095
+ BSON_ASSERT (DEFAULT_MAX_COMMIT_TIME_MS == session -> txn .opts .max_commit_time_ms );
1096
+
1097
+ mongoc_transaction_opts_set_max_commit_time_ms (txn_opts , DEFAULT_MAX_COMMIT_TIME_MS );
1098
+
1099
+ r = mongoc_client_session_start_transaction (session , txn_opts , & error );
1100
+ ASSERT_OR_PRINT (r , error );
1101
+ BSON_ASSERT (DEFAULT_MAX_COMMIT_TIME_MS == session -> txn .opts .max_commit_time_ms );
1102
+
1103
+ r = mongoc_client_session_abort_transaction (session , & error );
1104
+ ASSERT_OR_PRINT (r , error );
1105
+
1106
+ mongoc_session_opts_destroy (session_opts );
1107
+ mongoc_transaction_opts_destroy (txn_opts );
1108
+ mongoc_client_session_destroy (session );
1109
+ mongoc_client_destroy (client );
1110
+ mongoc_uri_destroy (uri );
1111
+ mock_rs_destroy (rs );
1112
+ }
1113
+
1058
1114
void
1059
1115
test_transactions_install (TestSuite * suite )
1060
1116
{
@@ -1134,4 +1190,10 @@ test_transactions_install (TestSuite *suite)
1134
1190
"/transactions/get_transaction_opts" ,
1135
1191
test_get_transaction_opts ,
1136
1192
test_framework_skip_if_no_crypto );
1193
+ TestSuite_AddFull (suite ,
1194
+ "/transactions/max_commit_time_ms_is_reset" ,
1195
+ test_max_commit_time_ms_is_reset ,
1196
+ NULL ,
1197
+ NULL ,
1198
+ NULL );
1137
1199
}
0 commit comments