summaryrefslogtreecommitdiff
path: root/jstests/hooks
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-07-05 16:33:23 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2016-07-05 16:33:23 -0400
commit71424c1c4b87c5819b1fc5cf114078a6f33c6078 (patch)
tree5ed4704f569967f9bdc37d30cc4e1d07ce4516e5 /jstests/hooks
parent1aa84a66de0d2f83f9bc224d85278feff78b686a (diff)
downloadmongo-71424c1c4b87c5819b1fc5cf114078a6f33c6078.tar.gz
SERVER-23306 Enhance checkDBHashes hook - add more comparisons from collStats & getCollectionInfos
Diffstat (limited to 'jstests/hooks')
-rw-r--r--jstests/hooks/check_repl_dbhash.js40
1 files changed, 19 insertions, 21 deletions
diff --git a/jstests/hooks/check_repl_dbhash.js b/jstests/hooks/check_repl_dbhash.js
index d47f5a29ff4..b518d131507 100644
--- a/jstests/hooks/check_repl_dbhash.js
+++ b/jstests/hooks/check_repl_dbhash.js
@@ -141,16 +141,14 @@ function checkDBHashes(rst, dbBlacklist, phase) {
// Check that collection information is consistent on the primary and secondaries.
var secondaryCollInfo = secondary.getDB(dbName).getCollectionInfos();
- // capped, autoIndexId, size, max, validator, validationLevel, validationAction,
- // indexOptionDefaults
secondaryCollInfo.forEach(secondaryInfo => {
primaryCollInfo.forEach(primaryInfo => {
if (secondaryInfo.name === primaryInfo.name) {
- if (secondaryInfo.options.temp !== primaryInfo.options.temp) {
+ if (bsonWoCompare(secondaryInfo, primaryInfo) !== 0) {
print(
phase +
', the primary and secondary have different attributes for the collection ' +
- dbName + '.' + collName);
+ dbName + '.' + secondaryInfo.name);
print('Collection info on the primary: ' + tojson(primaryInfo));
print('Collection info on the secondary: ' + tojson(secondaryInfo));
success = false;
@@ -159,24 +157,24 @@ function checkDBHashes(rst, dbBlacklist, phase) {
});
});
- // Check that collection attributes are the same across replica set members.
+ // Check that the following collection stats are the same across replica set members:
+ // capped
+ // nindexes
+ // ns
primaryCollections.forEach(collName => {
- var cappedOnPrimary = nonCappedCollNames.indexOf(collName) === -1;
- var res = secondary.getDB(dbName).runCommand({collStats: collName});
- assert.commandWorked(res);
- var cappedOnSecondary = res.capped;
-
- // Cast cappedOnSecondary to a boolean to prevent unexpected behavior from values
- // that evaluate to true or false. E.g. "undefined".
- cappedOnSecondary = !!cappedOnSecondary;
- if (cappedOnPrimary !== cappedOnSecondary) {
- var status;
- if (cappedOnPrimary) {
- status = 'capped on the primary but not on the secondary';
- } else {
- status = 'capped on the secondary but not on the primary';
- }
- print(phase + ' the collection ' + dbName + '.' + collname + ' is ' + status);
+ var primaryCollStats = primary.getDB(dbName).runCommand({collStats: collName});
+ assert.commandWorked(primaryCollStats);
+ var secondaryCollStats = secondary.getDB(dbName).runCommand({collStats: collName});
+ assert.commandWorked(secondaryCollStats);
+
+ if (primaryCollStats.capped !== secondaryCollStats.capped ||
+ primaryCollStats.nindexes !== secondaryCollStats.nindexes ||
+ primaryCollStats.ns !== secondaryCollStats.ns) {
+ print(phase +
+ ', the primary and secondary have different stats for the collection ' +
+ dbName + '.' + collName);
+ print('Collection stats on the primary: ' + tojson(primaryCollStats));
+ print('Collection stats on the secondary: ' + tojson(secondaryCollStats));
success = false;
}
});