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 -11
View File
@@ -7,29 +7,30 @@ ROOT=$(dirname $0)/../..
fn=nodejs-logtest-$(date +%N)
function cleanup {
log "Cleanup route"
cleanup() {
log "Cleaning up..."
var=$(fission route list | grep $fn | awk '{print $1;}')
fission route delete --name $var
log "delete logfile"
rm "/tmp/logfile"
fission fn delete --name $fn || true
fission env delete --name nodejs || true
log "delete logfile" || true
rm "/tmp/logfile" || true
}
# Create a hello world function in nodejs, test it with an http trigger
log "Pre-test cleanup"
fission env delete --name nodejs || 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 "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 log.js
trap "fission fn delete --name $fn" EXIT
log "Creating route"
fission route create --function $fn --url /$fn --method GET
trap cleanup EXIT
log "Waiting for router to catch up"
sleep 15