Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ main(void)
/* Create the collection with the encryption JSON Schema. */
create_cmd = BCON_NEW("create", ENCRYPTED_COLL, "validator", "{", "$jsonSchema", BCON_DOCUMENT(schema), "}");
wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, 0);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
create_cmd_opts = bson_new();
mongoc_write_concern_append(wc, create_cmd_opts);
ret = mongoc_client_command_with_opts(
Expand Down
4 changes: 1 addition & 3 deletions src/libmongoc/src/mongoc/mongoc-write-concern.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,7 @@ _mongoc_write_concern_new_from_iter(const bson_iter_t *iter, bson_error_t *error
mongoc_write_concern_set_w(write_concern, w);
} else if (BSON_ITER_HOLDS_UTF8(&inner)) {
if (!strcmp(bson_iter_utf8(&inner, NULL), "majority")) {
/* mongoc_write_concern_set_wmajority() only assigns wtimeout if
* it is >= 0. Since we set wtimeout below, pass -1 here. */
mongoc_write_concern_set_wmajority(write_concern, -1);
mongoc_write_concern_set_w(write_concern, MONGOC_WRITE_CONCERN_W_MAJORITY);
} else {
mongoc_write_concern_set_wtag(write_concern, bson_iter_utf8(&inner, NULL));
}
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/tests/test-conveniences.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ bson_lookup_write_concern(const bson_t *b, const char *key)
if (BSON_ITER_HOLDS_NUMBER(&w)) {
mongoc_write_concern_set_w(wc, (int32_t)bson_iter_as_int64(&w));
} else if (!strcmp(bson_iter_utf8(&w, NULL), "majority")) {
mongoc_write_concern_set_wmajority(wc, 0);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
} else {
mongoc_write_concern_set_wtag(wc, bson_iter_utf8(&w, NULL));
}
Expand Down
12 changes: 6 additions & 6 deletions src/libmongoc/tests/test-mongoc-change-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ test_change_stream_live_track_resume_token(void *test_ctx)

/* Insert a few docs to listen for. Use write concern majority, so subsequent
* call to watch will be guaranteed to retrieve them. */
mongoc_write_concern_set_wmajority(wc, 30000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_write_concern_append(wc, &opts);
ASSERT_OR_PRINT(mongoc_collection_insert_one(coll, tmp_bson("{'_id': 0}"), &opts, NULL, &error), error);

Expand Down Expand Up @@ -428,7 +428,7 @@ test_change_stream_live_batch_size(void *test_ctx)

ctx.expected_getmore_batch_size = 1;

mongoc_write_concern_set_wmajority(wc, 30000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_write_concern_append(wc, &opts);
for (i = 0; i < 10; i++) {
bson_t *doc = BCON_NEW("_id", BCON_INT32(i));
Expand Down Expand Up @@ -486,7 +486,7 @@ _test_resume_token_error(const char *id_projection)
ASSERT(stream);
ASSERT_OR_PRINT(!mongoc_change_stream_error_document(stream, &err, NULL), err);

mongoc_write_concern_set_wmajority(wc, 30000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_write_concern_append(wc, &opts);
ASSERT_OR_PRINT(mongoc_collection_insert_one(coll, tmp_bson("{'_id': 2}"), &opts, NULL, &err), err);

Expand Down Expand Up @@ -888,7 +888,7 @@ test_change_stream_live_watch(void *test_ctx)

BSON_UNUSED(test_ctx);

mongoc_write_concern_set_wmajority(wc, 30000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);

coll = drop_and_get_coll(client, "db", "coll_watch");
ASSERT(coll);
Expand Down Expand Up @@ -1610,7 +1610,7 @@ prose_test_11(void *ctx)
post_batch_expected = (_data_change_stream_t *)stream->cursor->impl.data;
ASSERT(bson_compare(resume_token, &post_batch_expected->post_batch_resume_token) == 0);

mongoc_write_concern_set_wmajority(wc, 30000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_write_concern_append(wc, &opts);
ASSERT_OR_PRINT(mongoc_collection_insert_one(coll, tmp_bson("{'_id': 0}"), &opts, NULL, &error), error);

Expand Down Expand Up @@ -1661,7 +1661,7 @@ prose_test_13(void *ctx)

/* Insert a few docs to listen for. Use write concern majority, so subsequent
* call to watch will be guaranteed to retrieve them. */
mongoc_write_concern_set_wmajority(wc, 30000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_write_concern_append(wc, &opts);
ASSERT_OR_PRINT(mongoc_collection_insert_one(coll, tmp_bson("{'_id': 0}"), &opts, NULL, &error), error);

Expand Down
12 changes: 6 additions & 6 deletions src/libmongoc/tests/test-mongoc-client-side-encryption.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _before_test(json_test_ctx_t *ctx, const bson_t *test)
/* Insert data into the key vault. */
client = test_framework_new_default_client();
wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, 1000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
bson_init(&insert_opts);
mongoc_write_concern_append(wc, &insert_opts);

Expand Down Expand Up @@ -397,7 +397,7 @@ test_bson_size_limits_and_batch_splitting(void *unused)
(void)mongoc_collection_drop(coll, NULL);
datakey = get_bson_from_json_file("./src/libmongoc/tests/client_side_encryption_prose/limits-key.json");
wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, 1000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_collection_set_write_concern(coll, wc);
ASSERT_OR_PRINT(mongoc_collection_insert_one(coll, datakey, NULL /* opts */, NULL /* reply */, &error), error);
mongoc_write_concern_destroy(wc);
Expand Down Expand Up @@ -951,7 +951,7 @@ _test_key_vault(bool with_external_key_vault)

/* Insert the document external-key.json into ``keyvault.datakeys``. */
wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, 1000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_collection_set_write_concern(coll, wc);
datakey = get_bson_from_json_file("./src/libmongoc/tests/"
"client_side_encryption_prose/external/"
Expand Down Expand Up @@ -1725,7 +1725,7 @@ _test_corpus(bool local_schema)
coll = mongoc_client_get_collection(client, "keyvault", "datakeys");
(void)mongoc_collection_drop(coll, NULL);
wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, 1000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_collection_set_write_concern(coll, wc);
_insert_from_file(coll,
"./src/libmongoc/tests/client_side_encryption_prose/"
Expand Down Expand Up @@ -1898,7 +1898,7 @@ _reset(mongoc_client_pool_t **pool,
coll = mongoc_client_get_collection(*singled_threaded_client, "db", "keyvault");
(void)mongoc_collection_drop(coll, NULL);
wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, 1000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_collection_set_write_concern(coll, wc);
datakey = get_bson_from_json_file("./src/libmongoc/tests/client_side_encryption_prose/limits-key.json");
BSON_ASSERT(datakey);
Expand Down Expand Up @@ -2129,7 +2129,7 @@ _test_multi_threaded(bool external_key_vault)
datakey = get_bson_from_json_file("./src/libmongoc/tests/client_side_encryption_prose/limits-key.json");
BSON_ASSERT(datakey);
wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, 1000);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
mongoc_collection_set_write_concern(coll, wc);
ASSERT_OR_PRINT(mongoc_collection_insert_one(coll, datakey, NULL /* opts */, NULL /* reply */, &error), error);

Expand Down
4 changes: 2 additions & 2 deletions src/libmongoc/tests/test-mongoc-primary-stepdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ _setup_test_with_client(mongoc_client_t *client)

{
mongoc_write_concern_t *const wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, -1);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
ASSERT(mongoc_write_concern_append(wc, &opts));
mongoc_write_concern_destroy(wc);
}
Expand Down Expand Up @@ -158,7 +158,7 @@ test_getmore_iteration(mongoc_client_t *client, stream_tracker_t *st)

{
mongoc_write_concern_t *const wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, -1);
mongoc_write_concern_set_w(wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
ASSERT(mongoc_write_concern_append(wc, &opts));
mongoc_write_concern_destroy(wc);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/tests/test-mongoc-sample-commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -3933,7 +3933,7 @@ with_transaction_example(bson_error_t *error)
* concern by default.
*/
wc = mongoc_write_concern_new();
mongoc_write_concern_set_wmajority(wc, 0);
mongoc_write_concern_set_wmajority(wc, 1000);
insert_opts = bson_new();
mongoc_write_concern_append(wc, insert_opts);
coll = mongoc_client_get_collection(client, "mydb1", "foo");
Expand Down