// rs_basic.js load("../../jstests/rs/test_framework.js"); function go() { assert(__nextPort == 27000, "_nextPort==27000"); a = null; try {init a = new Mongo("localhost:27000"); print("using already open mongod on port 27000 -- presume you are debugging or something. should start empty."); __nextPort++; } catch (e) { a = rs_mongod(); } b = rs_mongod(); x = a.getDB("admin"); y = b.getDB("admin"); memb = []; memb[0] = x; memb[1] = y; print("rs_basic.js go(): started 2 servers"); cfg = { _id: 'asdf', members: [] }; var hn = hostname(); cfg.members[0] = { _id: 0, host: hn + ":27000" }; cfg.members[1] = { _id: 1, host: hn + ":27001" }; print("cfg=" + tojson(cfg)); } function init(server) { var i = server; //i = Random.randInt(2); // a random member of the set var m = memb[i]; assert(!m.ismaster(), "not ismaster"); var res = m.runCommand({ replSetInitiate: cfg }); return res; } _path = '../../db/Debug/'; print("_path var set to " + _path); print("go() to run"); print("init() to initiate"); /* 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 ); } 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