Skip to content

Use majority write concern and remove assert in change stream tests #1980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/libmongoc/tests/test-mongoc-change-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,10 @@ test_change_stream_live_track_resume_token (void *test_ctx)
ASSERT (bson_compare (resume_token, &doc1_rt) != 0);
bson_copy_to (resume_token, &doc2_rt);

/* There are no docs left. But the next call should still keep the same
* resume token */
/* There are no docs left. */
ASSERT (!mongoc_change_stream_next (stream, &next_doc));
ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), error);
ASSERT (!next_doc);
resume_token = mongoc_change_stream_get_resume_token (stream);
ASSERT (!bson_empty0 (resume_token));
ASSERT (bson_compare (resume_token, &doc2_rt) == 0);

bson_destroy (&doc0_rt);
bson_destroy (&doc1_rt);
Expand Down Expand Up @@ -2160,6 +2156,13 @@ test_change_stream_batchSize0 (void *test_ctx)
{
mongoc_client_t *client = test_framework_new_default_client ();
mongoc_collection_t *coll = drop_and_get_coll (client, "db", "coll");
// Insert with majority write concern to ensure documents are visible to change stream.
{
mongoc_write_concern_t *wc = mongoc_write_concern_new ();
mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_collection_set_write_concern (coll, wc);
mongoc_write_concern_destroy (wc);
}
mongoc_change_stream_t *cs = mongoc_collection_watch (coll, tmp_bson ("{}"), NULL);
resumeToken = bson_copy (mongoc_change_stream_get_resume_token (cs));
// Insert documents to create future events.
Expand Down