summaryrefslogtreecommitdiff
path: root/jstests/replsets/slavedelay3.js
blob: e89fe965f46d16034fbe175078125e1d3e8f8ac5 (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
load("jstests/replsets/rslib.js");

var name = 'slavedelay3';
var replTest = new ReplSetTest({ name: name, nodes: 3 });
var nodes = replTest.startSet();
var config = replTest.getReplSetConfig();
// ensure member 0 is primary
config.members[0].priority = 2;
config.members[1].priority = 0;
config.members[1].slaveDelay = 5;

replTest.initiate(config);
replTest.awaitReplication();
replTest.bridge();


var master = replTest.getMaster().getDB(name);
 var slaveConns = replTest.liveNodes.slaves;
 var slave = [];
 for (var i in slaveConns) {
     var d = slaveConns[i].getDB(name);
     d.getMongo().setSlaveOk();
     slave.push(d);
 }

waitForAllMembers(master);



replTest.partition(0,2);
replTest.awaitReplication();

master.foo.insert({x:1});

// make sure the record still appears in the remote slave
assert.soon( function() { return slave[1].foo.findOne() != null; } );

replTest.stopSet();