Skip to content

Commit 9499b6a

Browse files
committed
CDRIVER-2219 Fix couple of leaks and opcode expectations
1 parent a3abe9d commit 9499b6a

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

tests/mock_server/request.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ request_matches_query (const request_t *request,
173173

174174
if (!request->is_command && is_command) {
175175
test_error ("expected command, got query");
176+
abort ();
176177
return false;
177178
}
178179

tests/test-mongoc-bulk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ test_bulk_error_unordered (void)
316316
int i;
317317
mongoc_uri_t *uri;
318318

319+
if (test_suite_valgrind ()) {
320+
return;
321+
}
319322
mock_server = mock_server_with_autoismaster (WIRE_VERSION_WRITE_CMD);
320323
mock_server_run (mock_server);
321324

tests/test-mongoc-client.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ test_client_cmd_w_write_concern (void *context)
201201
error);
202202

203203
bson_reinit (opts);
204+
bson_destroy (&reply);
204205

205206
mongoc_write_concern_append_bad (bad_wc, opts);
206207
ASSERT (!mongoc_client_write_command_with_opts (
@@ -231,6 +232,7 @@ test_client_cmd_w_write_concern (void *context)
231232
ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_SERVER);
232233
ASSERT_CMPINT (error.code, ==, 2);
233234
}
235+
bson_destroy (&reply);
234236
}
235237
}
236238

@@ -677,7 +679,7 @@ test_wire_version (void)
677679
"{'ok': 1.0,"
678680
" 'ismaster': true,"
679681
" 'minWireVersion': 2,"
680-
" 'maxWireVersion': 6}");
682+
" 'maxWireVersion': 5}");
681683

682684
/* wait until it's time for next heartbeat */
683685
_mongoc_usleep (600 * 1000);
@@ -691,6 +693,7 @@ test_wire_version (void)
691693
BSON_ASSERT (future_get_bool (future));
692694
BSON_ASSERT (!mongoc_cursor_error (cursor, &error));
693695

696+
future_destroy (future);
694697
mongoc_cursor_destroy (cursor);
695698
mongoc_collection_destroy (collection);
696699
mongoc_client_destroy (client);

tests/test-mongoc-collection.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ test_aggregate_inherit_collection (void)
9999
mongoc_write_concern_t *wc2;
100100
mongoc_write_concern_t *wc;
101101

102-
server = mock_server_with_autoismaster (WIRE_VERSION_MAX);
102+
server = mock_server_with_autoismaster (WIRE_VERSION_MAX_STALENESS);
103103
mock_server_run (server);
104104
client = mongoc_client_new_from_uri (mock_server_get_uri (server));
105105
collection = mongoc_client_get_collection (client, "db", "collection");
@@ -1907,6 +1907,9 @@ test_index_w_write_concern ()
19071907
bson_t *opts = NULL;
19081908
bool result;
19091909
bool wire_version_5;
1910+
bool at_least_2 = test_framework_max_wire_version_at_least (2);
1911+
bool is_replicaset = test_framework_is_replset ();
1912+
bool is_mongos = test_framework_is_mongos ();
19101913

19111914
mongoc_index_opt_init (&opt);
19121915
opts = bson_new ();
@@ -1967,11 +1970,11 @@ test_index_w_write_concern ()
19671970
bson_reinit (opts);
19681971
mongoc_write_concern_append_bad (bad_wc, opts);
19691972
/* skip this part of the test if sharded cluster */
1970-
if (!test_framework_is_mongos ()) {
1973+
if (!is_mongos) {
19711974
if (wire_version_5) {
19721975
ASSERT (!mongoc_collection_create_index_with_opts (
19731976
collection, &keys, &opt, opts, &reply, &error));
1974-
if (test_framework_is_replset ()) { /* replica set */
1977+
if (is_replicaset) { /* replica set */
19751978
ASSERT_ERROR_CONTAINS (
19761979
error, MONGOC_ERROR_WRITE_CONCERN, 100, "Write Concern error:");
19771980
} else { /* standalone */
@@ -1986,13 +1989,12 @@ test_index_w_write_concern ()
19861989
ASSERT (!error.domain);
19871990
}
19881991
}
1989-
1990-
if (!test_framework_max_wire_version_at_least (2)) {
1992+
if (at_least_2) {
1993+
ASSERT (!bson_empty (&reply));
1994+
} else {
19911995
/* On very old versions of the server, create_index_with_write_concern
19921996
* will give an empty reply even if the call succeeds */
19931997
ASSERT (bson_empty (&reply));
1994-
} else {
1995-
ASSERT (!bson_empty (&reply));
19961998
}
19971999
bson_destroy (&reply);
19982000

0 commit comments

Comments
 (0)