Add cleanup function to test scripts (#863)
This commit is contained in:
@@ -10,13 +10,25 @@ env_old=python-$(date +%N)
|
||||
env_new=python-$(date +%N)
|
||||
fn=hellopy-$(date +%N)
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission env delete --name $env_old || true
|
||||
fission fn delete --name $fn || true
|
||||
fission env delete --name $env_old || 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 env $env_old"
|
||||
fission env create --name $env_old --image fission/python-env
|
||||
trap "fission env delete --name $env_old" EXIT
|
||||
|
||||
log "Creating function $fn"
|
||||
fission fn create --name $fn --env $env_old --code $ROOT/examples/python/hello.py --minscale 1 --maxscale 4 --executortype newdeploy --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||
trap "fission fn delete --name $fn" EXIT
|
||||
|
||||
log "Creating route for function $fn"
|
||||
fission route create --function ${fn} --url /${fn} --method GET
|
||||
@@ -28,7 +40,6 @@ timeout 60 bash -c "test_fn $fn 'world'"
|
||||
|
||||
log "Creating a new env $env_new"
|
||||
fission env create --name $env_new --image fission/python-env
|
||||
trap "fission env delete --name $env_old" EXIT
|
||||
|
||||
log "Updating function with a new environment"
|
||||
fission fn update --name $fn --env $env_new --code $ROOT/examples/python/hello.py --minscale 1 --maxscale 4 --executortype newdeploy --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||
@@ -36,4 +47,4 @@ fission fn update --name $fn --env $env_new --code $ROOT/examples/python/hello.p
|
||||
log "Waiting for update 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