Ensure newly build image is used for K6 (performance) job 05/143505/3
authoremaclee <lee.anjella.macabuhay@est.tech>
Thu, 5 Mar 2026 11:12:20 +0000 (11:12 +0000)
committeremaclee <lee.anjella.macabuhay@est.tech>
Mon, 16 Mar 2026 08:35:57 +0000 (08:35 +0000)
- updated helm install command to accept env variables
- updated teardown script in k6-tests to remove built images
- change pullPolicy to Never

Issue-ID: CPS-3171
Change-Id: I406d19dbed1629cfb91213b27a8c6479ffdfa4f8
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
cps-charts/values.yaml
k6-tests/k6-main.sh
k6-tests/teardown.sh

index 52ed227..f262a86 100644 (file)
@@ -51,8 +51,8 @@ postgresql:
 cps:
   image:
     repository: "nexus3.onap.org:10003/onap/cps-and-ncmp"
-    tag: "latest"
-    pullPolicy: Always
+    tag: "" # Overridden by IMAGE_TAG in k6-main.sh (default: latest)
+    pullPolicy: Never # Overridden by IMAGE_PULL_POLICY in k6-main.sh (default: IfNotPresent)
   replicas: 2
   servicePort: 8080
   service:
@@ -198,7 +198,7 @@ dmiStub:
   enabled: true
   image:
     repository: nexus3.onap.org:10003/onap/dmi-stub
-    tag: "1.8.0-SNAPSHOT"
+    tag: "1.8.0-SNAPSHOT" # Overridden by DMI_STUB_VERSION in k6-main.sh (default: 1.8.0-SNAPSHOT)
     pullPolicy: IfNotPresent
   replicaCount: 1
   deployment1:
@@ -250,8 +250,8 @@ policyExecutorStub:
   enabled: true
   image:
     repository: nexus3.onap.org:10003/onap/policy-executor-stub
-    tag: "latest"
-    pullPolicy: Always
+    tag: "" # Overridden by POLICY_EXECUTOR_STUB_VERSION in k6-main.sh (default: latest)
+    pullPolicy: Never # Overridden by IMAGE_PULL_POLICY in k6-main.sh (default: IfNotPresent)
   replicaCount: 1
   service:
     type: NodePort
index ad56776..4bf94f2 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright 2024-2025 OpenInfra Foundation Europe. All rights reserved.
+# Copyright 2024-2026 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.
@@ -53,13 +53,48 @@ if [[ "$deploymentType" == "dockerHosts" ]]; then
 elif [[ "$deploymentType" == "k8sHosts" ]]; then
     echo "Test profile: $testProfile, and deployment type: $deploymentType provided for k8s cluster"
 
+    # Set default values for local development if not provided by Jenkins
+    IMAGE_TAG="${IMAGE_TAG:-latest}"
+    DMI_STUB_VERSION="${DMI_STUB_VERSION:-1.8.0-SNAPSHOT}"
+    POLICY_EXECUTOR_STUB_VERSION="${POLICY_EXECUTOR_STUB_VERSION:-latest}"
+    IMAGE_PULL_POLICY="${IMAGE_PULL_POLICY:-IfNotPresent}"
+
+    # Display image configuration for verification
+    cat << EOF
+==========================================
+IMAGE CONFIGURATION FOR K6 TESTS:
+==========================================
+CPS Image Tag:                ${IMAGE_TAG}
+DMI Stub Version:             ${DMI_STUB_VERSION}
+Policy Executor Stub Version: ${POLICY_EXECUTOR_STUB_VERSION}
+Image Pull Policy:            ${IMAGE_PULL_POLICY}
+==========================================
+EOF
+
     # Deploy cps charts for k8s
