diff options
author | Mathias Stearn <mathias@10gen.com> | 2015-01-14 16:45:39 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2015-01-15 18:08:36 -0500 |
commit | 59fec904c441998dc6381b8e26bd4b90d8718a3e (patch) | |
tree | ac9d21d5937844422c9cd3afc2f858bff42c01ba /jstests/core/compact_keeps_indexes.js | |
parent | d1910c70e2e3eb6ce057a474dece00b737645631 (diff) | |
download | mongo-59fec904c441998dc6381b8e26bd4b90d8718a3e.tar.gz |
SERVER-16676 don't trash indexes for RecordStores that can compact in-place
Diffstat (limited to 'jstests/core/compact_keeps_indexes.js')
-rw-r--r-- | jstests/core/compact_keeps_indexes.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/jstests/core/compact_keeps_indexes.js b/jstests/core/compact_keeps_indexes.js new file mode 100644 index 00000000000..4047c048e17 --- /dev/null +++ b/jstests/core/compact_keeps_indexes.js @@ -0,0 +1,21 @@ +// SERVER-16676 Make sure compact doesn't leave the collection with bad indexes + +(function() { + 'use strict'; + + var coll = db.compact_keeps_indexes; + + coll.insert({_id:1, x:1}); + coll.ensureIndex({x:1}); + + assert.eq(coll.getIndexes().length, 2); + + var res = coll.runCommand('compact'); + if (res.code != 115) { // CommandNotSupported + 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); +}()) |