blob: 0c92609535a65505ead141ab5806e9a261266351 (
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
|
// 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});
if (rs.getReplSetConfigFromNode().protocolVersion != 1) {
assert.lt(statusBefore.members[0].optime, statusAfter.members[0].optime);
} else {
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();
|