-    helm install cps ../cps-charts
+    helm install cps ../cps-charts \
+      --set cps.image.tag="${IMAGE_TAG}" \
+      --set cps.image.pullPolicy="${IMAGE_PULL_POLICY}" \
+      --set dmiStub.image.tag="${DMI_STUB_VERSION}" \
+      --set policyExecutorStub.image.tag="${POLICY_EXECUTOR_STUB_VERSION}" \
+      --set policyExecutorStub.image.pullPolicy="${IMAGE_PULL_POLICY}"
 
     # Wait for pods and services until becomes ready
     echo "Waiting for cps and ncmp pods to be ready..."
     kubectl wait --for=condition=available deploy -l app=ncmp --timeout=300s
 
+    # Verify actual images running in pods
+    cat << EOF
+==========================================
+VERIFYING ACTUAL IMAGES IN RUNNING PODS:
+==========================================
+EOF
+    kubectl get pods -l app=ncmp -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].image}{"\n"}{end}' | while read -r pod_name images; do
+      echo "Pod: $pod_name"
+      echo "  Images: $images"
+    done
+    echo "=========================================="
+
 else
     echo "Error: Unsupported deployment type: $deploymentType"
     echo "Supported deployment types: dockerHosts, k8sHosts"
index 4188b10..f33affa 100755 (executable)
@@ -22,28 +22,39 @@ deploymentType=${2:-dockerHosts}
 # Function to clean Docker images based on CLEAN_DOCKER_IMAGES environment variable
 clean_docker_images_if_needed() {
   if [[ "${CLEAN_DOCKER_IMAGES:-0}" -eq 1 ]]; then
-    echo "Also cleaning up all CPS images"
-    remove_cps_images
+    echo "Also cleaning up CPS images"
+    remove_cps_images "$deploymentType"
   fi
 }
 
 # All CPS docker images:
-# nexus3.onap.org:10003/onap/cps-and-ncmp:latest
-# nexus3.onap.org:10003/onap/dmi-stub:1.8.0-SNAPSHOT
-# nexus3.onap.org:10003/onap/policy-executor-stub:latest
+# nexus3.onap.org:10003/onap/cps-and-ncmp:SNAPSHOT-*
+# nexus3.onap.org:10003/onap/policy-executor-stub:SNAPSHOT-*
+# Note: DMI stub is pulled from Nexus, not built, so we don't clean it
 remove_cps_images() {
+  local deployment_type=$1
   local cps_image_names=(cps-and-ncmp policy-executor-stub)
+  
+  echo "Cleaning up Docker images..."
   for cps_image_name in "${cps_image_names[@]}"; do
     local image_path="nexus3.onap.org:10003/onap/$cps_image_name"
-    # list all images for all tags except 'latest' since it would be in use
-    # result will store in snapshot_tags[0], snapshot_tags[1]
-    local snapshot_tags=( $(docker images "$image_path" --format '{{.Tag}}' | grep -v '^latest$') )
+    
+    # List all images for all tags except 'latest' since it would be in use
+    # For k8sHosts: remove SNAPSHOT-* tags (timestamp-based from Jenkins)
+    # For dockerHosts: remove all non-latest tags
+    if [[ "$deployment_type" == "k8sHosts" ]]; then
+      local snapshot_tags=( $(docker images "$image_path" --format '{{.Tag}}' | grep 'SNAPSHOT-' || true) )
+    else
+      local snapshot_tags=( $(docker images "$image_path" --format '{{.Tag}}' | grep -v '^latest$' || true) )
+    fi
+    
     if [ ${#snapshot_tags[@]} -gt 0 ]; then
-      echo "Removing snapshot images for tags $image_path: ${snapshot_tags[*]}"
-      # remove each snapshot image explicitly
+      echo "Removing images for $image_path: ${snapshot_tags[*]}"
       for tag in "${snapshot_tags[@]}"; do
-        docker rmi "$image_path:$tag"
+        docker rmi "$image_path:$tag" || echo "  Warning: Failed to remove $image_path:$tag"
       done
+    else
+      echo "No images to remove for $image_path"
     fi
   done
 }
@@ -96,4 +107,4 @@ case "$deploymentType" in
     echo "Supported deployment types: k8sHosts, dockerHosts"
     exit 1
     ;;
-esac
\ No newline at end of file
+esac