Fix endurance failures 77/141477/2
authorhalil.cakal <halil.cakal@est.tech>
Mon, 7 Jul 2025 11:03:06 +0000 (12:03 +0100)
committerhalil.cakal <halil.cakal@est.tech>
Tue, 8 Jul 2025 08:23:04 +0000 (09:23 +0100)
- endurance test failed since it exited with 'Unsucessful' termination
  because teardown.sh  was not able to remove CPS images (cps-and-nmcp,
policy-executor-stub). The tag 'latest' was used for both pipelines at
the same time: Regular KPI and Endurance
- teardown algorithm changed: it only remove cps images having 'Snapshot' tag.
- dmi-stub removed from the image list since it should always use the
  Snapshot version in the deployment!

Issue-ID: CPS-2870

Change-Id: I1a7d6dbf717e2686c70d845e6f44c7efb1171dae
Signed-off-by: halil.cakal <halil.cakal@est.tech>
k6-tests/teardown.sh

index 0ee8af6..a51ede2 100755 (executable)
@@ -30,14 +30,18 @@ docker_compose_shutdown_cmd="docker-compose -f ../docker-compose/docker-compose.
 # nexus3.onap.org:10003/onap/dmi-stub:1.8.0-SNAPSHOT
 # nexus3.onap.org:10003/onap/policy-executor-stub:latest
 remove_cps_images() {
-  local cps_image_names=(cps-and-ncmp dmi-stub policy-executor-stub)
+  local cps_image_names=(cps-and-ncmp policy-executor-stub)
   for cps_image_name in "${cps_image_names[@]}"; do
     local image_path="nexus3.onap.org:10003/onap/$cps_image_name"
-    # list all image IDs for this repository (all tags)
-    image_tags=$(docker images -q "$image_path")
-    if [ -n "$image_tags" ]; then
-      echo "Removing images for $image_path..."
-      docker rmi -f $image_tags
+    # 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$') )
+    if [ ${#snapshot_tags[@]} -gt 0 ]; then
+      echo "Removing snapshot images for tags $image_path: ${snapshot_tags[*]}"
+      # remove each snapshot image explicitly
+      for tag in "${snapshot_tags[@]}"; do
+        docker rmi "$image_path:$tag"
+      done
     fi
   done
 }