0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

a basic repl test that just ensures master/salve are the same - multi update test as well SERVER-268

This commit is contained in:
Eliot Horowitz 2009-10-26 14:32:20 -04:00
parent 21964f0873
commit a361b49376
2 changed files with 70 additions and 7 deletions

59
jstests/repl/basic1.js Normal file
View File

@ -0,0 +1,59 @@
// test repl basics
// data on master/slave is the same
var rt = new ReplTest( "basic1" );
m = rt.start( true );
s = rt.start( false );
function hash( db ){
var s = "";
var a = db.getCollectionNames();
a = a.sort();
a.forEach(
function(cn){
var c = db.getCollection( cn );
s += cn + "\t" + c.find().count() + "\n";
c.find().sort( { _id : 1 } ).forEach(
function(o){
s += tojson( o , "" , true ) + "\n";
}
);
}
);
return s;
}
am = m.getDB( "foo" );
as = s.getDB( "foo" );
function check( note ){
var start = new Date();
var x,y;
while ( (new Date()).getTime() - start.getTime() < 30000 ){
x = hash( am );
y = hash( as );
if ( x == y )
return;
sleep( 200 );
}
assert.eq( x , y , note );
}
am.a.save( { x : 1 } );
check( "A" );
am.a.save( { x : 5 } );
am.a.update( {} , { $inc : { x : 1 } } );
check( "B" );
am.a.update( {} , { $inc : { x : 1 } } , false , true );
check( "C" );
rt.stop();

View File

@ -461,6 +461,12 @@ ReplTest.prototype.getPath = function( master ){
ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst ){
if ( ! extra )
extra = {};
if ( ! extra.oplogSize )
extra.oplogSize = 10;
var a = []
if ( putBinaryFirst )
@ -483,13 +489,11 @@ ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst ){
a.push( "127.0.0.1:" + this.ports[0] );
}
if ( extra ){
for ( var k in extra ){
var v = extra[k];
a.push( "--" + k );
if ( v != null )
a.push( v );
}
for ( var k in extra ){
var v = extra[k];
a.push( "--" + k );
if ( v != null )
a.push( v );
}
return a;