summaryrefslogtreecommitdiffstats
path: root/k6-tests/ncmp/common/cmhandle-crud.js
diff options
context:
space:
mode:
authorsourabh_sourabh <sourabh.sourabh@est.tech>2024-08-30 16:25:04 +0100
committerSourabh Sourabh <sourabh.sourabh@est.tech>2024-09-10 09:07:17 +0000
commit175d12da41b1257fe3be5b3e95540e99c8952f82 (patch)
treefce9bc5589eb88e3b1c4bcaf7366324f5bf13f84 /k6-tests/ncmp/common/cmhandle-crud.js
parent8b3258f21f9957f356bed6cb222361ec09cefd04 (diff)
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>
Diffstat (limited to 'k6-tests/ncmp/common/cmhandle-crud.js')
-rw-r--r--k6-tests/ncmp/common/cmhandle-crud.js47
1 files changed, 23 insertions, 24 deletions
diff --git a/k6-tests/ncmp/common/cmhandle-crud.js b/k6-tests/ncmp/common/cmhandle-crud.js
index aa3beb3091..7fab62abd8 100644
--- a/k6-tests/ncmp/common/cmhandle-crud.js
+++ b/k6-tests/ncmp/common/cmhandle-crud.js
@@ -18,42 +18,24 @@
* ============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 = {
- "dmiPlugin": DMI_PLUGIN_URL,
- "createdCmHandles": cmHandleIds.map((cmHandleId, index) => ({
- "cmHandle": cmHandleId,
- "alternateId": cmHandleId.replace('ch-', 'alt-'),
- "moduleSetTag": MODULE_SET_TAGS[index % MODULE_SET_TAGS.length],
- "cmHandleProperties": {"neType": "RadioNode"},
- "publicCmHandleProperties": {
- "Color": "yellow",
- "Size": "small",
- "Shape": "cube"
- }
- })),
- };
- const response = http.post(url, JSON.stringify(payload), CONTENT_TYPE_JSON_PARAM);
- return response;
+ 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 = {
+ const payload = JSON.stringify({
"dmiPlugin": DMI_PLUGIN_URL,
"removedCmHandles": cmHandleIds,
- };
- const response = http.post(url, JSON.stringify(payload), CONTENT_TYPE_JSON_PARAM);
- return response;
+ });
+ return performPostRequest(url, payload, 'deleteCmHandles');
}
export function waitForAllCmHandlesToBeReady() {
@@ -66,6 +48,23 @@ export function waitForAllCmHandlesToBeReady() {
} while (cmHandlesReady < TOTAL_CM_HANDLES);
}
+function createCmHandlePayload(cmHandleIds) {
+ return {
+ "dmiPlugin": DMI_PLUGIN_URL,
+ "createdCmHandles": cmHandleIds.map((cmHandleId, index) => ({
+ "cmHandle": cmHandleId,
+ "alternateId": cmHandleId.replace('ch-', 'alt-'),
+ "moduleSetTag": MODULE_SET_TAGS[index % MODULE_SET_TAGS.length],
+ "cmHandleProperties": {"neType": "RadioNode"},
+ "publicCmHandleProperties": {
+ "Color": "yellow",
+ "Size": "small",
+ "Shape": "cube"
+ }
+ })),
+ };
+}
+
function getNumberOfReadyCmHandles() {
const response = executeCmHandleIdSearch('readyCmHandles');
const arrayOfCmHandleIds = JSON.parse(response.body);