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 23, 2024
1 parent 3a65137 commit 97ad930
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 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,28 @@ function run_git_tempest {
tempest init openshift
pushd $TEMPEST_DIR

# We're running cleanup only under certain circumstances
if [[ ${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 list -c Name -f value | grep cirros | xargs -I {} openstack image delete {}
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_CLEANUP} == true ]]; then
tempest cleanup
fi

deactivate

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

# We're running cleanup only under certain circumstances
if [[ ${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 list -c Name -f value | grep cirros | xargs -I {} openstack image delete {}
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_CLEANUP} == true ]]; then
tempest cleanup
fi

popd
popd
}
Expand Down Expand Up @@ -390,10 +427,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 97ad930

Please sign in to comment.