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
+12 -3
View File
@@ -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