From 060abae9a1766084c17d0a6563ff8a3bc6b7e046 Mon Sep 17 00:00:00 2001 From: leventecsanyi Date: Thu, 6 Mar 2025 16:15:16 +0100 Subject: Randomize cm handle ids in a legacy batch array - added new JS method to get a random list of CmHandle IDs Issue-ID: CPS-2687 Change-Id: I3b02d4b7c03af3a05860e30b32877475b7e70dba Signed-off-by: leventecsanyi --- k6-tests/ncmp/common/utils.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'k6-tests/ncmp/common/utils.js') 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 @@ -47,6 +47,19 @@ export function makeBatchOfCmHandleIds(batchSize, batchNumber) { return Array.from({ length: batchSize }, (_, i) => `ch-${startIndex + i}`); } +/** + * 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. -- cgit