@@ -448,37 +448,33 @@ _test_client_kill_cursor (bool has_primary,
448
448
{
449
449
mock_rs_t * rs ;
450
450
mongoc_client_t * client ;
451
- mongoc_collection_t * collection ;
452
451
mongoc_read_prefs_t * read_prefs ;
453
- mongoc_cursor_t * cursor ;
454
- const bson_t * doc ;
452
+ bson_error_t error ;
455
453
future_t * future ;
456
454
request_t * request ;
457
455
458
- /* maybe a primary, definitely a secondary and no arbiter */
459
456
rs = mock_rs_with_autoismaster (wire_version_4 ? 4 : 3 ,
460
- has_primary ,
461
- 1 ,
462
- 0 );
457
+ has_primary , /* maybe a primary*/
458
+ 1 , /* definitely a secondary */
459
+ 0 ); /* no arbiter */
463
460
mock_rs_run (rs );
464
461
client = mongoc_client_new_from_uri (mock_rs_get_uri (rs ));
465
- collection = mongoc_client_get_collection (client , "test" , "test" );
466
462
read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY );
467
- cursor = mongoc_collection_find (collection , MONGOC_QUERY_NONE , 0 , 0 ,
468
- 0 , tmp_bson ("{}" ), NULL , read_prefs );
469
463
470
- future = future_cursor_next (cursor , & doc );
464
+ /* make client open a connection - it won't open one to kill a cursor */
465
+ future = future_client_command_simple (client , "admin" ,
466
+ tmp_bson ("{'foo': 1}" ),
467
+ read_prefs , NULL , & error );
471
468
472
- request = mock_rs_receives_request (rs );
473
- mock_rs_replies_to_find (request , MONGOC_QUERY_SLAVE_OK , 123 , 1 , "test.test" ,
474
- "{'a': 1}" , wire_version_4 );
469
+ request = mock_rs_receives_command (rs , "admin" ,
470
+ MONGOC_QUERY_SLAVE_OK , NULL );
475
471
476
- assert ( future_get_bool ( future )); /* mongoc_cursor_next returned true */
477
- future_destroy ( future );
472
+ mock_rs_replies_simple ( request , "{'ok': 1}" );
473
+ ASSERT_OR_PRINT ( future_get_bool ( future ), error );
478
474
request_destroy (request );
475
+ future_destroy (future );
479
476
480
477
future = future_client_kill_cursor (client , 123 );
481
-
482
478
mock_rs_set_request_timeout_msec (rs , 100 );
483
479
484
480
/* we don't pass namespace so client always sends legacy OP_KILLCURSORS */
@@ -497,14 +493,8 @@ _test_client_kill_cursor (bool has_primary,
497
493
}
498
494
499
495
future_wait (future ); /* no return value */
500
-
501
496
future_destroy (future );
502
-
503
- /* clean up memory, but don't send killCursors command */
504
- cursor -> rpc .reply .cursor_id = 0 ;
505
- mongoc_cursor_destroy (cursor );
506
497
mongoc_read_prefs_destroy (read_prefs );
507
- mongoc_collection_destroy (collection );
508
498
mongoc_client_destroy (client );
509
499
mock_rs_destroy (rs );
510
500
}
0 commit comments