diff options
Diffstat (limited to 'jstests/core/compact_keeps_indexes.js')
-rw-r--r-- | jstests/core/compact_keeps_indexes.js | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/jstests/core/compact_keeps_indexes.js b/jstests/core/compact_keeps_indexes.js index 1a050d27469..25b3909df1c 100644 --- a/jstests/core/compact_keeps_indexes.js +++ b/jstests/core/compact_keeps_indexes.js @@ -8,39 +8,38 @@ // ] (function() { - 'use strict'; +'use strict'; - var coll = db.compact_keeps_indexes; +var coll = db.compact_keeps_indexes; - coll.drop(); - coll.insert({_id: 1, x: 1}); - coll.ensureIndex({x: 1}); +coll.drop(); +coll.insert({_id: 1, x: 1}); +coll.ensureIndex({x: 1}); - assert.eq(coll.getIndexes().length, 2); +assert.eq(coll.getIndexes().length, 2); - // force:true is for replset passthroughs - var res = coll.runCommand('compact', {force: true}); - // Some storage engines (for example, inMemoryExperiment) do not support the compact command. - if (res.code == 115) { // CommandNotSupported - return; - } - assert.commandWorked(res); +// force:true is for replset passthroughs +var res = coll.runCommand('compact', {force: true}); +// Some storage engines (for example, inMemoryExperiment) do not support the compact command. +if (res.code == 115) { // CommandNotSupported + return; +} +assert.commandWorked(res); - assert.eq(coll.getIndexes().length, 2); - assert.eq(coll.find({_id: 1}).itcount(), 1); - assert.eq(coll.find({x: 1}).itcount(), 1); +assert.eq(coll.getIndexes().length, 2); +assert.eq(coll.find({_id: 1}).itcount(), 1); +assert.eq(coll.find({x: 1}).itcount(), 1); - var dropCollectionShell = startParallelShell(function() { - var t = db.getSiblingDB('test_compact_keeps_indexes_drop').testcoll; +var dropCollectionShell = startParallelShell(function() { + var t = db.getSiblingDB('test_compact_keeps_indexes_drop').testcoll; + t.drop(); + for (var i = 0; i < 100; i++) { + t.save({a: 1}); t.drop(); - for (var i = 0; i < 100; i++) { - t.save({a: 1}); - t.drop(); - } - }); - for (var i = 0; i < 10; i++) { - coll.runCommand('compact'); } - dropCollectionShell(); - +}); +for (var i = 0; i < 10; i++) { + coll.runCommand('compact'); +} +dropCollectionShell(); }()); |