Addressing review comments.
This commit is contained in:
@@ -15,7 +15,7 @@ cp cfgmap.py.template cfgmap.py
|
||||
sed -i "s/{{ FN_CFGMAP }}/${fn_cfgmap}/g" cfgmap.py
|
||||
|
||||
function cleanup {
|
||||
echo_log "Cleanup everything"
|
||||
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_log "Pre-test cleanup"
|
||||
log "Pre-test cleanup"
|
||||
fission env delete --name python || true
|
||||
|
||||
echo_log "Creating python env"
|
||||
log "Creating python env"
|
||||
fission env create --name python --image fission/python-env
|
||||
trap "fission env delete --name python" EXIT
|
||||
|
||||
echo_log "Creating secret"
|
||||
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_log "Creating function with secret"
|
||||
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_log "Creating route"
|
||||
log "Creating route"
|
||||
fission route create --function ${fn_secret} --url /${fn_secret} --method GET
|
||||
|
||||
echo_log "Waiting for router to catch up"
|
||||
log "Waiting for router to catch up"
|
||||
sleep 5
|
||||
|
||||
echo_log "HTTP GET on the function's route"
|
||||
log "HTTP GET on the function's route"
|
||||
res=$(curl http://${FISSION_ROUTER}/${fn_secret})
|
||||
val='TESTVALUE'
|
||||
|
||||
if [[ ${res} != ${val} ]]
|
||||
then
|
||||
echo_log "test secret failed"
|
||||
log "test secret failed"
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
echo_log "test secret passed"
|
||||
log "test secret passed"
|
||||
|
||||
echo_log "Creating configmap"
|
||||
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_log "creating function with configmap"
|
||||
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_log "Creating route"
|
||||
log "Creating route"
|
||||
fission route create --function ${fn_cfgmap} --url /${fn_cfgmap} --method GET
|
||||
|
||||
echo_log "Waiting for router to catch up"
|
||||
log "Waiting for router to catch up"
|
||||
sleep 5
|
||||
|
||||
echo_log "HTTP GET on the function's route"
|
||||
log "HTTP GET on the function's route"
|
||||
rescfg=$(curl http://${FISSION_ROUTER}/${fn_cfgmap})
|
||||
|
||||
if [ ${rescfg} != ${val} ]
|
||||
then
|
||||
echo_log "test cfgmap failed"
|
||||
log "test cfgmap failed"
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
echo_log "test configmap passed"
|
||||
log "test configmap passed"
|
||||
|
||||
echo_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
|
||||
trap "fission fn delete --name ${fn}" EXIT
|
||||
|
||||
echo_log "Creating route"
|
||||
log "Creating route"
|
||||
fission route create --function ${fn} --url /${fn} --method GET
|
||||
|
||||
echo_log "Waiting for router to catch up"
|
||||
log "Waiting for router to catch up"
|
||||
sleep 5
|
||||
|
||||
echo_log "HTTP GET on the function's route"
|
||||
log "HTTP GET on the function's route"
|
||||
resnormal=$(curl http://${FISSION_ROUTER}/${fn})
|
||||
if [ ${resnormal} != "yes" ]
|
||||
then
|
||||
echo_log "test empty failed"
|
||||
log "test empty failed"
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
echo_log "test empty passed"
|
||||
log "test empty passed"
|
||||
|
||||
echo_log "All done."
|
||||
log "All done."
|
||||
trap "cleanup" EXIT
|
||||
|
||||
Reference in New Issue
Block a user