summaryrefslogtreecommitdiff
path: root/jstests/core/rollback_index_drop.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/rollback_index_drop.js')
-rw-r--r--jstests/core/rollback_index_drop.js41
1 files changed, 20 insertions, 21 deletions
diff --git a/jstests/core/rollback_index_drop.js b/jstests/core/rollback_index_drop.js
index 3e7c3a97952..6f999f56209 100644
--- a/jstests/core/rollback_index_drop.js
+++ b/jstests/core/rollback_index_drop.js
@@ -5,31 +5,30 @@
//
// @tags: [does_not_support_stepdowns, assumes_unsharded_collection]
(function() {
- "use strict";
+"use strict";
- const coll = db.rollback_index_drop;
- coll.drop();
+const coll = db.rollback_index_drop;
+coll.drop();
- assert.commandWorked(coll.insert([{a: 1}, {a: 2}, {a: 3}]));
- assert.commandWorked(coll.createIndex({a: 1}));
+assert.commandWorked(coll.insert([{a: 1}, {a: 2}, {a: 3}]));
+assert.commandWorked(coll.createIndex({a: 1}));
- // Verify that the index has the expected set of keys.
- assert.eq([{a: 1}, {a: 2}, {a: 3}],
- coll.find().hint({a: 1}).sort({a: 1}).returnKey().toArray());
+// Verify that the index has the expected set of keys.
+assert.eq([{a: 1}, {a: 2}, {a: 3}], coll.find().hint({a: 1}).sort({a: 1}).returnKey().toArray());
- // Run a dropIndexes command that attempts to drop both {a: 1} and an invalid index. This should
- // cause the drop of {a: 1} to rollback, since the set of index drops happen atomically.
- assert.commandFailedWithCode(
- db.runCommand({dropIndexes: coll.getName(), index: ["a_1", "unknown"]}),
- ErrorCodes.IndexNotFound);
+// Run a dropIndexes command that attempts to drop both {a: 1} and an invalid index. This should
+// cause the drop of {a: 1} to rollback, since the set of index drops happen atomically.
+assert.commandFailedWithCode(
+ db.runCommand({dropIndexes: coll.getName(), index: ["a_1", "unknown"]}),
+ ErrorCodes.IndexNotFound);
- // Verify that the {a: 1} index is still present in listIndexes output.
- const indexList = coll.getIndexes();
- assert.neq(undefined, indexList.find((idx) => idx.name === "a_1"), indexList);
+// Verify that the {a: 1} index is still present in listIndexes output.
+const indexList = coll.getIndexes();
+assert.neq(undefined, indexList.find((idx) => idx.name === "a_1"), indexList);
- // Write to the collection and ensure that the resulting set of index keys is correct.
- assert.commandWorked(coll.update({a: 3}, {$inc: {a: 1}}));
- assert.commandWorked(coll.insert({a: 5}));
- assert.eq([{a: 1}, {a: 2}, {a: 4}, {a: 5}],
- coll.find().hint({a: 1}).sort({a: 1}).returnKey().toArray());
+// Write to the collection and ensure that the resulting set of index keys is correct.
+assert.commandWorked(coll.update({a: 3}, {$inc: {a: 1}}));
+assert.commandWorked(coll.insert({a: 5}));
+assert.eq([{a: 1}, {a: 2}, {a: 4}, {a: 5}],
+ coll.find().hint({a: 1}).sort({a: 1}).returnKey().toArray());
}());