summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod
diff options
context:
space:
mode:
authorKevin Albertson <kevin.albertson@10gen.com>2016-08-19 17:39:56 -0400
committerKyle Suarez <kyle.suarez@mongodb.com>2016-08-19 17:44:29 -0400
commit9efbffec2c4be8c597a6d39ba3474f5d4a110454 (patch)
tree896138bdcd31977321fadffe6f8575d37bc2ddb6 /jstests/noPassthroughWithMongod
parent3ff28718ccd78d876beafcaa437890dc08b71a42 (diff)
downloadmongo-9efbffec2c4be8c597a6d39ba3474f5d4a110454.tar.gz
SERVER-21168 Update top on database drop
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r--jstests/noPassthroughWithMongod/top_drop.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/top_drop.js b/jstests/noPassthroughWithMongod/top_drop.js
new file mode 100644
index 00000000000..e31129b4a4d
--- /dev/null
+++ b/jstests/noPassthroughWithMongod/top_drop.js
@@ -0,0 +1,35 @@
+/**
+ * Checks that top removes entries after dropping a collection or database.
+ * TODO(SERVER-21167): Move this test from noPassthrough to core.
+ */
+(function() {
+ 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) {
+ return ns.startsWith(topDB.getName() + ".");
+ });
+ let expectedEntryNames = expectedEntries.map(function(coll) {
+ return coll.getFullName();
+ });
+ assert.eq(namesFromTotals.sort(), expectedEntryNames.sort());
+ }
+
+ // Create a few entries in top.
+ assert.writeOK(topDB.coll1.insert({}));
+ assert.writeOK(topDB.coll2.insert({}));
+ assert.writeOK(topDB.coll3.insert({}));
+ checkTopEntries([topDB.coll1, topDB.coll2, topDB.coll3]);
+
+ // Check that dropping a collection removes that collection but leaves the others.
+ assert.commandWorked(topDB.runCommand({drop: "coll3"}));
+ checkTopEntries([topDB.coll1, topDB.coll2]);
+
+ // Check that dropping the database removes the remaining collections.
+ assert.commandWorked(topDB.dropDatabase());
+ checkTopEntries([]);
+}());