Chore: Add gerrit maven verify GHA workflow
[sdnc/oam.git] / csit / run-csit.sh
index 36fdc59..7021f0f 100755 (executable)
@@ -2,6 +2,7 @@
 #
 # Copyright 2016-2017 Huawei Technologies Co., Ltd.
 # Modification Copyright 2019-2021 © Samsung Electronics Co., Ltd.
+# Modification Copyright 2021 © highstreet-technologies GmbH
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -153,15 +154,18 @@ TESTPLANDIR="${WORKSPACE}/${TESTPLAN}"
 
 # Set env variables
 source_safely "${WORKSPACE}/sdnc-csit.env"
-
-# Run installation of prerequired libraries
-source_safely "${WORKSPACE}/prepare-csit.sh"
-
-# Activate the virtualenv containing all the required libraries installed by prepare-csit.sh
-source_safely "${ROBOT_VENV}/bin/activate"
+if [[ -z $ROBOT_IMAGE ]]; then
+  # Run installation of prerequired libraries
+  source_safely "${WORKSPACE}/prepare-csit.sh"
+  # Activate the virtualenv containing all the required libraries installed by prepare-csit.sh
+  source_safely "${ROBOT_VENV}/bin/activate"
+fi
 
 WORKDIR=$(mktemp -d --suffix=-robot-workdir)
-cd "${WORKDIR}"
+chmod a+rwx "${WORKDIR}"
+echo "Additional info"
+ls -lsa "${WORKDIR}"
+id
 
 # Add csit scripts to PATH
 export PATH="${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT_VENV}/bin"
@@ -192,7 +196,36 @@ SUITES=$( xargs -a testplan.txt )
 echo ROBOT_VARIABLES="${ROBOT_VARIABLES}"
 echo "Starting Robot test suites ${SUITES} ..."
 relax_set
-python -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
+
+if [[ -z $SDNC_RELEASE_WITHOUT_ROBOT ]] ; then
+    if [[ -z $SDNC_READY_STATE_TIME_OUT ]] ; then
+        # Runs an alternative robotframework setup as docker image in $ROBOT_IMAGE
+        # test suites will be executed within this docker container
+        # and results are stored as usual
+        if [[ -z $ROBOT_IMAGE ]]; then
+            echo "*** TRACE **** python is $(which python) [version $(python --version)]"
+            env
+            python -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
+        else
+            echo "*** TRACE **** python is running in a container"
+            docker run --rm --net="host" \
+            --env-file ${WORKSPACE}/sdnc-csit-robot.env \
+            -v ${WORKSPACE}:${WORKSPACE} -v ${WORKDIR}:${WORKDIR} $ROBOT_IMAGE  \
+            python3 -B -m robot -N ${TESTPLAN} -v WORKSPACE:/tmp --outputdir ${WORKDIR} ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
+        fi
+    else
+            echo "[INFO] Skip Robot test suite, because SDNC is not in ready state"
+            echo "[ERROR] SDNC is not in ready state, check karaf.log!"
+            false
+    fi
+else
+    echo "[WARNING] SDNC_RELEASE_WITHOUT_ROBOT is TRUE "
+    echo "[WARNING] Dummy Robot test suite is executed, job remains ok. "
+    docker run --rm --net="host" \
+    -v ${WORKSPACE}:${WORKSPACE} -v ${WORKDIR}:${WORKDIR} $ROBOT_IMAGE  \
+    python3 -B -m robot -N ${TESTPLAN} -v WORKSPACE:/tmp --outputdir ${WORKDIR} ${ROBOT_VARIABLES} ${TESTOPTIONS} ${WORKSPACE}/tests/sdnr/debug/10_dummy.robot
+   true
+fi
 RESULT=$?
 load_set
 echo "RESULT: $RESULT"