@@ -1106,6 +1106,19 @@ test_cursor_new_tailable_await (void)
11061106
11071107 client =
11081108 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+
11091122 cursor = mongoc_cursor_new_from_command_reply_with_opts (
11101123 client ,
11111124 bson_copy (tmp_bson ("{'ok': 1,"
@@ -1120,8 +1133,9 @@ test_cursor_new_tailable_await (void)
11201133 "}" )),
11211134 tmp_bson ("{'tailable': true,"
11221135 " 'awaitData': true,"
1123- " 'maxAwaitTimeMS': 100"
1124- "}" ));
1136+ " 'maxAwaitTimeMS': 100,"
1137+ " 'serverId': %" PRIu32 "}" ,
1138+ server_id ));
11251139
11261140 ASSERT_OR_PRINT (!mongoc_cursor_error (cursor , & error ), error );
11271141
@@ -1172,13 +1186,27 @@ test_cursor_int64_t_maxtimems (void)
11721186 client =
11731187 test_framework_client_new_from_uri (mock_server_get_uri (server ), NULL );
11741188
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+
11751201 max_await_time_ms = tmp_bson (NULL );
11761202 bson_append_bool (max_await_time_ms , "tailable" , 8 , true);
11771203 bson_append_bool (max_await_time_ms , "awaitData" , 9 , true);
11781204 bson_append_int64 (max_await_time_ms ,
11791205 MONGOC_CURSOR_MAX_AWAIT_TIME_MS ,
11801206 MONGOC_CURSOR_MAX_AWAIT_TIME_MS_LEN ,
11811207 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 );
11821210
11831211 cursor = mongoc_cursor_new_from_command_reply_with_opts (
11841212 client ,
0 commit comments