diff options
Diffstat (limited to 'k6-tests')
-rw-r--r-- | k6-tests/ncmp/common/passthrough-crud.js | 6 | ||||
-rw-r--r-- | k6-tests/ncmp/common/produce-avc-event.js (renamed from k6-tests/once-off-test/kafka/produce-avc-event.js) | 38 | ||||
-rw-r--r-- | k6-tests/ncmp/config/kpi.json | 10 | ||||
-rw-r--r-- | k6-tests/ncmp/ncmp-test-runner.js | 7 | ||||
-rwxr-xr-x | k6-tests/setup.sh | 32 | ||||
-rwxr-xr-x | k6-tests/teardown.sh | 8 |
6 files changed, 51 insertions, 50 deletions
diff --git a/k6-tests/ncmp/common/passthrough-crud.js b/k6-tests/ncmp/common/passthrough-crud.js index 251ddf8890..a3d48fd590 100644 --- a/k6-tests/ncmp/common/passthrough-crud.js +++ b/k6-tests/ncmp/common/passthrough-crud.js @@ -29,7 +29,7 @@ import { export function passthroughRead(useAlternateId) { const cmHandleReference = getRandomCmHandleReference(useAlternateId); - const resourceIdentifier = 'NRCellDU/attributes/cellLocalId'; + const resourceIdentifier = 'ManagedElement=NRNode1/GNBDUFunction=1'; const datastoreName = 'ncmp-datastore:passthrough-operational'; const includeDescendants = true; const url = generatePassthroughUrl(cmHandleReference, datastoreName, resourceIdentifier, includeDescendants); @@ -38,7 +38,7 @@ export function passthroughRead(useAlternateId) { export function passthroughWrite(useAlternateId) { const cmHandleReference = getRandomCmHandleReference(useAlternateId); - const resourceIdentifier = 'NRCellDU/attributes/cellLocalId'; + const resourceIdentifier = 'ManagedElement=NRNode1/GNBDUFunction=1'; const datastoreName = 'ncmp-datastore:passthrough-running'; const includeDescendants = false; const url = generatePassthroughUrl(cmHandleReference, datastoreName, resourceIdentifier, includeDescendants); @@ -54,7 +54,7 @@ export function legacyBatchRead(cmHandleIds) { const payload = JSON.stringify({ "operations": [ { - "resourceIdentifier": "NRCellDU/attributes/cellLocalId", + "resourceIdentifier": "ManagedElement=NRNode1/GNBDUFunction=1", "targetIds": cmHandleIds, "datastore": "ncmp-datastore:passthrough-operational", "options": "(fields=NRCellDU/attributes/cellLocalId)", diff --git a/k6-tests/once-off-test/kafka/produce-avc-event.js b/k6-tests/ncmp/common/produce-avc-event.js index db222f6a4a..220265c6e7 100644 --- a/k6-tests/once-off-test/kafka/produce-avc-event.js +++ b/k6-tests/ncmp/common/produce-avc-event.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation + * Copyright (C) 2024-2025 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,14 @@ * ============LICENSE_END========================================================= */ -import { crypto } from 'k6/experimental/webcrypto'; -import { check } from 'k6'; -import { Writer, SchemaRegistry, SCHEMA_TYPE_STRING } from 'k6/x/kafka'; +import {crypto} from 'k6/experimental/webcrypto'; +import {check} from 'k6'; +import {Writer, SchemaRegistry, SCHEMA_TYPE_STRING} from 'k6/x/kafka'; const testEventPayload = JSON.stringify(JSON.parse(open('../../resources/sampleAvcInputEvent.json'))); const schemaRegistry = new SchemaRegistry(); +let messagesSent = 0; + const kafkaProducer = new Writer({ brokers: ['localhost:9092'], topic: 'dmi-cm-events', @@ -33,26 +35,8 @@ const kafkaProducer = new Writer({ requestTimeout: 30000 }); -const TOTAL_MESSAGES = 100000; -const VIRTUAL_USERS = 1000; - -export const options = { - setupTimeout: '1m', - teardownTimeout: '1m', - scenarios: { - produceKafkaMessages: { - executor: 'shared-iterations', - exec: 'sendKafkaMessages', - vus: VIRTUAL_USERS, - iterations: TOTAL_MESSAGES, - maxDuration: '10m', - } - } -}; - const getRandomNetworkElement = () => { - const networkElementIds = Array.from({ length: 10 }, (_, i) => `neType-${i + 1}`); - return networkElementIds[Math.floor(Math.random() * networkElementIds.length)]; + return `neType-${Math.floor(Math.random() * 10) + 1}`; }; function getCloudEventHeaders() { @@ -69,6 +53,7 @@ function getCloudEventHeaders() { } export function sendKafkaMessages() { + const cloudEventHeaders = getCloudEventHeaders(); const networkElementId = getRandomNetworkElement(); @@ -85,8 +70,8 @@ export function sendKafkaMessages() { }; try { - kafkaProducer.produce({ messages: [avcCloudEvent] }); - + kafkaProducer.produce({messages: [avcCloudEvent]}); + messagesSent++; const isMessageSent = check(kafkaProducer, { 'Message sent successfully': (producer) => producer != null, }); @@ -94,9 +79,8 @@ export function sendKafkaMessages() { if (!isMessageSent) { console.error('Failed to send message:', avcCloudEvent); } - } catch (error) { - console.error('Error during message production:', error, avcCloudEvent); + console.error(`Error during message production: ${error.message}`, avcCloudEvent); } } diff --git a/k6-tests/ncmp/config/kpi.json b/k6-tests/ncmp/config/kpi.json index eed041de85..b691ed5d7f 100644 --- a/k6-tests/ncmp/config/kpi.json +++ b/k6-tests/ncmp/config/kpi.json @@ -147,6 +147,16 @@ "exec": "legacyBatchConsumeScenario", "vus": 1, "iterations": 1 + }, + "produceKafkaMessages": { + "executor": "constant-arrival-rate", + "rate": 500, + "timeUnit": "1s", + "duration": "15m", + "preAllocatedVUs": 10, + "maxVUs": 10, + "exec": "produceAvcEventsScenario", + "gracefulStop": "10s" } }, "thresholds": { diff --git a/k6-tests/ncmp/ncmp-test-runner.js b/k6-tests/ncmp/ncmp-test-runner.js index 9ab326c44c..3c87057e8c 100644 --- a/k6-tests/ncmp/ncmp-test-runner.js +++ b/k6-tests/ncmp/ncmp-test-runner.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation + * Copyright (C) 2024-2025 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import { import { createCmHandles, deleteCmHandles, waitForAllCmHandlesToBeReady } from './common/cmhandle-crud.js'; import { executeCmHandleSearch, executeCmHandleIdSearch } from './common/search-base.js'; import { passthroughRead, passthroughWrite, legacyBatchRead } from './common/passthrough-crud.js'; +import { sendKafkaMessages } from './common/produce-avc-event.js'; let cmHandlesCreatedPerSecondTrend = new Trend('cmhandles_created_per_second', false); let cmHandlesDeletedPerSecondTrend = new Trend('cmhandles_deleted_per_second', false); @@ -219,6 +220,10 @@ export function legacyBatchProduceScenario() { check(response, { 'data operation batch read status equals 200': (r) => r.status === 200 }); } +export function produceAvcEventsScenario() { + sendKafkaMessages(); +} + export function legacyBatchConsumeScenario() { const TOTAL_MESSAGES_TO_CONSUME = LEGACY_BATCH_THROUGHPUT_TEST_NUMBER_OF_REQUESTS * LEGACY_BATCH_THROUGHPUT_TEST_BATCH_SIZE; try { diff --git a/k6-tests/setup.sh b/k6-tests/setup.sh index c794c64dd0..c01a0f6c60 100755 --- a/k6-tests/setup.sh +++ b/k6-tests/setup.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright 2024 Nordix Foundation. +# Copyright 2024-2025 Nordix Foundation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,24 +18,20 @@ testProfile=$1 echo "Spinning off the CPS and NCMP containers for $testProfile testing..." -if [[ "$testProfile" == "endurance" ]]; then - docker-compose -f ../docker-compose/docker-compose.yml --profile dmi-stub --project-name "$testProfile" --env-file ../docker-compose/config/endurance.env up --quiet-pull -d - CONTAINER_IDS=$(docker ps --filter "name=endurance-cps-and-ncmp" --format "{{.ID}}") -else - docker-compose -f ../docker-compose/docker-compose.yml --profile dmi-stub --project-name "$testProfile" up --quiet-pull -d - CONTAINER_IDS=$(docker ps --filter "name=kpi-cps-and-ncmp" --format "{{.ID}}") -fi +ENV_FILE="../docker-compose/env/${testProfile}.env" +docker-compose \ + --file "../docker-compose/docker-compose.yml" \ + --env-file "$ENV_FILE" \ + --project-name "$testProfile" \ + --profile dmi-stub \ + up --quiet-pull --detach --wait || exit 1 -echo "Waiting for CPS to start..." -READY_MESSAGE="Inventory Model updated successfully" + if [[ "$testProfile" == "kpi" ]]; then + ACTUATOR_PORT=8883 + elif [[ "$testProfile" == "endurance" ]]; then + ACTUATOR_PORT=8884 + fi -# Check the logs for each container -for CONTAINER_ID in $CONTAINER_IDS; do - echo "Checking logs for container: $CONTAINER_ID" - docker logs "$CONTAINER_ID" -f | grep -m 1 "$READY_MESSAGE" >/dev/null && echo "CPS is ready in container: $CONTAINER_ID" || true -done - -# Output build information including git commit info echo "Build information:" -curl http://localhost:8883/actuator/info +curl --silent --show-error http://localhost:$ACTUATOR_PORT/actuator/info echo diff --git a/k6-tests/teardown.sh b/k6-tests/teardown.sh index c3233919dc..10db7ac7e0 100755 --- a/k6-tests/teardown.sh +++ b/k6-tests/teardown.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright 2024 Nordix Foundation. +# Copyright 2024-2025 Nordix Foundation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,6 +18,12 @@ echo '================================== docker info ==========================' docker ps -a +echo '================================== CPS-NCMP Logs ========================' +for CONTAINER_ID in $(docker ps --filter "name=cps-and-ncmp" --format "{{.ID}}"); do + echo "CPS-NCMP Logs for container: $CONTAINER_ID" + docker logs "$CONTAINER_ID" +done + testProfile=$1 docker_compose_shutdown_cmd="docker-compose -f ../docker-compose/docker-compose.yml --profile dmi-stub --project-name $testProfile down --volumes" |