Add cleanup function to test scripts (#863)
This commit is contained in:
@@ -9,9 +9,20 @@ ROOT=$(dirname $0)/../../..
|
||||
env=python-$(date +%N)
|
||||
fn=hellopython-$(date +%N)
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission env delete --name $env || 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
|
||||
|
||||
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
|
||||
@@ -38,4 +49,4 @@ fission fn update --name $fn --code $ROOT/examples/python/hello.py --executortyp
|
||||
log "Waiting for router to catch up"
|
||||
sleep 5
|
||||
|
||||
timeout 60 bash -c "test_fn $fn 'world'"
|
||||
timeout 60 bash -c "test_fn $fn 'world'"
|
||||
|
||||
Reference in New Issue
Block a user