summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorAllison Easton <allison.easton@mongodb.com>2022-02-14 13:25:50 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-14 13:55:28 +0000
commit3a0132fcb97a7559b9bfdb0021b25e30f873acb1 (patch)
tree43c8b9572d4933e1b0564eacf4703c405d92220f /jstests
parent5821087022c74d30750f0adcc366871f33af5dc9 (diff)
downloadmongo-3a0132fcb97a7559b9bfdb0021b25e30f873acb1.tar.gz
SERVER-63332 Log random parameters for defragment_large_collection jstest
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/defragment_large_collection.js7
-rw-r--r--jstests/sharding/libs/defragmentation_util.js18
2 files changed, 18 insertions, 7 deletions
diff --git a/jstests/sharding/defragment_large_collection.js b/jstests/sharding/defragment_large_collection.js
index 46b649a394b..1422c314fc3 100644
--- a/jstests/sharding/defragment_large_collection.js
+++ b/jstests/sharding/defragment_large_collection.js
@@ -21,6 +21,9 @@ const maxChunkFillMB = 20;
const maxChunkSizeMB = 30;
const chunkSpacing = 1000;
+jsTest.log("Creating new test with " + numCollections + " collections over " + numShards +
+ " shards.");
+
const st = new ShardingTest({
mongos: 1,
shards: numShards,
@@ -47,10 +50,6 @@ for (let i = 0; i < numCollections; ++i) {
defragmentationUtil.createFragmentedCollection(
st.s, coll.getFullName(), numChunks, maxChunkFillMB, numZones, docSizeBytes, chunkSpacing);
- const beginningNumberChunks =
- findChunksUtil.countChunksForNs(st.s.getDB('config'), coll.getFullName());
- jsTest.log("Create collection " + coll + " with " + beginningNumberChunks + " chunks.");
-
collections.push(coll);
}
diff --git a/jstests/sharding/libs/defragmentation_util.js b/jstests/sharding/libs/defragmentation_util.js
index 37b6a2c786d..65a3e49eb18 100644
--- a/jstests/sharding/libs/defragmentation_util.js
+++ b/jstests/sharding/libs/defragmentation_util.js
@@ -1,20 +1,32 @@
var defragmentationUtil = (function() {
load("jstests/sharding/libs/find_chunks_util.js");
- // This function creates a randomized, fragmented collection. It does not necessarily make a
- // collection with exactly numChunks chunks nor exactly numZones zones.
let createFragmentedCollection = function(
mongos, ns, numChunks, maxChunkFillMB, numZones, docSizeBytes, chunkSpacing) {
+ jsTest.log("Creating fragmented collection " + ns + " with parameters: numChunks = " +
+ numChunks + ", numZones = " + numZones + ", docSizeBytes = " + docSizeBytes +
+ ", maxChunkFillMB = " + maxChunkFillMB + ", chunkSpacing = " + chunkSpacing);
assert.commandWorked(mongos.adminCommand({shardCollection: ns, key: {key: 1}}));
createAndDistributeChunks(mongos, ns, numChunks, chunkSpacing);
createRandomZones(mongos, ns, numZones, chunkSpacing);
fillChunksToRandomSize(mongos, ns, docSizeBytes, maxChunkFillMB);
+
+ const beginningNumberChunks = findChunksUtil.countChunksForNs(mongos.getDB('config'), ns);
+ const beginningNumberZones = mongos.getDB('config').tags.countDocuments({ns: ns});
+ jsTest.log("Collection " + ns + " created with " + beginningNumberChunks + " chunks and " +
+ beginningNumberZones + " zones.");
};
let createAndDistributeChunks = function(mongos, ns, numChunks, chunkSpacing) {
const shards = mongos.getCollection('config.shards').find().toArray();
- for (let i = -Math.floor(numChunks / 2); i <= Math.floor(numChunks / 2); i++) {
+ const existingNumChunks = findChunksUtil.countChunksForNs(mongos.getDB('config'), ns);
+ let numChunksToCreate = numChunks - existingNumChunks;
+ if (numChunksToCreate <= 0) {
+ return;
+ }
+ for (let i = -Math.floor(numChunksToCreate / 2); i < Math.ceil(numChunksToCreate / 2);
+ i++) {
assert.commandWorked(mongos.adminCommand({split: ns, middle: {key: i * chunkSpacing}}));
assert.soon(() => {
let toShard = Random.randInt(shards.length);