Add cleanup function to test scripts (#863)
This commit is contained in:
@@ -5,6 +5,18 @@ ROOT=$(dirname $0)/../..
|
||||
|
||||
fn=nodejs-hello-$(date +%s)
|
||||
|
||||
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 function in nodejs, test it with an HTTP trigger.
|
||||
# Update it and check it's output, the output should be
|
||||
# different from the previous one.
|
||||
@@ -14,12 +26,10 @@ 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"
|
||||
echo 'module.exports = function(context, callback) { callback(200, "foo!\n"); }' > foo.js
|
||||
fission fn create --name $fn --env nodejs --code foo.js
|
||||
trap "fission fn delete --name $fn" EXIT
|
||||
|
||||
log "Creating route"
|
||||
fission route create --function $fn --url /$fn --method GET
|
||||
@@ -42,7 +52,6 @@ pid=$!
|
||||
log "Updating function"
|
||||
echo 'module.exports = function(context, callback) { callback(200, "bar!\n"); }' > bar.js
|
||||
fission fn update --name $fn --code bar.js
|
||||
trap "fission fn delete --name $fn" EXIT
|
||||
|
||||
log "Waiting for router to update cache"
|
||||
sleep 10
|
||||
|
||||
Reference in New Issue
Block a user