diff options
author | Martin Bligh <mbligh@mongodb.com> | 2015-10-26 10:19:39 -0400 |
---|---|---|
committer | Martin Bligh <mbligh@mongodb.com> | 2015-10-26 10:21:05 -0400 |
commit | b9c5d9f97d63429c36cb9027b6fc1594b67373a9 (patch) | |
tree | 3e2dc520f6f6d15c2c2f4fc1687c4b32b435af70 /jstests/core | |
parent | b82f1a20b8c3b44f84e5744fcf9ed062341e7d58 (diff) | |
download | mongo-b9c5d9f97d63429c36cb9027b6fc1594b67373a9.tar.gz |
SERVER-21093: Make ordered bulk insert operation error out properly
Diffstat (limited to 'jstests/core')
-rw-r--r-- | jstests/core/batch_write_command_insert.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/jstests/core/batch_write_command_insert.js b/jstests/core/batch_write_command_insert.js index 54ed12d846b..a9c271f3d24 100644 --- a/jstests/core/batch_write_command_insert.js +++ b/jstests/core/batch_write_command_insert.js @@ -302,6 +302,22 @@ assert(!result.ok, tojson(result)); assert.eq(coll.getIndexes().length, 0); // +// Ensure we error out correctly in the middle of a batch +coll.drop(); +coll.insert({_id: 50}); // Create a document to force a duplicate key exception. + +var bulk = coll.initializeOrderedBulkOp(); +for (i = 1; i < 100; i++) { + bulk.insert( { _id: i } ); +} +try { + bulk.execute(); + assert(false, "should have failed due to duplicate key"); +} catch(err) { + assert(coll.count() == 50, "Unexpected number inserted by bulk write: " + coll.count()); +} + +// // Background index creation // Note: due to SERVER-13304 this test is at the end of this file, and we don't drop // the collection afterwards. |