Addressing review comments.
This commit is contained in:
@@ -18,9 +18,25 @@ package fission
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime/debug"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func UrlForFunction(name string) string {
|
||||
prefix := "/fission-function"
|
||||
return fmt.Sprintf("%v/%v", prefix, name)
|
||||
}
|
||||
|
||||
func SetupStackTraceHandler() {
|
||||
// register signal handler for dumping stack trace.
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-c
|
||||
fmt.Println("Received SIGTERM : Dumping stack trace")
|
||||
debug.PrintStack()
|
||||
os.Exit(1)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -18,28 +18,14 @@ package controller
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime/debug"
|
||||
"syscall"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
)
|
||||
|
||||
func dumpStackTrace() {
|
||||
debug.PrintStack()
|
||||
}
|
||||
|
||||
func Start(port int) {
|
||||
// register signal handler for dumping stack trace.
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-c
|
||||
log.Println("Received SIGTERM : Dumping stack trace")
|
||||
dumpStackTrace()
|
||||
os.Exit(1)
|
||||
}()
|
||||
// setup a signal handler for SIGTERM
|
||||
fission.SetupStackTraceHandler()
|
||||
|
||||
fc, _, apiExtClient, err := crd.MakeFissionClient()
|
||||
if err != nil {
|
||||
|
||||
+2
-12
@@ -18,12 +18,9 @@ package executor
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
@@ -192,15 +189,8 @@ func dumpStackTrace() {
|
||||
// StartExecutor Starts executor and the executor components such as Poolmgr,
|
||||
// deploymgr and potential future executor types
|
||||
func StartExecutor(fissionNamespace string, functionNamespace string, port int) error {
|
||||
// register signal handler for dumping stack trace.
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-c
|
||||
log.Println("Received SIGTERM : Dumping stack trace")
|
||||
dumpStackTrace()
|
||||
os.Exit(1)
|
||||
}()
|
||||
// setup a signal handler for SIGTERM
|
||||
fission.SetupStackTraceHandler()
|
||||
|
||||
fissionClient, kubernetesClient, _, err := crd.MakeFissionClient()
|
||||
restClient := fissionClient.GetCrdClient()
|
||||
|
||||
+3
-16
@@ -45,14 +45,12 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime/debug"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
executorClient "github.com/fission/fission/executor/client"
|
||||
)
|
||||
@@ -74,20 +72,9 @@ func serve(ctx context.Context, port int, httpTriggerSet *HTTPTriggerSet, resolv
|
||||
http.ListenAndServe(url, handlers.LoggingHandler(os.Stdout, mr))
|
||||
}
|
||||
|
||||
func dumpStackTrace() {
|
||||
debug.PrintStack()
|
||||
}
|
||||
|
||||
func Start(port int, executorUrl string) {
|
||||
// register signal handler for dumping stack trace.
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-c
|
||||
log.Println("Received SIGTERM : Dumping stack trace")
|
||||
dumpStackTrace()
|
||||
os.Exit(1)
|
||||
}()
|
||||
// setup a signal handler for SIGTERM
|
||||
fission.SetupStackTraceHandler()
|
||||
|
||||
fmap := makeFunctionServiceMap(time.Minute)
|
||||
|
||||
|
||||
@@ -22,12 +22,10 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
_ "github.com/graymeta/stow/local"
|
||||
@@ -174,20 +172,9 @@ func (ss *StorageService) Start(port int) {
|
||||
log.Fatal(http.ListenAndServe(address, handlers.LoggingHandler(os.Stdout, r)))
|
||||
}
|
||||
|
||||
func dumpStackTrace() {
|
||||
debug.PrintStack()
|
||||
}
|
||||
|
||||
func RunStorageService(storageType StorageType, storagePath string, containerName string, port int, enablePruner bool) *StorageService {
|
||||
// register signal handler for dumping stack trace.
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-c
|
||||
log.Println("Received SIGTERM : Dumping stack trace")
|
||||
dumpStackTrace()
|
||||
os.Exit(1)
|
||||
}()
|
||||
// setup a signal handler for SIGTERM
|
||||
fission.SetupStackTraceHandler()
|
||||
|
||||
// initialize logger
|
||||
log.SetLevel(log.InfoLevel)
|
||||
|
||||
@@ -60,7 +60,6 @@ var (
|
||||
)
|
||||
|
||||
func MakeStowClient(storageType StorageType, storagePath string, containerName string) (*StowClient, error) {
|
||||
log.Infof("start : MakeStowClient")
|
||||
if storageType != StorageTypeLocal {
|
||||
return nil, errors.New("Storage types other than 'local' are not implemented")
|
||||
}
|
||||
@@ -105,7 +104,6 @@ func MakeStowClient(storageType StorageType, storagePath string, containerName s
|
||||
}
|
||||
stowClient.container = con
|
||||
|
||||
log.Infof("end : MakeStowClient")
|
||||
return stowClient, nil
|
||||
}
|
||||
|
||||
|
||||
+13
-10
@@ -174,8 +174,11 @@ helm_install_fission() {
|
||||
echo "Deleting old releases"
|
||||
helm list -q|xargs -I@ bash -c "helm_uninstall_fission @"
|
||||
|
||||
# deleting ns does take a while after command is issued.
|
||||
sleep 45
|
||||
# deleting ns does take a while after command is issued
|
||||
while `kubectl get ns| grep fission-builder`
|
||||
do
|
||||
sleep 5
|
||||
done
|
||||
|
||||
echo "Installing fission"
|
||||
helm install \
|
||||
@@ -352,7 +355,7 @@ dump_env_pods() {
|
||||
|
||||
describe_pods_ns() {
|
||||
echo "--- describe pods $1---"
|
||||
kubect describe pods -n $1
|
||||
kubectl describe pods -n $1
|
||||
echo "--- End describe pods $1 ---"
|
||||
}
|
||||
|
||||
@@ -405,11 +408,11 @@ dump_logs() {
|
||||
dump_fission_crds
|
||||
}
|
||||
|
||||
echo_log() {
|
||||
log() {
|
||||
echo `date +%Y/%m/%d:%H:%M:%S`" $1"
|
||||
}
|
||||
|
||||
export -f echo_log
|
||||
export -f log
|
||||
export FAILURES=0
|
||||
|
||||
run_all_tests() {
|
||||
@@ -464,9 +467,9 @@ install_and_test() {
|
||||
trap "helm_uninstall_fission $id" EXIT
|
||||
if ! helm_install_fission $id $image $imageTag $fetcherImage $fetcherImageTag $controllerPort $routerPort $fluentdImage $fluentdImageTag $pruneInterval
|
||||
then
|
||||
describe_all_pods $id
|
||||
dump_kubernetes_events $id
|
||||
dump_tiller_logs
|
||||
describe_all_pods $id
|
||||
dump_kubernetes_events $id
|
||||
dump_tiller_logs
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -481,8 +484,8 @@ install_and_test() {
|
||||
|
||||
if [ $FAILURES -ne 0 ]
|
||||
then
|
||||
# describe each pod in fission ns and function namespace
|
||||
describe_all_pods $id
|
||||
# describe each pod in fission ns and function namespace
|
||||
describe_all_pods $id
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ cleanup() {
|
||||
}
|
||||
|
||||
create_archive() {
|
||||
echo_log "Creating an archive"
|
||||
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_log "Creating package"
|
||||
log "Creating package"
|
||||
pkg=$(fission package create --deploy "test-deploy-pkg.zip" --env python| cut -f2 -d' '| tr -d \')
|
||||
}
|
||||
|
||||
delete_package() {
|
||||
echo_log "Deleting package: $1"
|
||||
log "Deleting package: $1"
|
||||
fission package delete --name $1
|
||||
}
|
||||
|
||||
get_archive_url_from_package() {
|
||||
echo_log "Getting archive URL from package: $1"
|
||||
log "Getting archive URL from package: $1"
|
||||
url=`kubectl get package $1 -ojsonpath='{.spec.deployment.url}'`
|
||||
}
|
||||
|
||||
@@ -55,63 +55,63 @@ main() {
|
||||
|
||||
# create a huge archive
|
||||
create_archive
|
||||
echo_log "created archive test-deploy-pkg.zip"
|
||||
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_log "pkg: $pkg_1, archive_url : $url_1"
|
||||
log "pkg: $pkg_1, archive_url : $url_1"
|
||||
|
||||
create_package
|
||||
pkg_2=$pkg
|
||||
get_archive_url_from_package $pkg_2
|
||||
url_2=$url
|
||||
echo_log "pkg: $pkg_2, archive_url : $url_2"
|
||||
log "pkg: $pkg_2, archive_url : $url_2"
|
||||
|
||||
# delete packages
|
||||
delete_package $pkg_1
|
||||
delete_package $pkg_2
|
||||
echo_log "deleted packages : $pkg_1 $pkg_2"
|
||||
log "deleted packages : $pkg_1 $pkg_2"
|
||||
|
||||
# curl on the archive url
|
||||
get_archive_from_storage $url_1
|
||||
echo_log "http_status for $url_1 : $http_status"
|
||||
log "http_status for $url_1 : $http_status"
|
||||
if [ "$http_status" -ne "200" ]; then
|
||||
echo_log "Archive $url_1 absent on storage, while expected to be present"
|
||||
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_log "http_status for $url_2 : $http_status"
|
||||
log "http_status for $url_2 : $http_status"
|
||||
if [ "$http_status" -ne "200" ]; then
|
||||
echo_log "Archive $url_2 absent on storage, while expected to be present"
|
||||
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_log "waiting for packages to get recycled"
|
||||
log "waiting for packages to get recycled"
|
||||
sleep 120
|
||||
|
||||
# curl on the archive url
|
||||
get_archive_from_storage $url_1
|
||||
echo_log "http_status for $url_1 : $http_status"
|
||||
log "http_status for $url_1 : $http_status"
|
||||
if [ "$http_status" -ne "404" ]; then
|
||||
echo_log "Archive $url_1 should have been recycled, but curl returned $http_status, while expected status is 404."
|
||||
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_log "http_status for $url_2 : $http_status"
|
||||
log "http_status for $url_2 : $http_status"
|
||||
if [ "$http_status" -ne "404" ]; then
|
||||
echo_log "Archive $url_2 should have been recycled, but curl returned $http_status, while expected status is 404."
|
||||
log "Archive $url_2 should have been recycled, but curl returned $http_status, while expected status is 404."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo_log "Test archive pruner PASSED"
|
||||
log "Test archive pruner PASSED"
|
||||
}
|
||||
|
||||
main
|
||||
@@ -5,51 +5,51 @@ set -euo pipefail
|
||||
ROOT=$(dirname $0)/../..
|
||||
|
||||
# Create a hello world function in nodejs, test it with an http trigger
|
||||
echo_log "NewDeploy ExecutorType: Pre-test cleanup"
|
||||
log "NewDeploy ExecutorType: Pre-test cleanup"
|
||||
fission env delete --name nodejs || true
|
||||
|
||||
echo_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
|
||||
trap "fission env delete --name nodejs" EXIT
|
||||
|
||||
# TODO Imporve test code by reusing common blocks
|
||||
|
||||
echo_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)
|
||||
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_log "Creating route"
|
||||
log "Creating route"
|
||||
fission route create --function $fn0 --url /$fn0 --method GET
|
||||
|
||||
echo_log "Waiting for router & newdeploy deployment creation"
|
||||
log "Waiting for router & newdeploy deployment creation"
|
||||
sleep 5
|
||||
|
||||
echo_log "Doing an HTTP GET on the function's route"
|
||||
log "Doing an HTTP GET on the function's route"
|
||||
response0=$(curl http://$FISSION_ROUTER/$fn0)
|
||||
|
||||
echo_log "Checking for valid response"
|
||||
log "Checking for valid response"
|
||||
echo $response0 | grep -i hello
|
||||
|
||||
|
||||
echo_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)
|
||||
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_log "Creating route"
|
||||
log "Creating route"
|
||||
fission route create --function $fn1 --url /$fn1 --method GET
|
||||
|
||||
echo_log "Waiting for router & newdeploy deployment creation"
|
||||
log "Waiting for router & newdeploy deployment creation"
|
||||
sleep 5
|
||||
|
||||
echo_log "Doing an HTTP GET on the function's route"
|
||||
log "Doing an HTTP GET on the function's route"
|
||||
response1=$(curl http://$FISSION_ROUTER/$fn0)
|
||||
|
||||
echo_log "Checking for valid response"
|
||||
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_log "NewDeploy ExecutorType: All done."
|
||||
log "NewDeploy ExecutorType: All done."
|
||||
@@ -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_log "Poolmgr ExecutorType: Pre-test cleanup"
|
||||
log "Poolmgr ExecutorType: Pre-test cleanup"
|
||||
fission env delete --name nodejs || true
|
||||
|
||||
echo_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
|
||||
trap "fission env delete --name nodejs" EXIT
|
||||
|
||||
echo_log "Creating function"
|
||||
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_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 "Doing an HTTP GET on the function's route"
|
||||
log "Doing an HTTP GET on the function's route"
|
||||
response=$(curl http://$FISSION_ROUTER/$fn)
|
||||
|
||||
echo_log "Checking for valid response"
|
||||
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_log "Poolmgr ExecutorType: All done."
|
||||
log "Poolmgr ExecutorType: All done."
|
||||
@@ -15,16 +15,16 @@ PYTHON_BUILDER_IMAGE=gcr.io/fission-ci/python-env-builder:test
|
||||
fn=python-srcbuild-$(date +%s)
|
||||
|
||||
checkFunctionResponse() {
|
||||
echo_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)
|
||||
|
||||
echo_log "Checking for valid response"
|
||||
echo_log $response
|
||||
log "Checking for valid response"
|
||||
log $response
|
||||
echo $response | grep -i "a: 1 b: {c: 3, d: 4}"
|
||||
}
|
||||
|
||||
waitBuild() {
|
||||
echo_log "Waiting for builder manager to finish the build"
|
||||
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_log "Waiting for env builder to catch up"
|
||||
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_log "Pre-test cleanup"
|
||||
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_log "Creating python env"
|
||||
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_log "Creating source pacakage"
|
||||
log "Creating source pacakage"
|
||||
zip -jr demo-src-pkg.zip $ROOT/examples/python/sourcepkg/
|
||||
|
||||
echo_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"
|
||||
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 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_log "Updating function " $fn
|
||||
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_log "All done."
|
||||
log "All done."
|
||||
|
||||
@@ -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_log "Pre-test cleanup"
|
||||
log "Pre-test cleanup"
|
||||
fission env delete --name nodejs || true
|
||||
|
||||
echo_log "Creating nodejs env"
|
||||
log "Creating nodejs env"
|
||||
fission env create --name nodejs --image fission/node-env
|
||||
trap "fission env delete --name nodejs" EXIT
|
||||
|
||||
echo_log "Creating function"
|
||||
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_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 10
|
||||
|
||||
echo_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/$fn)
|
||||
|
||||
echo_log "Checking for valid response"
|
||||
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_log "Updating function"
|
||||
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_log "Waiting for router to update cache"
|
||||
log "Waiting for router to update cache"
|
||||
sleep 10
|
||||
|
||||
echo_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/$fn)
|
||||
|
||||
echo_log "Checking for valid response again"
|
||||
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_log "All done."
|
||||
log "All done."
|
||||
|
||||
@@ -9,38 +9,38 @@ set -euo pipefail
|
||||
|
||||
ROOT=$(dirname $0)/../..
|
||||
|
||||
echo_log "Pre-test cleanup"
|
||||
log "Pre-test cleanup"
|
||||
fission env delete --name nodejs || true
|
||||
|
||||
echo_log "Creating nodejs env"
|
||||
log "Creating nodejs env"
|
||||
fission env create --name nodejs --image fission/node-env
|
||||
trap "fission env delete --name nodejs" EXIT
|
||||
|
||||
echo_log "Writing functions"
|
||||
log "Writing functions"
|
||||
f1=f1-$(date +%s)
|
||||
f2=f2-$(date +%s)
|
||||
echo_log $f1 $f2
|
||||
log $f1 $f2
|
||||
|
||||
for f in $f1 $f2
|
||||
do
|
||||
echo "module.exports = function(context, callback) { callback(200, \"$f\n\"); }" > $f.js
|
||||
done
|
||||
|
||||
echo_log "Creating functions"
|
||||
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_log "Waiting for router to catch up"
|
||||
log "Waiting for router to catch up"
|
||||
sleep 2
|
||||
|
||||
echo_log "Testing internal routes"
|
||||
log "Testing internal routes"
|
||||
for f in $f1 $f2
|
||||
do
|
||||
response=$(curl http://$FISSION_ROUTER/fission-function/$f)
|
||||
echo $response | grep $f
|
||||
done
|
||||
|
||||
echo_log "All done."
|
||||
log "All done."
|
||||
|
||||
@@ -8,39 +8,39 @@ ROOT=$(dirname $0)/../..
|
||||
fn=nodejs-logtest-$(date +%N)
|
||||
|
||||
function cleanup {
|
||||
echo_log "Cleanup route"
|
||||
log "Cleanup route"
|
||||
var=$(fission route list | grep $fn | awk '{print $1;}')
|
||||
fission route delete --name $var
|
||||
echo_log "delete logfile"
|
||||
log "delete logfile"
|
||||
rm "/tmp/logfile"
|
||||
}
|
||||
|
||||
# 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 nodejs || true
|
||||
|
||||
echo_log "Creating nodejs env"
|
||||
log "Creating nodejs env"
|
||||
fission env create --name nodejs --image fission/node-env
|
||||
trap "fission env delete --name nodejs" EXIT
|
||||
|
||||
echo_log "Creating function"
|
||||
log "Creating function"
|
||||
fission fn create --name $fn --env nodejs --code log.js
|
||||
trap "fission fn delete --name $fn" EXIT
|
||||
|
||||
echo_log "Creating route"
|
||||
log "Creating route"
|
||||
fission route create --function $fn --url /$fn --method GET
|
||||
trap cleanup EXIT
|
||||
|
||||
echo_log "Waiting for router to catch up"
|
||||
log "Waiting for router to catch up"
|
||||
sleep 15
|
||||
|
||||
echo_log "Doing 4 HTTP GETs on the function's route"
|
||||
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_log "Grabbing logs, should have 4 calls in logs"
|
||||
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_log "---function logs---"
|
||||
log "---function logs---"
|
||||
cat /tmp/logfile
|
||||
echo_log "------"
|
||||
log "------"
|
||||
num=$(grep 'log test' /tmp/logfile | wc -l)
|
||||
echo_log $num logs found
|
||||
log $num logs found
|
||||
|
||||
if [ $num -ne 4 ]
|
||||
then
|
||||
echo_log "Test Failed: expected 4, found $num logs"
|
||||
log "Test Failed: expected 4, found $num logs"
|
||||
fi
|
||||
|
||||
echo_log "All done."
|
||||
log "All done."
|
||||
|
||||
@@ -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_log "Pre-test cleanup"
|
||||
log "Pre-test cleanup"
|
||||
fission env delete --name nodejs || true
|
||||
|
||||
echo_log "Creating nodejs env"
|
||||
log "Creating nodejs env"
|
||||
fission env create --name nodejs --image fission/node-env
|
||||
trap "fission env delete --name nodejs" EXIT
|
||||
|
||||
echo_log "Creating function"
|
||||
log "Creating function"
|
||||
fission fn create --name $fn --env nodejs --code $ROOT/examples/nodejs/hello.js
|
||||
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 3
|
||||
|
||||
echo_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/$fn)
|
||||
|
||||
echo_log "Checking for valid response"
|
||||
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_log "All done."
|
||||
log "All done."
|
||||
|
||||
@@ -14,7 +14,7 @@ PYTHON_BUILDER_IMAGE=gcr.io/fission-ci/python-env-builder:test
|
||||
fn=python-srcbuild-$(date +%s)
|
||||
|
||||
waitBuild() {
|
||||
echo_log "Waiting for builder manager to finish the build"
|
||||
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_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)
|
||||
|
||||
echo_log "Checking for valid response"
|
||||
echo_log $response
|
||||
log "Checking for valid response"
|
||||
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_log "Waiting for env builder to catch up"
|
||||
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_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 $PYTHON_RUNTIME_IMAGE --builder $PYTHON_BUILDER_IMAGE
|
||||
trap "fission env delete --name python" EXIT
|
||||
|
||||
timeout 180s bash -c "waitEnvBuilder python"
|
||||
|
||||
echo_log "Creating pacakage with source archive"
|
||||
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_log "Creating function " $fn
|
||||
log "Creating function " $fn
|
||||
fission fn create --name $fn --pkg $pkgName --entrypoint "user.main"
|
||||
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 3
|
||||
|
||||
checkFunctionResponse $fn 'a: 1 b: {c: 3, d: 4}'
|
||||
|
||||
echo_log "Creating package with deploy archive"
|
||||
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_log "Updating function " $fn
|
||||
log "Updating function " $fn
|
||||
fission fn update --name $fn --pkg $pkgName --entrypoint "hello.main"
|
||||
trap "fission fn delete --name $fn" EXIT
|
||||
|
||||
echo_log "Waiting for router to update cache"
|
||||
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_log "All done."
|
||||
log "All done."
|
||||
|
||||
@@ -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_log "Test test, please ignore."
|
||||
log "Test test, please ignore."
|
||||
|
||||
echo_log $FISSION_URL
|
||||
echo_log $FISSION_ROUTER
|
||||
log $FISSION_URL
|
||||
log $FISSION_ROUTER
|
||||
which fission
|
||||
|
||||
@@ -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