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
@@ -19,9 +19,21 @@ maxcpu2=200
minmem2=512
maxmem2=768
cleanup() {
log "Cleaning up..."
fission env delete --name $env || true
fission fn delete --name $fn || true
}
cleanup
if [ -z "${TEST_NOCLEANUP:-}" ]; then
trap cleanup EXIT
else
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
fi
log "Creating Python env $env"
fission env create --name $env --image fission/python-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
trap "fission env delete --name $env" EXIT
log "Creating function $fn"
fission fn create --name $fn --env $env --code $ROOT/examples/python/hello.py --minscale 1 --maxscale 4 --executortype newdeploy --mincpu $mincpu1 --maxcpu $maxcpu1 --minmemory $minmem1 --maxmemory $maxmem1
@@ -74,4 +86,4 @@ then
exit 1
fi
timeout 60 bash -c "test_fn $fn 'world'"
timeout 60 bash -c "test_fn $fn 'world'"