Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
a basic repl test that just ensures master/salve are the same - multi…
… update test as well SERVER-268
- Loading branch information
Showing
2 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters