@@ -1106,6 +1106,19 @@ test_cursor_new_tailable_await (void)
1106
1106
1107
1107
client =
1108
1108
test_framework_client_new_from_uri (mock_server_get_uri (server ), NULL );
1109
+
1110
+ // Select a server to get the server_id.
1111
+ // mongoc_cursor_new_from_command_reply_with_opts expects to receive a
1112
+ // serverId when creating an open cursor (non-zero cursor.id)
1113
+ uint32_t server_id ;
1114
+ {
1115
+ mongoc_server_description_t * sd = mongoc_client_select_server (
1116
+ client , false /* for_writes */ , NULL /* prefs */ , & error );
1117
+ ASSERT_OR_PRINT (sd , error );
1118
+ server_id = mongoc_server_description_id (sd );
1119
+ mongoc_server_description_destroy (sd );
1120
+ }
1121
+
1109
1122
cursor = mongoc_cursor_new_from_command_reply_with_opts (
1110
1123
client ,
1111
1124
bson_copy (tmp_bson ("{'ok': 1,"
@@ -1120,8 +1133,9 @@ test_cursor_new_tailable_await (void)
1120
1133
"}" )),
1121
1134
tmp_bson ("{'tailable': true,"
1122
1135
" 'awaitData': true,"
1123
- " 'maxAwaitTimeMS': 100"
1124
- "}" ));
1136
+ " 'maxAwaitTimeMS': 100,"
1137
+ " 'serverId': %" PRIu32 "}" ,
1138
+ server_id ));
1125
1139
1126
1140
ASSERT_OR_PRINT (!mongoc_cursor_error (cursor , & error ), error );
1127
1141
@@ -1172,13 +1186,27 @@ test_cursor_int64_t_maxtimems (void)
1172
1186
client =
1173
1187
test_framework_client_new_from_uri (mock_server_get_uri (server ), NULL );
1174
1188
1189
+ // Select a server to get the server_id.
1190
+ // mongoc_cursor_new_from_command_reply_with_opts expects to receive a
1191
+ // serverId when creating an open cursor (non-zero cursor.id)
1192
+ uint32_t server_id ;
1193
+ {
1194
+ mongoc_server_description_t * sd = mongoc_client_select_server (
1195
+ client , false /* for_writes */ , NULL /* prefs */ , & error );
1196
+ ASSERT_OR_PRINT (sd , error );
1197
+ server_id = mongoc_server_description_id (sd );
1198
+ mongoc_server_description_destroy (sd );
1199
+ }
1200
+
1175
1201
max_await_time_ms = tmp_bson (NULL );
1176
1202
bson_append_bool (max_await_time_ms , "tailable" , 8 , true);
1177
1203
bson_append_bool (max_await_time_ms , "awaitData" , 9 , true);
1178
1204
bson_append_int64 (max_await_time_ms ,
1179
1205
MONGOC_CURSOR_MAX_AWAIT_TIME_MS ,
1180
1206
MONGOC_CURSOR_MAX_AWAIT_TIME_MS_LEN ,
1181
1207
ms_int64 );
1208
+ ASSERT (bson_in_range_int32_t_unsigned (server_id ));
1209
+ BSON_APPEND_INT32 (max_await_time_ms , "serverId" , (uint32_t ) server_id );
1182
1210
1183
1211
cursor = mongoc_cursor_new_from_command_reply_with_opts (
1184
1212
client ,
0 commit comments