Skip to content

Commit

Permalink
Fix cleanup function after all tests. Clear images between test runs.
Browse files Browse the repository at this point in the history
Cleanup function wasn't properly cleaning all the folders after test run.
This resulted in unstaged changes after running tests.
One of the cleaning parts were not in the for each loop by mistake.

Adds clearing code for container images that normally would stay between
test runs and would result in the possibility of tests reusing the image
from previous test.

Fixes: sclorg#557
  • Loading branch information
SlouchyButton committed Aug 30, 2024
1 parent 9ef88c8 commit f07ad29
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,22 @@ function test_from_dockerfile_s2i() {
}

app_cleanup() {
info "Cleaning up the test app folders"
for server in ${WEB_SERVERS[*]}; do
if [ ! -z "${server}" ]; then
if [[ "${server}" == "db" ]]; then
echo "Removing ${test_dir}/db-test-app"
rm -rf ${test_dir}/db-test-app
elif [ ! -z "${server}" ]; then
echo "Removing ${test_dir}/${server}-test-app/.git"
rm -rf ${test_dir}/${server}-test-app/.git
fi
done
if [[ "${server}" == "db" ]]; then
rm -rf ${test_dir}/db-test-app
}

function cleanup() {
info "Cleaning up the test application image ${IMAGE_NAME}-testapp"
if image_exists ${IMAGE_NAME}-testapp; then
docker rmi -f ${IMAGE_NAME}-testapp
fi
}

Expand Down Expand Up @@ -223,6 +232,8 @@ for server in ${WEB_SERVERS[@]}; do
evaluate_build_result $? "$server" || continue

TEST_SET=${TESTS:-$TEST_LIST} ct_run_tests_from_testset "$server"

cleanup
done

TEST_LIST="test_from_dockerfile test_from_dockerfile_s2i"
Expand Down

0 comments on commit f07ad29

Please sign in to comment.