summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorRobert Guo <robert.guo@10gen.com>2016-02-23 13:30:11 -0500
committerRobert Guo <robert.guo@10gen.com>2016-02-23 19:01:23 -0500
commitc578e4cd57875b6960a265540e93353ccc00b22b (patch)
tree13d8b960adab69391238cd70ffee8c509c59d540 /buildscripts
parent4c22c7fec0af9cff3a13b22f17f81dbdcf13c6e6 (diff)
downloadmongo-c578e4cd57875b6960a265540e93353ccc00b22b.tar.gz
SERVER-22776 Dump oplog on CheckReplDBHash failure
(cherry picked from commit ab811bfec98e7b5042c786a1c6938932bb65a5b1)
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/resmokelib/testing/hooks.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/buildscripts/resmokelib/testing/hooks.py b/buildscripts/resmokelib/testing/hooks.py
index da8693c78be..97717277687 100644
--- a/buildscripts/resmokelib/testing/hooks.py
+++ b/buildscripts/resmokelib/testing/hooks.py
@@ -189,6 +189,8 @@ class CheckReplDBHash(CustomBehavior):
success = all_matched and success
if not success:
+ CheckReplDBHash._dump_oplog(primary_conn, secondary_conn, sb)
+
# Adding failures to a TestReport requires traceback information, so we raise
# a 'self.test_case.failureException' that we will catch ourselves.
self.test_case.logger.info("\n ".join(sb))
@@ -222,6 +224,20 @@ class CheckReplDBHash(CustomBehavior):
self.started = False
@staticmethod
+ def _dump_oplog(primary_conn, secondary_conn, sb):
+
+ def dump_latest_docs(coll, limit=0):
+ docs = (doc for doc in coll.find().sort("$natural", pymongo.DESCENDING).limit(limit))
+ for doc in docs:
+ sb.append(" %s" % (doc))
+
+ LIMIT = 100
+ sb.append("Dumping the latest %d documents from the primary's oplog" % (LIMIT))
+ dump_latest_docs(primary_conn.local.oplog.rs, LIMIT)
+ sb.append("Dumping the latest %d documents from the secondary's oplog" % (LIMIT))
+ dump_latest_docs(secondary_conn.local.oplog.rs, LIMIT)
+
+ @staticmethod
def _check_all_db_hashes(primary_conn, secondary_conn, sb):
"""
Returns true if for each database, except "local" and