Skip to content

Commit 0a8e8c6

Browse files
authored
CDRIVER-5714 Skip /Stepdown/getmore tests (#1726)
* Add /Stepdown/getmore tests to skip-tests.txt * Modernize surrounding code for /Stepdown/getmore tests
1 parent 8a85033 commit 0a8e8c6

File tree

2 files changed

+45
-37
lines changed

2 files changed

+45
-37
lines changed

.evergreen/etc/skip-tests.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@
3030
/transactions/legacy/pin-mongos/"unpin after transient error within a transaction and commit" # (CDRIVER-4351) server selection timeout (on ASAN Tests Ubuntu 18.04 build variant)
3131

3232
/client_side_encryption/bypass_spawning_mongocryptd/mongocryptdBypassSpawn # Fails if crypt_shared is visible
33+
34+
/Stepdown/getmore/single # SPEC-1442: C Driver does not implement connection pools or CMAP.
35+
/Stepdown/getmore/pooled # SPEC-1442: C Driver does not implement connection pools or CMAP.

src/libmongoc/tests/test-mongoc-primary-stepdown.c

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,39 @@ _get_test_uri (void)
3434
static void
3535
_setup_test_with_client (mongoc_client_t *client)
3636
{
37-
mongoc_write_concern_t *wc;
38-
mongoc_database_t *db;
39-
mongoc_collection_t *coll;
4037
bson_error_t error;
41-
bson_t *opts;
4238

4339
ASSERT (client);
4440

45-
wc = mongoc_write_concern_new ();
46-
mongoc_write_concern_set_wmajority (wc, -1);
47-
opts = bson_new ();
48-
ASSERT (mongoc_write_concern_append (wc, opts));
49-
5041
/* Drop the "step-down.step-down" collection and re-create it */
51-
coll = mongoc_client_get_collection (client, "step-down", "step-down");
52-
if (!mongoc_collection_drop (coll, &error)) {
53-
if (NULL == strstr (error.message, "ns not found")) {
54-
ASSERT_OR_PRINT (false, error);
42+
{
43+
mongoc_collection_t *const coll = mongoc_client_get_collection (client, "step-down", "step-down");
44+
if (!mongoc_collection_drop (coll, &error)) {
45+
if (NULL == strstr (error.message, "ns not found")) {
46+
ASSERT_OR_PRINT (false, error);
47+
}
5548
}
49+
mongoc_collection_destroy (coll);
5650
}
5751

58-
db = mongoc_client_get_database (client, "step-down");
59-
mongoc_collection_destroy (coll);
60-
coll = mongoc_database_create_collection (db, "step-down", opts, &error);
61-
ASSERT_OR_PRINT (coll, error);
52+
{
53+
mongoc_database_t *const db = mongoc_client_get_database (client, "step-down");
6254

63-
mongoc_collection_destroy (coll);
64-
mongoc_database_destroy (db);
65-
mongoc_write_concern_destroy (wc);
66-
bson_destroy (opts);
55+
bson_t opts = BSON_INITIALIZER;
56+
57+
{
58+
mongoc_write_concern_t *const wc = mongoc_write_concern_new ();
59+
mongoc_write_concern_set_wmajority (wc, -1);
60+
ASSERT (mongoc_write_concern_append (wc, &opts));
61+
mongoc_write_concern_destroy (wc);
62+
}
63+
64+
mongoc_collection_t *const coll = mongoc_database_create_collection (db, "step-down", &opts, &error);
65+
ASSERT_OR_PRINT (coll, error);
66+
mongoc_collection_destroy (coll);
67+
mongoc_database_destroy (db);
68+
bson_destroy (&opts);
69+
}
6770
}
6871

6972
static int
@@ -132,26 +135,17 @@ _run_test_single_or_pooled (_test_fn_t test, bool use_pooled)
132135
static void
133136
test_getmore_iteration (mongoc_client_t *client)
134137
{
135-
mongoc_write_concern_t *wc;
136138
mongoc_database_t *db;
137139
mongoc_collection_t *coll;
138140
mongoc_cursor_t *cursor;
139141
const bson_t *doc;
140142
bson_error_t error;
141-
bson_t *insert;
142-
bson_t *opts;
143143
bool res;
144144
int conn_count;
145-
int i;
146145
uint32_t primary_id;
147146

148147
ASSERT (client);
149148

150-
wc = mongoc_write_concern_new ();
151-
mongoc_write_concern_set_wmajority (wc, -1);
152-
opts = bson_new ();
153-
ASSERT (mongoc_write_concern_append (wc, opts));
154-
155149
coll = mongoc_client_get_collection (client, "step-down", "step-down");
156150

157151
db = mongoc_client_get_database (client, "admin");
@@ -168,13 +162,26 @@ test_getmore_iteration (mongoc_client_t *client)
168162
conn_count = _connection_count (client, primary_id);
169163

170164
/* Insert 5 documents */
171-
for (i = 0; i < 5; i++) {
172-
insert = bson_new ();
165+
{
166+
bson_t opts = BSON_INITIALIZER;
167+
168+
{
169+
mongoc_write_concern_t *const wc = mongoc_write_concern_new ();
170+
mongoc_write_concern_set_wmajority (wc, -1);
171+
ASSERT (mongoc_write_concern_append (wc, &opts));
172+
mongoc_write_concern_destroy (wc);
173+
}
174+
175+
for (int i = 0; i < 5; i++) {
176+
bson_t insert = BSON_INITIALIZER;
173177

174-
bson_append_int32 (insert, "a", -1, i);
175-
ASSERT (mongoc_collection_insert_one (coll, insert, opts, NULL, NULL));
178+
bson_append_int32 (&insert, "a", -1, i);
179+
ASSERT (mongoc_collection_insert_one (coll, &insert, &opts, NULL, NULL));
180+
181+
bson_destroy (&insert);
182+
}
176183

177-
bson_destroy (insert);
184+
bson_destroy (&opts);
178185
}
179186

180187
/* Retrieve the first batch of 2 documents */
@@ -200,8 +207,6 @@ test_getmore_iteration (mongoc_client_t *client)
200207
mongoc_cursor_destroy (cursor);
201208
mongoc_collection_destroy (coll);
202209
mongoc_database_destroy (db);
203-
mongoc_write_concern_destroy (wc);
204-
bson_destroy (opts);
205210
}
206211

207212
static void

0 commit comments

Comments
 (0)