diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2018-12-12 11:16:13 -0500 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-01-07 22:54:19 -0500 |
commit | 09fdd6cd55bfaca9ac525f6a0668ed97a7f3d048 (patch) | |
tree | d402ff485f3ca1c26ad23535867c6525a6c40268 /jstests | |
parent | c2892222a633609fd14706062d8ed6086352004d (diff) | |
download | mongo-09fdd6cd55bfaca9ac525f6a0668ed97a7f3d048.tar.gz |
SERVER-38510 Set moreToCome flag with OP_MSG writes from shell
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/batch_write_command_delete.js | 19 | ||||
-rw-r--r-- | jstests/core/batch_write_command_insert.js | 12 | ||||
-rw-r--r-- | jstests/core/batch_write_command_update.js | 16 | ||||
-rw-r--r-- | jstests/core/crud_api.js | 12 | ||||
-rw-r--r-- | jstests/noPassthrough/shell_can_retry_writes.js | 4 | ||||
-rw-r--r-- | jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js | 1 |
6 files changed, 48 insertions, 16 deletions
diff --git a/jstests/core/batch_write_command_delete.js b/jstests/core/batch_write_command_delete.js index f83a9984936..bb87fa4876d 100644 --- a/jstests/core/batch_write_command_delete.js +++ b/jstests/core/batch_write_command_delete.js @@ -33,6 +33,16 @@ function resultNOK(result) { return !result.ok && typeof(result.code) == 'number' && typeof(result.errmsg) == 'string'; } +function countEventually(collection, n) { + assert.soon( + function() { + return collection.count() === n; + }, + function() { + return "unacknowledged write timed out"; + }); +} + // EACH TEST BELOW SHOULD BE SELF-CONTAINED, FOR EASIER DEBUGGING // @@ -70,7 +80,7 @@ request = { }; result = coll.runCommand(request); assert(resultOK(result), tojson(result)); -assert.eq(0, coll.count()); +countEventually(coll, 0); var fields = ['ok']; assert.hasFields(result, fields, 'fields in result do not match: ' + tojson(fields)); @@ -218,7 +228,7 @@ request = { }; result = coll.runCommand(request); assert.commandWorked(result); -assert.eq(0, coll.count()); +countEventually(coll, 0); assert.hasFields(result, fields, 'fields in result do not match: ' + tojson(fields)); @@ -235,7 +245,7 @@ request = { }; result = coll.runCommand(request); assert.commandWorked(result); -assert.eq(1, coll.count()); +countEventually(coll, 1); assert.hasFields(result, fields, 'fields in result do not match: ' + tojson(fields)); @@ -250,4 +260,5 @@ request = { ordered: false }; result = coll.runCommand(request); -assert(resultNOK(result), tojson(result)); +// Unacknowledged writes are always OK +assert.commandWorked(result); diff --git a/jstests/core/batch_write_command_insert.js b/jstests/core/batch_write_command_insert.js index 5d0a85fa763..feddcb50ea6 100644 --- a/jstests/core/batch_write_command_insert.js +++ b/jstests/core/batch_write_command_insert.js @@ -36,6 +36,16 @@ function resultNOK(result) { return !result.ok && typeof(result.code) == 'number' && typeof(result.errmsg) == 'string'; } +function countEventually(collection, n) { + assert.soon( + function() { + return collection.count() === n; + }, + function() { + return "unacknowledged write timed out"; + }); +} + // EACH TEST BELOW SHOULD BE SELF-CONTAINED, FOR EASIER DEBUGGING // @@ -69,7 +79,7 @@ request = { }; result = coll.runCommand(request); assert(resultOK(result), tojson(result)); -assert.eq(coll.count(), 1); +countEventually(coll, 1); var fields = ['ok']; assert.hasFields(result, fields, 'fields in result do not match: ' + tojson(fields)); diff --git a/jstests/core/batch_write_command_update.js b/jstests/core/batch_write_command_update.js index 59c327db233..1c124bfadb7 100644 --- a/jstests/core/batch_write_command_update.js +++ b/jstests/core/batch_write_command_update.js @@ -32,6 +32,16 @@ function resultNOK(result) { return !result.ok && typeof(result.code) == 'number' && typeof(result.errmsg) == 'string'; } +function countEventually(collection, n) { + assert.soon( + function() { + return collection.count() === n; + }, + function() { + return "unacknowledged write timed out"; + }); +} + // EACH TEST BELOW SHOULD BE SELF-CONTAINED, FOR EASIER DEBUGGING // @@ -114,7 +124,7 @@ request = { }; result = coll.runCommand(request); assert(resultOK(result), tojson(result)); -assert.eq(1, coll.count({})); +countEventually(coll, 1); var fields = ['ok']; assert.hasFields(result, fields, 'fields in result do not match: ' + tojson(fields)); @@ -133,7 +143,7 @@ request = { }; result = coll.runCommand(request); assert(resultOK(result), tojson(result)); -assert.eq(2, coll.count()); +countEventually(coll, 2); assert.hasFields(result, fields, 'fields in result do not match: ' + tojson(fields)); @@ -272,7 +282,7 @@ request = { }; result = coll.runCommand(request); assert(result.ok, tojson(result)); -assert.eq(1, coll.count()); +countEventually(coll, 1); assert.hasFields(result, fields, 'fields in result do not match: ' + tojson(fields)); diff --git a/jstests/core/crud_api.js b/jstests/core/crud_api.js index 7a7790fa673..e0f099fb09a 100644 --- a/jstests/core/crud_api.js +++ b/jstests/core/crud_api.js @@ -33,9 +33,15 @@ verifyResult(args.result, r); // Get all the results - var results = coll.find({}).sort({_id: 1}).toArray(); - - assert.docEq(args.expected, results); + assert.soonNoExcept( + function() { + var results = coll.find({}).sort({_id: 1}).toArray(); + assert.docEq(args.expected, results); + return true; + }, + function() { + return "collection never contained expected documents"; + }); }; } diff --git a/jstests/noPassthrough/shell_can_retry_writes.js b/jstests/noPassthrough/shell_can_retry_writes.js index 2a7deb83818..60ef8df9cd1 100644 --- a/jstests/noPassthrough/shell_can_retry_writes.js +++ b/jstests/noPassthrough/shell_can_retry_writes.js @@ -112,10 +112,6 @@ coll.insertOne({_id: "majority"}, {w: "majority"}); }); - testCommandCanBeRetried(function() { - coll.insertOne({_id: 0}, {w: 0}); - }, false); - // // Tests for bulkWrite(). // diff --git a/jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js b/jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js index 3e93574ca18..d4be74ed8bc 100644 --- a/jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js +++ b/jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js @@ -14,7 +14,6 @@ // Commands sent directly to the config server should fail with WC < majority. const unacceptableWCsForConfig = [ - {writeConcern: {w: 0}}, {writeConcern: {w: 1}}, {writeConcern: {w: 2}}, {writeConcern: {w: 3}}, |