diff options
author | Pol Pinol Castuera <pol.pinol@mongodb.com> | 2022-11-29 10:57:11 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-29 11:16:03 +0000 |
commit | 6e3beb9b537815b1d6efa4cb530037c99261d10a (patch) | |
tree | 456f6b8094524dba0ddede5cb79c3cbcf32bcaeb /jstests | |
parent | aaa13e066cbddbfbdc1debc41a8fe903100bf9e9 (diff) | |
download | mongo-6e3beb9b537815b1d6efa4cb530037c99261d10a.tar.gz |
SERVER-68576 Added number of sharded collections to serverStatus command.
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/sharding_statistics_server_status.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/jstests/sharding/sharding_statistics_server_status.js b/jstests/sharding/sharding_statistics_server_status.js index acb2c8a18f0..a87fcdeba39 100644 --- a/jstests/sharding/sharding_statistics_server_status.js +++ b/jstests/sharding/sharding_statistics_server_status.js @@ -64,6 +64,13 @@ function checkServerStatusAbortedMigrationCount(shardConn, count) { assert.eq(count, shardStats.countDonorMoveChunkAbortConflictingIndexOperation); } +function checkServerStatusNumShardedCollections(conn, count) { + const shardStats = + assert.commandWorked(conn.adminCommand({serverStatus: 1})).shardingStatistics; + assert(shardStats.hasOwnProperty("numShardedCollections")); + assert.eq(count, shardStats.numShardedCollections); +} + function runConcurrentMoveChunk(host, ns, toShard) { const mongos = new Mongo(host); let result = mongos.adminCommand({moveChunk: ns, find: {_id: 1}, to: toShard}); @@ -100,6 +107,17 @@ st.ensurePrimaryShard(coll.getDB() + "", st.shard0.shardName); assert.commandWorked(admin.runCommand({shardCollection: coll + "", key: {_id: 1}})); assert.commandWorked(admin.runCommand({split: coll + "", middle: {_id: 0}})); +// Check the number of sharded collections. +const testDB = st.rs0.getPrimary().getDB(dbName); +const fcvDoc = testDB.adminCommand({getParameter: 1, featureCompatibilityVersion: 1}); +if (MongoRunner.compareBinVersions(fcvDoc.featureCompatibilityVersion.version, '4.4') >= 0) { + st.shardColl(dbName + ".coll2", {_id: 1}, false); + st.shardColl(dbName + ".coll3", {_id: 1}, false); + const configCollections = mongos.getCollection("config.collections"); + checkServerStatusNumShardedCollections(st.configRS.getPrimary(), + configCollections.countDocuments({})); +} + // Move chunk from shard0 to shard1 without docs. assert.commandWorked( mongos.adminCommand({moveChunk: coll + '', find: {_id: 1}, to: st.shard1.shardName})); |