blob: a2875d61150d8f9f403dd93cdf2cabccddb73b2c (
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
|
// Runner for checkOplogs() that compares the oplog on all replica set nodes
// to ensure all nodes have the same data.
'use strict';
(function() {
// Master/Slave does not support oplog test, since the oplog.$main is empty on the Slave.
var MasterSlaveOplogTest = function() {
throw new Error('checkOplogs not supported for Master/Slave');
};
var startTime = Date.now();
assert.neq(typeof db, 'undefined', 'No `db` object, is the shell connected to a mongod?');
var primaryInfo = db.isMaster();
assert(primaryInfo.ismaster,
'shell is not connected to the primary or master node: ' + tojson(primaryInfo));
var cmdLineOpts = db.adminCommand('getCmdLineOpts');
assert.commandWorked(cmdLineOpts);
var isMasterSlave = cmdLineOpts.parsed.master === true;
var testFixture =
isMasterSlave ? new MasterSlaveOplogTest() : new ReplSetTest(db.getMongo().host);
testFixture.checkOplogs();
var totalTime = Date.now() - startTime;
print('Finished consistency oplog checks of cluster in ' + totalTime + ' ms.');
})();
|