Fix high-cardinality metrics in k6, causing high memory use
- Added unique IDs as metric tags for all the endpoints.
- Re-arranged order of public and prive js methods.
Issue-ID: CPS-2331
Change-Id: Ib876a647fb35110c50670c7222986e8a8a6f5ca0
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
diff --git a/k6-tests/ncmp/common/cmhandle-crud.js b/k6-tests/ncmp/common/cmhandle-crud.js
index aa3beb3..7fab62a 100644
--- a/k6-tests/ncmp/common/cmhandle-crud.js
+++ b/k6-tests/ncmp/common/cmhandle-crud.js
@@ -18,17 +18,38 @@
* ============LICENSE_END=========================================================
*/
-import http from 'k6/http';
import { sleep } from 'k6';
-import {
- NCMP_BASE_URL, DMI_PLUGIN_URL, TOTAL_CM_HANDLES,
- MODULE_SET_TAGS, CONTENT_TYPE_JSON_PARAM
+import { performPostRequest, NCMP_BASE_URL, DMI_PLUGIN_URL, TOTAL_CM_HANDLES, MODULE_SET_TAGS
} from './utils.js';
import { executeCmHandleIdSearch } from './search-base.js';
export function createCmHandles(cmHandleIds) {
const url = `${NCMP_BASE_URL}/ncmpInventory/v1/ch`;
- const payload = {
+ const payload = JSON.stringify(createCmHandlePayload(cmHandleIds));
+ return performPostRequest(url, payload, 'createCmHandles');
+}
+
+export function deleteCmHandles(cmHandleIds) {
+ const url = `${NCMP_BASE_URL}/ncmpInventory/v1/ch`;
+ const payload = JSON.stringify({
+ "dmiPlugin": DMI_PLUGIN_URL,
+ "removedCmHandles": cmHandleIds,
+ });
+ return performPostRequest(url, payload, 'deleteCmHandles');
+}
+
+export function waitForAllCmHandlesToBeReady() {
+ const POLLING_INTERVAL_SECONDS = 5;
+ let cmHandlesReady = 0;
+ do {
+ sleep(POLLING_INTERVAL_SECONDS);
+ cmHandlesReady = getNumberOfReadyCmHandles();
+ console.log(`${cmHandlesReady}/${TOTAL_CM_HANDLES} CM handles are READY`);
+ } while (cmHandlesReady < TOTAL_CM_HANDLES);
+}
+
+function createCmHandlePayload(cmHandleIds) {
+ return {
"dmiPlugin": DMI_PLUGIN_URL,
"createdCmHandles": cmHandleIds.map((cmHandleId, index) => ({
"cmHandle": cmHandleId,
@@ -42,28 +63,6 @@
}
})),
};
- const response = http.post(url, JSON.stringify(payload), CONTENT_TYPE_JSON_PARAM);
- return response;
-}
-
-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);
- return response;
-}
-
-export function waitForAllCmHandlesToBeReady() {
- const POLLING_INTERVAL_SECONDS = 5;
- let cmHandlesReady = 0;
- do {
- sleep(POLLING_INTERVAL_SECONDS);
- cmHandlesReady = getNumberOfReadyCmHandles();
- console.log(`${cmHandlesReady}/${TOTAL_CM_HANDLES} CM handles are READY`);
- } while (cmHandlesReady < TOTAL_CM_HANDLES);
}
function getNumberOfReadyCmHandles() {