// test repl basics // data on master/slave is the same var rt = new ReplTest( "basic1" ); m = rt.start( true ); s = rt.start( false ); function block(){ am.runCommand( { getlasterror : 1 , w : 2 , wtimeout : 3000 } ) } 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 = am.runCommand( "dbhash" ); y = as.runCommand( "dbhash" ); if ( x.md5 == y.md5 ) return; sleep( 200 ); } lastOpLogEntry = m.getDB("local").oplog.$main.find({op:{$ne:"n"}}).sort({$natural:-1}).limit(-1).next(); note = note + tojson(am.a.find().toArray()) + " != " + tojson(as.a.find().toArray()) + "last oplog:" + tojson(lastOpLogEntry); assert.eq( x.md5 , y.md5 , 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" ); // ----- check features ------- // map/reduce am.mr.insert( { tags : [ "a" ] } ) am.mr.insert( { tags : [ "a" , "b" ] } ) am.getLastError(); check( "mr setup" ); m = function(){ for ( var i=0; i