fix issues with robot not finding some of the python libs 61/140361/2
authoradheli.tavares <adheli.tavares@est.tech>
Mon, 3 Mar 2025 16:18:09 +0000 (16:18 +0000)
committeradheli.tavares <adheli.tavares@est.tech>
Fri, 7 Mar 2025 10:05:29 +0000 (10:05 +0000)
- fixed the dockerfile libs installation
- fixed some scripting sonar issues
- fixed the kafka and co images to be downloaded from nexus

Issue-ID: POLICY-5300
Change-Id: If8a7142f9204c0558c9941960c421fde1f0b9669
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
compose/compose.common.yml
csit/resources/Dockerfile
csit/resources/scripts/build-csit-docker-image.sh
csit/run-project-csit.sh

index 47212ad..ba53053 100644 (file)
@@ -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.
@@ -93,7 +93,7 @@ services:
 
 # messaging services:
   zookeeper:
-    image: confluentinc/cp-zookeeper:latest
+    image: nexus3.onap.org:10001/confluentinc/cp-zookeeper:latest
     container_name: zookeeper
     hostname: zookeeper
     ports:
@@ -102,7 +102,7 @@ services:
       ZOOKEEPER_CLIENT_PORT: 2181
 
   kafka:
-    image: confluentinc/cp-kafka:latest
+    image: nexus3.onap.org:10001/confluentinc/cp-kafka:latest
     container_name: kafka
     hostname: kafka
     depends_on:
@@ -120,7 +120,7 @@ services:
       KAFKA_ADVERTISED_HOST_NAME: kafka
 
   jaeger:
-    image: jaegertracing/all-in-one:1.58
+    image: nexus3.onap.org:10001/jaegertracing/all-in-one:1.58
     container_name: jaeger
     ports:
       - "4318:4318"
index 77231d5..8f0190b 100644 (file)
@@ -3,9 +3,9 @@ ARG CSIT_SCRIPT=${CSIT_SCRIPT}
 ARG ROBOT_FILE=${ROBOT_FILE}
 ENV ROBOT_WORKSPACE=/opt/robotworkspace ROBOT_FILE=$ROBOT_FILE TEST_ENV=$TEST_ENV
 RUN apt-get update && apt-get install -y gcc; \
-    python3 -m pip -qq install --upgrade pip && \
-    python3 -m pip -qq install --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==0.6.0.*' --pre && \
-    python3 -m pip -qq install --upgrade confluent-kafka && \
+    python3 -m pip -qq install --upgrade pip; \
+    python3 -m pip -qq install --upgrade confluent-kafka; \
+    python3 -m pip -qq install --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==0.6.0.*' --pre; \
     python3 -m pip freeze; \
     mkdir -p ${ROBOT_WORKSPACE}
 COPY scripts/run-test.sh tests/ ${ROBOT_WORKSPACE}/
