summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@mongodb.com>2014-05-27 18:22:39 -0400
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-09-02 16:46:07 -0400
commite748e49c88b0ea282770e3ddd46a7e3c3d96dd30 (patch)
treeaced00c2f254c4c14069ead352ac9e6087d72067
parent61730dca01746a5eb7faada07fa16bbe52460157 (diff)
downloadmongo-e748e49c88b0ea282770e3ddd46a7e3c3d96dd30.tar.gz
SERVER-13985 Remove old v3 to v4 config metadata upgrade jstests
(cherry picked from commit 6511fae500f5d3c3205499d0b48c842c199222f4)
-rw-r--r--jstests/multiVersion/upgrade_cluster_v3_to_v4.js259
-rw-r--r--jstests/multiVersion/upgrade_cluster_v3_to_v4_db.js245
-rw-r--r--jstests/multiVersion/upgrade_cluster_v3_to_v4_wait_for_mongos.js74
-rw-r--r--jstests/multiVersion/upgrade_cluster_v3_to_v4_with_parallel_ops.js281
-rw-r--r--jstests/multiVersion/upgrade_cluster_v3_to_v4_with_stale_mongod.js165
5 files changed, 0 insertions, 1024 deletions
diff --git a/jstests/multiVersion/upgrade_cluster_v3_to_v4.js b/jstests/multiVersion/upgrade_cluster_v3_to_v4.js
deleted file mode 100644
index 139aa83f1c2..00000000000
--- a/jstests/multiVersion/upgrade_cluster_v3_to_v4.js
+++ /dev/null
@@ -1,259 +0,0 @@
-/**
- * Tests upgrading a cluster which has 2.0-style sharded collections as well as 2.2-style sharded
- * collections to be compatible with 2.4.
- */
-
-load( './jstests/multiVersion/libs/multi_rs.js' )
-load( './jstests/multiVersion/libs/multi_cluster.js' )
-
-// BIG OUTER LOOP, RS CLUSTER OR NOT!
-for( var test = 0; test < 4; test++ ){
-
-var isRSCluster = (test % 2 == 1);
-var isSyncCluster = (test / 2 >= 1);
-
-jsTest.log( "Starting" + ( isRSCluster ? " (replica set)" : "" ) + " cluster" +
- ( isSyncCluster ? " (sync)" : "" ) + "..." );
-
-jsTest.log( "Starting 2.0 cluster..." );
-
-var options = {
-
- mongosOptions : { binVersion : "2.0" },
- configOptions : { binVersion : "2.0" },
- shardOptions : { binVersion : "2.0" },
-
- rsOptions : { binVersion : "2.0" /*, oplogSize : 100, smallfiles : null */ },
-
- separateConfig : true,
- sync : isSyncCluster,
- rs : isRSCluster
-}
-
-var st = new ShardingTest({ shards : 2, mongos : 2, other : options });
-
-// Just stop balancer, to simulate race conds
-st.setBalancer(false);
-
-var shards = st.s0.getDB("config").shards.find().toArray();
-var configConnStr = st._configDB;
-
-//
-// Make sure 2.4 mongoses won't start in 2.0 cluster
-//
-
-jsTest.log("Starting v2.4 mongos in 2.0 cluster...")
-
-var mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr })
-assert.eq(null, mongos);
-
-var mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.eq(null, mongos);
-
-jsTest.log("2.4 mongoses did not start or upgrade in 2.0 cluster (which is correct).")
-
-//
-// Add sharded collection in 2.0 cluster
-//
-
-/**
- * Creates a sharded collection and splits on both shards, to ensure multi-version clusters
- * have metadata created by mongoses and mongods of different versions.
- */
-var createShardedCollection = function(admin, coll) {
-
- printjson(admin.runCommand({ enableSharding : coll.getDB() + "" }));
- printjson(admin.runCommand({ movePrimary : coll.getDB() + "", to : shards[0]._id }));
- printjson(admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }));
-
- printjson(admin.runCommand({ split : coll + "", middle : { _id : 0 } }));
- printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : 0 }, to : shards[1]._id }));
-
- printjson(admin.runCommand({ split : coll + "", middle : { _id : -300 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : -200 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : -100 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : 100 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : 200 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : 300 } }));
-
- printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : -200 }, to : shards[1]._id }));
- printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : 200 }, to : shards[0]._id }));
-}
-
-jsTest.log("Creating new collection in 2.0 cluster...");
-
-var mongos20 = st.s0;
-
-createShardedCollection(mongos20.getDB("admin"), mongos20.getCollection("foo20.bar20"));
-
-st.printShardingStatus();
-
-//
-// Upgrade 2.0 cluster to 2.0/2.2
-//
-
-jsTest.log("Upgrading 2.0 cluster to 2.0/2.2 cluster...");
-
-st.upgradeCluster(MongoRunner.versionIterator(["2.0","2.2"]));
-// Restart of mongos here is unfortunately necessary, connection pooling otherwise causes problems
-st.restartMongoses();
-
-//
-// Make sure 2.4 mongoses won't start in 2.0/2.2 cluster
-//
-
-jsTest.log("Starting v2.4 mongos in 2.0/2.2 cluster....")
-
-var mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr })
-assert.eq(null, mongos);
-
-var mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.eq(null, mongos);
-
-jsTest.log("2.4 mongoses did not start or upgrade in 2.0/2.2 cluster (which is correct).")
-
-//
-// Add sharded collections in 2.0/2.2 cluster
-//
-
-jsTest.log("Creating new collection in 2.0/2.2 cluster...");
-
-var mongos22 = st.getMongosAtVersion("2.2")
-var mongos20 = st.getMongosAtVersion("2.0")
-
-createShardedCollection(mongos20.getDB("admin"), mongos20.getCollection("fooMixed20.barMixed20"));
-createShardedCollection(mongos22.getDB("admin"), mongos22.getCollection("fooMixed22.barMixed22"));
-
-st.printShardingStatus();
-
-//
-// Upgrade 2.0/2.2 cluster to all mongoses at 2.2
-//
-
-jsTest.log("Upgrading all mongoses to 2.2...");
-
-st.upgradeCluster("2.2", { upgradeShards : false, upgradeMongos : true, upgradeConfigs : true });
-st.restartMongoses();
-
-//
-// Make sure 2.4 mongoses won't start in 2.0/2.2 shard cluster
-//
-
-jsTest.log("Starting v2.4 mongos in 2.0/2.2 (shard) cluster....")
-
-var mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr })
-assert.eq(null, mongos);
-
-var mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.eq(null, mongos);
-
-jsTest.log("2.4 mongoses did not start or upgrade in 2.0/2.2 (shard) cluster (which is correct).")
-
-//
-// Upgrade 2.0/2.2 cluster to only 2.2
-//
-
-jsTest.log("Upgrading 2.0/2.2 cluster to 2.2 cluster...");
-
-st.upgradeCluster("2.2");
-st.restartMongoses();
-
-//
-// Make sure 2.4 mongoses will successfully upgrade in 2.4 cluster
-//
-
-jsTest.log("Starting v2.4 mongos in 2.2 cluster....")
-
-var mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr })
-assert.eq(null, mongos);
-
-var mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.neq(null, mongos);
-MongoRunner.stopMongos(mongos);
-
-jsTest.log("2.4 mongoses started in 2.2 cluster.")
-
-//
-// Add sharded collection in 2.2 cluster
-//
-
-jsTest.log("Creating new collection in 2.2 cluster...");
-
-var mongos22 = st.getMongosAtVersion("2.2")
-
-createShardedCollection(mongos22.getDB("admin"), mongos22.getCollection("foo22.bar22"));
-
-st.printShardingStatus();
-
-//
-// Verify that all collections have correct epochs in new cluster
-//
-
-var config = mongos22.getDB("config")
-
-var collections = config.collections.find().toArray();
-var chunks = config.chunks.find().toArray();
-
-for (var i = 0; i < collections.length; i++) {
-
- var collection = collections[i];
- var epoch = collection.lastmodEpoch
- assert(epoch);
-
- for (var j = 0; j < chunks.length; j++) {
- var chunk = chunks[j];
- if (chunk.ns != collection._id) continue;
- assert.eq(chunk.lastmodEpoch, epoch);
- }
-}
-
-//
-// Verify backup collections are present
-//
-
-var collNames = config.getCollectionNames();
-
-var hasBackupColls = false;
-var hasBackupChunks = false;
-
-for (var i = 0; i < collNames.length; i++) {
- var collName = collNames[i];
- if (/^collections-backup/.test(collName)) {
- print("Found backup collections " + collName + "...")
- hasBackupColls = true;
- }
- if (/^chunks-backup/.test(collName)) {
- print("Found backup chunks " + collName + "...")
- hasBackupChunks = true;
- }
-}
-
-assert(hasBackupColls);
-assert(hasBackupChunks);
-
-//
-// Verify cluster version is correct
-//
-
-var version = config.getMongo().getCollection("config.version").findOne();
-printjson(version)
-
-assert.eq(version.version, 3);
-assert.eq(version.minCompatibleVersion, 3);
-assert.eq(version.currentVersion, 4);
-assert(version.clusterId);
-assert.eq(version.excluding, undefined);
-
-jsTest.log("DONE!")
-
-st.stop();
-
-} // END OUTER LOOP FOR RS CLUSTER
-
-
-
-
-
-
-
-
diff --git a/jstests/multiVersion/upgrade_cluster_v3_to_v4_db.js b/jstests/multiVersion/upgrade_cluster_v3_to_v4_db.js
deleted file mode 100644
index 93413f1bfb1..00000000000
--- a/jstests/multiVersion/upgrade_cluster_v3_to_v4_db.js
+++ /dev/null
@@ -1,245 +0,0 @@
-/**
- * Tests upgrading a config db which has different types of sharded collection data from v3 to v4
- */
-
-load( './jstests/multiVersion/libs/multi_rs.js' )
-load( './jstests/multiVersion/libs/multi_cluster.js' )
-
-jsTest.log( "Starting 2.2 cluster..." );
-
-var options = {
-
- mongosOptions : { binVersion : "2.2" },
- configOptions : { binVersion : "2.2" },
- shardOptions : { binVersion : "2.2" },
-
- separateConfig : true,
- sync : false
-}
-
-var st = new ShardingTest({ shards : 1, mongos : 1, other : options });
-
-// Just set balancer to false, don't wait for it
-st.setBalancer(false);
-
-var mongos = st.s0
-var config = mongos.getDB("config")
-var admin = mongos.getDB("admin")
-var shards = config.shards.find().toArray();
-var configConnStr = st._configDB;
-var originalVersion = config.getMongo().getCollection("config.version").findOne();
-
-st.printShardingStatus();
-
-var resetBackupDBs = function() {
-
- var configConn = new Mongo(configConnStr);
- var databases = configConn.getDBs().databases;
-
- //
- // Drop all new backup databases
- //
-
- for (var i = 0; i < databases.length; i++) {
- var dbName = databases[i].name + "";
- if (!/^config$|^admin$|^local$/.test(dbName)) {
- print("Dropping " + dbName + "...")
- configConn.getDB(dbName).dropDatabase();
- }
- }
-}
-
-var resetVersion = function() {
- config.getMongo().getCollection("config.version").update({ _id : 1 }, originalVersion, true);
- assert.eq(null, config.getLastError());
-}
-
-var checkUpgraded = function() {
-
- //
- // Verify backup collections are present
- //
-
- var collNames = config.getCollectionNames();
-
- var hasBackupColls = false;
- var hasBackupChunks = false;
-
- for (var i = 0; i < collNames.length; i++) {
- var collName = collNames[i];
- if (/^collections-backup/.test(collName)) {
- print("Found backup collections " + collName + "...")
- hasBackupColls = true;
- }
- if (/^chunks-backup/.test(collName)) {
- print("Found backup chunks " + collName + "...")
- hasBackupChunks = true;
- }
- }
-
- assert(hasBackupColls);
- assert(hasBackupChunks);
-
- //
- // Verify cluster version is correct
- //
-
- var version = config.getMongo().getCollection("config.version").findOne();
- printjson(version)
-
- assert.eq(version.version, 3);
- assert.eq(version.minCompatibleVersion, 3);
- assert.eq(version.currentVersion, 4);
- assert(version.clusterId);
- assert.eq(version.excluding, undefined)
-
-}
-
-//
-// Default config upgrade
-//
-
-jsTest.log("Upgrading empty config server from v3 to v4...");
-
-// Make sure up
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.neq(null, mongosNew);
-MongoRunner.stopMongos(mongosNew);
-checkUpgraded();
-resetVersion();
-resetBackupDBs();
-
-
-//
-// Invalid config.version upgrade
-//
-
-jsTest.log("Clearing config.version collection...")
-
-config.getMongo().getCollection("config.version").remove({})
-assert.eq(null, config.getLastError());
-
-// Make sure down
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.eq(null, mongosNew);
-resetVersion();
-resetBackupDBs();
-
-
-//
-// Bad config.version upgrade
-//
-
-jsTest.log("Adding bad config.version data...")
-
-config.getMongo().getCollection("config.version").update({ _id : 1 }, { $unset : { version : 1 } });
-assert.eq(null, config.getLastError());
-
-// Make sure down
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.eq(null, mongosNew);
-resetVersion();
-resetBackupDBs();
-
-
-//
-// Invalid config.collections upgrade
-//
-
-jsTest.log("Adding bad sharded collection data...")
-
-var coll = mongos.getCollection("foo.bar");
-
-printjson(admin.runCommand({ enableSharding : coll.getDB() + "" }));
-printjson(admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }));
-printjson(admin.runCommand({ split : coll + "", middle : { _id : 0 } }));
-
-config.collections.update({ _id : coll + "" }, { $set : { lastmodEpoch : ObjectId() }});
-assert.eq(null, config.getLastError());
-
-// Make sure down
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.eq(null, mongosNew);
-resetBackupDBs();
-
-
-//
-// Dropped collection upgrade
-//
-
-jsTest.log("Adding bad (dropped) sharded collection data...")
-
-printjson(coll.drop());
-// Disable balancing on the (dropped) coll to trigger additional collection validation.
-// At least in 2.2, dropping a collection drops the noBalance flag as well, but this has been seen
-// in the wild.
-// TODO: Enable when 2.4.4 comes out
-//sh.disableBalancing( coll );
-printjson(config.collections.find().toArray());
-
-// Make sure up
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.neq(null, mongosNew);
-MongoRunner.stopMongos(mongosNew);
-checkUpgraded();
-resetVersion();
-resetBackupDBs();
-
-
-//
-// Invalid chunks collection upgrade
-//
-
-jsTest.log("Adding bad sharded chunks data...")
-
-var coll = mongos.getCollection("foo2.bar2");
-
-printjson(admin.runCommand({ enableSharding : coll.getDB() + "" }));
-printjson(admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }));
-printjson(admin.runCommand({ split : coll + "", middle : { _id : 0 } }));
-
-config.chunks.update({ ns : coll + "" }, { $set : { lastmodEpoch : ObjectId() }});
-assert.eq(null, config.getLastError());
-
-// Make sure down
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.eq(null, mongosNew);
-
-//
-// Upgrade with modified old upgrade data
-//
-
-jsTest.log("Fiddling with data from last failed upgrade...")
-
-var upgradeCollRegex = /^collections-upgrade/;
-var configColls = config.getCollectionNames();
-for (var i = 0; i < configColls.length; i++) {
- var configColl = configColls[i];
- if (upgradeCollRegex.test(configColl)) {
- print("Dropping collection: " + configColl);
- config.getCollection(configColl).drop();
- break;
- }
-}
-
-// Fix chunk data
-config.chunks.update({}, { $unset : { versionEpoch : 1 }, $unset : { lastmodEpoch : 1 }}, false, true);
-assert.eq(null, config.getLastError());
-
-// Make sure up
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.neq(null, mongosNew);
-MongoRunner.stopMongos(mongosNew);
-checkUpgraded();
-
-jsTest.log("DONE!")
-
-st.stop();
-
-
-
-
-
-
-
-
diff --git a/jstests/multiVersion/upgrade_cluster_v3_to_v4_wait_for_mongos.js b/jstests/multiVersion/upgrade_cluster_v3_to_v4_wait_for_mongos.js
deleted file mode 100644
index ba859edd7a7..00000000000
--- a/jstests/multiVersion/upgrade_cluster_v3_to_v4_wait_for_mongos.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Tests upgrading a cluster where there was a recently active mongos process.
- */
-
-load( './jstests/multiVersion/libs/multi_rs.js' )
-load( './jstests/multiVersion/libs/multi_cluster.js' )
-
-jsTest.log( "Starting 2.2 cluster..." );
-
-var options = {
-
- mongosOptions : { binVersion : "2.2" },
- configOptions : { binVersion : "2.2" },
- shardOptions : { binVersion : "2.2" },
-
- separateConfig : true,
- sync : false
-};
-
-var st = new ShardingTest({ shards : 1, mongos : 1, other : options });
-
-// Turn balancer off, don't wait
-st.setBalancer(false);
-
-var mongos = st.s0;
-
-jsTest.log( "Starting v2.0 mongos..." );
-
-var mongos20 = MongoRunner.runMongos({ binVersion : "2.0", configdb : st._configDB })
-
-jsTest.log( "Waiting for 2.0 ping document..." );
-
-var hasPing = function() {
- return mongos.getCollection("config.mongos").findOne({ _id : RegExp(":" + mongos20.port + "$") }) != null;
-}
-
-assert.soon( hasPing );
-
-jsTest.log( "Stopping 2.0 mongos..." );
-
-MongoRunner.stopMongos(mongos20);
-
-jsTest.log( "Upgrade should be unsuccessful..." );
-
-// Make sure down
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : st._configDB, upgrade : "" })
-assert.eq(null, mongosNew);
-
-jsTest.log("Resetting time to zero...");
-
-printjson(mongos.getCollection("config.mongos").findOne({ _id : RegExp(":" + mongos20.port + "$") }));
-
-mongos.getCollection("config.mongos").update({ _id : RegExp(":" + mongos20.port + "$") },
- { $set : { ping : new Date(0) } });
-assert.eq(null, mongos.getDB("config").getLastError());
-
-printjson(mongos.getCollection("config.mongos").findOne({ _id : RegExp(":" + mongos20.port + "$") }));
-
-jsTest.log("Trying to restart mongos...");
-
-// Make sure up
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : st._configDB, upgrade : "" })
-assert.neq(null, mongosNew);
-
-jsTest.log("Mongos started!");
-
-MongoRunner.stopMongos(mongosNew);
-
-jsTest.log("DONE!")
-
-st.stop();
-
-
-
diff --git a/jstests/multiVersion/upgrade_cluster_v3_to_v4_with_parallel_ops.js b/jstests/multiVersion/upgrade_cluster_v3_to_v4_with_parallel_ops.js
deleted file mode 100644
index 77579de5615..00000000000
--- a/jstests/multiVersion/upgrade_cluster_v3_to_v4_with_parallel_ops.js
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- * Tests upgrading a config db which has different types of sharded collection data from v3 to v4
- */
-
-load( './jstests/multiVersion/libs/multi_rs.js' )
-load( './jstests/multiVersion/libs/multi_cluster.js' )
-load( './jstests/libs/test_background_ops.js' )
-
-jsTest.log( "Starting mixed 2.2/2.0 cluster..." );
-
-var options = {
-
- mongosOptions : { binVersion : MongoRunner.versionIterator(["2.0","2.2"]) },
- configOptions : { binVersion : MongoRunner.versionIterator(["2.0","2.2"]) },
- shardOptions : { binVersion : MongoRunner.versionIterator(["2.0","2.2"]) },
-
- separateConfig : true,
- sync : true
-}
-
-//
-// Create a basic mixed sharded cluster with extra mongoses to do work while we upgrade
-//
-
-var st = new ShardingTest({ shards : 2, mongos : 3, other : options });
-
-var mongos = st.s0
-var parallelMongoses = st._mongos.concat([]).splice(1);
-var config = mongos.getDB("config")
-var admin = mongos.getDB("admin")
-
-var shards = config.shards.find().toArray();
-var configConnStr = st._configDB;
-var originalVersion = config.getMongo().getCollection("config.version").findOne();
-
-//
-// Shard a collection for each of our extra mongoses and distribute chunks to v2.0 and v2.2 shards
-//
-
-st.stopBalancer();
-
-var shardedColls = [];
-for (var i = 0; i < parallelMongoses.length; i++) {
-
- var parallelMongos = parallelMongoses[i];
-
- var coll = parallelMongos.getCollection("foo" + i + ".bar" + i);
- var admin = parallelMongos.getDB("admin");
-
- printjson(admin.runCommand({ enableSharding : coll.getDB() + "" }));
- printjson(admin.runCommand({ movePrimary : coll.getDB() + "", to : shards[0]._id }));
- printjson(admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }));
-
- printjson(admin.runCommand({ split : coll + "", middle : { _id : 0 } }));
- printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : 0 }, to : shards[1]._id }));
-
- printjson(admin.runCommand({ split : coll + "", middle : { _id : -0.3 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : -0.2 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : -0.1 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : 0.1 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : 0.2 } }));
- printjson(admin.runCommand({ split : coll + "", middle : { _id : 0.3 } }));
-
- printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : -0.2 }, to : shards[1]._id }));
- printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : 0.2 }, to : shards[0]._id }));
-
- shardedColls.push(coll);
-}
-
-st.startBalancer();
-
-st.printShardingStatus();
-
-//
-// Upgrade cluster to v2.2
-//
-
-jsTest.log("Upgrading cluster to 2.2...")
-
-st.upgradeCluster("2.2");
-//Restart of mongos here is unfortunately necessary, connection pooling otherwise causes problems
-st.restartMongoses();
-
-jsTest.log("Cluster upgraded...")
-
-var mongos = st.s0
-var parallelMongoses = st._mongos.concat([]).splice(1);
-var config = mongos.getDB("config");
-var admin = mongos.getDB("admin");
-
-function splitAndMove( mongosURL, shards, ns ){
-
- var coll = null;
-
- // Make sure we can eventually connect to the mongos
- assert.soon( function(){
- try{
- print("Waiting for connect to " + mongosURL + "...");
- coll = new Mongo(mongosURL).getCollection(ns + "");
- return true;
- }
- catch (e) {
- printjson(e);
- return false;
- }
- })
-
- var splitCount = 0;
- var moveCount = 0;
-
- jsTest.log("Starting splits and moves to " + ns + "...")
-
- while (!isFinished()) {
- try {
- // Split 75% of the time
- var isSplit = Random.rand() < 0.75;
- var key = (Random.rand() * 2.0) - 1.0;
- var shard = shards[parseInt(Random.rand() * shards.length)]
-
- var admin = coll.getMongo().getDB("admin");
- var result = null;
-
- if (isSplit) {
- result = admin.runCommand({ split : coll + "",
- middle : { _id : key } });
- splitCount++;
- result["isSplit"] = true;
- }
- else {
- result = admin.runCommand({ moveChunk : coll + "",
- find : key,
- to : shards[shard]._id })
- moveCount++;
- result["isMove"] = true;
- }
-
- if (result.ok != 0) printjson(result);
- }
- catch (e) {
- sleep(1);
- printjson(e);
- }
- }
-
- jsTest.log("Finished splits and moves to " + ns + "...")
- return { splitCount : splitCount, moveCount : moveCount };
-}
-
-//
-// Start split and move operations in the 2.2 cluster
-//
-
-jsTest.log("Starting split and move operations...")
-
-var staticMongod = MongoRunner.runMongod({})
-printjson( staticMongod )
-
-var joinSplitAndMoves = [];
-for (var i = 0; i < parallelMongoses.length; i++) {
- joinSplitAndMoves.push(
- startParallelOps( staticMongod, // The connection where the test info is passed and stored
- splitAndMove,
- [ parallelMongoses[i].host, shards, shardedColls[i] + "" ] )
- );
-}
-
-jsTest.log("Sleeping for metadata operations to start...")
-
-sleep(10 * 1000);
-
-printShardingStatus(config, true);
-
-//
-// Do a config upgrade while the split and move operations are active
-//
-
-jsTest.log("Upgrading config db from v3 to v4...");
-
-// Just stop the balancer, but don't wait for it to stop, to simulate race conds
-st.setBalancer(false);
-printjson(config.settings.find().toArray());
-
-var startTime = new Date();
-
-// Make sure up
-var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.neq(null, mongosNew);
-MongoRunner.stopMongos(mongosNew);
-
-var endTime = new Date();
-
-jsTest.log( "Config db upgrade took " + ((endTime - startTime) / 1000) + " secs" );
-
-//
-// Stop the split and move operations
-//
-
-for (var i = 0; i < parallelMongoses.length; i++) {
- joinSplitAndMoves[i]();
-}
-
-printShardingStatus(config, true)
-
-//
-// Make sure our cluster was successfully upgraded with epochs
-//
-
-var checkUpgraded = function() {
-
- //
- // Verify backup collections are present
- //
-
- var collNames = config.getCollectionNames();
-
- var hasBackupColls = false;
- var hasBackupChunks = false;
-
- for (var i = 0; i < collNames.length; i++) {
- var collName = collNames[i];
- if (/^collections-backup/.test(collName)) {
- print("Found backup collections " + collName + "...")
- hasBackupColls = true;
- }
- if (/^chunks-backup/.test(collName)) {
- print("Found backup chunks " + collName + "...")
- hasBackupChunks = true;
- }
- }
-
- assert(hasBackupColls);
- assert(hasBackupChunks);
-
- //
- // Verify that all collections have correct epochs in new cluster
- //
- var collections = config.collections.find().toArray();
-
- var chunks = config.chunks.find().toArray();
- for (var i = 0; i < collections.length; i++) {
-
- var collection = collections[i];
- if (collection.dropped) continue;
-
- var epoch = collection.lastmodEpoch
- assert(epoch);
-
- for (var j = 0; j < chunks.length; j++) {
- var chunk = chunks[j];
- if (chunk.ns != collection._id) continue;
- assert.eq(chunk.lastmodEpoch, epoch);
- }
- }
-
- //
- // Verify cluster version is correct
- //
-
- var version = config.getMongo().getCollection("config.version").findOne();
- printjson(version)
-
- assert.eq(version.version, 3);
- assert.eq(version.minCompatibleVersion, 3);
- assert.eq(version.currentVersion, 4);
- assert(version.clusterId);
- assert.eq(version.excluding, undefined);
-}
-
-checkUpgraded();
-
-jsTest.log("DONE!")
-
-st.stop();
-
-
-
-
-
-
-
-
diff --git a/jstests/multiVersion/upgrade_cluster_v3_to_v4_with_stale_mongod.js b/jstests/multiVersion/upgrade_cluster_v3_to_v4_with_stale_mongod.js
deleted file mode 100644
index 36119e85483..00000000000
--- a/jstests/multiVersion/upgrade_cluster_v3_to_v4_with_stale_mongod.js
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * Tests upgrading a cluster to config version 4 with epochs and ensures 2.2 mongod will write the
- * correct epochs on the next move/split.
- */
-
-load( './jstests/multiVersion/libs/multi_rs.js' )
-load( './jstests/multiVersion/libs/multi_cluster.js' )
-
-jsTest.log( "Starting 2.0 cluster..." );
-
-var options = {
-
- mongosOptions : { binVersion : "2.0" },
- configOptions : { binVersion : "2.0" },
- shardOptions : { binVersion : "2.0" },
-
- separateConfig : true,
- sync : false
-}
-
-var st = new ShardingTest({ shards : 3, mongos : 2, other : options });
-
-// Stop balancer, otherwise the balancer lock can get wedged for 15 mins after our upgrades
-// on bad mongos shutdowns.
-st.stopBalancer();
-
-var shards = st.s0.getDB("config").shards.find().toArray();
-var configConnStr = st._configDB;
-
-//
-// Add sharded collection in 2.0 cluster
-//
-
-jsTest.log("Creating new collection in 2.0 cluster...");
-
-var mongos20 = st.s0;
-var coll = mongos20.getCollection("foo.bar");
-var admin = mongos20.getDB("admin");
-
-printjson(admin.runCommand({ enableSharding : coll.getDB() + "" }));
-printjson(admin.runCommand({ movePrimary : coll.getDB() + "", to : shards[0]._id }));
-printjson(admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }));
-
-st.printShardingStatus();
-
-//
-// Upgrade 2.0 cluster to 2.0/2.2
-//
-
-jsTest.log("Upgrading 2.0 cluster to 2.2 cluster...");
-
-st.upgradeCluster("2.2");
-// Restart of mongos here is unfortunately necessary, connection pooling otherwise causes problems
-st.restartMongoses();
-
-var mongos22A = st.s0;
-var mongos22B = st.s1;
-
-jsTest.log("Performing metadata operations without epochs...");
-
-var coll = mongos22A.getCollection("foo.bar");
-var admin = mongos22A.getDB("admin");
-var config = mongos22A.getDB("config");
-
-//Split collection into several parts
-printjson(admin.runCommand({ split : coll + "", middle : { _id : 0 } }));
-printjson(admin.runCommand({ split : coll + "", middle : { _id : 1 } }));
-printjson(admin.runCommand({ split : coll + "", middle : { _id : 2 } }));
-
-//Put one part on each shard
-printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : 1 }, to : shards[1]._id }));
-printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : 2 }, to : shards[2]._id }));
-
-//Split the first chunk into two parts, so all shards will have chunks after one migrate
-printjson(admin.runCommand({ split : coll + "", middle : { _id : 0.5 } }));
-
-// Make sure mongos22B is up-to-date with the correct version
-mongos22B.getCollection("foo.bar").findOne();
-
-printjson(config.chunks.find().toArray());
-
-//
-// Upgrade cluster to new version
-//
-
-jsTest.log("Starting v2.4 mongos in 2.2 cluster....")
-
-var mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr, upgrade : "" })
-assert.neq(null, mongos);
-MongoRunner.stopMongos(mongos);
-
-jsTest.log("2.4 mongos upgraded cluster.")
-
-//
-// Do more metadata operations with 2.2 mongoses without updating versions
-//
-
-jsTest.log("Doing more metadata operations with un-refreshed 2.2 mongoses and ds");
-
-// Do a move operation
-printjson(mongos22A.getDB("admin").runCommand({ moveChunk : coll + "",
- find : { _id : 0 }, to : shards[1]._id }));
-
-// Do a split operation
-printjson(mongos22B.getDB("admin").runCommand({ split : coll + "",
- middle : { _id : 3 } }));
-
-printjson(config.chunks.find().toArray());
-
-//
-// Check that this didn't screw up our upgrade
-//
-
-jsTest.log("Was upgraded?")
-
-var checkUpgraded = function() {
-
- //
- // Verify that all collections have correct epochs in new cluster
- //
- var collections = config.collections.find().toArray();
-
- var chunks = config.chunks.find().toArray();
- for (var i = 0; i < collections.length; i++) {
-
- var collection = collections[i];
- if (collection.dropped) continue;
-
- var epoch = collection.lastmodEpoch
- assert(epoch);
-
- for (var j = 0; j < chunks.length; j++) {
- var chunk = chunks[j];
- if (chunk.ns != collection._id) continue;
- assert.eq(chunk.lastmodEpoch, epoch);
- }
- }
-
- //
- // Verify cluster version is correct
- //
-
- var version = config.getMongo().getCollection("config.version").findOne();
- printjson(version)
-
- assert.eq(version.version, 3);
- assert.eq(version.minCompatibleVersion, 3);
- assert.eq(version.currentVersion, 4);
- assert(version.clusterId);
- assert.eq(version.excluding, undefined);
-}
-
-checkUpgraded();
-
-jsTest.log("DONE!")
-
-st.stop();
-
-
-
-
-
-
-
-