blob: 9668a9135c9e1989723060af5b9fe0813649fa46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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();
|