summaryrefslogtreecommitdiffstats
path: root/k6-tests/ncmp/common/cmhandle-crud.js
diff options
context:
space:
mode:
authorhalil.cakal <halil.cakal@est.tech>2024-08-06 14:02:49 +0100
committerhalil.cakal <halil.cakal@est.tech>2024-08-26 16:19:32 +0100
commit1745d2073c8ebca9e8c5384a9086a2170d7b90ec (patch)
tree86e0179a3d3732ada082d49fff24e8ead6ed7b0a /k6-tests/ncmp/common/cmhandle-crud.js
parent64ff45847a3466cb24a8dab57b65be753ee3cd03 (diff)
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 <halil.cakal@est.tech>
Diffstat (limited to 'k6-tests/ncmp/common/cmhandle-crud.js')
-rw-r--r--k6-tests/ncmp/common/cmhandle-crud.js34
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