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 -3
View File
@@ -4,6 +4,18 @@ set -euo pipefail
ROOT=$(dirname $0)/../..
cleanup() {
log "Cleaning up..."
fission env delete --name nodejs || true
fission fn delete --name $fn || true
}
if [ -z "${TEST_NOCLEANUP:-}" ]; then
trap cleanup EXIT
else
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
fi
fn=nodejs-hello-$(date +%N)
# Create a hello world function in nodejs, test it with an http trigger
@@ -12,11 +24,9 @@ fission env delete --name nodejs || true
log "Creating nodejs env"
fission env create --name nodejs --image fission/node-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
trap "fission env delete --name nodejs" EXIT
log "Creating function"
fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js --executortype poolmgr
trap "fission fn delete --name $fn" EXIT
log "Creating route"
fission route create --function $fn --url /$fn --method GET
@@ -33,4 +43,4 @@ echo $response | grep -i hello
# crappy cleanup, improve this later
kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger
log "Poolmgr ExecutorType: All done."
log "Poolmgr ExecutorType: All done."