From 4b32ce9710900c2c308970e0ae8ec913bf64f813 Mon Sep 17 00:00:00 2001 From: Mykyta Karpin Date: Tue, 15 Nov 2016 14:14:18 +0200 Subject: [PATCH] Fix resource deallocation Change-Id: I8e9c7964c923f1c8c709897e73ccc240c571bd76 Partial-Bug: #1611432 --- murano-ci/jenkins/jobs/macros.yaml | 17 +++++++++++++++ murano-ci/scripts/functions.inc | 33 +++++++++++++++++++----------- murano-ci/scripts/run_tests.sh | 2 -- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/murano-ci/jenkins/jobs/macros.yaml b/murano-ci/jenkins/jobs/macros.yaml index 86b05d6a..0049e65d 100755 --- a/murano-ci/jenkins/jobs/macros.yaml +++ b/murano-ci/jenkins/jobs/macros.yaml @@ -10,8 +10,25 @@ source "${WORKSPACE}/murano-ci/scripts/common.inc" #----------------- + pushd "${STACK_HOME}/devstack" + set +o xtrace + echo "Importing openrc ..." + source openrc "${ADMIN_USERNAME}" "${ADMIN_TENANT}" + set -o xtrace + popd + source "${WORKSPACE}/murano-ci/scripts/collect_results.sh" source "${WORKSPACE}/murano-ci/scripts/collect_logs.sh" + + # Cleaning up resources + sudo pkill murano || true + # wait till murano processes gracefully shutdown + while pgrep -f murano-api || pgrep -f murano-engine ; do + sleep 10 + done + # cleanup stacks + ensure_no_heat_stacks_left + onsuccess: false onfailure: false script-only-if-succeeded: false diff --git a/murano-ci/scripts/functions.inc b/murano-ci/scripts/functions.inc index 2f81bba5..f3c006d5 100644 --- a/murano-ci/scripts/functions.inc +++ b/murano-ci/scripts/functions.inc @@ -246,21 +246,31 @@ function ensure_no_heat_stacks_left() { local log_file="${STACK_HOME}/log/murano-engine.log" local retval=0 - pushd "${STACK_HOME}/devstack" - - for id in $(sed -n 's/.*\"OS\:\:stack_id\"\: \"\(.\{36\}\)\".*/\1/p' "${log_file}" | sort | uniq); do - stack_info=$(heat stack-list | grep "${id}") - if [ -n "${stack_info}" ]; then - retval=1 - echo "Stack '${id}' found!" - echo "${stack_info}" - echo "Deleting stack '${id}'" - heat stack-delete "${id}" > /dev/null + for stack_name in $(grep -oP '(?<=generatedStackName\", \").*?(?=\"]+, )' "${log_file}" | sort | uniq); do + # get string, containing stack id + stack_id_string=$(openstack stack list | grep "${stack_name}" | cut -d '|' -f 2) + # strip spaces + stack_id="${stack_id_string//[[:blank:]]/}" + if [ -n "${stack_id}" ]; then + retval=1 + stack_info=$(openstack stack list | grep "${stack_id}") + set +o xtrace + cat << EOF +******************************************************************************** +* +* Stack $stack_id found! +* Full stack information: +* $stack_info +* Deleting stack $stack_id +* +******************************************************************************** +EOF + set -o xtrace + openstack stack delete "${stack_id}" --yes > /dev/null fi done popd - return $retval } @@ -269,5 +279,4 @@ function tear_down() { if [[ "${PROJECT_NAME}" == 'murano-agent' ]]; then remove_image_with_murano_agent fi - ensure_no_heat_stacks_left } diff --git a/murano-ci/scripts/run_tests.sh b/murano-ci/scripts/run_tests.sh index ab8e6f7e..842c1ece 100644 --- a/murano-ci/scripts/run_tests.sh +++ b/murano-ci/scripts/run_tests.sh @@ -126,8 +126,6 @@ EOF popd - ensure_no_heat_stacks_left || retval=$? - return $retval }