From 1745d2073c8ebca9e8c5384a9086a2170d7b90ec Mon Sep 17 00:00:00 2001 From: "halil.cakal" Date: Tue, 6 Aug 2024 14:02:49 +0100 Subject: Plot request failures for each k6 test - add request failures to plot for each tests - simplify setup and teardown function Issue-ID: CPS-2347 Change-Id: I81226518af7bda12b0489ec46de08e27c96cc16d Signed-off-by: halil.cakal --- k6-tests/ncmp/common/cmhandle-crud.js | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'k6-tests/ncmp/common/cmhandle-crud.js') diff --git a/k6-tests/ncmp/common/cmhandle-crud.js b/k6-tests/ncmp/common/cmhandle-crud.js index 88ecdb45b8..8f53c9b9be 100644 --- a/k6-tests/ncmp/common/cmhandle-crud.js +++ b/k6-tests/ncmp/common/cmhandle-crud.js @@ -19,28 +19,14 @@ */ import http from 'k6/http'; -import { check, sleep } from 'k6'; -import { NCMP_BASE_URL, DMI_PLUGIN_URL, TOTAL_CM_HANDLES, MODULE_SET_TAGS, REGISTRATION_BATCH_SIZE, CONTENT_TYPE_JSON_PARAM, makeBatchOfCmHandleIds } from './utils.js'; +import { sleep } from 'k6'; +import { + NCMP_BASE_URL, DMI_PLUGIN_URL, TOTAL_CM_HANDLES, + MODULE_SET_TAGS, CONTENT_TYPE_JSON_PARAM +} from './utils.js'; import { executeCmHandleIdSearch } from './search-base.js'; -export function registerAllCmHandles() { - forEachBatchOfCmHandles(createCmHandles); - waitForAllCmHandlesToBeReady(); -} - -export function deregisterAllCmHandles() { - forEachBatchOfCmHandles(deleteCmHandles); -} - -function forEachBatchOfCmHandles(functionToExecute) { - const TOTAL_BATCHES = Math.ceil(TOTAL_CM_HANDLES / REGISTRATION_BATCH_SIZE); - for (let batchNumber = 0; batchNumber < TOTAL_BATCHES; batchNumber++) { - const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(REGISTRATION_BATCH_SIZE, batchNumber); - functionToExecute(nextBatchOfCmHandleIds); - } -} - -function createCmHandles(cmHandleIds) { +export function createCmHandles(cmHandleIds) { const url = `${NCMP_BASE_URL}/ncmpInventory/v1/ch`; const payload = { "dmiPlugin": DMI_PLUGIN_URL, @@ -57,22 +43,20 @@ function createCmHandles(cmHandleIds) { })), }; const response = http.post(url, JSON.stringify(payload), CONTENT_TYPE_JSON_PARAM); - check(response, { 'create CM-handles status equals 200': (r) => r.status === 200 }); return response; } -function deleteCmHandles(cmHandleIds) { +export function deleteCmHandles(cmHandleIds) { const url = `${NCMP_BASE_URL}/ncmpInventory/v1/ch`; const payload = { "dmiPlugin": DMI_PLUGIN_URL, "removedCmHandles": cmHandleIds, }; const response = http.post(url, JSON.stringify(payload), CONTENT_TYPE_JSON_PARAM); - check(response, { 'delete CM-handles status equals 200': (r) => r.status === 200 }); return response; } -function waitForAllCmHandlesToBeReady() { +export function waitForAllCmHandlesToBeReady() { const POLLING_INTERVAL_SECONDS = 5; let cmHandlesReady = 0; do { @@ -86,4 +70,4 @@ function getNumberOfReadyCmHandles() { const response = executeCmHandleIdSearch('readyCmHandles'); const arrayOfCmHandleIds = JSON.parse(response.body); return arrayOfCmHandleIds.length; -} +} \ No newline at end of file -- cgit 1.2.3-korg