Add cleanup function to test scripts (#863)
This commit is contained in:
Executable
+71
@@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Create a function and trigger it using NATS
|
||||||
|
#
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
set +x
|
||||||
|
|
||||||
|
ROOT=$(dirname $0)/../..
|
||||||
|
DIR=$(dirname $0)
|
||||||
|
|
||||||
|
clusterID="fissionMQTrigger"
|
||||||
|
topic="foo.bar"
|
||||||
|
resptopic="foo.foo"
|
||||||
|
expectedRespOutput="[foo.foo]: 'Hello, World!'"
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name nodejs || true
|
||||||
|
fission fn delete --name $fn || true
|
||||||
|
fission mqtrigger delete --name $mqt || true
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||||
|
trap cleanup EXIT
|
||||||
|
else
|
||||||
|
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Pre-test cleanup"
|
||||||
|
fission env delete --name nodejs || true
|
||||||
|
|
||||||
|
log "Creating nodejs env"
|
||||||
|
fission env create --name nodejs --image fission/node-env
|
||||||
|
|
||||||
|
log "Creating function"
|
||||||
|
fn=hello-$(date +%s)
|
||||||
|
fission fn create --name $fn --env nodejs --code $DIR/main.js --method GET
|
||||||
|
|
||||||
|
log "Creating message queue trigger"
|
||||||
|
mqt=mqt-$(date +%s)
|
||||||
|
fission mqtrigger create --name $mqt --function $fn --mqtype "nats-streaming" --topic $topic --resptopic $resptopic
|
||||||
|
|
||||||
|
# wait until nats trigger is created
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
#
|
||||||
|
# Send a message
|
||||||
|
#
|
||||||
|
log "Sending message"
|
||||||
|
go run $DIR/stan-pub.go -s $FISSION_NATS_STREAMING_URL -c $clusterID -id clientPub $topic ""
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wait for message on response topic
|
||||||
|
#
|
||||||
|
log "Waiting for response"
|
||||||
|
TIMEOUT=timeout
|
||||||
|
if [ $(uname -s) == 'Darwin' ]
|
||||||
|
then
|
||||||
|
# If this fails on mac os, do "brew install coreutils".
|
||||||
|
TIMEOUT=gtimeout
|
||||||
|
fi
|
||||||
|
response=$($TIMEOUT 120s go run $DIR/stan-sub.go --last -s $FISSION_NATS_STREAMING_URL -c $clusterID -id clientSub $resptopic 2>&1)
|
||||||
|
|
||||||
|
if [[ "$response" != "$expectedRespOutput" ]]; then
|
||||||
|
log "$response is not equal to $expectedRespOutput"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Subscriber received expected response: $response"
|
||||||
@@ -18,24 +18,34 @@ maxretries=1
|
|||||||
# FISSION_NATS_STREAMING_URL="http://defaultFissionAuthToken@$(minikube ip):4222"
|
# FISSION_NATS_STREAMING_URL="http://defaultFissionAuthToken@$(minikube ip):4222"
|
||||||
expectedRespOutput="[foo.error]: 'Hello, World!'"
|
expectedRespOutput="[foo.error]: 'Hello, World!'"
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name nodejs || true
|
||||||
|
fission fn delete --name $fn || true
|
||||||
|
fission mqtrigger delete --name $mqt || true
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||||
|
trap cleanup EXIT
|
||||||
|
else
|
||||||
|
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||||
|
fi
|
||||||
|
|
||||||
log "Pre-test cleanup"
|
log "Pre-test cleanup"
|
||||||
fission env delete --name nodejs || true
|
fission env delete --name nodejs || true
|
||||||
|
|
||||||
log "Creating nodejs env"
|
log "Creating nodejs env"
|
||||||
fission env create --name nodejs --image fission/node-env
|
fission env create --name nodejs --image fission/node-env
|
||||||
#trap "fission env delete --name nodejs" EXIT
|
|
||||||
|
|
||||||
log "Creating function"
|
log "Creating function"
|
||||||
fn=hello-$(date +%s)
|
fn=hello-$(date +%s)
|
||||||
fission fn create --name $fn --env nodejs --code $DIR/main_error.js --method GET
|
fission fn create --name $fn --env nodejs --code $DIR/main_error.js --method GET
|
||||||
##trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "Creating message queue trigger"
|
log "Creating message queue trigger"
|
||||||
mqt=mqt-$(date +%s)
|
mqt=mqt-$(date +%s)
|
||||||
fission mqtrigger create --name $mqt --function $fn --mqtype "nats-streaming" --topic $topic --resptopic $resptopic --errortopic $errortopic --maxretries $maxretries
|
fission mqtrigger create --name $mqt --function $fn --mqtype "nats-streaming" --topic $topic --resptopic $resptopic --errortopic $errortopic --maxretries $maxretries
|
||||||
log "Updated mqtrigger list"
|
log "Updated mqtrigger list"
|
||||||
fission mqtrigger list
|
fission mqtrigger list
|
||||||
#trap "fission mqtrigger delete --name $mqt" EXIT
|
|
||||||
|
|
||||||
# wait until nats trigger is created
|
# wait until nats trigger is created
|
||||||
sleep 5
|
sleep 5
|
||||||
@@ -68,4 +78,4 @@ if [[ "$response" != "$expectedRespOutput" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
log "Responses match."
|
log "Responses match."
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -4,20 +4,32 @@ set -euo pipefail
|
|||||||
|
|
||||||
ROOT=$(dirname $0)/../..
|
ROOT=$(dirname $0)/../..
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name nodejs || true
|
||||||
|
fission fn delete --name $fn1 || 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
|
# Create a hello world function in nodejs, test it with an http trigger
|
||||||
log "NewDeploy ExecutorType: Pre-test cleanup"
|
log "NewDeploy ExecutorType: Pre-test cleanup"
|
||||||
fission env delete --name nodejs || true
|
fission env delete --name nodejs || true
|
||||||
|
|
||||||
log "Creating nodejs env"
|
log "Creating nodejs env"
|
||||||
fission env create --name nodejs --image fission/node-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
fission env create --name nodejs --image fission/node-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||||
trap "fission env delete --name nodejs" EXIT
|
#trap "fission env delete --name nodejs" EXIT
|
||||||
|
|
||||||
# TODO Imporve test code by reusing common blocks
|
# TODO Imporve test code by reusing common blocks
|
||||||
|
|
||||||
log "Creating function, testing for cold start with MinScale 0"
|
log "Creating function, testing for cold start with MinScale 0"
|
||||||
fn0=nodejs-hello-$(date +%N)
|
fn0=nodejs-hello-$(date +%N)
|
||||||
fission fn create --name $fn0 --env nodejs --code $ROOT/examples/nodejs/hello.js --minscale 0 --maxscale 4 --executortype newdeploy
|
fission fn create --name $fn0 --env nodejs --code $ROOT/examples/nodejs/hello.js --minscale 0 --maxscale 4 --executortype newdeploy
|
||||||
trap "fission fn delete --name $fn0" EXIT
|
#trap "fission fn delete --name $fn0" EXIT
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function $fn0 --url /$fn0 --method GET
|
fission route create --function $fn0 --url /$fn0 --method GET
|
||||||
@@ -35,7 +47,7 @@ echo $response0 | grep -i hello
|
|||||||
log "Creating function, testing for warm start with MinScale 1"
|
log "Creating function, testing for warm start with MinScale 1"
|
||||||
fn1=nodejs-hello-$(date +%N)
|
fn1=nodejs-hello-$(date +%N)
|
||||||
fission fn create --name $fn1 --env nodejs --code $ROOT/examples/nodejs/hello.js --minscale 1 --maxscale 4 --executortype newdeploy
|
fission fn create --name $fn1 --env nodejs --code $ROOT/examples/nodejs/hello.js --minscale 1 --maxscale 4 --executortype newdeploy
|
||||||
trap "fission fn delete --name $fn1" EXIT
|
#trap "fission fn delete --name $fn1" EXIT
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function $fn1 --url /$fn1 --method GET
|
fission route create --function $fn1 --url /$fn1 --method GET
|
||||||
@@ -52,4 +64,4 @@ echo $response1 | grep -i hello
|
|||||||
# crappy cleanup, improve this later
|
# crappy cleanup, improve this later
|
||||||
kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger
|
kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger
|
||||||
|
|
||||||
log "NewDeploy ExecutorType: All done."
|
log "NewDeploy ExecutorType: All done."
|
||||||
|
|||||||
@@ -4,6 +4,18 @@ set -euo pipefail
|
|||||||
|
|
||||||
ROOT=$(dirname $0)/../..
|
ROOT=$(dirname $0)/../..
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name nodejs || 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
|
||||||
|
|
||||||
fn=nodejs-hello-$(date +%N)
|
fn=nodejs-hello-$(date +%N)
|
||||||
|
|
||||||
# Create a hello world function in nodejs, test it with an http trigger
|
# Create a hello world function in nodejs, test it with an http trigger
|
||||||
@@ -12,11 +24,9 @@ fission env delete --name nodejs || true
|
|||||||
|
|
||||||
log "Creating nodejs env"
|
log "Creating nodejs env"
|
||||||
fission env create --name nodejs --image fission/node-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
fission env create --name nodejs --image fission/node-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||||
trap "fission env delete --name nodejs" EXIT
|
|
||||||
|
|
||||||
log "Creating function"
|
log "Creating function"
|
||||||
fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js --executortype poolmgr
|
fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js --executortype poolmgr
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function $fn --url /$fn --method GET
|
fission route create --function $fn --url /$fn --method GET
|
||||||
@@ -33,4 +43,4 @@ echo $response | grep -i hello
|
|||||||
# crappy cleanup, improve this later
|
# crappy cleanup, improve this later
|
||||||
kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger
|
kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger
|
||||||
|
|
||||||
log "Poolmgr ExecutorType: All done."
|
log "Poolmgr ExecutorType: All done."
|
||||||
|
|||||||
@@ -51,13 +51,24 @@ waitEnvBuilder() {
|
|||||||
}
|
}
|
||||||
export -f waitEnvBuilder
|
export -f waitEnvBuilder
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name python || 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 "Pre-test cleanup"
|
log "Pre-test cleanup"
|
||||||
fission env delete --name python || true
|
fission env delete --name python || true
|
||||||
kubectl --namespace default get packages|grep -v NAME|awk '{print $1}'|xargs -I@ bash -c 'kubectl --namespace default delete packages @' || true
|
kubectl --namespace default get packages|grep -v NAME|awk '{print $1}'|xargs -I@ bash -c 'kubectl --namespace default delete packages @' || true
|
||||||
|
|
||||||
log "Creating python env"
|
log "Creating python env"
|
||||||
fission env create --name python --image $PYTHON_RUNTIME_IMAGE --builder $PYTHON_BUILDER_IMAGE
|
fission env create --name python --image $PYTHON_RUNTIME_IMAGE --builder $PYTHON_BUILDER_IMAGE
|
||||||
trap "fission env delete --name python" EXIT
|
|
||||||
|
|
||||||
timeout 180s bash -c "waitEnvBuilder python"
|
timeout 180s bash -c "waitEnvBuilder python"
|
||||||
|
|
||||||
@@ -66,7 +77,6 @@ zip -jr demo-src-pkg.zip $ROOT/examples/python/sourcepkg/
|
|||||||
|
|
||||||
log "Creating function " $fn
|
log "Creating function " $fn
|
||||||
fission fn create --name $fn --env python --src demo-src-pkg.zip --entrypoint "user.main" --buildcmd "./build.sh"
|
fission fn create --name $fn --env python --src demo-src-pkg.zip --entrypoint "user.main" --buildcmd "./build.sh"
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function $fn --url /$fn --method GET
|
fission route create --function $fn --url /$fn --method GET
|
||||||
@@ -83,7 +93,6 @@ checkFunctionResponse $fn
|
|||||||
|
|
||||||
log "Updating function " $fn
|
log "Updating function " $fn
|
||||||
fission fn update --name $fn --src demo-src-pkg.zip
|
fission fn update --name $fn --src demo-src-pkg.zip
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
pkg=$(kubectl --namespace default get functions $fn -o jsonpath='{.spec.package.packageref.name}')
|
pkg=$(kubectl --namespace default get functions $fn -o jsonpath='{.spec.package.packageref.name}')
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ set -euo pipefail
|
|||||||
ROOT=$(dirname $0)/../../..
|
ROOT=$(dirname $0)/../../..
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
fission fn delete --name pbuilderhello
|
fission fn delete --name pbuilderhello || true
|
||||||
fission fn delete --name nbuilderhello
|
fission fn delete --name nbuilderhello || true
|
||||||
fission env delete --name java
|
fission env delete --name java || true
|
||||||
}
|
}
|
||||||
|
|
||||||
test_fn() {
|
test_fn() {
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ set -euo pipefail
|
|||||||
ROOT=$(dirname $0)/../../..
|
ROOT=$(dirname $0)/../../..
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
fission fn delete --name hellon
|
fission fn delete --name hellon || true
|
||||||
fission fn delete --name hellop
|
fission fn delete --name hellop || true
|
||||||
fission env delete --name jvm
|
fission env delete --name jvm || true
|
||||||
}
|
}
|
||||||
|
|
||||||
test_fn() {
|
test_fn() {
|
||||||
|
|||||||
@@ -12,23 +12,34 @@ fn_name=hellopy-$(date +%N)
|
|||||||
old_cfgmap=old-cfgmap-$(date +%N)
|
old_cfgmap=old-cfgmap-$(date +%N)
|
||||||
new_cfgmap=new-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
|
cp ../test_secret_cfgmap/cfgmap.py.template cfgmap.py
|
||||||
sed -i "s/{{ FN_CFGMAP }}/${old_cfgmap}/g" cfgmap.py
|
sed -i "s/{{ FN_CFGMAP }}/${old_cfgmap}/g" cfgmap.py
|
||||||
|
|
||||||
log "Creating env $env"
|
log "Creating env $env"
|
||||||
fission env create --name $env --image fission/python-env
|
fission env create --name $env --image fission/python-env
|
||||||
trap "fission env delete --name $env" EXIT
|
|
||||||
|
|
||||||
log "Creating configmap $old_cfgmap"
|
log "Creating configmap $old_cfgmap"
|
||||||
kubectl create configmap ${old_cfgmap} --from-literal=TEST_KEY="TESTVALUE" -n default
|
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"
|
log "Creating NewDeploy function spec: $fn_name"
|
||||||
fission spec init
|
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 fn create --spec --name $fn_name --env $env --code cfgmap.py --configmap $old_cfgmap --minscale 1 --maxscale 4 --executortype newdeploy
|
||||||
fission spec apply ./specs/
|
fission spec apply ./specs/
|
||||||
trap "fission spec destroy" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function ${fn_name} --url /${fn_name} --method GET
|
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"
|
log "Creating a new cfgmap"
|
||||||
kubectl create configmap ${new_cfgmap} --from-literal=TEST_KEY="TESTVALUE_NEW" -n default
|
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"
|
log "Updating cfgmap and code for the function"
|
||||||
sed -i "s/${old_cfgmap}/${new_cfgmap}/g" cfgmap.py
|
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"
|
log "Applying function changes"
|
||||||
fission spec apply ./specs/
|
fission spec apply ./specs/
|
||||||
trap "fission spec destroy" EXIT
|
|
||||||
|
|
||||||
log "Waiting for changes to take effect"
|
log "Waiting for changes to take effect"
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
log "Testing function for cfgmap value"
|
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)
|
env_new=python-$(date +%N)
|
||||||
fn=hellopy-$(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"
|
log "Creating env $env_old"
|
||||||
fission env create --name $env_old --image fission/python-env
|
fission env create --name $env_old --image fission/python-env
|
||||||
trap "fission env delete --name $env_old" EXIT
|
|
||||||
|
|
||||||
log "Creating function $fn"
|
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
|
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"
|
log "Creating route for function $fn"
|
||||||
fission route create --function ${fn} --url /${fn} --method GET
|
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"
|
log "Creating a new env $env_new"
|
||||||
fission env create --name $env_new --image fission/python-env
|
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"
|
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
|
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"
|
log "Waiting for update to catch up"
|
||||||
sleep 5
|
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
|
source $(dirname $0)/fnupdate_utils.sh
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
|
||||||
if [ -e "test-deploy-pkg.zip" ]; then
|
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
|
fi
|
||||||
if [ -e "/tmp/file" ]; then
|
if [ -e "/tmp/file" ]; then
|
||||||
rm -rf /tmp/file
|
rm -rf /tmp/file || true
|
||||||
fi
|
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:
|
# 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
|
# 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
|
# Then updates archive with a different word and udpates functions to check for new string in response
|
||||||
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
env=python-$(date +%N)
|
env=python-$(date +%N)
|
||||||
fn_name=hellopython-$(date +%N)
|
fn_name=hellopython-$(date +%N)
|
||||||
|
|
||||||
@@ -58,4 +67,4 @@ sleep 5
|
|||||||
|
|
||||||
timeout 60 bash -c "test_fn $fn_name 'fission'"
|
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)
|
env=python-$(date +%N)
|
||||||
fn=hellopython-$(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"
|
log "Creating Python env $env"
|
||||||
fission env create --name $env --image fission/python-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
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"
|
log "Creating function $fn"
|
||||||
fission fn create --name $fn --env $env --code $ROOT/examples/python/hello.py
|
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"
|
log "Waiting for router to catch up"
|
||||||
sleep 5
|
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
|
minmem2=512
|
||||||
maxmem2=768
|
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"
|
log "Creating Python env $env"
|
||||||
fission env create --name $env --image fission/python-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
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"
|
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
|
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
|
exit 1
|
||||||
fi
|
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
|
targetMaxScale=6
|
||||||
targetCpuPercent=60
|
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"
|
log "Creating Python env $env"
|
||||||
fission env create --name $env --image fission/python-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
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"
|
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
|
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)
|
old_secret=old-secret-$(date +%N)
|
||||||
new_secret=new-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
|
cp ../test_secret_cfgmap/secret.py.template secret.py
|
||||||
sed -i "s/{{ FN_SECRET }}/${old_secret}/g" secret.py
|
sed -i "s/{{ FN_SECRET }}/${old_secret}/g" secret.py
|
||||||
|
|
||||||
log "Creating env $env"
|
log "Creating env $env"
|
||||||
fission env create --name $env --image fission/python-env
|
fission env create --name $env --image fission/python-env
|
||||||
trap "fission env delete --name $env" EXIT
|
|
||||||
|
|
||||||
log "Creating secret $old_secret"
|
log "Creating secret $old_secret"
|
||||||
kubectl create secret generic ${old_secret} --from-literal=TEST_KEY="TESTVALUE" -n default
|
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"
|
log "Creating NewDeploy function spec: $fn_name"
|
||||||
fission spec init
|
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 fn create --spec --name $fn_name --env $env --code secret.py --secret $old_secret --minscale 1 --maxscale 4 --executortype newdeploy
|
||||||
fission spec apply ./specs/
|
fission spec apply ./specs/
|
||||||
trap "fission spec destroy" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function ${fn_name} --url /${fn_name} --method GET
|
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"
|
log "Creating a new secret"
|
||||||
kubectl create secret generic ${new_secret} --from-literal=TEST_KEY="TESTVALUE_NEW" -n default
|
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"
|
log "Updating secret and code for the function"
|
||||||
sed -i "s/${old_secret}/${new_secret}/g" secret.py
|
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"
|
log "Applying function changes"
|
||||||
fission spec apply ./specs/
|
fission spec apply ./specs/
|
||||||
trap "fission spec destroy" EXIT
|
|
||||||
|
|
||||||
log "Waiting for changes to take effect"
|
log "Waiting for changes to take effect"
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
log "Testing function for secret value"
|
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'"
|
||||||
|
|||||||
@@ -9,16 +9,21 @@ env=nodejs-$(date +%N)
|
|||||||
valid_fn_name=hello-$(date +%N)
|
valid_fn_name=hello-$(date +%N)
|
||||||
invalid_fn_name=errhello-$(date +%N)
|
invalid_fn_name=errhello-$(date +%N)
|
||||||
|
|
||||||
function cleanup {
|
cleanup() {
|
||||||
log "Cleaning up"
|
log "Cleaning up..."
|
||||||
fission env delete --name $env
|
fission env delete --name $env || true
|
||||||
fission fn delete --name $valid_fn_name
|
fission fn delete --name $valid_fn_name || true
|
||||||
fission fn delete --name $invalid_fn_name
|
fission fn delete --name $invalid_fn_name || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"
|
log "Creating env $env"
|
||||||
fission env create --name $env --image fission/node-env
|
fission env create --name $env --image fission/node-env
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
log "Creating valid function $valid_fn_name"
|
log "Creating valid function $valid_fn_name"
|
||||||
fission fn create --name $valid_fn_name --env $env --code hello.js
|
fission fn create --name $valid_fn_name --env $env --code hello.js
|
||||||
@@ -65,4 +70,4 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "All tests passed"
|
log "All tests passed"
|
||||||
|
|||||||
@@ -5,6 +5,18 @@ ROOT=$(dirname $0)/../..
|
|||||||
|
|
||||||
fn=nodejs-hello-$(date +%s)
|
fn=nodejs-hello-$(date +%s)
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name nodejs || 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
|
||||||
|
|
||||||
# Create a function in nodejs, test it with an HTTP trigger.
|
# Create a function in nodejs, test it with an HTTP trigger.
|
||||||
# Update it and check it's output, the output should be
|
# Update it and check it's output, the output should be
|
||||||
# different from the previous one.
|
# different from the previous one.
|
||||||
@@ -14,12 +26,10 @@ fission env delete --name nodejs || true
|
|||||||
|
|
||||||
log "Creating nodejs env"
|
log "Creating nodejs env"
|
||||||
fission env create --name nodejs --image fission/node-env
|
fission env create --name nodejs --image fission/node-env
|
||||||
trap "fission env delete --name nodejs" EXIT
|
|
||||||
|
|
||||||
log "Creating function"
|
log "Creating function"
|
||||||
echo 'module.exports = function(context, callback) { callback(200, "foo!\n"); }' > foo.js
|
echo 'module.exports = function(context, callback) { callback(200, "foo!\n"); }' > foo.js
|
||||||
fission fn create --name $fn --env nodejs --code foo.js
|
fission fn create --name $fn --env nodejs --code foo.js
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function $fn --url /$fn --method GET
|
fission route create --function $fn --url /$fn --method GET
|
||||||
@@ -42,7 +52,6 @@ pid=$!
|
|||||||
log "Updating function"
|
log "Updating function"
|
||||||
echo 'module.exports = function(context, callback) { callback(200, "bar!\n"); }' > bar.js
|
echo 'module.exports = function(context, callback) { callback(200, "bar!\n"); }' > bar.js
|
||||||
fission fn update --name $fn --code bar.js
|
fission fn update --name $fn --code bar.js
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "Waiting for router to update cache"
|
log "Waiting for router to update cache"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|||||||
@@ -9,12 +9,24 @@ set -euo pipefail
|
|||||||
|
|
||||||
ROOT=$(dirname $0)/../..
|
ROOT=$(dirname $0)/../..
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name nodejs || true
|
||||||
|
fission fn delete --name $f1 || true
|
||||||
|
fission fn delete --name $f2 || true
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||||
|
trap cleanup EXIT
|
||||||
|
else
|
||||||
|
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||||
|
fi
|
||||||
|
|
||||||
log "Pre-test cleanup"
|
log "Pre-test cleanup"
|
||||||
fission env delete --name nodejs || true
|
fission env delete --name nodejs || true
|
||||||
|
|
||||||
log "Creating nodejs env"
|
log "Creating nodejs env"
|
||||||
fission env create --name nodejs --image fission/node-env
|
fission env create --name nodejs --image fission/node-env
|
||||||
trap "fission env delete --name nodejs" EXIT
|
|
||||||
|
|
||||||
log "Writing functions"
|
log "Writing functions"
|
||||||
f1=f1-$(date +%s)
|
f1=f1-$(date +%s)
|
||||||
@@ -30,7 +42,6 @@ log "Creating functions"
|
|||||||
for f in $f1 $f2
|
for f in $f1 $f2
|
||||||
do
|
do
|
||||||
fission fn create --name $f --env nodejs --code $f.js
|
fission fn create --name $f --env nodejs --code $f.js
|
||||||
trap "fission fn delete --name $f" EXIT
|
|
||||||
done
|
done
|
||||||
|
|
||||||
log "Waiting for router to catch up"
|
log "Waiting for router to catch up"
|
||||||
|
|||||||
@@ -7,29 +7,30 @@ ROOT=$(dirname $0)/../..
|
|||||||
|
|
||||||
fn=nodejs-logtest-$(date +%N)
|
fn=nodejs-logtest-$(date +%N)
|
||||||
|
|
||||||
function cleanup {
|
cleanup() {
|
||||||
log "Cleanup route"
|
log "Cleaning up..."
|
||||||
var=$(fission route list | grep $fn | awk '{print $1;}')
|
var=$(fission route list | grep $fn | awk '{print $1;}')
|
||||||
fission route delete --name $var
|
fission fn delete --name $fn || true
|
||||||
log "delete logfile"
|
fission env delete --name nodejs || true
|
||||||
rm "/tmp/logfile"
|
log "delete logfile" || true
|
||||||
|
rm "/tmp/logfile" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a hello world function in nodejs, test it with an http trigger
|
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||||
log "Pre-test cleanup"
|
trap cleanup EXIT
|
||||||
fission env delete --name nodejs || true
|
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"
|
log "Creating nodejs env"
|
||||||
fission env create --name nodejs --image fission/node-env
|
fission env create --name nodejs --image fission/node-env
|
||||||
trap "fission env delete --name nodejs" EXIT
|
|
||||||
|
|
||||||
log "Creating function"
|
log "Creating function"
|
||||||
fission fn create --name $fn --env nodejs --code log.js
|
fission fn create --name $fn --env nodejs --code log.js
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function $fn --url /$fn --method GET
|
fission route create --function $fn --url /$fn --method GET
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
log "Waiting for router to catch up"
|
log "Waiting for router to catch up"
|
||||||
sleep 15
|
sleep 15
|
||||||
|
|||||||
@@ -6,17 +6,27 @@ ROOT=$(dirname $0)/../..
|
|||||||
|
|
||||||
fn=nodejs-hello-$(date +%N)
|
fn=nodejs-hello-$(date +%N)
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name nodejs || 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
|
||||||
|
|
||||||
# Create a hello world function in nodejs, test it with an http trigger
|
# Create a hello world function in nodejs, test it with an http trigger
|
||||||
log "Pre-test cleanup"
|
log "Pre-test cleanup"
|
||||||
fission env delete --name nodejs || true
|
fission env delete --name nodejs || true
|
||||||
|
|
||||||
log "Creating nodejs env"
|
log "Creating nodejs env"
|
||||||
fission env create --name nodejs --image fission/node-env
|
fission env create --name nodejs --image fission/node-env
|
||||||
trap "fission env delete --name nodejs" EXIT
|
|
||||||
|
|
||||||
log "Creating function"
|
log "Creating function"
|
||||||
fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js
|
fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function $fn --url /$fn --method GET
|
fission route create --function $fn --url /$fn --method GET
|
||||||
|
|||||||
@@ -50,12 +50,23 @@ waitEnvBuilder() {
|
|||||||
}
|
}
|
||||||
export -f waitEnvBuilder
|
export -f waitEnvBuilder
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name python || 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 "Pre-test cleanup"
|
log "Pre-test cleanup"
|
||||||
fission env delete --name python || true
|
fission env delete --name python || true
|
||||||
|
|
||||||
log "Creating python env"
|
log "Creating python env"
|
||||||
fission env create --name python --image $PYTHON_RUNTIME_IMAGE --builder $PYTHON_BUILDER_IMAGE
|
fission env create --name python --image $PYTHON_RUNTIME_IMAGE --builder $PYTHON_BUILDER_IMAGE
|
||||||
trap "fission env delete --name python" EXIT
|
|
||||||
|
|
||||||
timeout 180s bash -c "waitEnvBuilder python"
|
timeout 180s bash -c "waitEnvBuilder python"
|
||||||
|
|
||||||
@@ -68,7 +79,6 @@ timeout 60s bash -c "waitBuild $pkgName"
|
|||||||
|
|
||||||
log "Creating function " $fn
|
log "Creating function " $fn
|
||||||
fission fn create --name $fn --pkg $pkgName --entrypoint "user.main"
|
fission fn create --name $fn --pkg $pkgName --entrypoint "user.main"
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function $fn --url /$fn --method GET
|
fission route create --function $fn --url /$fn --method GET
|
||||||
@@ -87,7 +97,6 @@ pkgName=$(fission package create --deploy demo-deploy-pkg.zip --env python| cut
|
|||||||
|
|
||||||
log "Updating function " $fn
|
log "Updating function " $fn
|
||||||
fission fn update --name $fn --pkg $pkgName --entrypoint "hello.main"
|
fission fn update --name $fn --pkg $pkgName --entrypoint "hello.main"
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "Waiting for router to update cache"
|
log "Waiting for router to update cache"
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|||||||
@@ -1,6 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
fission env delete --name python || true
|
||||||
|
fission fn delete --name $fn || true
|
||||||
|
rm -rf testDir-$fn || true
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||||
|
trap cleanup EXIT
|
||||||
|
else
|
||||||
|
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||||
|
fi
|
||||||
|
|
||||||
# 1. This test first creates a python function with a route
|
# 1. This test first creates a python function with a route
|
||||||
# 2. Makes a curl request to the route and verifies http.StatusOK is received.
|
# 2. Makes a curl request to the route and verifies http.StatusOK is received.
|
||||||
# This step ensures the pod address is cached in router.
|
# This step ensures the pod address is cached in router.
|
||||||
@@ -18,16 +32,13 @@ fission env delete --name python || true
|
|||||||
|
|
||||||
log "Creating python env"
|
log "Creating python env"
|
||||||
fission env create --name python --image $PYTHON_RUNTIME_IMAGE
|
fission env create --name python --image $PYTHON_RUNTIME_IMAGE
|
||||||
trap "fission env delete --name python" EXIT
|
|
||||||
|
|
||||||
log "Creating hello.py"
|
log "Creating hello.py"
|
||||||
mkdir testDir-$fn
|
mkdir testDir-$fn
|
||||||
printf 'def main():\n return "Hello, world!"' > testDir-$fn/hello.py
|
printf 'def main():\n return "Hello, world!"' > testDir-$fn/hello.py
|
||||||
trap "rm -rf testDir-$fn" EXIT
|
|
||||||
|
|
||||||
log "Creating function " $fn
|
log "Creating function " $fn
|
||||||
fission fn create --name $fn --env python --code testDir-$fn/hello.py
|
fission fn create --name $fn --env python --code testDir-$fn/hello.py
|
||||||
trap "fission fn delete --name $fn" EXIT
|
|
||||||
|
|
||||||
log "rm testDir-$fn"
|
log "rm testDir-$fn"
|
||||||
rm -rf testDir-$fn
|
rm -rf testDir-$fn
|
||||||
@@ -57,4 +68,4 @@ log "http_status: $http_status"
|
|||||||
if [ "$http_status" -ne "200" ]; then
|
if [ "$http_status" -ne "200" ]; then
|
||||||
log "Something went wrong, http status after deleting function pod is $http_status"
|
log "Something went wrong, http status after deleting function pod is $http_status"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -8,16 +8,11 @@ fn=testnormal-$(date +%s)
|
|||||||
fn_secret=testsecret-$(date +%s)
|
fn_secret=testsecret-$(date +%s)
|
||||||
fn_cfgmap=testcfgmap-$(date +%s)
|
fn_cfgmap=testcfgmap-$(date +%s)
|
||||||
|
|
||||||
cp secret.py.template secret.py
|
cleanup() {
|
||||||
sed -i "s/{{ FN_SECRET }}/${fn_secret}/g" secret.py
|
log "Cleaning up..."
|
||||||
|
fission env delete --name python || true
|
||||||
cp cfgmap.py.template cfgmap.py
|
kubectl delete secret -n default ${fn_secret} || true
|
||||||
sed -i "s/{{ FN_CFGMAP }}/${fn_cfgmap}/g" cfgmap.py
|
kubectl delete configmap -n default ${fn_cfgmap} || true
|
||||||
|
|
||||||
function cleanup {
|
|
||||||
log "Cleanup everything"
|
|
||||||
kubectl delete secret -n default ${fn_secret}
|
|
||||||
kubectl delete configmap -n default ${fn_cfgmap}
|
|
||||||
# delete functions
|
# delete functions
|
||||||
for f in ${fn_secret} ${fn_cfgmap} ${fn}
|
for f in ${fn_secret} ${fn_cfgmap} ${fn}
|
||||||
do
|
do
|
||||||
@@ -30,6 +25,18 @@ function cleanup {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||||
|
trap cleanup EXIT
|
||||||
|
else
|
||||||
|
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp secret.py.template secret.py
|
||||||
|
sed -i "s/{{ FN_SECRET }}/${fn_secret}/g" secret.py
|
||||||
|
|
||||||
|
cp cfgmap.py.template cfgmap.py
|
||||||
|
sed -i "s/{{ FN_CFGMAP }}/${fn_cfgmap}/g" cfgmap.py
|
||||||
|
|
||||||
checkFunctionResponse() {
|
checkFunctionResponse() {
|
||||||
log "Doing an HTTP GET on the function's route"
|
log "Doing an HTTP GET on the function's route"
|
||||||
response=$(curl http://$FISSION_ROUTER/${1})
|
response=$(curl http://$FISSION_ROUTER/${1})
|
||||||
@@ -54,15 +61,12 @@ fission env delete --name python || true
|
|||||||
|
|
||||||
log "Creating python env"
|
log "Creating python env"
|
||||||
fission env create --name python --image fission/python-env
|
fission env create --name python --image fission/python-env
|
||||||
trap "fission env delete --name python" EXIT
|
|
||||||
|
|
||||||
log "Creating secret"
|
log "Creating secret"
|
||||||
kubectl create secret generic ${fn_secret} --from-literal=TEST_KEY="TESTVALUE" -n default
|
kubectl create secret generic ${fn_secret} --from-literal=TEST_KEY="TESTVALUE" -n default
|
||||||
trap "kubectl delete secret ${fn_secret} -n default" EXIT
|
|
||||||
|
|
||||||
log "Creating function with secret"
|
log "Creating function with secret"
|
||||||
fission fn create --name ${fn_secret} --env python --code secret.py --secret ${fn_secret}
|
fission fn create --name ${fn_secret} --env python --code secret.py --secret ${fn_secret}
|
||||||
trap "fission fn delete --name ${fn_secret}" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function ${fn_secret} --url /${fn_secret} --method GET
|
fission route create --function ${fn_secret} --url /${fn_secret} --method GET
|
||||||
@@ -75,7 +79,6 @@ checkFunctionResponse ${fn_secret} 'TESTVALUE' 'secret'
|
|||||||
log "Creating function with newdeploy executorType and new secret value"
|
log "Creating function with newdeploy executorType and new secret value"
|
||||||
kubectl patch secrets ${fn_secret} -p '{"data":{"TEST_KEY":"TkVXVkFMCg=="}}' -n default
|
kubectl patch secrets ${fn_secret} -p '{"data":{"TEST_KEY":"TkVXVkFMCg=="}}' -n default
|
||||||
fission fn create --name ${fn_secret}-1 --env python --code secret.py --secret ${fn_secret} --executortype newdeploy
|
fission fn create --name ${fn_secret}-1 --env python --code secret.py --secret ${fn_secret} --executortype newdeploy
|
||||||
trap "fission fn delete --name ${fn_secret}-1" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function ${fn_secret}-1 --url /${fn_secret}-1 --method GET
|
fission route create --function ${fn_secret}-1 --url /${fn_secret}-1 --method GET
|
||||||
@@ -87,11 +90,9 @@ checkFunctionResponse ${fn_secret}-1 'NEWVAL' 'secret'
|
|||||||
|
|
||||||
log "Creating configmap"
|
log "Creating configmap"
|
||||||
kubectl create configmap ${fn_cfgmap} --from-literal=TEST_KEY="TESTVALUE" -n default
|
kubectl create configmap ${fn_cfgmap} --from-literal=TEST_KEY="TESTVALUE" -n default
|
||||||
trap "kubectl delete configmap ${fn_cfgmap} -n default" EXIT
|
|
||||||
|
|
||||||
log "creating function with configmap"
|
log "creating function with configmap"
|
||||||
fission fn create --name ${fn_cfgmap} --env python --code cfgmap.py --configmap ${fn_cfgmap}
|
fission fn create --name ${fn_cfgmap} --env python --code cfgmap.py --configmap ${fn_cfgmap}
|
||||||
trap "fission fn delete --name ${fn_cfgmap}" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function ${fn_cfgmap} --url /${fn_cfgmap} --method GET
|
fission route create --function ${fn_cfgmap} --url /${fn_cfgmap} --method GET
|
||||||
@@ -104,7 +105,6 @@ checkFunctionResponse ${fn_cfgmap} 'TESTVALUE' 'configmap'
|
|||||||
log "Creating function with newdeploy executorType and new configmap value"
|
log "Creating function with newdeploy executorType and new configmap value"
|
||||||
kubectl patch configmap ${fn_cfgmap} -p '{"data":{"TEST_KEY":"NEWVAL"}}' -n default
|
kubectl patch configmap ${fn_cfgmap} -p '{"data":{"TEST_KEY":"NEWVAL"}}' -n default
|
||||||
fission fn create --name ${fn_cfgmap}-1 --env python --code cfgmap.py --configmap ${fn_cfgmap} --executortype newdeploy
|
fission fn create --name ${fn_cfgmap}-1 --env python --code cfgmap.py --configmap ${fn_cfgmap} --executortype newdeploy
|
||||||
trap "fission fn delete --name ${fn_cfgmap}-1" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function ${fn_cfgmap}-1 --url /${fn_cfgmap}-1 --method GET
|
fission route create --function ${fn_cfgmap}-1 --url /${fn_cfgmap}-1 --method GET
|
||||||
@@ -116,7 +116,6 @@ checkFunctionResponse ${fn_cfgmap}-1 'NEWVAL' 'configmap'
|
|||||||
|
|
||||||
log "testing creating a function without a secret or configmap"
|
log "testing creating a function without a secret or configmap"
|
||||||
fission function create --name ${fn} --env python --code empty.py
|
fission function create --name ${fn} --env python --code empty.py
|
||||||
trap "fission fn delete --name ${fn}" EXIT
|
|
||||||
|
|
||||||
log "Creating route"
|
log "Creating route"
|
||||||
fission route create --function ${fn} --url /${fn} --method GET
|
fission route create --function ${fn} --url /${fn} --method GET
|
||||||
@@ -135,4 +134,3 @@ fi
|
|||||||
log "test empty passed"
|
log "test empty passed"
|
||||||
|
|
||||||
log "All done."
|
log "All done."
|
||||||
trap "cleanup" EXIT
|
|
||||||
|
|||||||
Reference in New Issue
Block a user