summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorAllison Easton <allison.easton@mongodb.com>2022-05-31 12:05:44 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-10 07:40:07 +0000
commit774260fa0e3fb862e8cc7a31862c72196e5683c0 (patch)
tree5e6ac17cc9465cfef1d7d9ccc919d2e2850588af /jstests
parent4c5b24082e6336d97b1f3b19f1c0b9156a6d8ad2 (diff)
downloadmongo-774260fa0e3fb862e8cc7a31862c72196e5683c0.tar.gz
SERVER-66074 Remove usage of toArray in collection_defragmentation.js
(cherry picked from commit 2a61fb48311b141c92bb0185fe7cb3caa0480ac0)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/concurrency/fsm_workloads/collection_defragmentation.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/jstests/concurrency/fsm_workloads/collection_defragmentation.js b/jstests/concurrency/fsm_workloads/collection_defragmentation.js
index b986e0f73ee..7ec9bb8b071 100644
--- a/jstests/concurrency/fsm_workloads/collection_defragmentation.js
+++ b/jstests/concurrency/fsm_workloads/collection_defragmentation.js
@@ -38,6 +38,19 @@ function getExtendedCollectionShardKey(configDB, ns) {
return currentShardKey;
}
+function getAllChunks(configDB, ns, keyPattern) {
+ let chunksCursor = findChunksUtil.findChunksByNs(configDB, ns).sort(keyPattern);
+ let chunkArray = [];
+ while (!chunksCursor.isExhausted()) {
+ while (chunksCursor.objsLeftInBatch()) {
+ chunkArray.push(chunksCursor.next());
+ }
+ chunksCursor =
+ findChunksUtil.findChunksByNs(configDB, ns).sort(keyPattern).skip(chunkArray.length);
+ }
+ return chunkArray;
+}
+
var $config = (function() {
var states = {
init: function init(db, collName, connCache) {
@@ -98,12 +111,10 @@ var $config = (function() {
const configDB = randomDB.getSiblingDB('config');
const keyPattern = getCollectionShardKey(configDB, randomColl.getFullName());
- // Get all the chunks
- const chunks = findChunksUtil.findChunksByNs(configDB, randomColl.getFullName())
- .sort(keyPattern)
- .toArray();
+ // Get all the chunks without using getMore so the test can run with stepdowns.
+ const chunks = getAllChunks(configDB, randomColl.getFullName(), keyPattern);
- // No chunks to merge is there are less than 2 chunks
+ // No possible merges if there are less than 2 chunks.
if (chunks.length < 2) {
return;
}