summaryrefslogtreecommitdiff
path: root/jstests/replsets/replsetadd_profile.js
blob: d0cc27bf7ecaf17126c8c732d217b5b1e61d4838 (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
// Tests adding node to replica set with profiling enabled.
// Verifies that the oplog replay hack is compatible with
// the profiling option.
// One of the ways to exercise the oplog replay hack is to
// add a new node to an existing active replica set.

// Initialize a single node replica set where
// the only node is running at a profiling level of 2.
var collectionName = 'jstests_replsetadd_profile';

var replTest = new ReplSetTest({name: 'ReplSetAddProfileTestSet',
                                nodes: [{profile: 2}],
                                host: "localhost"});
replTest.startSet();
replTest.initiate();
var master = replTest.getMaster();
var masterCollection = master.getDB('test').getCollection(collectionName);
masterCollection.save({a: 1});

// Add a new node with no profiling level.
var newNode = replTest.add();
replTest.reInitiate();

// Allow documents to propagate to new replica set member.
replTest.awaitReplication();

var newNodeCollection = newNode.getDB('test').getCollection(collectionName);
assert.eq(1, newNodeCollection.find({a: 1}).itcount(),
          'expect documents to be present in slave after replication');

var signal = 15;
replTest.stopSet( signal );