@@ -95,6 +95,7 @@ CONCURRENCY="${CONCURRENCY:-}"
9595TEMPESTCONF_ARGS=" "
9696TEMPEST_ARGS=" "
9797TEMPEST_DEBUG_MODE=" ${TEMPEST_DEBUG_MODE:- false} "
98+ TEMPEST_CLEANUP=" ${TEMPEST_CLEANUP:- false} "
9899
99100function catch_error_if_debug {
100101 echo " File run_tempest.sh has run into an error!"
@@ -328,10 +329,28 @@ function run_git_tempest {
328329 tempest init openshift
329330 pushd $TEMPEST_DIR
330331
332+ # We're running cleanup only under certain circumstances
333+ if [[ ${TEMPEST_CLEANUP} == true ]]; then
334+ # generate a simple tempest.conf so that we can run --init-saved-state
335+ discover-tempest-config
336+ # let's remove the images that discover-tempest-config creates by default
337+ # so that the're not part of the saved_state.json and can be deleted
338+ # by tempest cleanup later
339+ openstack image list -c Name -f value | grep cirros | xargs -I {} openstack image delete {}
340+ tempest cleanup --init-saved-state
341+ fi
342+
343+ upload_extra_images
344+
331345 discover_tempest_config ${TEMPESTCONF_ARGS} ${TEMPESTCONF_OVERRIDES} \
332346 && tempest run ${TEMPEST_ARGS}
333347 RETURN_VALUE=$?
334348
349+ # Run tempest cleanup to delete any leftover resources when not in debug mode
350+ if [[ ${TEMPEST_CLEANUP} == true ]]; then
351+ tempest cleanup
352+ fi
353+
335354 deactivate
336355
337356 popd
@@ -350,10 +369,28 @@ function run_rpm_tempest {
350369 # List Tempest packages
351370 rpm -qa | grep tempest
352371
372+ # We're running cleanup only under certain circumstances
373+ if [[ ${TEMPEST_CLEANUP} == true ]]; then
374+ # generate a simple tempest.conf so that we can run --init-saved-state
375+ discover-tempest-config
376+ # let's remove the images that discover-tempest-config creates by default
377+ # so that the're not part of the saved_state.json and can be deleted
378+ # by tempest cleanup later
379+ openstack image list -c Name -f value | grep cirros | xargs -I {} openstack image delete {}
380+ tempest cleanup --init-saved-state
381+ fi
382+
383+ upload_extra_images
384+
353385 discover_tempest_config ${TEMPESTCONF_ARGS} ${TEMPESTCONF_OVERRIDES} \
354386 && tempest run ${TEMPEST_ARGS}
355387 RETURN_VALUE=$?
356388
389+ # Run tempest cleanup to delete any leftover resources when not in debug mode
390+ if [[ ${TEMPEST_CLEANUP} == true ]]; then
391+ tempest cleanup
392+ fi
393+
357394 popd
358395 popd
359396}
@@ -390,10 +427,6 @@ function generate_test_results {
390427
391428export OS_CLOUD=default
392429
393- if [[ ! ${# TEMPEST_EXTRA_IMAGES_NAME[@]} -eq 0 ]]; then
394- upload_extra_images
395- fi
396-
397430if [ ! -z ${USE_EXTERNAL_FILES} ] && [ -e ${TEMPEST_PATH} clouds.yaml ]; then
398431 mkdir -p $HOME /.config/openstack
399432 cp ${TEMPEST_PATH} clouds.yaml $HOME /.config/openstack/clouds.yaml
0 commit comments