Added describe pods in case of integration test failures.

This commit is contained in:
smruthi2187
2018-02-08 13:58:44 -08:00
parent bce45d6d25
commit a98370ca63
12 changed files with 163 additions and 139 deletions
+24
View File
@@ -352,6 +352,23 @@ dump_env_pods() {
echo --- End environment 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() { dump_all_fission_resources() {
ns=$1 ns=$1
@@ -389,6 +406,11 @@ dump_logs() {
dump_fission_crds dump_fission_crds
} }
DATE='date +%Y/%m/%d:%H:%M:%S'
echo_log() {
echo `$DATE`" $1"
}
export FAILURES=0 export FAILURES=0
run_all_tests() { run_all_tests() {
@@ -460,6 +482,8 @@ install_and_test() {
if [ $FAILURES -ne 0 ] if [ $FAILURES -ne 0 ]
then then
# describe each pod in fission ns and function namespace
exit 1 exit 1
fi fi
} }
+21 -21
View File
@@ -16,7 +16,7 @@ cleanup() {
} }
create_archive() { create_archive() {
echo "Creating an archive" echo_log "Creating an archive"
mkdir test_dir mkdir test_dir
dd if=/dev/urandom of=test_dir/dynamically_generated_file bs=256k count=1 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 printf 'def main():\n return "Hello, world!"' > test_dir/hello.py
@@ -24,17 +24,17 @@ create_archive() {
} }
create_package() { 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 \') pkg=$(fission package create --deploy "test-deploy-pkg.zip" --env python| cut -f2 -d' '| tr -d \')
} }
delete_package() { delete_package() {
echo "Deleting package: $1" echo_log "Deleting package: $1"
fission package delete --name $1 fission package delete --name $1
} }
get_archive_url_from_package() { 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}'` 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` http_status=`curl -sw "%{http_code}" $1 -o /tmp/file`
} }
#1. declare trap to cleanup for all the required signals #1. declare trap to cleanup for EXIT
#2. create an archives with large files such that total size of archive is > 256KB #2. create an archive with large files such that total size of archive is > 256KB
#3. create 2 pkgs referencing those archives #3. create 2 pkgs referencing those archives
#4. delete both the packages #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. #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 #6. sleep for two minutes
#7. now verify that both get deleted. #7. now verify that both got deleted.
main() { main() {
# trap # trap
trap cleanup EXIT trap cleanup EXIT
# create a huge archive # create a huge archive
create_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 packages with the huge archive
create_package create_package
pkg_1=$pkg pkg_1=$pkg
get_archive_url_from_package $pkg_1 get_archive_url_from_package $pkg_1
url_1=$url url_1=$url
echo "pkg: $pkg_1, archive_url : $url_1" echo_log "pkg: $pkg_1, archive_url : $url_1"
create_package create_package
pkg_2=$pkg pkg_2=$pkg
get_archive_url_from_package $pkg_2 get_archive_url_from_package $pkg_2
url_2=$url url_2=$url
echo "pkg: $pkg_2, archive_url : $url_2" echo_log "pkg: $pkg_2, archive_url : $url_2"
# delete packages # delete packages
delete_package $pkg_1 delete_package $pkg_1
delete_package $pkg_2 delete_package $pkg_2
echo "deleted packages : $pkg_1 $pkg_2" echo_log "deleted packages : $pkg_1 $pkg_2"
# curl on the archive url # curl on the archive url
get_archive_from_storage $url_1 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 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 exit 1
fi fi
# curl on the archive url # curl on the archive url
get_archive_from_storage $url_2 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 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 exit 1
fi fi
# archivePruner is set to run every minute for test. In production, its set to run every hour. # 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 sleep 120
# curl on the archive url # curl on the archive url
get_archive_from_storage $url_1 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 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 exit 1
fi fi
# curl on the archive url # curl on the archive url
get_archive_from_storage $url_2 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 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 exit 1
fi fi
echo "Test archive pruner PASSED" echo_log "Test archive pruner PASSED"
} }
main main
+13 -13
View File
@@ -5,51 +5,51 @@ set -euo pipefail
ROOT=$(dirname $0)/../.. ROOT=$(dirname $0)/../..
# 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
echo "NewDeploy ExecutorType: Pre-test cleanup" echo_log "NewDeploy ExecutorType: Pre-test cleanup"
fission env delete --name nodejs || true 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 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
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) 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
echo "Creating route" echo_log "Creating route"
fission route create --function $fn0 --url /$fn0 --method GET 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 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) response0=$(curl http://$FISSION_ROUTER/$fn0)
echo "Checking for valid response" echo_log "Checking for valid response"
echo $response0 | grep -i hello 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) 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
echo "Creating route" echo_log "Creating route"
fission route create --function $fn1 --url /$fn1 --method GET 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 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) response1=$(curl http://$FISSION_ROUTER/$fn0)
echo "Checking for valid response" echo_log "Checking for valid response"
echo $response1 | grep -i hello 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
echo "NewDeploy ExecutorType: All done." echo_log "NewDeploy ExecutorType: All done."
+8 -8
View File
@@ -7,30 +7,30 @@ ROOT=$(dirname $0)/../..
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
echo "Poolmgr ExecutorType: Pre-test cleanup" echo_log "Poolmgr ExecutorType: Pre-test cleanup"
fission env delete --name nodejs || true 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 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
echo "Creating function" echo_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 trap "fission fn delete --name $fn" EXIT
echo "Creating route" echo_log "Creating route"
fission route create --function $fn --url /$fn --method GET 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 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) response=$(curl http://$FISSION_ROUTER/$fn)
echo "Checking for valid response" echo_log "Checking for valid response"
echo $response | grep -i hello 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
echo "Poolmgr ExecutorType: All done." echo_log "Poolmgr ExecutorType: All done."
+13 -13
View File
@@ -15,16 +15,16 @@ PYTHON_BUILDER_IMAGE=gcr.io/fission-ci/python-env-builder:test
fn=python-srcbuild-$(date +%s) fn=python-srcbuild-$(date +%s)
checkFunctionResponse() { 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) response=$(curl http://$FISSION_ROUTER/$1)
echo "Checking for valid response" echo_log "Checking for valid response"
echo $response echo_log $response
echo $response | grep -i "a: 1 b: {c: 3, d: 4}" echo $response | grep -i "a: 1 b: {c: 3, d: 4}"
} }
waitBuild() { waitBuild() {
echo "Waiting for builder manager to finish the build" echo_log "Waiting for builder manager to finish the build"
while true; do while true; do
kubectl --namespace default get packages $1 -o jsonpath='{.status.buildstatus}'|grep succeeded kubectl --namespace default get packages $1 -o jsonpath='{.status.buildstatus}'|grep succeeded
@@ -39,7 +39,7 @@ waitEnvBuilder() {
env=$1 env=$1
envRV=$(kubectl -n default get environments ${env} -o jsonpath='{.metadata.resourceVersion}') 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 while true; do
kubectl -n fission-builder get pod -l envName=${env},envResourceVersion=${envRV} \ kubectl -n fission-builder get pod -l envName=${env},envResourceVersion=${envRV} \
@@ -51,27 +51,27 @@ waitEnvBuilder() {
} }
export -f waitEnvBuilder export -f waitEnvBuilder
echo "Pre-test cleanup" echo_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
echo "Creating python env" echo_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 trap "fission env delete --name python" EXIT
timeout 180s bash -c "waitEnvBuilder python" 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/ 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" 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 trap "fission fn delete --name $fn" EXIT
echo "Creating route" echo_log "Creating route"
fission route create --function $fn --url /$fn --method GET 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 sleep 3
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}')
@@ -81,7 +81,7 @@ timeout 60s bash -c "waitBuild $pkg"
checkFunctionResponse $fn checkFunctionResponse $fn
echo "Updating function " $fn echo_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 trap "fission fn delete --name $fn" EXIT
@@ -95,4 +95,4 @@ checkFunctionResponse $fn
# 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
echo "All done." echo_log "All done."
+12 -12
View File
@@ -10,28 +10,28 @@ fn=nodejs-hello-$(date +%s)
# 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.
echo "Pre-test cleanup" echo_log "Pre-test cleanup"
fission env delete --name nodejs || true fission env delete --name nodejs || true
echo "Creating nodejs env" echo_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 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 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 trap "fission fn delete --name $fn" EXIT
echo "Creating route" echo_log "Creating route"
fission route create --function $fn --url /$fn --method GET 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 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) response=$(curl http://$FISSION_ROUTER/$fn)
echo "Checking for valid response" echo_log "Checking for valid response"
echo $response | grep -i foo echo $response | grep -i foo
# Running a background process to keep access the # 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 & ( watch -n1 curl http://$FISSION_ROUTER/$fn ) > /dev/null 2>&1 &
pid=$! pid=$!
echo "Updating function" echo_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 trap "fission fn delete --name $fn" EXIT
echo "Waiting for router to update cache" echo_log "Waiting for router to update cache"
sleep 10 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) response=$(curl http://$FISSION_ROUTER/$fn)
echo "Checking for valid response again" echo_log "Checking for valid response again"
echo $response | grep -i bar echo $response | grep -i bar
kill -15 $pid kill -15 $pid
@@ -59,4 +59,4 @@ kill -15 $pid
# 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
echo "All done." echo_log "All done."
+8 -8
View File
@@ -9,38 +9,38 @@ set -euo pipefail
ROOT=$(dirname $0)/../.. ROOT=$(dirname $0)/../..
echo "Pre-test cleanup" echo_log "Pre-test cleanup"
fission env delete --name nodejs || true fission env delete --name nodejs || true
echo "Creating nodejs env" echo_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 trap "fission env delete --name nodejs" EXIT
echo "Writing functions" echo_log "Writing functions"
f1=f1-$(date +%s) f1=f1-$(date +%s)
f2=f2-$(date +%s) f2=f2-$(date +%s)
echo $f1 $f2 echo_log $f1 $f2
for f in $f1 $f2 for f in $f1 $f2
do do
echo "module.exports = function(context, callback) { callback(200, \"$f\n\"); }" > $f.js echo "module.exports = function(context, callback) { callback(200, \"$f\n\"); }" > $f.js
done done
echo "Creating functions" echo_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 trap "fission fn delete --name $f" EXIT
done done
echo "Waiting for router to catch up" echo_log "Waiting for router to catch up"
sleep 2 sleep 2
echo "Testing internal routes" echo_log "Testing internal routes"
for f in $f1 $f2 for f in $f1 $f2
do do
response=$(curl http://$FISSION_ROUTER/fission-function/$f) response=$(curl http://$FISSION_ROUTER/fission-function/$f)
echo $response | grep $f echo $response | grep $f
done done
echo "All done." echo_log "All done."
+14 -14
View File
@@ -8,39 +8,39 @@ ROOT=$(dirname $0)/../..
fn=nodejs-logtest-$(date +%N) fn=nodejs-logtest-$(date +%N)
function cleanup { function cleanup {
echo "Cleanup route" echo_log "Cleanup route"
var=$(fission route list | grep $fn | awk '{print $1;}') var=$(fission route list | grep $fn | awk '{print $1;}')
fission route delete --name $var fission route delete --name $var
echo "delete logfile" echo_log "delete logfile"
rm "/tmp/logfile" rm "/tmp/logfile"
} }
# 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
echo "Pre-test cleanup" echo_log "Pre-test cleanup"
fission env delete --name nodejs || true fission env delete --name nodejs || true
echo "Creating nodejs env" echo_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 trap "fission env delete --name nodejs" EXIT
echo "Creating function" echo_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 trap "fission fn delete --name $fn" EXIT
echo "Creating route" echo_log "Creating route"
fission route create --function $fn --url /$fn --method GET fission route create --function $fn --url /$fn --method GET
trap cleanup EXIT trap cleanup EXIT
echo "Waiting for router to catch up" echo_log "Waiting for router to catch up"
sleep 15 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 for i in 1 2 3 4
do do
curl -s http://$FISSION_ROUTER/$fn curl -s http://$FISSION_ROUTER/$fn
done done
echo "Grabbing logs, should have 4 calls in logs" echo_log "Grabbing logs, should have 4 calls in logs"
sleep 15 sleep 15
@@ -52,15 +52,15 @@ then
fission function logs --name $fn --detail > /tmp/logfile fission function logs --name $fn --detail > /tmp/logfile
fi fi
echo "---function logs---" echo_log "---function logs---"
cat /tmp/logfile cat /tmp/logfile
echo "------" echo_log "------"
num=$(grep 'log test' /tmp/logfile | wc -l) num=$(grep 'log test' /tmp/logfile | wc -l)
echo $num logs found echo_log $num logs found
if [ $num -ne 4 ] if [ $num -ne 4 ]
then then
echo "Test Failed: expected 4, found $num logs" echo_log "Test Failed: expected 4, found $num logs"
fi fi
echo "All done." echo_log "All done."
+8 -8
View File
@@ -7,30 +7,30 @@ ROOT=$(dirname $0)/../..
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
echo "Pre-test cleanup" echo_log "Pre-test cleanup"
fission env delete --name nodejs || true fission env delete --name nodejs || true
echo "Creating nodejs env" echo_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 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 fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js
trap "fission fn delete --name $fn" EXIT trap "fission fn delete --name $fn" EXIT
echo "Creating route" echo_log "Creating route"
fission route create --function $fn --url /$fn --method GET 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 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) response=$(curl http://$FISSION_ROUTER/$fn)
echo "Checking for valid response" echo_log "Checking for valid response"
echo $response | grep -i hello 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
echo "All done." echo_log "All done."
+15 -15
View File
@@ -14,7 +14,7 @@ PYTHON_BUILDER_IMAGE=gcr.io/fission-ci/python-env-builder:test
fn=python-srcbuild-$(date +%s) fn=python-srcbuild-$(date +%s)
waitBuild() { waitBuild() {
echo "Waiting for builder manager to finish the build" echo_log "Waiting for builder manager to finish the build"
while true; do while true; do
kubectl --namespace default get packages $1 -o jsonpath='{.status.buildstatus}'|grep succeeded kubectl --namespace default get packages $1 -o jsonpath='{.status.buildstatus}'|grep succeeded
@@ -26,11 +26,11 @@ waitBuild() {
export -f waitBuild export -f waitBuild
checkFunctionResponse() { 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) response=$(curl http://$FISSION_ROUTER/$1)
echo "Checking for valid response" echo_log "Checking for valid response"
echo $response echo_log $response
echo $response | grep -i "$2" echo $response | grep -i "$2"
} }
@@ -38,7 +38,7 @@ waitEnvBuilder() {
env=$1 env=$1
envRV=$(kubectl -n default get environments ${env} -o jsonpath='{.metadata.resourceVersion}') 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 while true; do
kubectl -n fission-builder get pod -l envName=${env},envResourceVersion=${envRV} \ kubectl -n fission-builder get pod -l envName=${env},envResourceVersion=${envRV} \
@@ -50,46 +50,46 @@ waitEnvBuilder() {
} }
export -f waitEnvBuilder export -f waitEnvBuilder
echo "Pre-test cleanup" echo_log "Pre-test cleanup"
fission env delete --name python || true 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 fission env create --name python --image $PYTHON_RUNTIME_IMAGE --builder $PYTHON_BUILDER_IMAGE
trap "fission env delete --name python" EXIT trap "fission env delete --name python" EXIT
timeout 180s bash -c "waitEnvBuilder python" 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/ 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 \') 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 # wait for build to finish at most 60s
timeout 60s bash -c "waitBuild $pkgName" 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" fission fn create --name $fn --pkg $pkgName --entrypoint "user.main"
trap "fission fn delete --name $fn" EXIT trap "fission fn delete --name $fn" EXIT
echo "Creating route" echo_log "Creating route"
fission route create --function $fn --url /$fn --method GET 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 sleep 3
checkFunctionResponse $fn 'a: 1 b: {c: 3, d: 4}' checkFunctionResponse $fn 'a: 1 b: {c: 3, d: 4}'
echo "Creating package with deploy archive" echo_log "Creating package with deploy archive"
mkdir testDir mkdir testDir
touch testDir/__init__.py touch testDir/__init__.py
printf 'def main():\n return "Hello, world!"' > testDir/hello.py printf 'def main():\n return "Hello, world!"' > testDir/hello.py
zip -jr demo-deploy-pkg.zip testDir/ zip -jr demo-deploy-pkg.zip testDir/
pkgName=$(fission package create --deploy demo-deploy-pkg.zip --env python| cut -f2 -d' '| tr -d \') 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" fission fn update --name $fn --pkg $pkgName --entrypoint "hello.main"
trap "fission fn delete --name $fn" EXIT trap "fission fn delete --name $fn" EXIT
echo "Waiting for router to update cache" echo_log "Waiting for router to update cache"
sleep 3 sleep 3
checkFunctionResponse $fn 'Hello, world!' checkFunctionResponse $fn 'Hello, world!'
@@ -97,4 +97,4 @@ checkFunctionResponse $fn 'Hello, world!'
# 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
echo "All done." echo_log "All done."
+3 -3
View File
@@ -5,8 +5,8 @@ set -euo pipefail
# This doesn't test fission, just the test framework. It ensures we # This doesn't test fission, just the test framework. It ensures we
# have the right environment, that's all. # have the right environment, that's all.
echo "Test test, please ignore." echo_log "Test test, please ignore."
echo $FISSION_URL echo_log $FISSION_URL
echo $FISSION_ROUTER echo_log $FISSION_ROUTER
which fission which fission
@@ -15,7 +15,7 @@ cp cfgmap.py.template cfgmap.py
sed -i "s/{{ FN_CFGMAP }}/${fn_cfgmap}/g" cfgmap.py sed -i "s/{{ FN_CFGMAP }}/${fn_cfgmap}/g" cfgmap.py
function cleanup { function cleanup {
echo "Cleanup everything" echo_log "Cleanup everything"
kubectl delete secret -n default ${fn_secret} kubectl delete secret -n default ${fn_secret}
kubectl delete configmap -n default ${fn_cfgmap} kubectl delete configmap -n default ${fn_cfgmap}
fission function delete --name ${fn_secret} 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 # 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 fission env delete --name python || true
echo "Creating python env" echo_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 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 kubectl create secret generic ${fn_secret} --from-literal=TEST_KEY="TESTVALUE" -n default
trap "kubectl delete secret ${fn_secret} -n default" EXIT 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} fission fn create --name ${fn_secret} --env python --code secret.py --secret ${fn_secret}
trap "fission fn delete --name ${fn_secret}" EXIT 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 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 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}) res=$(curl http://${FISSION_ROUTER}/${fn_secret})
val='TESTVALUE' val='TESTVALUE'
if [[ ${res} != ${val} ]] if [[ ${res} != ${val} ]]
then then
echo "test secret failed" echo_log "test secret failed"
cleanup cleanup
exit 1 exit 1
fi 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 kubectl create configmap ${fn_cfgmap} --from-literal=TEST_KEY=TESTVALUE -n default
trap "kubectl delete configmap ${fn_cfgmap} -n default" EXIT 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} fission fn create --name ${fn_cfgmap} --env python --code cfgmap.py --configmap ${fn_cfgmap}
trap "fission fn delete --name ${fn_cfgmap}" EXIT 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 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 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}) rescfg=$(curl http://${FISSION_ROUTER}/${fn_cfgmap})
if [ ${rescfg} != ${val} ] if [ ${rescfg} != ${val} ]
then then
echo "test cfgmap failed" echo_log "test cfgmap failed"
cleanup cleanup
exit 1 exit 1
fi 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 fission function create --name ${fn} --env python --code empty.py
trap "fission fn delete --name ${fn}" EXIT trap "fission fn delete --name ${fn}" EXIT
echo "Creating route" echo_log "Creating route"
fission route create --function ${fn} --url /${fn} --method GET 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 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}) resnormal=$(curl http://${FISSION_ROUTER}/${fn})
if [ ${resnormal} != "yes" ] if [ ${resnormal} != "yes" ]
then then
echo "test empty failed" echo_log "test empty failed"
cleanup cleanup
exit 1 exit 1
fi fi
echo "test empty passed" echo_log "test empty passed"
echo "All done." echo_log "All done."
trap "cleanup" EXIT trap "cleanup" EXIT