summaryrefslogtreecommitdiff
path: root/jstests/replsets/oplog_note_cmd.js
blob: 4a501211cd666cd3c1c8c61972157de272d818dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Test that the "appendOplogNote" command works properly

var rs = new ReplSetTest({name: "oplogNoteTest", nodes: 1});
rs.startSet();
rs.initiate();

var primary = rs.getPrimary();
var db = primary.getDB('admin');
db.foo.insert({a:1});

// Make sure "optime" field gets updated
var statusBefore = db.runCommand({replSetGetStatus: 1});
assert.commandWorked(db.runCommand({appendOplogNote: 1, data: {a: 1}}));
var statusAfter = db.runCommand({replSetGetStatus: 1});
assert.lt(statusBefore.members[0].optime.ts, statusAfter.members[0].optime.ts);

// Make sure note written successfully
var op = db.getSiblingDB('local').oplog.rs.find().sort({$natural: -1}).limit(1).next();
assert.eq(1, op.o.a);

rs.stopSet();