index 8b5aa7d..ad5dd7e 100755 (executable)
@@ -13,6 +13,8 @@
 # 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
 
 function clone_models() {
     # download models examples
@@ -37,16 +39,21 @@ fi
 GERRIT_BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' "${WORKSPACE}"/.gitreview)
 export ROBOT_DOCKER_IMAGE="policy-csit-robot"
 
-cd ${WORKSPACE}/csit/resources || exit
+cd "${WORKSPACE}"/csit/resources || exit
+
+IMAGE_ID=$(docker images -q "onap/${ROBOT_DOCKER_IMAGE}")
 
-docker image rm -f ${ROBOT_DOCKER_IMAGE}
+if [ -n "$IMAGE_ID" ]; then
+    echo "Image onap/${ROBOT_DOCKER_IMAGE} exists. Removing..."
+    docker rmi "onap/${ROBOT_DOCKER_IMAGE}"
+fi
 
 # get models
 clone_models
 
-echo "Build robot framework docker image"
+echo "Building robot framework docker image"
 docker build . --file Dockerfile  --tag "onap/${ROBOT_DOCKER_IMAGE}" --quiet
-docker save -o policy-csit-robot.tar ${ROBOT_DOCKER_IMAGE}:latest
+docker save -o policy-csit-robot.tar "onap/${ROBOT_DOCKER_IMAGE}":latest
 
-rm -rf ${WORKSPACE}/csit/resources/policy-csit-robot.tar
-rm -rf ${WORKSPACE}/csit/resources/tests/models/
+rm -rf "${WORKSPACE}"/csit/resources/policy-csit-robot.tar
+rm -rf "${WORKSPACE}"/csit/resources/tests/models/
index d9c93c1..ad3f41c 100755 (executable)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+# SPDX-License-Identifier: Apache-2.0
 
 SKIP_BUILDING_ROBOT_IMG=false
 DO_NOT_TEARDOWN=false
 
 # even with forced finish, clean up docker containers
 function on_exit(){
-    rm -rf ${CSAR_DIR}/csar_temp.csar
+    rm -rf "${CSAR_DIR}"/csar_temp.csar
 
     if [ "${DO_NOT_TEARDOWN}" = false ]; then
         # teardown of compose containers for acm-replicas doesn't work with normal stop-compose script
         if [ "${ACM_REPLICA_TEARDOWN}" = true ]; then
-            source ${DOCKER_COMPOSE_DIR}/start-acm-replica.sh --stop --replicas=2
+            source "${DOCKER_COMPOSE_DIR}"/start-acm-replica.sh --stop --replicas=2
         elif [ "${APEX_REPLICA_TEARDOWN}" = true ]; then
-            source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --stop --replicas=2
+            source "${DOCKER_COMPOSE_DIR}"/start-multiple-pdp.sh --stop --replicas=2
         else
-            source ${DOCKER_COMPOSE_DIR}/stop-compose.sh ${PROJECT}
+            source "${DOCKER_COMPOSE_DIR}"/stop-compose.sh "${PROJECT}"
         fi
 
-        mv ${DOCKER_COMPOSE_DIR}/*.log ${ROBOT_LOG_DIR}
+        mv "${DOCKER_COMPOSE_DIR}"/*.log "${ROBOT_LOG_DIR}"
     fi
 
     exit $RC
@@ -71,7 +72,7 @@ function apex_healthcheck() {
 
     while [ $healthy = false ]
     do
-        msg=`curl -s -k --user 'policyadmin:zb!XztG34' http://localhost:${APEX_PORT}/policy/apex-pdp/v1/healthcheck`
+        msg=$(curl -s -k --user 'policyadmin:zb!XztG34' http://localhost:"${APEX_PORT}"/policy/apex-pdp/v1/healthcheck)
         echo "${msg}" | grep -q true
         if [ "${?}" -eq 0 ]
         then
@@ -87,7 +88,7 @@ function apex_healthcheck() {
 }
 
 function check_rest_endpoint() {
-    bash ${SCRIPTS}/wait_for_rest.sh localhost "${1}"
+    bash "${SCRIPTS}"/wait_for_rest.sh localhost "${1}"
     rc=$?
     if [ $rc -ne 0 ]; then
         on_exit
@@ -96,7 +97,7 @@ function check_rest_endpoint() {
 
 function setup_clamp() {
     export ROBOT_FILES="policy-clamp-test.robot clamp-slas.robot"
-    source ${DOCKER_COMPOSE_DIR}/start-compose.sh policy-clamp-runtime-acm --grafana
+    source "${DOCKER_COMPOSE_DIR}"/start-compose.sh policy-clamp-runtime-acm --grafana
     echo "Waiting 2 minutes acm-runtime and participants to start..."
     sleep 120
     check_rest_endpoint "${ACM_PORT}"
@@ -107,79 +108,80 @@ function setup_clamp_replica() {
     export ROBOT_FILES="policy-clamp-test.robot"
     export TEST_ENV="docker"
     export PROJECT=clamp
-    source ${DOCKER_COMPOSE_DIR}/start-acm-replica.sh --start --replicas=2
+    source "${DOCKER_COMPOSE_DIR}"/start-acm-replica.sh --start --replicas=2
     echo "Waiting 2 minutes for the replicas to be started..."
     sleep 120
     # checking on apex-pdp status because acm-r replicas only start after apex-pdp is running
-    check_rest_endpoint ${PAP_PORT}
-    check_rest_endpoint ${APEX_PORT}
+    check_rest_endpoint "${PAP_PORT}"
+    check_rest_endpoint "${APEX_PORT}"
     apex_healthcheck
-    check_rest_endpoint ${ACM_PORT}
+    check_rest_endpoint "${ACM_PORT}"
 }
 
 function setup_api() {
     export ROBOT_FILES="api-test.robot api-slas.robot"
-    source ${DOCKER_COMPOSE_DIR}/start-compose.sh api --grafana
+    source "${DOCKER_COMPOSE_DIR}"/start-compose.sh api --grafana
     echo "Waiting 1 minute for policy-api to start..."
     sleep 60
-    check_rest_endpoint ${API_PORT}
+    check_rest_endpoint "${API_PORT}"
 }
 
 function setup_pap() {
     export ROBOT_FILES="pap-test.robot pap-slas.robot"
-    source ${DOCKER_COMPOSE_DIR}/start-compose.sh apex-pdp --grafana
+    source "${DOCKER_COMPOSE_DIR}"/start-compose.sh apex-pdp --grafana
     echo "Waiting 1 minute for policy-pap to start..."
     sleep 60
-    check_rest_endpoint ${PAP_PORT}
-    check_rest_endpoint ${APEX_PORT}
+    check_rest_endpoint "${PAP_PORT}"
+    check_rest_endpoint "${APEX_PORT}"
     apex_healthcheck
 }
 
 function setup_apex() {
     export ROBOT_FILES="apex-pdp-test.robot apex-slas.robot"
-    source ${DOCKER_COMPOSE_DIR}/start-compose.sh apex-pdp --grafana
+    source "${DOCKER_COMPOSE_DIR}"/start-compose.sh apex-pdp --grafana
     echo "Waiting 1 minute for apex-pdp to start..."
     sleep 60
-    check_rest_endpoint ${PAP_PORT}
-    check_rest_endpoint ${APEX_PORT}
+    check_rest_endpoint "${PAP_PORT}"
+    check_rest_endpoint "${APEX_PORT}"
     apex_healthcheck
 }
 
 function setup_apex_medium() {
     export ROBOT_FILES="apex-slas-3.robot"
     export APEX_REPLICA_TEARDOWN=true
-    source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --start --replicas=3
+    source "${DOCKER_COMPOSE_DIR}"/start-multiple-pdp.sh --start --replicas=3
     echo "Waiting 1 minute for apex-pdp to start..."
     sleep 60
-    check_rest_endpoint ${PAP_PORT}
-    check_rest_endpoint ${APEX_PORT}
+    check_rest_endpoint "${PAP_PORT}"
+    check_rest_endpoint "${APEX_PORT}"
     apex_healthcheck
 }
 
 function setup_apex_large() {
     export ROBOT_FILES="apex-slas-10.robot"
     export APEX_REPLICA_TEARDOWN=true
-    source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --start --replicas=10
+    source "${DOCKER_COMPOSE_DIR}"/start-multiple-pdp.sh --start --replicas=10
     echo "Waiting 1 minute for apex-pdp to start..."
     sleep 60
-    check_rest_endpoint ${PAP_PORT}
-    check_rest_endpoint ${APEX_PORT}
+    check_rest_endpoint "${PAP_PORT}"
+    check_rest_endpoint "${APEX_PORT}"
     apex_healthcheck
 }
 
 function setup_drools_apps() {
     export ROBOT_FILES="drools-applications-test.robot drools-applications-slas.robot"
-    source ${DOCKER_COMPOSE_DIR}/start-compose.sh drools-applications --grafana
+    source "${DOCKER_COMPOSE_DIR}"/start-compose.sh drools-applications --grafana
     echo "Waiting 1 minute for drools-pdp and drools-applications to start..."
-    sleep 60
-    check_rest_endpoint ${PAP_PORT}
-    check_rest_endpoint ${DROOLS_APPS_PORT}
-    check_rest_endpoint ${DROOLS_APPS_TELEMETRY_PORT}
+    sleep 80
+    check_rest_endpoint "${PAP_PORT}"
+    check_rest_endpoint "${XACML_PORT}"
+    check_rest_endpoint "${DROOLS_APPS_PORT}"
+    check_rest_endpoint "${DROOLS_APPS_TELEMETRY_PORT}"
 }
 
 function setup_xacml_pdp() {
     export ROBOT_FILES="xacml-pdp-test.robot xacml-pdp-slas.robot"
-    source ${DOCKER_COMPOSE_DIR}/start-compose.sh xacml-pdp --grafana
+    source "${DOCKER_COMPOSE_DIR}"/start-compose.sh xacml-pdp --grafana
     echo "Waiting 1 minute for xacml-pdp to start..."
     sleep 60
     check_rest_endpoint "${XACML_PORT}"
@@ -188,7 +190,7 @@ function setup_xacml_pdp() {
 function setup_opa_pdp() {
     export ROBOT_FILES="opa-pdp-test.robot"
     export PROJECT="opa-pdp"
-    source ${DOCKER_COMPOSE_DIR}/start-compose.sh opa-pdp
+    source "${DOCKER_COMPOSE_DIR}"/start-compose.sh opa-pdp
     echo "Waiting 3 minutes for OPA-PDP to start..."
     sleep 145
     check_rest_endpoint "${OPA_PDP_PORT}"
@@ -196,35 +198,35 @@ function setup_opa_pdp() {
 
 function setup_drools_pdp() {
     export ROBOT_FILES="drools-pdp-test.robot"
-    source ${DOCKER_COMPOSE_DIR}/start-compose.sh drools-pdp --grafana
+    source "${DOCKER_COMPOSE_DIR}"/start-compose.sh drools-pdp --grafana
     echo "Waiting 1 minute for drools-pdp to start..."
     sleep 60
-    check_rest_endpoint ${DROOLS_TELEMETRY_PORT}
+    check_rest_endpoint "${DROOLS_TELEMETRY_PORT}"
 }
 
 function setup_distribution() {
-    zip -F ${CSAR_DIR}/sample_csar_with_apex_policy.csar --out ${CSAR_DIR}/csar_temp.csar -q
+    zip -F "${CSAR_DIR}"/sample_csar_with_apex_policy.csar --out "${CSAR_DIR}"/csar_temp.csar -q
 
     # Remake temp directory
     sudo rm -rf /tmp/distribution
     sudo mkdir /tmp/distribution
 
     export ROBOT_FILES="distribution-test.robot"
-    source ${DOCKER_COMPOSE_DIR}/start-compose.sh distribution --grafana
+    source "${DOCKER_COMPOSE_DIR}"/start-compose.sh distribution --grafana
     echo "Waiting 1 minute for distribution to start..."
     sleep 60
     check_rest_endpoint "${DIST_PORT}"
-    check_rest_endpoint ${APEX_PORT}
+    check_rest_endpoint "${APEX_PORT}"
     apex_healthcheck
 }
 
 function build_robot_image() {
-    bash ${SCRIPTS}/build-csit-docker-image.sh
-    cd ${WORKSPACE}
+    bash "${SCRIPTS}"/build-csit-docker-image.sh
+    cd "${WORKSPACE}" || exit
 }
 
 function run_robot() {
-    docker compose -f ${DOCKER_COMPOSE_DIR}/compose.yaml up csit-tests
+    docker compose -f "${DOCKER_COMPOSE_DIR}"/compose.yaml up csit-tests
     export RC=$?
 }
 
@@ -332,11 +334,11 @@ export ROBOT_FILES=""
 export ACM_REPLICA_TEARDOWN=false
 export APEX_REPLICA_TEARDOWN=false
 
-cd "${WORKSPACE}"
+cd "${WORKSPACE}" || exit
 
 # recreate the log folder with test results
-sudo rm -rf ${ROBOT_LOG_DIR}
-mkdir -p ${ROBOT_LOG_DIR}
+sudo rm -rf "${ROBOT_LOG_DIR}"
+mkdir -p "${ROBOT_LOG_DIR}"
 
 # log into nexus docker
 docker login -u docker -p docker nexus3.onap.org:10001
@@ -345,7 +347,7 @@ docker login -u docker -p docker nexus3.onap.org:10001
 compose_version=$(docker compose version)
 
 if [[ $compose_version == *"Docker Compose version"* ]]; then
-    echo $compose_version
+    echo "$compose_version"
 else
     echo "Docker Compose Plugin not installed. Installing now..."
     sudo mkdir -p /usr/local/lib/docker/cli-plugins