2
// test for SERVER-5040 - if documents move forward during an initial sync.
4
var rt = new ReplSetTest( { name : "replset7tests" , nodes: 1 } );
6
var nodes = rt.startSet();
8
var master = rt.getMaster();
10
var md = master.getDB( 'd' );
14
var doccount = 100000;
15
for( i = 0; i < doccount; ++i ) {
16
mdc.insert( { _id:i, x:i } );
20
mdc.ensureIndex( { x : 1 }, { unique: true } );
26
print ("initiation complete!");
27
var sc = slave.getDB( 'd' )[ 'c' ];
30
// Wait for slave to start cloning.
31
//assert.soon( function() { c = sc.find( { _id:1, x:1 } ); print( c ); return c > 0; } );
34
// Move all documents to the end by growing it
35
for (i = 0; i < doccount; ++i) {
36
mdc.remove( { _id:i, x:i } );
37
mdc.insert( { _id:doccount+i, x:i, bigstring: "ayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayayay" } );
41
// Wait for replication to catch up.
42
rt.awaitSecondaryNodes();
44
// Do we have an index?
45
assert.eq (1, slave.getDB( 'd' )['system.indexes']
46
.find({"v" : 1,"key" : {"x" : 1},"unique" : true,"ns" : "d.c","name" : "x_1"}).count());