Test framework improvement (#1128)
This commit is contained in:
committed by
Ta-Ching Chen
parent
1e8dfa38da
commit
c3177f9ebd
@@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Common methods used for testing function update
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
test_fn() {
|
||||
echo "Doing an HTTP GET on the function's route"
|
||||
echo "Checking for valid response"
|
||||
|
||||
while true; do
|
||||
response0=$(curl http://$FISSION_ROUTER/$1)
|
||||
echo $response0 | grep -i $2
|
||||
if [[ $? -eq 0 ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
export -f test_fn
|
||||
@@ -1,25 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
source $(dirname $0)/fnupdate_utils.sh
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
tmp_dir="/tmp/test-$TEST_ID"
|
||||
mkdir -p $tmp_dir
|
||||
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
env=python-$(date +%N)
|
||||
fn_name=hellopy-$(date +%N)
|
||||
env=python-$TEST_ID
|
||||
fn_name=hellopy-$TEST_ID
|
||||
|
||||
old_cfgmap=old-cfgmap-$(date +%N)
|
||||
new_cfgmap=new-cfgmap-$(date +%N)
|
||||
old_cfgmap=old-cfgmap-$TEST_ID
|
||||
new_cfgmap=new-cfgmap-$TEST_ID
|
||||
|
||||
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
|
||||
rm cfgmap.py || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
@@ -28,22 +29,25 @@ 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
|
||||
sed "s/{{ FN_CFGMAP }}/${old_cfgmap}/g" \
|
||||
$(dirname $0)/../test_secret_cfgmap/cfgmap.py.template \
|
||||
> $tmp_dir/cfgmap.py
|
||||
|
||||
log "Creating env $env"
|
||||
fission env create --name $env --image fission/python-env
|
||||
fission env create --name $env --image $PYTHON_RUNTIME_IMAGE
|
||||
|
||||
log "Creating configmap $old_cfgmap"
|
||||
kubectl create configmap ${old_cfgmap} --from-literal=TEST_KEY="TESTVALUE" -n default
|
||||
|
||||
log "Creating NewDeploy function spec: $fn_name"
|
||||
pushd $tmp_dir
|
||||
fission spec init
|
||||
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
|
||||
popd
|
||||
|
||||
log "Creating route"
|
||||
fission route create --function ${fn_name} --url /${fn_name} --method GET
|
||||
fission route create --name ${fn_name} --function ${fn_name} --url /${fn_name} --method GET
|
||||
|
||||
log "Waiting for router to catch up"
|
||||
sleep 5
|
||||
@@ -55,14 +59,18 @@ log "Creating a new cfgmap"
|
||||
kubectl create configmap ${new_cfgmap} --from-literal=TEST_KEY="TESTVALUE_NEW" -n default
|
||||
|
||||
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" specs/function-$fn_name.yaml
|
||||
sed -i "s/${old_cfgmap}/${new_cfgmap}/g" $tmp_dir/cfgmap.py
|
||||
sed -i "s/${old_cfgmap}/${new_cfgmap}/g" $tmp_dir/specs/function-$fn_name.yaml
|
||||
|
||||
log "Applying function changes"
|
||||
fission spec apply ./specs/
|
||||
pushd $tmp_dir
|
||||
fission spec apply
|
||||
popd
|
||||
|
||||
log "Waiting for changes to take effect"
|
||||
sleep 5
|
||||
sleep 10
|
||||
|
||||
log "Testing function for cfgmap value"
|
||||
timeout 60 bash -c "test_fn $fn_name 'TESTVALUE_NEW'"
|
||||
timeout 90 bash -c "test_fn $fn_name 'TESTVALUE_NEW'"
|
||||
|
||||
log "Test PASSED"
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
source $(dirname $0)/fnupdate_utils.sh
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
env_old=python-$(date +%N)
|
||||
env_new=python-$(date +%N)
|
||||
fn=hellopy-$(date +%N)
|
||||
env_old=python-old-$TEST_ID
|
||||
env_new=python-new-$TEST_ID
|
||||
fn=hellopy-$TEST_ID
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission env delete --name $env_old || true
|
||||
fission fn delete --name $fn || true
|
||||
fission env delete --name $env_new || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
}
|
||||
|
||||
cleanup
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
@@ -25,7 +24,7 @@ else
|
||||
fi
|
||||
|
||||
log "Creating env $env_old"
|
||||
fission env create --name $env_old --image fission/python-env
|
||||
fission env create --name $env_old --image $PYTHON_RUNTIME_IMAGE
|
||||
|
||||
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
|
||||
@@ -39,7 +38,7 @@ sleep 5
|
||||
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
|
||||
fission env create --name $env_new --image $PYTHON_RUNTIME_IMAGE
|
||||
|
||||
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
|
||||
@@ -48,3 +47,5 @@ log "Waiting for update to catch up"
|
||||
sleep 5
|
||||
|
||||
timeout 60 bash -c "test_fn $fn 'world'"
|
||||
|
||||
log "Test PASSED"
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
#test:disabled
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
source $(dirname $0)/fnupdate_utils.sh
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
env=python-$(date +%s)
|
||||
fn=hellopython-$(date +%s)
|
||||
env=python-$TEST_ID
|
||||
fn=hellopython-$TEST_ID
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission fn delete --name ${fn}-nd || true
|
||||
fission fn delete --name ${fn}-gpm || true
|
||||
fission env delete --name $env || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
}
|
||||
|
||||
cleanup
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
@@ -25,7 +22,7 @@ else
|
||||
fi
|
||||
|
||||
log "Creating Python env $env"
|
||||
fission env create --name $env --image fission/python-env --period 5
|
||||
fission env create --name $env --image $PYTHON_RUNTIME_IMAGE --period 5
|
||||
|
||||
log "Creating function ${fn}-nd, ${fn}-gpm"
|
||||
fission fn create --name ${fn}-nd --env $env --code $ROOT/examples/python/hello.py --minscale 0 --maxscale 2 --executortype newdeploy
|
||||
@@ -50,14 +47,18 @@ sleep 260
|
||||
ndDeployReplicas=$(kubectl -n $FUNCTION_NAMESPACE get deploy -l functionName=${fn}-nd -ojsonpath='{.items[0].spec.replicas}')
|
||||
if [ "$ndDeployReplicas" -ne "0" ]
|
||||
then
|
||||
log "Failed to reap idle function pod for function ${fn}-nd"
|
||||
log "Failed to reap idle function pod for function ${fn}-nd. replicas should be 0 but got $ndDeployReplicas"
|
||||
kubectl -n $FUNCTION_NAMESPACE get deploy -l functionName=${fn}-nd -o yaml
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gpmNumberOfPod=$(kubectl -n $FUNCTION_NAMESPACE get pod -l functionName=${fn}-gpm -o name|wc -l)
|
||||
set +o pipefail
|
||||
gpmNumberOfPod=$(kubectl -n $FUNCTION_NAMESPACE get pod -l functionName=${fn}-gpm | grep Running | wc -l)
|
||||
set -o pipefail
|
||||
if [ "$gpmNumberOfPod" -ne "0" ]
|
||||
then
|
||||
log "Failed to reap idle function pod for function ${fn}-gpm"
|
||||
log "Failed to reap idle function pod for function ${fn}-gpm. replicas should be 0 but got $gpmNumberOfPod"
|
||||
kubectl -n $FUNCTION_NAMESPACE get pod -l functionName=${fn}-gpm -o yaml
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -70,13 +71,19 @@ timeout 60 bash -c "test_fn ${fn}-gpm 'world'"
|
||||
ndDeployReplicas=$(kubectl -n $FUNCTION_NAMESPACE get deploy -l functionName=${fn}-nd -ojsonpath='{.items[0].spec.replicas}')
|
||||
if [ "$ndDeployReplicas" -ne "1" ]
|
||||
then
|
||||
log "Failed to reap idle function pod for function ${fn}-nd"
|
||||
log "Failed to scale function pod for function ${fn}-nd. replicas should be 1 but got $ndDeployReplicas"
|
||||
kubectl -n $FUNCTION_NAMESPACE get deploy -l functionName=${fn}-nd -o yaml
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gpmNumberOfPod=$(kubectl -n $FUNCTION_NAMESPACE get pod -l functionName=${fn}-gpm -o name|wc -l)
|
||||
set +o pipefail
|
||||
gpmNumberOfPod=$(kubectl -n $FUNCTION_NAMESPACE get pod -l functionName=${fn}-gpm | grep Running | wc -l)
|
||||
set -o pipefail
|
||||
if [ "$gpmNumberOfPod" -ne "1" ]
|
||||
then
|
||||
log "Failed to reap idle function pod for function ${fn}-gpm"
|
||||
log "Failed to scale function pod for function ${fn}-gpm. replicas should be 1 but got $gpmNumberOfPod"
|
||||
kubectl -n $FUNCTION_NAMESPACE get pod -l functionName=${fn}-gpm -o yaml
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Test PASSED"
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
# global variables
|
||||
pkg=""
|
||||
http_status=""
|
||||
url=""
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
source $(dirname $0)/fnupdate_utils.sh
|
||||
tmp_dir="/tmp/test-$TEST_ID"
|
||||
mkdir -p $tmp_dir
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
|
||||
if [ -e "test-deploy-pkg.zip" ]; then
|
||||
rm -rf test-deploy-pkg.zip test_dir || true
|
||||
fi
|
||||
if [ -e "/tmp/file" ]; then
|
||||
rm -rf /tmp/file || true
|
||||
fi
|
||||
|
||||
fission env delete --name $env || true
|
||||
fission fn delete --name $fn_name || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
@@ -33,19 +25,19 @@ fi
|
||||
# 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
|
||||
|
||||
env=python-$(date +%N)
|
||||
fn_name=hellopython-$(date +%N)
|
||||
env=python-$TEST_ID
|
||||
fn_name=hellopython-$TEST_ID
|
||||
|
||||
log "Creating an archive"
|
||||
mkdir test_dir
|
||||
printf 'def main():\n return "Hello, world!"' > test_dir/hello.py
|
||||
zip -jr test-deploy-pkg.zip test_dir/
|
||||
mkdir -p $tmp_dir/test_dir
|
||||
printf 'def main():\n return "Hello, world!"' > $tmp_dir/test_dir/hello.py
|
||||
zip -jr $tmp_dir/test-deploy-pkg.zip $tmp_dir/test_dir/
|
||||
|
||||
log "Creating environment"
|
||||
fission env create --name $env --image fission/python-env:latest --builder fission/python-builder:latest --mincpu 40 --maxcpu 80 --minmemory 64 --maxmemory 128 --poolsize 2
|
||||
fission env create --name $env --image $PYTHON_RUNTIME_IMAGE --builder $PYTHON_BUILDER_IMAGE --mincpu 40 --maxcpu 80 --minmemory 64 --maxmemory 128 --poolsize 2
|
||||
|
||||
log "Creating functiom"
|
||||
fission fn create --name $fn_name --env $env --deploy test-deploy-pkg.zip --entrypoint "hello.main" --executortype newdeploy --minscale 1 --maxscale 4 --targetcpu 50
|
||||
fission fn create --name $fn_name --env $env --deploy $tmp_dir/test-deploy-pkg.zip --entrypoint "hello.main" --executortype newdeploy --minscale 1 --maxscale 4 --targetcpu 50
|
||||
|
||||
log "Creating route"
|
||||
fission route create --function $fn_name --url /$fn_name --method GET
|
||||
@@ -56,11 +48,11 @@ sleep 5
|
||||
timeout 60 bash -c "test_fn $fn_name 'world'"
|
||||
|
||||
log "Updating the archive"
|
||||
sed -i 's/world/fission/' test_dir/hello.py
|
||||
zip -jr test-deploy-pkg.zip test_dir/
|
||||
sed -i 's/world/fission/' $tmp_dir/test_dir/hello.py
|
||||
zip -jr $tmp_dir/test-deploy-pkg.zip $tmp_dir/test_dir/
|
||||
|
||||
log "Updating function with updated package"
|
||||
fission fn update --name $fn_name --deploy test-deploy-pkg.zip --entrypoint "hello.main" --executortype newdeploy --minscale 1 --maxscale 4 --targetcpu 50
|
||||
fission fn update --name $fn_name --deploy $tmp_dir/test-deploy-pkg.zip --entrypoint "hello.main" --executortype newdeploy --minscale 1 --maxscale 4 --targetcpu 50
|
||||
|
||||
log "Waiting for deployment to update"
|
||||
sleep 5
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
source $(dirname $0)/fnupdate_utils.sh
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
env=python-$(date +%N)
|
||||
fn=hellopython-$(date +%N)
|
||||
env=python-$TEST_ID
|
||||
fn=hellopython-$TEST_ID
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission env delete --name $env || true
|
||||
fission fn delete --name $fn || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
}
|
||||
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
@@ -22,7 +23,7 @@ else
|
||||
fi
|
||||
|
||||
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 $PYTHON_RUNTIME_IMAGE --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||
|
||||
log "Creating function $fn"
|
||||
fission fn create --name $fn --env $env --code $ROOT/examples/python/hello.py
|
||||
@@ -50,3 +51,4 @@ log "Waiting for router to catch up"
|
||||
sleep 5
|
||||
|
||||
timeout 60 bash -c "test_fn $fn 'world'"
|
||||
log "Test PASSED"
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
source $(dirname $0)/fnupdate_utils.sh
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
env=python-$(date +%N)
|
||||
fn=hellopython-$(date +%N)
|
||||
env=python-$TEST_ID
|
||||
fn=hellopython-$TEST_ID
|
||||
|
||||
mincpu1=40
|
||||
maxcpu1=140
|
||||
@@ -21,11 +23,9 @@ maxmem2=768
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission env delete --name $env || true
|
||||
fission fn delete --name $fn || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
}
|
||||
|
||||
cleanup
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
@@ -33,7 +33,7 @@ else
|
||||
fi
|
||||
|
||||
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 $PYTHON_RUNTIME_IMAGE --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||
|
||||
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
|
||||
@@ -87,3 +87,4 @@ then
|
||||
fi
|
||||
|
||||
timeout 60 bash -c "test_fn $fn 'world'"
|
||||
log "Test PASSED"
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
source $(dirname $0)/fnupdate_utils.sh
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
env=python-$(date +%N)
|
||||
fn=hellopython-$(date +%N)
|
||||
env=python-$TEST_ID
|
||||
fn=hellopython-$TEST_ID
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
targetMinScale=2
|
||||
@@ -14,11 +16,9 @@ targetCpuPercent=60
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
fission env delete --name $env || true
|
||||
fission fn delete --name $fn || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
}
|
||||
|
||||
cleanup
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
@@ -26,7 +26,7 @@ else
|
||||
fi
|
||||
|
||||
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 $PYTHON_RUNTIME_IMAGE --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256
|
||||
|
||||
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
|
||||
@@ -70,3 +70,4 @@ then
|
||||
fi
|
||||
|
||||
timeout 60 bash -c "test_fn $fn 'world'"
|
||||
log "Test PASSED"
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source $(dirname $0)/../../utils.sh
|
||||
|
||||
source $(dirname $0)/fnupdate_utils.sh
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
tmp_dir="/tmp/test-$TEST_ID"
|
||||
mkdir -p $tmp_dir
|
||||
|
||||
ROOT=$(dirname $0)/../../..
|
||||
|
||||
env=python-$(date +%N)
|
||||
fn_name=hellopython-$(date +%N)
|
||||
env=python-$TEST_ID
|
||||
fn_name=hellopython-$TEST_ID
|
||||
|
||||
old_secret=old-secret-$(date +%N)
|
||||
new_secret=new-secret-$(date +%N)
|
||||
old_secret=old-secret-$TEST_ID
|
||||
new_secret=new-secret-$TEST_ID
|
||||
|
||||
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
|
||||
rm secret.py || true
|
||||
clean_resource_by_id $TEST_ID
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
@@ -28,19 +29,22 @@ else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
cp $ROOT/test/tests/test_secret_cfgmap/secret.py.template secret.py
|
||||
sed -i "s/{{ FN_SECRET }}/${old_secret}/g" secret.py
|
||||
sed "s/{{ FN_SECRET }}/${old_secret}/g" \
|
||||
$ROOT/test/tests/test_secret_cfgmap/secret.py.template \
|
||||
> $tmp_dir/secret.py
|
||||
|
||||
log "Creating env $env"
|
||||
fission env create --name $env --image fission/python-env
|
||||
fission env create --name $env --image $PYTHON_RUNTIME_IMAGE
|
||||
|
||||
log "Creating secret $old_secret"
|
||||
kubectl create secret generic ${old_secret} --from-literal=TEST_KEY="TESTVALUE" -n default
|
||||
|
||||
log "Creating NewDeploy function spec: $fn_name"
|
||||
pushd $tmp_dir
|
||||
fission spec init
|
||||
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
|
||||
popd
|
||||
|
||||
log "Creating route"
|
||||
fission route create --function ${fn_name} --url /${fn_name} --method GET
|
||||
@@ -55,14 +59,17 @@ log "Creating a new secret"
|
||||
kubectl create secret generic ${new_secret} --from-literal=TEST_KEY="TESTVALUE_NEW" -n default
|
||||
|
||||
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" specs/function-$fn_name.yaml
|
||||
sed -i "s/${old_secret}/${new_secret}/g" $tmp_dir/secret.py
|
||||
sed -i "s/${old_secret}/${new_secret}/g" $tmp_dir/specs/function-$fn_name.yaml
|
||||
|
||||
log "Applying function changes"
|
||||
fission spec apply ./specs/
|
||||
pushd $tmp_dir
|
||||
fission spec apply
|
||||
popd
|
||||
|
||||
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'"
|
||||
log "Test PASSED"
|
||||
|
||||
Reference in New Issue
Block a user