diff options
author | Benety Goh <benety@mongodb.com> | 2019-01-09 08:14:46 -0500 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2019-01-09 08:15:09 -0500 |
commit | fca97b04fc5e1ea0e29548f11425845a566fcebe (patch) | |
tree | 04b990bfef9dec0a1cfb8866214ae3687f107d65 /src | |
parent | 863100174584d5bf77977d1d6ac77a3cf659f514 (diff) | |
download | mongo-fca97b04fc5e1ea0e29548f11425845a566fcebe.tar.gz |
SERVER-38800 ReplSetTest.dumpOplog() returns oplog entries in an array after logging the values
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/shell/replsettest.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index afd7dd88d17..6783114e252 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -1625,18 +1625,25 @@ var ReplSetTest = function(opts) { return {master: hashes[0], slaves: hashes.slice(1)}; }; + this.findOplog = function(conn, query, limit) { + return conn.getDB('local') + .getCollection(oplogName) + .find(query) + .sort({$natural: -1}) + .limit(limit); + }; + this.dumpOplog = function(conn, query = {}, limit = 10) { var log = 'Dumping the latest ' + limit + ' documents that match ' + tojson(query) + ' from the oplog ' + oplogName + ' of ' + conn.host; - var cursor = conn.getDB('local') - .getCollection(oplogName) - .find(query) - .sort({$natural: -1}) - .limit(limit); + let entries = []; + let cursor = this.findOplog(conn, query, limit); cursor.forEach(function(entry) { log = log + '\n' + tojsononeline(entry); + entries.push(entry); }); jsTestLog(log); + return entries; }; // Call the provided checkerFunction, after the replica set has been write locked. |