summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod
diff options
context:
space:
mode:
authorKyle Suarez <kyle.suarez@mongodb.com>2016-10-25 11:41:44 -0400
committerKyle Suarez <kyle.suarez@mongodb.com>2016-10-25 11:41:44 -0400
commit1e6fe6df6941e97c73db086e6ec7ebb24bc7dec9 (patch)
tree4c5f3ab014dd2758f096e7d2cd22403c8f4427c1 /jstests/noPassthroughWithMongod
parente147caa1752b47d6bfed0f069c6081f412d2efe7 (diff)
downloadmongo-1e6fe6df6941e97c73db086e6ec7ebb24bc7dec9.tar.gz
SERVER-26425 perform dropDatabase in WriteConflictException retry loop
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r--jstests/noPassthroughWithMongod/top_drop.js36
1 files changed, 33 insertions, 3 deletions
diff --git a/jstests/noPassthroughWithMongod/top_drop.js b/jstests/noPassthroughWithMongod/top_drop.js
index e31129b4a4d..c28791bc9ee 100644
--- a/jstests/noPassthroughWithMongod/top_drop.js
+++ b/jstests/noPassthroughWithMongod/top_drop.js
@@ -3,20 +3,50 @@
* TODO(SERVER-21167): Move this test from noPassthrough to core.
*/
(function() {
+ "use strict";
+
let topDB = db.getSiblingDB("topdrop");
assert.commandWorked(topDB.dropDatabase());
// Asserts that the output of top contains exactly these collection entries for topDB.
function checkTopEntries(expectedEntries) {
let res = topDB.adminCommand("top");
- assert.commandWorked(res);
- let namesFromTotals = Object.keys(res.totals).filter(function(ns) {
+ assert.commandWorked(res, "Failed to run the top command");
+
+ let entriesInTop = Object.keys(res.totals).filter(function(ns) {
return ns.startsWith(topDB.getName() + ".");
});
let expectedEntryNames = expectedEntries.map(function(coll) {
return coll.getFullName();
});
- assert.eq(namesFromTotals.sort(), expectedEntryNames.sort());
+
+ const entriesAreEqual = friendlyEqual(entriesInTop.sort(), expectedEntryNames.sort());
+ if (!entriesAreEqual) {
+ // TODO(SERVER-26750): This block can be removed once SERVER-26750 is resolved.
+ jsTest.log("Warning: expected to see " + tojson(expectedEntryNames) +
+ " in top, but got " + tojson(entriesInTop));
+
+ assert.lt(expectedEntryNames.length,
+ entriesInTop.length,
+ "Fewer entries in top than expected; got " + tojson(entriesInTop) +
+ " but expected " + tojson(expectedEntryNames) + "\nFull top output:\n" +
+ tojson(res.totals));
+
+ // We allow an unexpected entry in top if the insert counter has been cleared. This is
+ // probably due to a background job releasing an AutoGetCollectionForRead for that
+ // collection.
+ entriesInTop.forEach(function(coll) {
+ if (expectedEntryNames.includes(coll)) {
+ return;
+ }
+
+ let topStats = res.totals[coll];
+ assert.eq(0,
+ res.totals[coll].insert.count,
+ coll + " has unexpected insert entries in top. Full top output:\n" +
+ tojson(res.totals));
+ });
+ }
}
// Create a few entries in top.