Skip to content

Commit 39804da

Browse files
authored
Replace use of mock server *_replies_to_find when replying to OP_MSG requests (#1280)
* Replace use of mock server *_replies_to_find when replying to OP_MSG requests * Use common reply_to_* interface for mock server requests
1 parent a2fdd62 commit 39804da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+889
-1032
lines changed

src/libmongoc/tests/mock_server/mock-rs.c

Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -492,42 +492,6 @@ mock_rs_receives_query (mock_rs_t *rs,
492492
return request;
493493
}
494494

495-
496-
/*--------------------------------------------------------------------------
497-
*
498-
* mock_server_reply_to_find --
499-
*
500-
* Receive an OP_QUERY or a find command and reply to it.
501-
*
502-
* Pop a client request if one is enqueued, or wait up to
503-
* request_timeout_ms for the client to send a request.
504-
*
505-
* Side effects:
506-
* Logs and aborts if the current request is not a query or find command
507-
* matching "flags".
508-
*
509-
*--------------------------------------------------------------------------
510-
*/
511-
/*
512-
513-
void
514-
mock_rs_reply_to_find (mock_rs_t *rs,
515-
mongoc_query_flags_t flags,
516-
int64_t cursor_id,
517-
int32_t number_returned,
518-
const char *reply_json,
519-
bool is_command)
520-
{
521-
request_t *request;
522-
523-
request = mock_rs_receives_request (rs);
524-
BSON_ASSERT (request);
525-
526-
mock_server_reply_to_find (request, flags, cursor_id, number_returned,
527-
reply_json, is_command);
528-
}
529-
*/
530-
531495
/*--------------------------------------------------------------------------
532496
*
533497
* mock_rs_receives_command --
@@ -701,28 +665,6 @@ _mock_rs_receives_msg (mock_rs_t *rs, uint32_t flags, ...)
701665
}
702666

703667

704-
/*--------------------------------------------------------------------------
705-
*
706-
* mock_rs_hangs_up --
707-
*
708-
* Hang up on a client request.
709-
*
710-
* Returns:
711-
* None.
712-
*
713-
* Side effects:
714-
* Causes a network error on the client side.
715-
*
716-
*--------------------------------------------------------------------------
717-
*/
718-
719-
void
720-
mock_rs_hangs_up (request_t *request)
721-
{
722-
mock_server_hangs_up (request);
723-
}
724-
725-
726668
/*--------------------------------------------------------------------------
727669
*
728670
* mock_rs_receives_kill_cursors --
@@ -760,34 +702,6 @@ mock_rs_receives_kill_cursors (mock_rs_t *rs, int64_t cursor_id)
760702
}
761703

762704

763-
/*--------------------------------------------------------------------------
764-
*
765-
* mock_rs_replies --
766-
*
767-
* Respond to a client request.
768-
*
769-
* Returns:
770-
* None.
771-
*
772-
* Side effects:
773-
* Sends an OP_REPLY to the client.
774-
*
775-
*--------------------------------------------------------------------------
776-
*/
777-
778-
void
779-
mock_rs_replies (request_t *request,
780-
uint32_t flags,
781-
int64_t cursor_id,
782-
int32_t starting_from,
783-
int32_t number_returned,
784-
const char *docs_json)
785-
{
786-
mock_server_replies (
787-
request, flags, cursor_id, starting_from, number_returned, docs_json);
788-
}
789-
790-
791705
static mongoc_server_description_type_t
792706
_mock_rs_server_type (mock_rs_t *rs, uint16_t port)
793707
{
@@ -811,59 +725,6 @@ _mock_rs_server_type (mock_rs_t *rs, uint16_t port)
811725
}
812726

813727

814-
/*--------------------------------------------------------------------------
815-
*
816-
* mock_rs_replies_simple --
817-
*
818-
* Respond to a client request.
819-
*
820-
* Returns:
821-
* None.
822-
*
823-
* Side effects:
824-
* Sends an OP_REPLY to the client.
825-
*
826-
*--------------------------------------------------------------------------
827-
*/
828-
829-
void
830-
mock_rs_replies_simple (request_t *request, const char *docs_json)
831-
{
832-
mock_rs_replies (request, 0, 0, 0, 1, docs_json);
833-
}
834-
835-
836-
/*--------------------------------------------------------------------------
837-
*
838-
* mock_rs_replies_to_find --
839-
*
840-
* Receive an OP_QUERY or "find" command and reply appropriately.
841-
*
842-
* Returns:
843-
* None.
844-
*
845-
* Side effects:
846-
* Very roughly validates the query or "find" command or aborts.
847-
* The intent is not to test the driver's query or find command
848-
* implementation here, see _test_kill_cursors for example use.
849-
*
850-
*--------------------------------------------------------------------------
851-
*/
852-
853-
void
854-
mock_rs_replies_to_find (request_t *request,
855-
mongoc_query_flags_t flags,
856-
int64_t cursor_id,
857-
int32_t number_returned,
858-
const char *ns,
859-
const char *reply_json,
860-
bool is_command)
861-
{
862-
mock_server_replies_to_find (
863-
request, flags, cursor_id, number_returned, ns, reply_json, is_command);
864-
}
865-
866-
867728
/*--------------------------------------------------------------------------
868729
*
869730
* mock_rs_request_is_to_primary --

src/libmongoc/tests/mock_server/mock-rs.h

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ typedef struct _mock_rs_t mock_rs_t;
2525

2626
mock_rs_t *
2727
mock_rs_with_auto_hello (int32_t max_wire_version,
28-
bool has_primary,
29-
int n_secondaries,
30-
int n_arbiters);
28+
bool has_primary,
29+
int n_secondaries,
30+
int n_arbiters);
3131

3232

3333
void
@@ -88,30 +88,6 @@ _mock_rs_receives_msg (mock_rs_t *rs, uint32_t flags, ...);
8888
#define mock_rs_receives_msg(_rs, _flags, ...) \
8989
_mock_rs_receives_msg (_rs, _flags, __VA_ARGS__, NULL)
9090

91-
void
92-
mock_rs_replies (request_t *request,
93-
uint32_t flags,
94-
int64_t cursor_id,
95-
int32_t starting_from,
96-
int32_t number_returned,
97-
const char *docs_json);
98-
99-
void
100-
mock_rs_replies_simple (request_t *request, const char *docs_json);
101-
102-
void
103-
mock_rs_replies_to_find (request_t *request,
104-
mongoc_query_flags_t flags,
105-
int64_t cursor_id,
106-
int32_t number_returned,
107-
const char *ns,
108-
const char *reply_json,
109-
bool is_command);
110-
111-
void
112-
mock_rs_hangs_up (request_t *request);
113-
114-
11591
bool
11692
mock_rs_request_is_to_primary (mock_rs_t *rs, request_t *request);
11793

0 commit comments

Comments
 (0)