summaryrefslogtreecommitdiff
path: root/jstests/replsets/replsetrestart2.js
blob: 6d96697f8906e41cb6167e2fe07b213670f94370 (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
// config saved on shutdown

var compare_configs = function(c1, c2) {
    assert.eq(c1.version, c2.version, 'version same');
    assert.eq(c1._id, c2._id, '_id same');

    printjson(c1);
    printjson(c2);

    for (var i in c1.members) {
        assert(c2.members[i] !== undefined, 'field '+i+' exists in both configs');
        assert.eq(c1.members[i]._id, c2.members[i]._id, 'id is equal in both configs');
        assert.eq(c1.members[i].host, c2.members[i].host, 'id is equal in both configs');
    }
}

doTest = function( signal ) {
    var replTest = new ReplSetTest( {name: 'testSet', nodes: 3} );
    replTest.startSet();

    sleep(5000);

    replTest.initiate();

    sleep(5000);

    var master = replTest.getMaster();
    var config = master.getDB("local").system.replset.findOne();

    replTest.stopSet( signal , true );

    replTest.restart(0);
    replTest.restart(1);
    replTest.restart(2);

    sleep(5000);

    master = replTest.getMaster();
    var config2 = master.getDB("local").system.replset.findOne();

    compare_configs(config, config2);

    replTest.stopSet( signal );
}

doTest( 15 );