summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2015-11-30 16:00:47 -0500
committerRamon Fernandez <ramon@mongodb.com>2015-12-10 15:41:51 -0500
commit0511dffda040fdecd6c7a71835b59427670ff0c0 (patch)
tree9a7c3dd4da9ac20c6103c952251e61346a88ce3f /jstests/core
parent5c25a255711a30729a7a96e2fc25b44b4495dab8 (diff)
downloadmongo-0511dffda040fdecd6c7a71835b59427670ff0c0.tar.gz
SERVER-21545 Correctly roll back updating collection options
(cherry picked from commit a4d29291cc3ee4d44970fc450e0a7124828394b2)
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/collmod_bad_spec.js23
1 files changed, 23 insertions, 0 deletions
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);
+})();