diff options
author | Daniel Hanrahan <daniel.hanrahan@est.tech> | 2024-08-27 13:20:37 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2024-08-27 13:20:37 +0000 |
commit | 607a8563a6e9b935c6feb2604ae0752a07a91895 (patch) | |
tree | 11e700c8e9089c4518d42596d21bac2ed94b2e0b /k6-tests/ncmp/common/cmhandle-crud.js | |
parent | 47823dc78d4503c1abcc726f486355c5635e6494 (diff) | |
parent | 1745d2073c8ebca9e8c5384a9086a2170d7b90ec (diff) |
Merge "Plot request failures for each k6 test"
Diffstat (limited to 'k6-tests/ncmp/common/cmhandle-crud.js')
-rw-r--r-- | k6-tests/ncmp/common/cmhandle-crud.js | 34 |
1 files changed, 9 insertions, 25 deletions
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 |