0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

added another rs restart test

This commit is contained in:
Kristina Chodorow 2010-07-30 10:57:21 -04:00
parent db8bd901d8
commit 24b98746ca
4 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,46 @@
// config saved on shutdown
var compare_configs = function(c1, c2) {
assert(c1.version == c2.version, 'version same');
assert(c1._id == c2._id, '_id same');
printjson(c1);
printjson(c2);
for (var i in c1.members) {
assert(c2.members[i] !== undefined, 'field '+i+' exists in both configs');
assert(c1.members[i]._id == c2.members[i]._id, 'id is equal in both configs');
assert(c1.members[i].host == c2.members[i].host, 'id is equal in both configs');
}
}
doTest = function( signal ) {
var replTest = new ReplSetTest( {name: 'testSet', nodes: 3} );
replTest.startSet();
sleep(5000);
replTest.initiate();
sleep(5000);
var master = replTest.getMaster();
var config = master.getDB("local").system.replset.findOne();
replTest.stopSet( signal );
replTest.restart(0);
replTest.restart(1);
replTest.restart(2);
sleep(5000);
master = replTest.getMaster();
var config2 = master.getDB("local").system.replset.findOne();
compare_configs(config, config2);
replTest.stopSet( signal );
}
doTest( 15 );

View File

@ -71,7 +71,7 @@ doTest = function( signal ) {
count++;
if (count == 20) {
assert(false);
assert(false, 'sync never caught up, giving up');
break;
}
} while (max1.z != max2.z);

View File

@ -1158,6 +1158,14 @@ ReplSetTest.prototype.awaitReplication = function() {
});
}
/**
* Starts up a server.
*
* @param {int} n server number (0, 1, 2, ...)
* @param {object} [options]
* @param {boolean} [restart] If false, the data directory will be cleared
* before the server starts. Defaults to false.
*/
ReplSetTest.prototype.start = function( n , options , restart ){
var lockFile = this.getPath( n ) + "/mongod.lock";
removeFile( lockFile );
@ -1172,6 +1180,12 @@ ReplSetTest.prototype.start = function( n , options , restart ){
}
}
/**
* Restarts a db without clearing the data directory. If the server is not
* stopped first, this function will not work.
*
* @param {int} n server number (0, 1, 2, ...)
*/
ReplSetTest.prototype.restart = function( n , options ){
return this.start( n , options , true );
}