From 0511dffda040fdecd6c7a71835b59427670ff0c0 Mon Sep 17 00:00:00 2001 From: Charlie Swanson Date: Mon, 30 Nov 2015 16:00:47 -0500 Subject: SERVER-21545 Correctly roll back updating collection options (cherry picked from commit a4d29291cc3ee4d44970fc450e0a7124828394b2) --- jstests/core/collmod_bad_spec.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 jstests/core/collmod_bad_spec.js (limited to 'jstests/core') diff --git a/jstests/core/collmod_bad_spec.js b/jstests/core/collmod_bad_spec.js new file mode 100644 index 00000000000..ccce81fd4b1 --- /dev/null +++ b/jstests/core/collmod_bad_spec.js @@ -0,0 +1,23 @@ +// This is a regression test for SERVER-21545. +// +// Tests that a collMod with a bad specification does not cause any changes, and does not crash the +// server. +(function() { + "use strict"; + + var collName = "collModBadSpec"; + var coll = db.getCollection(collName); + + coll.drop(); + assert.commandWorked(db.createCollection(collName)); + + // Get the original collection options for the collection. + var originalResult = db.getCollectionInfos({name: collName}); + + // Issue an invalid command. + assert.commandFailed(coll.runCommand("collMod", {validationLevel: "off", unknownField: "x"})); + + // Make sure the options are unchanged. + var newResult = db.getCollectionInfos({name: collName}); + assert.eq(originalResult, newResult); +})(); -- cgit v1.2.1