diff options
Diffstat (limited to 'jstests/core/batch_write_command_delete.js')
-rw-r--r-- | jstests/core/batch_write_command_delete.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/jstests/core/batch_write_command_delete.js b/jstests/core/batch_write_command_delete.js index 335633e47d7..ec960e64741 100644 --- a/jstests/core/batch_write_command_delete.js +++ b/jstests/core/batch_write_command_delete.js @@ -11,6 +11,9 @@ jsTest.log("Starting delete tests..."); var request; var result; +var batch; + +var maxWriteBatchSize = 1000; function resultOK( result ) { return result.ok && @@ -103,6 +106,39 @@ assert.eq(2, result.n); assert.eq(0, coll.count()); // +// Large batch under the size threshold should delete successfully +coll.remove({}); +batch = []; +for (var i = 0; i < maxWriteBatchSize; ++i) { + coll.insert({a:i}); + batch.push({q:{a:i}, limit: 0}); +} +printjson( request = {'delete' : coll.getName(), + deletes: batch, + writeConcern:{w:1}, + ordered: false} ); +printjson( result = coll.runCommand(request) ); +assert(resultOK(result)); +assert.eq(batch.length, result.n); +assert.eq(0, coll.count()); + +// +// Large batch above the size threshold should fail to delete +coll.remove({}); +batch = []; +for (var i = 0; i < maxWriteBatchSize + 1; ++i) { + coll.insert({a:i}); + batch.push({q:{a:i}, limit: 0}); +} +printjson( request = {'delete' : coll.getName(), + deletes: batch, + writeConcern:{w:1}, + ordered: false} ); +printjson( result = coll.runCommand(request) ); +assert(resultNOK(result)); +assert.eq(batch.length, coll.count()); + +// // Cause remove error using ordered:true coll.remove({}); coll.insert({a:1}); |