Skip to content

Commit

Permalink
Cleanup tempest related resources after testing
Browse files Browse the repository at this point in the history
Let's run tempest cleanup after the tempest run if TEMPEST_CLEANUP
is set to true (false by default and debug mode is not enabled,
to delete any leftover resources (from the tempest run) so that
they won't disrupt any further testing - testing frameworks
executed after tempest.
  • Loading branch information
kopecmartin committed Sep 19, 2024
1 parent 3a65137 commit 30197fb
Showing 1 changed file with 41 additions and 6 deletions.
47 changes: 41 additions & 6 deletions container-images/tcib/base/os/tempest/run_tempest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ CONCURRENCY="${CONCURRENCY:-}"
TEMPESTCONF_ARGS=""
TEMPEST_ARGS=""
TEMPEST_DEBUG_MODE="${TEMPEST_DEBUG_MODE:-false}"
TEMPEST_CLEANUP="${TEMPEST_CLEANUP:-false}"

function catch_error_if_debug {
echo "File run_tempest.sh has run into an error!"
Expand Down Expand Up @@ -328,10 +329,29 @@ function run_git_tempest {
tempest init openshift
pushd $TEMPEST_DIR

discover_tempest_config ${TEMPESTCONF_ARGS} ${TEMPESTCONF_OVERRIDES} \
# We're running cleanup only under certain circumstances
if [[ ${TEMPEST_DEBUG_MODE} == false ]] && [[ ${TEMPEST_CLEANUP} == true ]]; then
# generate a simple tempest.conf so that we can run --init-saved-state
discover-tempest-config
# let's remove the images that discover-tempest-config creates by default
# so that the're not part of the saved_state.json and can be deleted
# by tempest cleanup later
openstack image delete cirros-0.6.2-x86_64-disk.img
openstack image delete cirros-0.6.2-x86_64-disk.img_alt
tempest cleanup --init-saved-state
fi

upload_extra_images

discover-tempest-config ${TEMPESTCONF_ARGS} ${TEMPESTCONF_OVERRIDES} \
&& tempest run ${TEMPEST_ARGS}
RETURN_VALUE=$?

# Run tempest cleanup to delete any leftover resources when not in debug mode
if [[ ${TEMPEST_DEBUG_MODE} == false ]] && [[ ${TEMPEST_CLEANUP} == true ]]; then
tempest cleanup
fi

deactivate

popd
Expand All @@ -350,10 +370,29 @@ function run_rpm_tempest {
# List Tempest packages
rpm -qa | grep tempest

discover_tempest_config ${TEMPESTCONF_ARGS} ${TEMPESTCONF_OVERRIDES} \
# We're running cleanup only under certain circumstances
if [[ ${TEMPEST_DEBUG_MODE} == false ]] && [[ ${TEMPEST_CLEANUP} == true ]]; then
# generate a simple tempest.conf so that we can run --init-saved-state
discover-tempest-config
# let's remove the images that discover-tempest-config creates by default
# so that the're not part of the saved_state.json and can be deleted
# by tempest cleanup later
openstack image delete cirros-0.6.2-x86_64-disk.img
openstack image delete cirros-0.6.2-x86_64-disk.img_alt
tempest cleanup --init-saved-state
fi

upload_extra_images

discover-tempest-config ${TEMPESTCONF_ARGS} ${TEMPESTCONF_OVERRIDES} \
&& tempest run ${TEMPEST_ARGS}
RETURN_VALUE=$?

# Run tempest cleanup to delete any leftover resources when not in debug mode
if [[ ${TEMPEST_DEBUG_MODE} == false ]] && [[ ${TEMPEST_CLEANUP} == true ]]; then
tempest cleanup
fi

popd
popd
}
Expand Down Expand Up @@ -390,10 +429,6 @@ function generate_test_results {

export OS_CLOUD=default

if [[ ! ${#TEMPEST_EXTRA_IMAGES_NAME[@]} -eq 0 ]]; then
upload_extra_images
fi

if [ ! -z ${USE_EXTERNAL_FILES} ] && [ -e ${TEMPEST_PATH}clouds.yaml ]; then
mkdir -p $HOME/.config/openstack
cp ${TEMPEST_PATH}clouds.yaml $HOME/.config/openstack/clouds.yaml
Expand Down

0 comments on commit 30197fb

Please sign in to comment.