summaryrefslogtreecommitdiff
path: root/jstests/core/dbstats.js
diff options
context:
space:
mode:
authorYu Jin Kang Park <yujin.kang@mongodb.com>2022-03-16 10:34:26 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-16 11:28:15 +0000
commit539165defa601981015f0e89eba9a0d957c3b031 (patch)
treeb8f0129bc044b9829d6ef767ef3234d2c5ee672a /jstests/core/dbstats.js
parent6184015b89d61a890d11f682d172c8473b60b513 (diff)
downloadmongo-539165defa601981015f0e89eba9a0d957c3b031.tar.gz
SERVER-63255 Fix dbStats output for non-existing database to match existing database output fields
Diffstat (limited to 'jstests/core/dbstats.js')
-rw-r--r--jstests/core/dbstats.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/jstests/core/dbstats.js b/jstests/core/dbstats.js
index a7cbd9c6bb8..559b6c11774 100644
--- a/jstests/core/dbstats.js
+++ b/jstests/core/dbstats.js
@@ -84,4 +84,17 @@ if (!isMongoS) {
assert.eq(2, dbStats.collections, tojson(dbStats)); // testColl + system.views
assert.eq(1, dbStats.views, tojson(dbStats));
}
+
+// Check that the output for non-existing database and the output for empty database
+// have the same fields.
+const testEmptyAndNonExistingDB = db.getSiblingDB(jsTestName() + "_non_existing_and_empty");
+testEmptyAndNonExistingDB.dropDatabase();
+
+const statsNonExistingDB = testEmptyAndNonExistingDB.runCommand({dbStats: 1, freeStorage: 1});
+testEmptyAndNonExistingDB.runCommand({create: "test_empty_collection"});
+
+const statsEmptyDB = testEmptyAndNonExistingDB.runCommand({dbStats: 1, freeStorage: 1});
+assert.sameMembers(Object.keys(statsNonExistingDB),
+ Object.keys(statsEmptyDB),
+ "dbStats for non-existing and empty dbs should return the same fields");
})();