summaryrefslogtreecommitdiff
path: root/jstests/hooks
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-09-30 16:25:50 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2016-09-30 16:25:50 -0400
commitd4b173439ae08f1c0c71191eb93fd1164245c351 (patch)
treeccbfbdd86d51135ca29f07c4c0f12755961f7dd3 /jstests/hooks
parent8da6c8665fc06deac4f9258291dc93eabf3b3996 (diff)
downloadmongo-d4b173439ae08f1c0c71191eb93fd1164245c351.tar.gz
SERVER-25376 Add checkOplog hook for replica sets
Diffstat (limited to 'jstests/hooks')
-rw-r--r--jstests/hooks/run_check_repl_dbhash.js4
-rw-r--r--jstests/hooks/run_check_repl_oplogs.js28
2 files changed, 32 insertions, 0 deletions
diff --git a/jstests/hooks/run_check_repl_dbhash.js b/jstests/hooks/run_check_repl_dbhash.js
index e05500c2d6b..632f4e25cfa 100644
--- a/jstests/hooks/run_check_repl_dbhash.js
+++ b/jstests/hooks/run_check_repl_dbhash.js
@@ -72,6 +72,10 @@
this.checkReplicatedDataHashes = function() {
ReplSetTest({nodes: 0}).checkReplicatedDataHashes.apply(this, arguments);
};
+
+ this.checkReplicaSet = function() {
+ ReplSetTest({nodes: 0}).checkReplicaSet.apply(this, arguments);
+ };
};
var startTime = Date.now();
diff --git a/jstests/hooks/run_check_repl_oplogs.js b/jstests/hooks/run_check_repl_oplogs.js
new file mode 100644
index 00000000000..a2875d61150
--- /dev/null
+++ b/jstests/hooks/run_check_repl_oplogs.js
@@ -0,0 +1,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.');
+})();