summaryrefslogtreecommitdiffstats
path: root/k6-tests/ncmp/common/cmhandle-crud.js
diff options
context:
space:
mode:
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);