summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authoralabid <alabidan@gmail.com>2015-01-20 15:28:26 -0500
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-01-26 11:27:36 -0500
commit021ea0a1a885d26e7c1010d71cf4152d40d5c04c (patch)
treea5564128302e3e082f7198fe74ae8cf80ff2689f /jstests
parentb51b97381792ba3e02fe02204f02c87863d2f664 (diff)
downloadmongo-021ea0a1a885d26e7c1010d71cf4152d40d5c04c.tar.gz
SERVER-16893 Disallow creation of v0 indexes with non-mmapv1 storage engines
Also moved jstests/tool/dumprestore6.js to jstests/mmapv1/dumprestore6.js since this JS test attempts to restore a v0 index Closes #914 Signed-off-by: Benety Goh <benety@mongodb.com> (cherry picked from commit 5f3fa2e77537d1be650af981effa2e66dc86e10d)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/create_indexes.js17
-rw-r--r--jstests/mmap_v1/dumprestore6.js (renamed from jstests/tool/dumprestore6.js)0
-rw-r--r--jstests/noPassthroughWithMongod/index_check10.js5
-rw-r--r--jstests/replsets/initSyncV1Index.js91
4 files changed, 73 insertions, 40 deletions
diff --git a/jstests/core/create_indexes.js b/jstests/core/create_indexes.js
index 2ace0cbb20e..7f003006388 100644
--- a/jstests/core/create_indexes.js
+++ b/jstests/core/create_indexes.js
@@ -103,4 +103,21 @@
assert( !res.ok )
assert.eq( 6, t.getIndexes().length );
+
+ //
+ // Test that v0 indexes can only be created with mmapv1
+ //
+ res = t.runCommand('createIndexes',
+ {indexes: [{key: {d: 1}, name: 'd_1', v: 0}]});
+
+ if (!isMongos) {
+ var status = db.serverStatus();
+ assert.commandWorked(status);
+ if (status.storageEngine.name === 'mmapv1') {
+ assert.commandWorked(res, 'v0 index creation should work for mmapv1');
+ } else {
+ assert.commandFailed(res, 'v0 index creation should fail for non-mmapv1 storage engines');
+ }
+ }
+
}());
diff --git a/jstests/tool/dumprestore6.js b/jstests/mmap_v1/dumprestore6.js
index 471a63cf150..471a63cf150 100644
--- a/jstests/tool/dumprestore6.js
+++ b/jstests/mmap_v1/dumprestore6.js
diff --git a/jstests/noPassthroughWithMongod/index_check10.js b/jstests/noPassthroughWithMongod/index_check10.js
index 84e7342e051..f507c687731 100644
--- a/jstests/noPassthroughWithMongod/index_check10.js
+++ b/jstests/noPassthroughWithMongod/index_check10.js
@@ -134,5 +134,8 @@ function doIt( indexVersion ) {
for( var z = 0; z < 5; ++z ) {
var indexVersion = z % 2;
- doIt( indexVersion );
+ var storageEngine = jsTest.options().storageEngine;
+ if (!storageEngine || storageEngine === 'mmapv1' || indexVersion !== 0) {
+ doIt(indexVersion);
+ }
}
diff --git a/jstests/replsets/initSyncV1Index.js b/jstests/replsets/initSyncV1Index.js
index e2fe06545b2..c3daa471b44 100644
--- a/jstests/replsets/initSyncV1Index.js
+++ b/jstests/replsets/initSyncV1Index.js
@@ -1,39 +1,52 @@
-// Create {v:0} index on primary. Add new secondary. Make sure same index on secondary is {v:1} - SERVER-3852
-
-var rs = new ReplSetTest( {name: 'rs', nodes: 1, host: 'localhost'} );
-rs.startSet();
-rs.initiate();
-var r1 = rs.getMaster();
-var db1 = r1.getDB('test');
-
-var t = '';
-for (var i = 0; i < 1000; i++) t += 'a';
-for (var i = 0; i < 10000; i++) db1.foo.insert( {_id:i, x:i%1000, t:t} );
-db1.foo.createIndex( {x:1}, {v: 0} );
-
-var r2 = rs.add();
-rs.reInitiate(60000);
-
-var db2 = r2.getDB('test');
-r2.setSlaveOk();
-rs.awaitSecondaryNodes();
-rs.awaitReplication();
-var idxes = db2.foo.getIndexes();
-assert.gt(idxes.length, 0, "Secondary reported no indexes on collection " + db2.foo);
-var idx = idxes.filter(function(idx) {
- return friendlyEqual(idx.key, {x: 1});
-})[0];
-assert(idx, "expected to find an index with key {x: 1} on the secondary's collection " + db2.foo);
-assert.eq (idx.v, 1,
- 'expected all indexes generated on Mongo version >= 2.0 to be {v:1}. See SERVER-3852');
-
-// add another new node, make sure ports _aren't_ closed SERVER-4315
-r1 = rs.getMaster();
-rs.add();
-var c = r1.getDB("local").system.replset.findOne();
-var config = rs.getReplSetConfig();
-config.version = c.version+1;
-var result = r1.getDB("admin").runCommand({replSetReconfig:config});
-assert.eq(result.ok, 1);
-
-rs.stopSet(15);
+// Create {v:0} index on primary. Add new secondary.
+// Make sure same index on secondary is {v:1} - SERVER-3852
+// Run only if storage engine is mmapv1 - SERVER-16893
+
+(function() {
+ 'use strict';
+
+ var storageEngine = jsTest.options().storageEngine;
+ if (storageEngine && storageEngine !== 'mmapv1') {
+ return;
+ }
+
+ var rs = new ReplSetTest( {name: 'rs', nodes: 1, host: 'localhost'} );
+ rs.startSet();
+ rs.initiate();
+ var r1 = rs.getMaster();
+ var db1 = r1.getDB('test');
+
+ var t = '';
+ for (var i = 0; i < 1000; i++) t += 'a';
+ for (var i = 0; i < 10000; i++) db1.foo.insert( {_id:i, x:i%1000, t:t} );
+
+ db1.foo.createIndex({x: 1}, {v: 0});
+
+ var r2 = rs.add();
+ rs.reInitiate(60000);
+
+ var db2 = r2.getDB('test');
+ r2.setSlaveOk();
+ rs.awaitSecondaryNodes();
+ rs.awaitReplication();
+ var idxes = db2.foo.getIndexes();
+ assert.gt(idxes.length, 0, "Secondary reported no indexes on collection " + db2.foo);
+ var idx = idxes.filter(function(idx) {
+ return friendlyEqual(idx.key, {x: 1});
+ })[0];
+ assert(idx, "expected to find an index with key {x: 1} on the secondary's collection " + db2.foo);
+ assert.eq (idx.v, 1,
+ 'expected all indexes generated on Mongo version >= 2.0 to be {v:1}. See SERVER-3852');
+
+ // add another new node, make sure ports _aren't_ closed SERVER-4315
+ r1 = rs.getMaster();
+ rs.add();
+ var c = r1.getDB("local").system.replset.findOne();
+ var config = rs.getReplSetConfig();
+ config.version = c.version+1;
+ var result = r1.getDB("admin").runCommand({replSetReconfig:config});
+ assert.eq(result.ok, 1);
+
+ rs.stopSet(15);
+
+})();