From: danielhanrahan Date: Wed, 19 Mar 2025 14:47:05 +0000 (+0000) Subject: k6 script to do CM-handle registration only X-Git-Tag: 3.6.2~30 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F22%2F140522%2F3;p=cps.git k6 script to do CM-handle registration only This script is intended to be used for populating the database with CM-handles, which is needed when doing SQL performance analysis. Issue-ID: CPS-2651 Signed-off-by: danielhanrahan Change-Id: Ie644f5f4c86d91a95134b7c67ed96e0650464e0c --- diff --git a/k6-tests/ncmp/register-cmhandles-only.js b/k6-tests/ncmp/register-cmhandles-only.js new file mode 100644 index 0000000000..18c2f85c06 --- /dev/null +++ b/k6-tests/ncmp/register-cmhandles-only.js @@ -0,0 +1,44 @@ +/* + * ============LICENSE_START======================================================= + * Copyright 2025 OpenInfra Foundation Europe. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +/** + * To run this script, ensure docker-compose is started, then run this k6 script: + * docker-compose -f docker-compose/docker-compose.yml --profile dmi-stub --project-name kpi up --wait + * k6 run register-cmhandles-only.js -e TEST_PROFILE=kpi + * After, the system will be running with 50,000 CM-handles created. + */ + +import { check } from 'k6'; +import { TOTAL_CM_HANDLES, REGISTRATION_BATCH_SIZE, makeBatchOfCmHandleIds } from './common/utils.js'; +import { createCmHandles, waitForAllCmHandlesToBeReady } from './common/cmhandle-crud.js'; + +/** + * This function registers CM-handles in batches and waits until all are in READY state. + * The number of handles to be registered is TOTAL_CM_HANDLES defined in common/utils.js + */ +export default function () { + const TOTAL_BATCHES = Math.ceil(TOTAL_CM_HANDLES / REGISTRATION_BATCH_SIZE); + for (let batchNumber = 0; batchNumber < TOTAL_BATCHES; batchNumber++) { + const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(REGISTRATION_BATCH_SIZE, batchNumber); + const response = createCmHandles(nextBatchOfCmHandleIds); + check(response, { 'create CM-handles status equals 200': (r) => r.status === 200 }); + } + waitForAllCmHandlesToBeReady(); +}