Add cleanup function to test scripts (#863)
This commit is contained in:
@@ -12,23 +12,34 @@ fn_name=hellopy-$(date +%N)
|
||||
old_cfgmap=old-cfgmap-$(date +%N)
|
||||
new_cfgmap=new-cfgmap-$(date +%N)
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission env delete --name $env || true
|
||||
kubectl delete configmap ${old_cfgmap} -n default || true
|
||||
kubectl delete configmap ${new_cfgmap} -n default || true
|
||||
fission spec destroy || true
|
||||
rm -rf specs || true
|
||||
}
|
||||
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
cp ../test_secret_cfgmap/cfgmap.py.template cfgmap.py
|
||||
sed -i "s/{{ FN_CFGMAP }}/${old_cfgmap}/g" cfgmap.py
|
||||
|
||||
log "Creating env $env"
|
||||
fission env create --name $env --image fission/python-env
|
||||
trap "fission env delete --name $env" EXIT
|
||||
|
||||
log "Creating configmap $old_cfgmap"
|
||||
kubectl create configmap ${old_cfgmap} --from-literal=TEST_KEY="TESTVALUE" -n default
|
||||
trap "kubectl delete configmap ${old_cfgmap} -n default" EXIT
|
||||
|
||||
log "Creating NewDeploy function spec: $fn_name"
|
||||
fission spec init
|
||||
trap "rm -rf specs" EXIT
|
||||
fission fn create --spec --name $fn_name --env $env --code cfgmap.py --configmap $old_cfgmap --minscale 1 --maxscale 4 --executortype newdeploy
|
||||
fission spec apply ./specs/
|
||||
trap "fission spec destroy" EXIT
|
||||
|
||||
log "Creating route"
|
||||
fission route create --function ${fn_name} --url /${fn_name} --method GET
|
||||
@@ -41,7 +52,6 @@ timeout 60 bash -c "test_fn $fn_name 'TESTVALUE'"
|
||||
|
||||
log "Creating a new cfgmap"
|
||||
kubectl create configmap ${new_cfgmap} --from-literal=TEST_KEY="TESTVALUE_NEW" -n default
|
||||
trap "kubectl delete configmap ${new_cfgmap} -n default" EXIT
|
||||
|
||||
log "Updating cfgmap and code for the function"
|
||||
sed -i "s/${old_cfgmap}/${new_cfgmap}/g" cfgmap.py
|
||||
@@ -49,10 +59,9 @@ sed -i "s/${old_cfgmap}/${new_cfgmap}/g" specs/function-$fn_name.yaml
|
||||
|
||||
log "Applying function changes"
|
||||
fission spec apply ./specs/
|
||||
trap "fission spec destroy" EXIT
|
||||
|
||||
log "Waiting for changes to take effect"
|
||||
sleep 5
|
||||
|
||||
log "Testing function for cfgmap value"
|
||||
timeout 60 bash -c "test_fn $fn_name 'TESTVALUE_NEW'"
|
||||
timeout 60 bash -c "test_fn $fn_name 'TESTVALUE_NEW'"
|
||||
|
||||
@@ -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'"
|
||||
|
||||
@@ -10,20 +10,29 @@ url=""
|
||||
source $(dirname $0)/fnupdate_utils.sh
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
|
||||
if [ -e "test-deploy-pkg.zip" ]; then
|
||||
rm -rf test-deploy-pkg.zip test_dir
|
||||
rm -rf test-deploy-pkg.zip test_dir || true
|
||||
fi
|
||||
if [ -e "/tmp/file" ]; then
|
||||
rm -rf /tmp/file
|
||||
rm -rf /tmp/file || true
|
||||
fi
|
||||
|
||||
fission env delete --name $env || true
|
||||
fission fn delete --name $fn_name || true
|
||||
}
|
||||
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
# This test tests updating package and checking results of function, it does:
|
||||
# Creates a archive, env. with builder and a function and tests for response
|
||||
# Then updates archive with a different word and udpates functions to check for new string in response
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
env=python-$(date +%N)
|
||||
fn_name=hellopython-$(date +%N)
|
||||
|
||||
@@ -58,4 +67,4 @@ sleep 5
|
||||
|
||||
timeout 60 bash -c "test_fn $fn_name 'fission'"
|
||||
|
||||
log "Update function for new deployment executor passed"
|
||||
log "Update function for new deployment executor passed"
|
||||
|
||||
@@ -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'"
|
||||
|
||||
@@ -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'"
|
||||
|
||||
@@ -12,9 +12,21 @@ targetMinScale=2
|
||||
targetMaxScale=6
|
||||
targetCpuPercent=60
|
||||
|
||||
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 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||
|
||||
@@ -12,23 +12,35 @@ fn_name=hellopython-$(date +%N)
|
||||
old_secret=old-secret-$(date +%N)
|
||||
new_secret=new-secret-$(date +%N)
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission env delete --name $env || true
|
||||
kubectl delete secret ${old_secret} -n default || true
|
||||
kubectl delete secret ${new_secret} -n default || true
|
||||
fission spec destroy || true
|
||||
rm -rf specs || true
|
||||
}
|
||||
|
||||
cleanup
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
cp ../test_secret_cfgmap/secret.py.template secret.py
|
||||
sed -i "s/{{ FN_SECRET }}/${old_secret}/g" secret.py
|
||||
|
||||
log "Creating env $env"
|
||||
fission env create --name $env --image fission/python-env
|
||||
trap "fission env delete --name $env" EXIT
|
||||
|
||||
log "Creating secret $old_secret"
|
||||
kubectl create secret generic ${old_secret} --from-literal=TEST_KEY="TESTVALUE" -n default
|
||||
trap "kubectl delete secret ${old_secret} -n default" EXIT
|
||||
|
||||
log "Creating NewDeploy function spec: $fn_name"
|
||||
fission spec init
|
||||
trap "rm -rf specs" EXIT
|
||||
fission fn create --spec --name $fn_name --env $env --code secret.py --secret $old_secret --minscale 1 --maxscale 4 --executortype newdeploy
|
||||
fission spec apply ./specs/
|
||||
trap "fission spec destroy" EXIT
|
||||
|
||||
log "Creating route"
|
||||
fission route create --function ${fn_name} --url /${fn_name} --method GET
|
||||
@@ -41,7 +53,6 @@ timeout 60 bash -c "test_fn $fn_name 'TESTVALUE'"
|
||||
|
||||
log "Creating a new secret"
|
||||
kubectl create secret generic ${new_secret} --from-literal=TEST_KEY="TESTVALUE_NEW" -n default
|
||||
trap "kubectl delete secret ${new_secret} -n default" EXIT
|
||||
|
||||
log "Updating secret and code for the function"
|
||||
sed -i "s/${old_secret}/${new_secret}/g" secret.py
|
||||
@@ -49,10 +60,9 @@ sed -i "s/${old_secret}/${new_secret}/g" specs/function-$fn_name.yaml
|
||||
|
||||
log "Applying function changes"
|
||||
fission spec apply ./specs/
|
||||
trap "fission spec destroy" EXIT
|
||||
|
||||
log "Waiting for changes to take effect"
|
||||
sleep 5
|
||||
|
||||
log "Testing function for secret value"
|
||||
timeout 60 bash -c "test_fn $fn_name 'TESTVALUE_NEW'"
|
||||
timeout 60 bash -c "test_fn $fn_name 'TESTVALUE_NEW'"
|
||||
|
||||
Reference in New Issue
Block a user