Skip to content

Commit cdb0a8f

Browse files
committed
Use majority write concern and remove assert in change stream tests (#1980)
* use majority write concern in change stream test * do not assert that resume token changed after receiving no documents
1 parent d79a0bd commit cdb0a8f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/libmongoc/tests/test-mongoc-change-stream.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,10 @@ test_change_stream_live_track_resume_token (void *test_ctx)
353353
ASSERT (bson_compare (resume_token, &doc1_rt) != 0);
354354
bson_copy_to (resume_token, &doc2_rt);
355355

356-
/* There are no docs left. But the next call should still keep the same
357-
* resume token */
356+
/* There are no docs left. */
358357
ASSERT (!mongoc_change_stream_next (stream, &next_doc));
359358
ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), error);
360359
ASSERT (!next_doc);
361-
resume_token = mongoc_change_stream_get_resume_token (stream);
362-
ASSERT (!bson_empty0 (resume_token));
363-
ASSERT (bson_compare (resume_token, &doc2_rt) == 0);
364360

365361
bson_destroy (&doc0_rt);
366362
bson_destroy (&doc1_rt);
@@ -2160,6 +2156,13 @@ test_change_stream_batchSize0 (void *test_ctx)
21602156
{
21612157
mongoc_client_t *client = test_framework_new_default_client ();
21622158
mongoc_collection_t *coll = drop_and_get_coll (client, "db", "coll");
2159+
// Insert with majority write concern to ensure documents are visible to change stream.
2160+
{
2161+
mongoc_write_concern_t *wc = mongoc_write_concern_new ();
2162+
mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
2163+
mongoc_collection_set_write_concern (coll, wc);
2164+
mongoc_write_concern_destroy (wc);
2165+
}
21632166
mongoc_change_stream_t *cs = mongoc_collection_watch (coll, tmp_bson ("{}"), NULL);
21642167
resumeToken = bson_copy (mongoc_change_stream_get_resume_token (cs));
21652168
// Insert documents to create future events.

0 commit comments

Comments
 (0)