X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=run-csit.sh;h=ce9cf80f79f6bd6a13d6a24daf9015c9031a0228;hb=refs%2Fheads%2Fhonolulu;hp=5551d212a215dfc90d464c11d7e43b50ca6023cb;hpb=e5a5cc2831042b07d26e177365e8ee631dd530a8;p=integration%2Fcsit.git diff --git a/run-csit.sh b/run-csit.sh index 5551d212..ce9cf80f 100755 --- a/run-csit.sh +++ b/run-csit.sh @@ -22,6 +22,31 @@ # functions # +function on_exit(){ + rc=$? + if [[ ${WORKSPACE} ]]; then + if [[ ${WORKDIR} ]]; then + rsync -av "$WORKDIR/" "$WORKSPACE/archives/$TESTPLAN" + fi + # Record list of active docker containers + docker ps --format "{{.Image}}" > "$WORKSPACE/archives/$TESTPLAN/_docker-images.log" + + # show memory consumption after all docker instances initialized + docker_stats | tee "$WORKSPACE/archives/$TESTPLAN/_sysinfo-2-after-robot.txt" + fi + # Run teardown script plan if it exists + cd "${TESTPLANDIR}" + TEARDOWN="${TESTPLANDIR}/teardown.sh" + if [ -f "${TEARDOWN}" ]; then + echo "Running teardown script ${TEARDOWN}" + source_safely "${TEARDOWN}" + fi + # TODO: do something with the output + exit $rc +} +# ensure that teardown and other finalizing steps are always executed +trap on_exit EXIT + function docker_stats(){ #General memory details echo "> top -bn1 | head -3" @@ -110,9 +135,6 @@ if [ -z "$WORKSPACE" ]; then export WORKSPACE=$(git rev-parse --show-toplevel) fi -rm -rf "$WORKSPACE/archives" -mkdir -p "$WORKSPACE/archives" - if [ -f "${WORKSPACE}/${1}/testplan.txt" ]; then export TESTPLAN="${1}" else @@ -122,6 +144,9 @@ fi export TESTOPTIONS="${2}" +rm -rf "$WORKSPACE/archives/$TESTPLAN" +mkdir -p "$WORKSPACE/archives/$TESTPLAN" + TESTPLANDIR="${WORKSPACE}/${TESTPLAN}" # Run installation of prerequired libraries @@ -139,7 +164,7 @@ export SCRIPTS="${WORKSPACE}/scripts" export ROBOT_VARIABLES= # Sign in to nexus3 docker repo -docker login -u anonymous -p anonymous nexus3.onap.org:10001 +docker login -u docker -p docker nexus3.onap.org:10001 # Run setup script plan if it exists cd "${TESTPLANDIR}" @@ -150,7 +175,7 @@ if [ -f "${SETUP}" ]; then fi # show memory consumption after all docker instances initialized -docker_stats | tee "$WORKSPACE/archives/_sysinfo-1-after-setup.txt" +docker_stats | tee "$WORKSPACE/archives/$TESTPLAN/_sysinfo-1-after-setup.txt" # Run test plan cd "$WORKDIR" @@ -166,22 +191,5 @@ python -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOP RESULT=$? load_set echo "RESULT: $RESULT" -rsync -av "$WORKDIR/" "$WORKSPACE/archives" - -# Record list of active docker containers -docker ps --format "{{.Image}}" > "$WORKSPACE/archives/_docker-images.log" - -# show memory consumption after all docker instances initialized -docker_stats | tee "$WORKSPACE/archives/_sysinfo-2-after-robot.txt" - -# Run teardown script plan if it exists -cd "${TESTPLANDIR}" -TEARDOWN="${TESTPLANDIR}/teardown.sh" -if [ -f "${TEARDOWN}" ]; then - echo "Running teardown script ${TEARDOWN}" - source_safely "${TEARDOWN}" -fi - -# TODO: do something with the output - +# Note that the final steps are done in on_exit function after this exit! exit $RESULT