summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/resharding_metrics.js52
1 files changed, 34 insertions, 18 deletions
diff --git a/jstests/sharding/resharding_metrics.js b/jstests/sharding/resharding_metrics.js
index f15644dc355..f051634ef7c 100644
--- a/jstests/sharding/resharding_metrics.js
+++ b/jstests/sharding/resharding_metrics.js
@@ -29,28 +29,37 @@ function verifyMetrics(metrics, expected) {
}
}
-function verifyServerStatusOutput(reshardingTest, inputCollection, expectedMetrics) {
- function testMetricsArePresent(mongo) {
- const stats = mongo.getDB('admin').serverStatus({});
- assert(stats.hasOwnProperty('shardingStatistics'), stats);
- const shardingStats = stats.shardingStatistics;
- assert(shardingStats.hasOwnProperty('resharding'),
- `Missing resharding section in ${tojson(shardingStats)}`);
-
- const metrics = shardingStats.resharding;
- verifyMetrics(metrics, expectedMetrics);
- }
+function testMetricsArePresent(mongo, expectedMetrics) {
+ const stats = mongo.getDB('admin').serverStatus({});
+ assert(stats.hasOwnProperty('shardingStatistics'), stats);
+ const shardingStats = stats.shardingStatistics;
+ assert(shardingStats.hasOwnProperty('resharding'),
+ `Missing resharding section in ${tojson(shardingStats)}`);
+
+ const metrics = shardingStats.resharding;
+ verifyMetrics(metrics, expectedMetrics);
+}
+function verifyParticipantServerStatusOutput(reshardingTest, inputCollection, expectedMetrics) {
const donorShardNames = reshardingTest.donorShardNames;
const recipientShardNames = reshardingTest.recipientShardNames;
const mongos = inputCollection.getMongo();
const topology = DiscoverTopology.findConnectedNodes(mongos);
- testMetricsArePresent(new Mongo(topology.shards[donorShardNames[0]].primary));
- testMetricsArePresent(new Mongo(topology.shards[donorShardNames[1]].primary));
- testMetricsArePresent(new Mongo(topology.shards[recipientShardNames[0]].primary));
- testMetricsArePresent(new Mongo(topology.shards[recipientShardNames[1]].primary));
+ testMetricsArePresent(new Mongo(topology.shards[donorShardNames[0]].primary), expectedMetrics);
+ testMetricsArePresent(new Mongo(topology.shards[donorShardNames[1]].primary), expectedMetrics);
+ testMetricsArePresent(new Mongo(topology.shards[recipientShardNames[0]].primary),
+ expectedMetrics);
+ testMetricsArePresent(new Mongo(topology.shards[recipientShardNames[1]].primary),
+ expectedMetrics);
+}
+
+function verifyCoordinatorServerStatusOutput(inputCollection, expectedMetrics) {
+ const mongos = inputCollection.getMongo();
+ const topology = DiscoverTopology.findConnectedNodes(mongos);
+
+ testMetricsArePresent(new Mongo(topology.configsvr.primary), expectedMetrics);
}
// Tests the currentOp output for each donor, each recipient, and the coordinator.
@@ -155,9 +164,11 @@ var initialServerStatusMetrics = {
"bytesCopied": 0,
"oplogEntriesApplied": 0,
"countWritesDuringCriticalSection": 0,
+ "lastOpEndingChunkImbalance": 0,
};
-verifyServerStatusOutput(reshardingTest, inputCollection, initialServerStatusMetrics);
+verifyParticipantServerStatusOutput(reshardingTest, inputCollection, initialServerStatusMetrics);
+verifyCoordinatorServerStatusOutput(inputCollection, {lastOpEndingChunkImbalance: 0});
var documentsInserted = [
{_id: "stays on shard0", oldKey: -10, newKey: -10},
@@ -174,7 +185,10 @@ reshardingTest.withReshardingInBackground( //
newShardKeyPattern: {newKey: 1},
newChunks: [
{min: {newKey: MinKey}, max: {newKey: 0}, shard: recipientShardNames[0]},
- {min: {newKey: 0}, max: {newKey: MaxKey}, shard: recipientShardNames[1]},
+ {min: {newKey: 0}, max: {newKey: 10}, shard: recipientShardNames[1]},
+ {min: {newKey: 10}, max: {newKey: 20}, shard: recipientShardNames[1]},
+ {min: {newKey: 20}, max: {newKey: 30}, shard: recipientShardNames[1]},
+ {min: {newKey: 30}, max: {newKey: MaxKey}, shard: recipientShardNames[1]},
],
},
(tempNs) => {
@@ -190,9 +204,11 @@ var finalServerStatusMetrics = {
"bytesCopied": Object.bsonsize(documentsInserted[1]) + Object.bsonsize(documentsInserted[2]),
"oplogEntriesApplied": 2,
"countWritesDuringCriticalSection": 0,
+ "lastOpEndingChunkImbalance": 0,
};
-verifyServerStatusOutput(reshardingTest, inputCollection, finalServerStatusMetrics);
+verifyParticipantServerStatusOutput(reshardingTest, inputCollection, finalServerStatusMetrics);
+verifyCoordinatorServerStatusOutput(inputCollection, {lastOpEndingChunkImbalance: 3});
reshardingTest.teardown();
})();