aboutsummaryrefslogtreecommitdiffstats
path: root/k6-tests/ncmp/common/passthrough-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/passthrough-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/passthrough-crud.js')
-rw-r--r--k6-tests/ncmp/common/passthrough-crud.js38
1 files changed, 23 insertions, 15 deletions
diff --git a/k6-tests/ncmp/common/passthrough-crud.js b/k6-tests/ncmp/common/passthrough-crud.js
index c5f2dddcf1..0cd96ad64d 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 @@ export function batchRead(cmHandleIds) {
"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