diff options
Diffstat (limited to 'k6-tests')
-rw-r--r-- | k6-tests/make-logs.sh | 43 | ||||
-rw-r--r-- | k6-tests/ncmp/common/cmhandle-crud.js | 37 | ||||
-rw-r--r-- | k6-tests/ncmp/common/passthrough-crud.js | 2 | ||||
-rw-r--r-- | k6-tests/ncmp/common/search-base.js | 2 | ||||
-rwxr-xr-x | k6-tests/teardown.sh | 8 |
5 files changed, 72 insertions, 20 deletions
diff --git a/k6-tests/make-logs.sh b/k6-tests/make-logs.sh new file mode 100644 index 0000000000..60976247e5 --- /dev/null +++ b/k6-tests/make-logs.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Copyright 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. +# 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. +# + +SERVICE_NAME="cps-and-ncmp" +TIMESTAMP=$(date +"%Y%m%d%H%M%S") +LOG_DIR="${WORKSPACE:-.}/logs" +TEMP_DIR="$LOG_DIR/temp_$TIMESTAMP" +ZIP_FILE="$LOG_DIR/${SERVICE_NAME}_logs_$TIMESTAMP.zip" + +mkdir -p "$LOG_DIR" +mkdir -p "$TEMP_DIR" + +# Store logs for cps-and-ncmp containers to temp directory +CONTAINER_IDS=$(docker ps --filter "name=$SERVICE_NAME" --format "{{.ID}}") +for CONTAINER_ID in $CONTAINER_IDS; do + CONTAINER_NAME=$(docker inspect --format="{{.Name}}" "$CONTAINER_ID" | sed 's/\///g') + LOG_FILE="$TEMP_DIR/${CONTAINER_NAME}_logs_$TIMESTAMP.log" + docker logs "$CONTAINER_ID" > "$LOG_FILE" +done + +# Zip the logs +zip -r "$ZIP_FILE" "$TEMP_DIR" +echo "Logs saved to $ZIP_FILE inside workspace" + +# Clean temp files +rm -r "$TEMP_DIR" + +# Delete logs older than 2 weeks +find "$LOG_DIR" -name "${SERVICE_NAME}_logs_*.zip" -mtime +14 -delete diff --git a/k6-tests/ncmp/common/cmhandle-crud.js b/k6-tests/ncmp/common/cmhandle-crud.js index 285028f13c..3b6c3ff7b7 100644 --- a/k6-tests/ncmp/common/cmhandle-crud.js +++ b/k6-tests/ncmp/common/cmhandle-crud.js @@ -51,19 +51,30 @@ export function waitForAllCmHandlesToBeReady() { function createCmHandlePayload(cmHandleIds) { return { "dmiPlugin": DMI_PLUGIN_URL, - "createdCmHandles": cmHandleIds.map((cmHandleId, index) => ({ - "cmHandle": cmHandleId, - "alternateId": cmHandleId.replace('ch-', 'Subnetwork=Europe,ManagedElement='), - "moduleSetTag": MODULE_SET_TAGS[index % MODULE_SET_TAGS.length], - "cmHandleProperties": { - "id": "123" - }, - "publicCmHandleProperties": { - "Color": "yellow", - "Size": "small", - "Shape": "cube" - } - })), + "createdCmHandles": cmHandleIds.map((cmHandleId, index) => { + // Ensure unique networkSegment within range 1-10 + let networkSegmentId = Math.floor(Math.random() * 10) + 1; // Random between 1-10 + let moduleTag = MODULE_SET_TAGS[index % MODULE_SET_TAGS.length]; + + return { + "cmHandle": cmHandleId, + "alternateId": cmHandleId.replace('ch-', 'Region=NorthAmerica,Segment='), + "moduleSetTag": moduleTag, + "cmHandleProperties": { + "segmentId": index + 1, + "networkSegment": `Region=NorthAmerica,Segment=${networkSegmentId}`, // Unique within range 1-10 + "deviceIdentifier": `Element=RadioBaseStation_5G_${index + 1000}`, // Unique per cmHandle + "hardwareVersion": `HW-${moduleTag}`, // Shares uniqueness with moduleSetTag + "softwareVersion": `Firmware_${moduleTag}`, // Shares uniqueness with moduleSetTag + "syncStatus": "ACTIVE", + "nodeCategory": "VirtualNode" + }, + "publicCmHandleProperties": { + "systemId": index + 1, + "systemName": "ncmp" + } + }; + }), }; } diff --git a/k6-tests/ncmp/common/passthrough-crud.js b/k6-tests/ncmp/common/passthrough-crud.js index a3d48fd590..eed1ab5190 100644 --- a/k6-tests/ncmp/common/passthrough-crud.js +++ b/k6-tests/ncmp/common/passthrough-crud.js @@ -67,7 +67,7 @@ export function legacyBatchRead(cmHandleIds) { } function getRandomCmHandleReference(useAlternateId) { - const prefix = useAlternateId ? 'Subnetwork=Europe,ManagedElement=' : 'ch-'; + const prefix = useAlternateId ? 'Region=NorthAmerica,Segment=' : 'ch-'; return `${prefix}${randomIntBetween(1, TOTAL_CM_HANDLES)}`; } diff --git a/k6-tests/ncmp/common/search-base.js b/k6-tests/ncmp/common/search-base.js index af2caf71ec..af7d153416 100644 --- a/k6-tests/ncmp/common/search-base.js +++ b/k6-tests/ncmp/common/search-base.js @@ -51,7 +51,7 @@ const SEARCH_PARAMETERS_PER_SCENARIO = { "cmHandleQueryParameters": [ { "conditionName": "hasAllProperties", - "conditionParameters": [{"Color": "yellow"}] + "conditionParameters": [{"systemName": "ncmp"}] } ] }, diff --git a/k6-tests/teardown.sh b/k6-tests/teardown.sh index 10db7ac7e0..7804a73286 100755 --- a/k6-tests/teardown.sh +++ b/k6-tests/teardown.sh @@ -18,11 +18,9 @@ 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 +# Zip and store logs for the containers +chmod +x make-logs.sh +./make-logs.sh testProfile=$1 docker_compose_shutdown_cmd="docker-compose -f ../docker-compose/docker-compose.yml --profile dmi-stub --project-name $testProfile down --volumes" |