Add cleanup function to test scripts (#863)

This commit is contained in:
Ta-Ching Chen
2018-08-18 02:11:08 +08:00
committed by GitHub
parent d443f8b2ef
commit 2d01382a82
22 changed files with 339 additions and 99 deletions
@@ -10,20 +10,29 @@ url=""
source $(dirname $0)/fnupdate_utils.sh
cleanup() {
log "Cleaning up..."
if [ -e "test-deploy-pkg.zip" ]; then
rm -rf test-deploy-pkg.zip test_dir
rm -rf test-deploy-pkg.zip test_dir || true
fi
if [ -e "/tmp/file" ]; then
rm -rf /tmp/file
rm -rf /tmp/file || true
fi
fission env delete --name $env || true
fission fn delete --name $fn_name || true
}
if [ -z "${TEST_NOCLEANUP:-}" ]; then
trap cleanup EXIT
else
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
fi
# This test tests updating package and checking results of function, it does:
# Creates a archive, env. with builder and a function and tests for response
# Then updates archive with a different word and udpates functions to check for new string in response
trap cleanup EXIT
env=python-$(date +%N)
fn_name=hellopython-$(date +%N)
@@ -58,4 +67,4 @@ sleep 5
timeout 60 bash -c "test_fn $fn_name 'fission'"
log "Update function for new deployment executor passed"
log "Update function for new deployment executor passed"