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/passthrough-crud.js b/k6-tests/ncmp/common/passthrough-crud.js
index c5f2ddd..0cd96ad 100644
--- a/k6-tests/ncmp/common/passthrough-crud.js
+++ b/k6-tests/ncmp/common/passthrough-crud.js
@@ -18,33 +18,37 @@
* ============LICENSE_END=========================================================
*/
-import http from 'k6/http';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
-import { TOTAL_CM_HANDLES, CONTENT_TYPE_JSON_PARAM, NCMP_BASE_URL, TOPIC_DATA_OPERATIONS_BATCH_READ } from './utils.js';
+import {
+ performPostRequest,
+ performGetRequest,
+ NCMP_BASE_URL,
+ TOPIC_DATA_OPERATIONS_BATCH_READ,
+ TOTAL_CM_HANDLES
+} from './utils.js';
export function passthroughRead(useAlternateId) {
const cmHandleReference = getRandomCmHandleReference(useAlternateId);
const resourceIdentifier = 'my-resource-identifier';
- const includeDescendants = true;
const datastoreName = 'ncmp-datastore:passthrough-operational';
- const url = `${NCMP_BASE_URL}/ncmp/v1/ch/${cmHandleReference}/data/ds/${datastoreName}?resourceIdentifier=${resourceIdentifier}&include-descendants=${includeDescendants}`
- const response = http.get(url);
- return response;
+ const includeDescendants = true;
+ const url = generatePassthroughUrl(cmHandleReference, datastoreName, resourceIdentifier, includeDescendants);
+ return performGetRequest(url, 'passthroughRead');
}
export function passthroughWrite(useAlternateId) {
const cmHandleReference = getRandomCmHandleReference(useAlternateId);
const resourceIdentifier = 'my-resource-identifier';
const datastoreName = 'ncmp-datastore:passthrough-running';
- const url = `${NCMP_BASE_URL}/ncmp/v1/ch/${cmHandleReference}/data/ds/${datastoreName}?resourceIdentifier=${resourceIdentifier}`
- const body = `{"neType": "BaseStation"}`
- const response = http.post(url, JSON.stringify(body), CONTENT_TYPE_JSON_PARAM);
- return response;
+ const includeDescendants = false;
+ const url = generatePassthroughUrl(cmHandleReference, datastoreName, resourceIdentifier, includeDescendants);
+ const payload = JSON.stringify({"neType": "BaseStation"});
+ return performPostRequest(url, payload, 'passthroughWrite');
}
export function batchRead(cmHandleIds) {
- const url = `${NCMP_BASE_URL}/ncmp/v1/data?topic=${TOPIC_DATA_OPERATIONS_BATCH_READ}`
- const payload = {
+ const url = `${NCMP_BASE_URL}/ncmp/v1/data?topic=${TOPIC_DATA_OPERATIONS_BATCH_READ}`;
+ const payload = JSON.stringify({
"operations": [
{
"resourceIdentifier": "parent/child",
@@ -55,12 +59,16 @@
"operation": "read"
}
]
- };
- const response = http.post(url, JSON.stringify(payload), CONTENT_TYPE_JSON_PARAM);
- return response;
+ });
+ return performPostRequest(url, payload, 'batchRead');
}
function getRandomCmHandleReference(useAlternateId) {
const prefix = useAlternateId ? 'alt' : 'ch';
return `${prefix}-${randomIntBetween(1, TOTAL_CM_HANDLES)}`;
}
+
+function generatePassthroughUrl(cmHandleReference, datastoreName, resourceIdentifier, includeDescendants) {
+ const descendantsParam = includeDescendants ? `&include-descendants=${includeDescendants}` : '';
+ return `${NCMP_BASE_URL}/ncmp/v1/ch/${cmHandleReference}/data/ds/${datastoreName}?resourceIdentifier=${resourceIdentifier}${descendantsParam}`;
+}
\ No newline at end of file