diff options
author | 2025-03-06 18:41:52 +0000 | |
---|---|---|
committer | 2025-03-06 18:41:52 +0000 | |
commit | d76f92c77790ffb02d800f924a07c0c4997deb41 (patch) | |
tree | bbf36ae72e4f23ae4f8607f11047da6919b16ae9 /k6-tests/ncmp/common/utils.js | |
parent | e012d12fecc6be54ab386e4fd73be0baed53cf1a (diff) | |
parent | 060abae9a1766084c17d0a6563ff8a3bc6b7e046 (diff) |
Merge "Randomize cm handle ids in a legacy batch array"
Diffstat (limited to 'k6-tests/ncmp/common/utils.js')
-rw-r--r-- | k6-tests/ncmp/common/utils.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/k6-tests/ncmp/common/utils.js b/k6-tests/ncmp/common/utils.js index 6bedb1f949..ee3e9c7b4b 100644 --- a/k6-tests/ncmp/common/utils.js +++ b/k6-tests/ncmp/common/utils.js @@ -48,6 +48,19 @@ export function makeBatchOfCmHandleIds(batchSize, batchNumber) { } /** + * Generates an unordered batch of CM-handle IDs based on batch size. + * @returns {string[]} Array of CM-handle IDs, for example ['ch-8', 'ch-2' ... 'ch-32432'] + */ +export function makeRandomBatchOfCmHandleIds() { + const cmHandleIds = new Set(); + while (cmHandleIds.size < LEGACY_BATCH_THROUGHPUT_TEST_BATCH_SIZE) { + const randomNum = Math.floor(Math.random() * TOTAL_CM_HANDLES) + 1; + cmHandleIds.add('ch-' + randomNum); + } + return Array.from(cmHandleIds) +} + +/** * Helper function to perform POST requests with JSON payload and content type. * @param {string} url - The URL to send the POST request to. * @param {Object} payload - The JSON payload to send in the POST request. |