From a98370ca63586eed88e2dd588c978fde1b3817df Mon Sep 17 00:00:00 2001 From: smruthi2187 Date: Wed, 7 Feb 2018 19:08:20 -0800 Subject: [PATCH] Added describe pods in case of integration test failures. --- test/test_utils.sh | 24 ++++++++++ test/tests/test_archive_pruner.sh | 42 ++++++++-------- test/tests/test_backend_newdeploy.sh | 26 +++++----- test/tests/test_backend_poolmgr.sh | 16 +++---- test/tests/test_buildermgr.sh | 26 +++++----- test/tests/test_function_update.sh | 24 +++++----- test/tests/test_internal_routes.sh | 16 +++---- test/tests/test_logging/test_function_logs.sh | 28 +++++------ test/tests/test_node_hello_http.sh | 16 +++---- test/tests/test_package_command.sh | 30 ++++++------ test/tests/test_pass.sh | 6 +-- .../test_secret_cfgmap/test_secret_cfgmap.sh | 48 +++++++++---------- 12 files changed, 163 insertions(+), 139 deletions(-) diff --git a/test/test_utils.sh b/test/test_utils.sh index 40c40440..74e293c0 100755 --- a/test/test_utils.sh +++ b/test/test_utils.sh @@ -352,6 +352,23 @@ dump_env_pods() { echo --- End environment pods --- } +describe_pods_ns() { + echo "--- describe pods $1---" + kubect describe pods -n $1 + echo "--- End describe pods $1 ---" +} + +describe_all_pods() { + id=$1 + ns=f-$id + fns=f-func-$id + bns=fission-builder + + describe_pods_ns $ns + describe_pods_ns $fns + describe_pods_ns $bns +} + dump_all_fission_resources() { ns=$1 @@ -389,6 +406,11 @@ dump_logs() { dump_fission_crds } +DATE='date +%Y/%m/%d:%H:%M:%S' +echo_log() { + echo `$DATE`" $1" +} + export FAILURES=0 run_all_tests() { @@ -460,6 +482,8 @@ install_and_test() { if [ $FAILURES -ne 0 ] then + # describe each pod in fission ns and function namespace + exit 1 fi } diff --git a/test/tests/test_archive_pruner.sh b/test/tests/test_archive_pruner.sh index cc85ea02..611c4581 100755 --- a/test/tests/test_archive_pruner.sh +++ b/test/tests/test_archive_pruner.sh @@ -16,7 +16,7 @@ cleanup() { } create_archive() { - echo "Creating an archive" + echo_log "Creating an archive" mkdir test_dir dd if=/dev/urandom of=test_dir/dynamically_generated_file bs=256k count=1 printf 'def main():\n return "Hello, world!"' > test_dir/hello.py @@ -24,17 +24,17 @@ create_archive() { } create_package() { - echo "Creating package" + echo_log "Creating package" pkg=$(fission package create --deploy "test-deploy-pkg.zip" --env python| cut -f2 -d' '| tr -d \') } delete_package() { - echo "Deleting package: $1" + echo_log "Deleting package: $1" fission package delete --name $1 } get_archive_url_from_package() { - echo "Getting archive URL from package: $1" + echo_log "Getting archive URL from package: $1" url=`kubectl get package $1 -ojsonpath='{.spec.deployment.url}'` } @@ -42,76 +42,76 @@ get_archive_from_storage() { http_status=`curl -sw "%{http_code}" $1 -o /tmp/file` } -#1. declare trap to cleanup for all the required signals -#2. create an archives with large files such that total size of archive is > 256KB +#1. declare trap to cleanup for EXIT +#2. create an archive with large files such that total size of archive is > 256KB #3. create 2 pkgs referencing those archives #4. delete both the packages #5. verify archives are not recycled . this handles the case where archives are just created but not referenced by pkgs yet. #6. sleep for two minutes -#7. now verify that both get deleted. +#7. now verify that both got deleted. main() { # trap trap cleanup EXIT # create a huge archive create_archive - echo "created archive test-deploy-pkg.zip" + echo_log "created archive test-deploy-pkg.zip" # create packages with the huge archive create_package pkg_1=$pkg get_archive_url_from_package $pkg_1 url_1=$url - echo "pkg: $pkg_1, archive_url : $url_1" + echo_log "pkg: $pkg_1, archive_url : $url_1" create_package pkg_2=$pkg get_archive_url_from_package $pkg_2 url_2=$url - echo "pkg: $pkg_2, archive_url : $url_2" + echo_log "pkg: $pkg_2, archive_url : $url_2" # delete packages delete_package $pkg_1 delete_package $pkg_2 - echo "deleted packages : $pkg_1 $pkg_2" + echo_log "deleted packages : $pkg_1 $pkg_2" # curl on the archive url get_archive_from_storage $url_1 - echo "http_status for $url_1 : $http_status" + echo_log "http_status for $url_1 : $http_status" if [ "$http_status" -ne "200" ]; then - echo "Archive $url_1 absent on storage, while expected to be present" + echo_log "Archive $url_1 absent on storage, while expected to be present" exit 1 fi # curl on the archive url get_archive_from_storage $url_2 - echo "http_status for $url_2 : $http_status" + echo_log "http_status for $url_2 : $http_status" if [ "$http_status" -ne "200" ]; then - echo "Archive $url_2 absent on storage, while expected to be present" + echo_log "Archive $url_2 absent on storage, while expected to be present" exit 1 fi # archivePruner is set to run every minute for test. In production, its set to run every hour. - echo "waiting for packages to get recycled" + echo_log "waiting for packages to get recycled" sleep 120 # curl on the archive url get_archive_from_storage $url_1 - echo "http_status for $url_1 : $http_status" + echo_log "http_status for $url_1 : $http_status" if [ "$http_status" -ne "404" ]; then - echo "Archive $url_1 should have been recycled, but curl returned $http_status, while expected status is 404." + echo_log "Archive $url_1 should have been recycled, but curl returned $http_status, while expected status is 404." exit 1 fi # curl on the archive url get_archive_from_storage $url_2 - echo "http_status for $url_2 : $http_status" + echo_log "http_status for $url_2 : $http_status" if [ "$http_status" -ne "404" ]; then - echo "Archive $url_2 should have been recycled, but curl returned $http_status, while expected status is 404." + echo_log "Archive $url_2 should have been recycled, but curl returned $http_status, while expected status is 404." exit 1 fi - echo "Test archive pruner PASSED" + echo_log "Test archive pruner PASSED" } main \ No newline at end of file diff --git a/test/tests/test_backend_newdeploy.sh b/test/tests/test_backend_newdeploy.sh index 1ec11b70..54f90fa3 100755 --- a/test/tests/test_backend_newdeploy.sh +++ b/test/tests/test_backend_newdeploy.sh @@ -5,51 +5,51 @@ set -euo pipefail ROOT=$(dirname $0)/../.. # Create a hello world function in nodejs, test it with an http trigger -echo "NewDeploy ExecutorType: Pre-test cleanup" +echo_log "NewDeploy ExecutorType: Pre-test cleanup" fission env delete --name nodejs || true -echo "Creating nodejs env" +echo_log "Creating nodejs env" fission env create --name nodejs --image fission/node-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256 trap "fission env delete --name nodejs" EXIT # TODO Imporve test code by reusing common blocks -echo "Creating function, testing for cold start with MinScale 0" +echo_log "Creating function, testing for cold start with MinScale 0" fn0=nodejs-hello-$(date +%N) 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 -echo "Creating route" +echo_log "Creating route" fission route create --function $fn0 --url /$fn0 --method GET -echo "Waiting for router & newdeploy deployment creation" +echo_log "Waiting for router & newdeploy deployment creation" sleep 5 -echo "Doing an HTTP GET on the function's route" +echo_log "Doing an HTTP GET on the function's route" response0=$(curl http://$FISSION_ROUTER/$fn0) -echo "Checking for valid response" +echo_log "Checking for valid response" echo $response0 | grep -i hello -echo "Creating function, testing for warm start with MinScale 1" +echo_log "Creating function, testing for warm start with MinScale 1" fn1=nodejs-hello-$(date +%N) 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 -echo "Creating route" +echo_log "Creating route" fission route create --function $fn1 --url /$fn1 --method GET -echo "Waiting for router & newdeploy deployment creation" +echo_log "Waiting for router & newdeploy deployment creation" sleep 5 -echo "Doing an HTTP GET on the function's route" +echo_log "Doing an HTTP GET on the function's route" response1=$(curl http://$FISSION_ROUTER/$fn0) -echo "Checking for valid response" +echo_log "Checking for valid response" echo $response1 | grep -i hello # crappy cleanup, improve this later kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger -echo "NewDeploy ExecutorType: All done." \ No newline at end of file +echo_log "NewDeploy ExecutorType: All done." \ No newline at end of file diff --git a/test/tests/test_backend_poolmgr.sh b/test/tests/test_backend_poolmgr.sh index f6999c20..e20749b5 100755 --- a/test/tests/test_backend_poolmgr.sh +++ b/test/tests/test_backend_poolmgr.sh @@ -7,30 +7,30 @@ ROOT=$(dirname $0)/../.. fn=nodejs-hello-$(date +%N) # Create a hello world function in nodejs, test it with an http trigger -echo "Poolmgr ExecutorType: Pre-test cleanup" +echo_log "Poolmgr ExecutorType: Pre-test cleanup" fission env delete --name nodejs || true -echo "Creating nodejs env" +echo_log "Creating nodejs env" fission env create --name nodejs --image fission/node-env --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256 trap "fission env delete --name nodejs" EXIT -echo "Creating function" +echo_log "Creating function" fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js --executortype poolmgr trap "fission fn delete --name $fn" EXIT -echo "Creating route" +echo_log "Creating route" fission route create --function $fn --url /$fn --method GET -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 5 -echo "Doing an HTTP GET on the function's route" +echo_log "Doing an HTTP GET on the function's route" response=$(curl http://$FISSION_ROUTER/$fn) -echo "Checking for valid response" +echo_log "Checking for valid response" echo $response | grep -i hello # crappy cleanup, improve this later kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger -echo "Poolmgr ExecutorType: All done." \ No newline at end of file +echo_log "Poolmgr ExecutorType: All done." \ No newline at end of file diff --git a/test/tests/test_buildermgr.sh b/test/tests/test_buildermgr.sh index 6eba91be..04d89e2e 100755 --- a/test/tests/test_buildermgr.sh +++ b/test/tests/test_buildermgr.sh @@ -15,16 +15,16 @@ PYTHON_BUILDER_IMAGE=gcr.io/fission-ci/python-env-builder:test fn=python-srcbuild-$(date +%s) checkFunctionResponse() { - echo "Doing an HTTP GET on the function's route" + echo_log "Doing an HTTP GET on the function's route" response=$(curl http://$FISSION_ROUTER/$1) - echo "Checking for valid response" - echo $response + echo_log "Checking for valid response" + echo_log $response echo $response | grep -i "a: 1 b: {c: 3, d: 4}" } waitBuild() { - echo "Waiting for builder manager to finish the build" + echo_log "Waiting for builder manager to finish the build" while true; do kubectl --namespace default get packages $1 -o jsonpath='{.status.buildstatus}'|grep succeeded @@ -39,7 +39,7 @@ waitEnvBuilder() { env=$1 envRV=$(kubectl -n default get environments ${env} -o jsonpath='{.metadata.resourceVersion}') - echo "Waiting for env builder to catch up" + echo_log "Waiting for env builder to catch up" while true; do kubectl -n fission-builder get pod -l envName=${env},envResourceVersion=${envRV} \ @@ -51,27 +51,27 @@ waitEnvBuilder() { } export -f waitEnvBuilder -echo "Pre-test cleanup" +echo_log "Pre-test cleanup" 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 -echo "Creating python env" +echo_log "Creating python env" 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" -echo "Creating source pacakage" +echo_log "Creating source pacakage" zip -jr demo-src-pkg.zip $ROOT/examples/python/sourcepkg/ -echo "Creating function " $fn +echo_log "Creating function " $fn 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 -echo "Creating route" +echo_log "Creating route" fission route create --function $fn --url /$fn --method GET -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 3 pkg=$(kubectl --namespace default get functions $fn -o jsonpath='{.spec.package.packageref.name}') @@ -81,7 +81,7 @@ timeout 60s bash -c "waitBuild $pkg" checkFunctionResponse $fn -echo "Updating function " $fn +echo_log "Updating function " $fn fission fn update --name $fn --src demo-src-pkg.zip trap "fission fn delete --name $fn" EXIT @@ -95,4 +95,4 @@ checkFunctionResponse $fn # crappy cleanup, improve this later kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger -echo "All done." +echo_log "All done." diff --git a/test/tests/test_function_update.sh b/test/tests/test_function_update.sh index 2a9eeb59..98d75630 100755 --- a/test/tests/test_function_update.sh +++ b/test/tests/test_function_update.sh @@ -10,28 +10,28 @@ fn=nodejs-hello-$(date +%s) # Update it and check it's output, the output should be # different from the previous one. -echo "Pre-test cleanup" +echo_log "Pre-test cleanup" fission env delete --name nodejs || true -echo "Creating nodejs env" +echo_log "Creating nodejs env" fission env create --name nodejs --image fission/node-env trap "fission env delete --name nodejs" EXIT -echo "Creating function" +echo_log "Creating function" echo 'module.exports = function(context, callback) { callback(200, "foo!\n"); }' > foo.js fission fn create --name $fn --env nodejs --code foo.js trap "fission fn delete --name $fn" EXIT -echo "Creating route" +echo_log "Creating route" fission route create --function $fn --url /$fn --method GET -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 10 -echo "Doing an HTTP GET on the function's route" +echo_log "Doing an HTTP GET on the function's route" response=$(curl http://$FISSION_ROUTER/$fn) -echo "Checking for valid response" +echo_log "Checking for valid response" echo $response | grep -i foo # Running a background process to keep access the @@ -40,18 +40,18 @@ echo $response | grep -i foo ( watch -n1 curl http://$FISSION_ROUTER/$fn ) > /dev/null 2>&1 & pid=$! -echo "Updating function" +echo_log "Updating function" echo 'module.exports = function(context, callback) { callback(200, "bar!\n"); }' > bar.js fission fn update --name $fn --code bar.js trap "fission fn delete --name $fn" EXIT -echo "Waiting for router to update cache" +echo_log "Waiting for router to update cache" sleep 10 -echo "Doing an HTTP GET on the function's route" +echo_log "Doing an HTTP GET on the function's route" response=$(curl http://$FISSION_ROUTER/$fn) -echo "Checking for valid response again" +echo_log "Checking for valid response again" echo $response | grep -i bar kill -15 $pid @@ -59,4 +59,4 @@ kill -15 $pid # crappy cleanup, improve this later kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger -echo "All done." +echo_log "All done." diff --git a/test/tests/test_internal_routes.sh b/test/tests/test_internal_routes.sh index 3fb6a3b7..0115da53 100755 --- a/test/tests/test_internal_routes.sh +++ b/test/tests/test_internal_routes.sh @@ -9,38 +9,38 @@ set -euo pipefail ROOT=$(dirname $0)/../.. -echo "Pre-test cleanup" +echo_log "Pre-test cleanup" fission env delete --name nodejs || true -echo "Creating nodejs env" +echo_log "Creating nodejs env" fission env create --name nodejs --image fission/node-env trap "fission env delete --name nodejs" EXIT -echo "Writing functions" +echo_log "Writing functions" f1=f1-$(date +%s) f2=f2-$(date +%s) -echo $f1 $f2 +echo_log $f1 $f2 for f in $f1 $f2 do echo "module.exports = function(context, callback) { callback(200, \"$f\n\"); }" > $f.js done -echo "Creating functions" +echo_log "Creating functions" for f in $f1 $f2 do fission fn create --name $f --env nodejs --code $f.js trap "fission fn delete --name $f" EXIT done -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 2 -echo "Testing internal routes" +echo_log "Testing internal routes" for f in $f1 $f2 do response=$(curl http://$FISSION_ROUTER/fission-function/$f) echo $response | grep $f done -echo "All done." +echo_log "All done." diff --git a/test/tests/test_logging/test_function_logs.sh b/test/tests/test_logging/test_function_logs.sh index 56fed61c..d07b1ac5 100755 --- a/test/tests/test_logging/test_function_logs.sh +++ b/test/tests/test_logging/test_function_logs.sh @@ -8,39 +8,39 @@ ROOT=$(dirname $0)/../.. fn=nodejs-logtest-$(date +%N) function cleanup { - echo "Cleanup route" + echo_log "Cleanup route" var=$(fission route list | grep $fn | awk '{print $1;}') fission route delete --name $var - echo "delete logfile" + echo_log "delete logfile" rm "/tmp/logfile" } # Create a hello world function in nodejs, test it with an http trigger -echo "Pre-test cleanup" +echo_log "Pre-test cleanup" fission env delete --name nodejs || true -echo "Creating nodejs env" +echo_log "Creating nodejs env" fission env create --name nodejs --image fission/node-env trap "fission env delete --name nodejs" EXIT -echo "Creating function" +echo_log "Creating function" fission fn create --name $fn --env nodejs --code log.js trap "fission fn delete --name $fn" EXIT -echo "Creating route" +echo_log "Creating route" fission route create --function $fn --url /$fn --method GET trap cleanup EXIT -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 15 -echo "Doing 4 HTTP GETs on the function's route" +echo_log "Doing 4 HTTP GETs on the function's route" for i in 1 2 3 4 do curl -s http://$FISSION_ROUTER/$fn done -echo "Grabbing logs, should have 4 calls in logs" +echo_log "Grabbing logs, should have 4 calls in logs" sleep 15 @@ -52,15 +52,15 @@ then fission function logs --name $fn --detail > /tmp/logfile fi -echo "---function logs---" +echo_log "---function logs---" cat /tmp/logfile -echo "------" +echo_log "------" num=$(grep 'log test' /tmp/logfile | wc -l) -echo $num logs found +echo_log $num logs found if [ $num -ne 4 ] then - echo "Test Failed: expected 4, found $num logs" + echo_log "Test Failed: expected 4, found $num logs" fi -echo "All done." +echo_log "All done." diff --git a/test/tests/test_node_hello_http.sh b/test/tests/test_node_hello_http.sh index 9e8caaf1..98e4984d 100755 --- a/test/tests/test_node_hello_http.sh +++ b/test/tests/test_node_hello_http.sh @@ -7,30 +7,30 @@ ROOT=$(dirname $0)/../.. fn=nodejs-hello-$(date +%N) # Create a hello world function in nodejs, test it with an http trigger -echo "Pre-test cleanup" +echo_log "Pre-test cleanup" fission env delete --name nodejs || true -echo "Creating nodejs env" +echo_log "Creating nodejs env" fission env create --name nodejs --image fission/node-env trap "fission env delete --name nodejs" EXIT -echo "Creating function" +echo_log "Creating function" fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js trap "fission fn delete --name $fn" EXIT -echo "Creating route" +echo_log "Creating route" fission route create --function $fn --url /$fn --method GET -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 3 -echo "Doing an HTTP GET on the function's route" +echo_log "Doing an HTTP GET on the function's route" response=$(curl http://$FISSION_ROUTER/$fn) -echo "Checking for valid response" +echo_log "Checking for valid response" echo $response | grep -i hello # crappy cleanup, improve this later kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger -echo "All done." +echo_log "All done." diff --git a/test/tests/test_package_command.sh b/test/tests/test_package_command.sh index 9e1c6ee5..041dc2a9 100755 --- a/test/tests/test_package_command.sh +++ b/test/tests/test_package_command.sh @@ -14,7 +14,7 @@ PYTHON_BUILDER_IMAGE=gcr.io/fission-ci/python-env-builder:test fn=python-srcbuild-$(date +%s) waitBuild() { - echo "Waiting for builder manager to finish the build" + echo_log "Waiting for builder manager to finish the build" while true; do kubectl --namespace default get packages $1 -o jsonpath='{.status.buildstatus}'|grep succeeded @@ -26,11 +26,11 @@ waitBuild() { export -f waitBuild checkFunctionResponse() { - echo "Doing an HTTP GET on the function's route" + echo_log "Doing an HTTP GET on the function's route" response=$(curl http://$FISSION_ROUTER/$1) - echo "Checking for valid response" - echo $response + echo_log "Checking for valid response" + echo_log $response echo $response | grep -i "$2" } @@ -38,7 +38,7 @@ waitEnvBuilder() { env=$1 envRV=$(kubectl -n default get environments ${env} -o jsonpath='{.metadata.resourceVersion}') - echo "Waiting for env builder to catch up" + echo_log "Waiting for env builder to catch up" while true; do kubectl -n fission-builder get pod -l envName=${env},envResourceVersion=${envRV} \ @@ -50,46 +50,46 @@ waitEnvBuilder() { } export -f waitEnvBuilder -echo "Pre-test cleanup" +echo_log "Pre-test cleanup" fission env delete --name python || true -echo "Creating python env" +echo_log "Creating python env" 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" -echo "Creating pacakage with source archive" +echo_log "Creating pacakage with source archive" zip -jr demo-src-pkg.zip $ROOT/examples/python/sourcepkg/ pkgName=$(fission package create --src demo-src-pkg.zip --env python --buildcmd "./build.sh"| cut -f2 -d' '| tr -d \') # wait for build to finish at most 60s timeout 60s bash -c "waitBuild $pkgName" -echo "Creating function " $fn +echo_log "Creating function " $fn fission fn create --name $fn --pkg $pkgName --entrypoint "user.main" trap "fission fn delete --name $fn" EXIT -echo "Creating route" +echo_log "Creating route" fission route create --function $fn --url /$fn --method GET -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 3 checkFunctionResponse $fn 'a: 1 b: {c: 3, d: 4}' -echo "Creating package with deploy archive" +echo_log "Creating package with deploy archive" mkdir testDir touch testDir/__init__.py printf 'def main():\n return "Hello, world!"' > testDir/hello.py zip -jr demo-deploy-pkg.zip testDir/ pkgName=$(fission package create --deploy demo-deploy-pkg.zip --env python| cut -f2 -d' '| tr -d \') -echo "Updating function " $fn +echo_log "Updating function " $fn fission fn update --name $fn --pkg $pkgName --entrypoint "hello.main" trap "fission fn delete --name $fn" EXIT -echo "Waiting for router to update cache" +echo_log "Waiting for router to update cache" sleep 3 checkFunctionResponse $fn 'Hello, world!' @@ -97,4 +97,4 @@ checkFunctionResponse $fn 'Hello, world!' # crappy cleanup, improve this later kubectl get httptrigger -o name | tail -1 | cut -f2 -d'/' | xargs kubectl delete httptrigger -echo "All done." +echo_log "All done." diff --git a/test/tests/test_pass.sh b/test/tests/test_pass.sh index 94d848c1..772a4729 100755 --- a/test/tests/test_pass.sh +++ b/test/tests/test_pass.sh @@ -5,8 +5,8 @@ set -euo pipefail # This doesn't test fission, just the test framework. It ensures we # have the right environment, that's all. -echo "Test test, please ignore." +echo_log "Test test, please ignore." -echo $FISSION_URL -echo $FISSION_ROUTER +echo_log $FISSION_URL +echo_log $FISSION_ROUTER which fission diff --git a/test/tests/test_secret_cfgmap/test_secret_cfgmap.sh b/test/tests/test_secret_cfgmap/test_secret_cfgmap.sh index 20a2933e..266703dd 100755 --- a/test/tests/test_secret_cfgmap/test_secret_cfgmap.sh +++ b/test/tests/test_secret_cfgmap/test_secret_cfgmap.sh @@ -15,7 +15,7 @@ cp cfgmap.py.template cfgmap.py sed -i "s/{{ FN_CFGMAP }}/${fn_cfgmap}/g" cfgmap.py function cleanup { - echo "Cleanup everything" + echo_log "Cleanup everything" kubectl delete secret -n default ${fn_secret} kubectl delete configmap -n default ${fn_cfgmap} fission function delete --name ${fn_secret} @@ -30,84 +30,84 @@ function cleanup { } # Create a hello world function in nodejs, test it with an http trigger -echo "Pre-test cleanup" +echo_log "Pre-test cleanup" fission env delete --name python || true -echo "Creating python env" +echo_log "Creating python env" fission env create --name python --image fission/python-env trap "fission env delete --name python" EXIT -echo "Creating secret" +echo_log "Creating secret" kubectl create secret generic ${fn_secret} --from-literal=TEST_KEY="TESTVALUE" -n default trap "kubectl delete secret ${fn_secret} -n default" EXIT -echo "Creating function with secret" +echo_log "Creating function with secret" fission fn create --name ${fn_secret} --env python --code secret.py --secret ${fn_secret} trap "fission fn delete --name ${fn_secret}" EXIT -echo "Creating route" +echo_log "Creating route" fission route create --function ${fn_secret} --url /${fn_secret} --method GET -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 5 -echo "HTTP GET on the function's route" +echo_log "HTTP GET on the function's route" res=$(curl http://${FISSION_ROUTER}/${fn_secret}) val='TESTVALUE' if [[ ${res} != ${val} ]] then - echo "test secret failed" + echo_log "test secret failed" cleanup exit 1 fi -echo "test secret passed" +echo_log "test secret passed" -echo "Creating configmap" +echo_log "Creating configmap" kubectl create configmap ${fn_cfgmap} --from-literal=TEST_KEY=TESTVALUE -n default trap "kubectl delete configmap ${fn_cfgmap} -n default" EXIT -echo "creating function with configmap" +echo_log "creating function with configmap" fission fn create --name ${fn_cfgmap} --env python --code cfgmap.py --configmap ${fn_cfgmap} trap "fission fn delete --name ${fn_cfgmap}" EXIT -echo "Creating route" +echo_log "Creating route" fission route create --function ${fn_cfgmap} --url /${fn_cfgmap} --method GET -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 5 -echo "HTTP GET on the function's route" +echo_log "HTTP GET on the function's route" rescfg=$(curl http://${FISSION_ROUTER}/${fn_cfgmap}) if [ ${rescfg} != ${val} ] then - echo "test cfgmap failed" + echo_log "test cfgmap failed" cleanup exit 1 fi -echo "test configmap passed" +echo_log "test configmap passed" -echo "testing creating a function without a secret or configmap" +echo_log "testing creating a function without a secret or configmap" fission function create --name ${fn} --env python --code empty.py trap "fission fn delete --name ${fn}" EXIT -echo "Creating route" +echo_log "Creating route" fission route create --function ${fn} --url /${fn} --method GET -echo "Waiting for router to catch up" +echo_log "Waiting for router to catch up" sleep 5 -echo "HTTP GET on the function's route" +echo_log "HTTP GET on the function's route" resnormal=$(curl http://${FISSION_ROUTER}/${fn}) if [ ${resnormal} != "yes" ] then - echo "test empty failed" + echo_log "test empty failed" cleanup exit 1 fi -echo "test empty passed" +echo_log "test empty passed" -echo "All done." +echo_log "All done." trap "cleanup" EXIT