Add cleanup function to test scripts (#863)
This commit is contained in:
@@ -6,17 +6,27 @@ ROOT=$(dirname $0)/../..
|
||||
|
||||
fn=nodejs-hello-$(date +%N)
|
||||
|
||||
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
|
||||
|
||||
# Create a hello world function in nodejs, test it with an http trigger
|
||||
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 "Creating function"
|
||||
fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js
|
||||
trap "fission fn delete --name $fn" EXIT
|
||||
|
||||
log "Creating route"
|
||||
fission route create --function $fn --url /$fn --method GET
|
||||
|
||||
Reference in New Issue
Block a user