summaryrefslogtreecommitdiff
path: root/jstests/replsets/replsetadd_profile.js
blob: dfb27ade23ef88683e13e6ce4e330fae318a5270 (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}]});
replTest.startSet();
replTest.initiate();
var primary = replTest.getPrimary();
var primaryCollection = primary.getDB('test').getCollection(collectionName);
primaryCollection.save({a: 1});

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

replTest.waitForState(replTest.nodes[1], ReplSetTest.State.SECONDARY);
// 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 secondary after replication');

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