aboutsummaryrefslogtreecommitdiffstats
path: root/k6-tests/ncmp/common/utils.js
diff options
context:
space:
mode:
authorleventecsanyi <levente.csanyi@est.tech>2025-03-06 16:15:16 +0100
committerleventecsanyi <levente.csanyi@est.tech>2025-03-06 18:16:01 +0100
commit060abae9a1766084c17d0a6563ff8a3bc6b7e046 (patch)
tree36a1fccb5664c240442bd27343dec9d864b1433c /k6-tests/ncmp/common/utils.js
parent1337752d3175309a66a50fe04aa9b289a33e4290 (diff)
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 <levente.csanyi@est.tech>
Diffstat (limited to 'k6-tests/ncmp/common/utils.js')
-rw-r--r--k6-tests/ncmp/common/utils.js13
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.