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
+13 -2
View File
@@ -9,12 +9,24 @@ set -euo pipefail
ROOT=$(dirname $0)/../..
cleanup() {
log "Cleaning up..."
fission env delete --name nodejs || true
fission fn delete --name $f1 || true
fission fn delete --name $f2 || true
}
if [ -z "${TEST_NOCLEANUP:-}" ]; then
trap cleanup EXIT
else
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
fi
log "Pre-test cleanup"
fission env delete --name nodejs || true
log "Creating nodejs env"
fission env create --name nodejs --image fission/node-env
trap "fission env delete --name nodejs" EXIT
log "Writing functions"
f1=f1-$(date +%s)
@@ -30,7 +42,6 @@ log "Creating functions"
for f in $f1 $f2
do
fission fn create --name $f --env nodejs --code $f.js
trap "fission fn delete --name $f" EXIT
done
log "Waiting for router to catch up"