diff --git a/charts/fission-all/Chart.yaml b/charts/fission-all/Chart.yaml index 3256ce5d..f5c8fa79 100644 --- a/charts/fission-all/Chart.yaml +++ b/charts/fission-all/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: fission-all -version: 0.1.0 +version: v0.2.0-20170822 description: Fission is a fast serverless framework for Kubernetes. keywords: - fission diff --git a/charts/fission-all/templates/deployment.yaml b/charts/fission-all/templates/deployment.yaml index a635dce2..2c9212bc 100644 --- a/charts/fission-all/templates/deployment.yaml +++ b/charts/fission-all/templates/deployment.yaml @@ -172,6 +172,7 @@ spec: containers: - name: controller image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--controllerPort", "8888"] serviceAccount: fission-svc @@ -193,8 +194,9 @@ spec: containers: - name: router image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--routerPort", "8888"] + args: ["--routerPort", "8888", "--poolmgrUrl", "http://poolmgr.{{ .Release.Namespace }}"] serviceAccount: fission-svc --- @@ -230,6 +232,7 @@ spec: containers: - name: poolmgr image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--poolmgrPort", "8888", "--namespace", "{{ .Values.functionNamespace }}", "--fission-namespace", "{{ .Release.Namespace }}"] env: @@ -254,6 +257,7 @@ spec: containers: - name: kubewatcher image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--kubewatcher"] serviceAccount: fission-svc @@ -321,7 +325,7 @@ spec: containers: - name: logger image: "{{ .Values.image }}:{{ .Values.imageTag }}" - imagePullPolicy: IfNotPresent + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--logger"] volumeMounts: @@ -340,7 +344,7 @@ spec: protocol: TCP - name: fluentd image: {{ .Values.logger.fluentdImage }} - imagePullPolicy: IfNotPresent + imagePullPolicy: {{ .Values.pullPolicy }} env: - name: INFLUXDB_ADDRESS value: influxdb @@ -397,6 +401,7 @@ spec: containers: - name: timer image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--timer"] serviceAccount: fission-svc @@ -468,6 +473,7 @@ spec: containers: - name: mqtrigger image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--mqt"] env: diff --git a/charts/fission-all/values.yaml b/charts/fission-all/values.yaml index 092e1d8c..54c4f71f 100644 --- a/charts/fission-all/values.yaml +++ b/charts/fission-all/values.yaml @@ -10,16 +10,16 @@ serviceType: LoadBalancer image: fission/fission-bundle ## Image pull policy -pullPolicy: ifNotPresent +pullPolicy: IfNotPresent ## Fission image version -imageTag: nightly20170705 +imageTag: v0.2.0-20170822 ## Fission fetcher repository fetcherImage: fission/fetcher ## Fission fetcher image version -fetcherImageTag: latest +fetcherImageTag: v0.2.0-20170822 ## Port at which Fission controller service should be exposed controllerPort: 31313 diff --git a/charts/fission-core/Chart.yaml b/charts/fission-core/Chart.yaml index f66aa4c4..2c06a94d 100644 --- a/charts/fission-core/Chart.yaml +++ b/charts/fission-core/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: fission-core -version: 0.1.0 +version: v0.2.0-20170822 description: Fission is a fast serverless framework for Kubernetes. keywords: - fission diff --git a/charts/fission-core/templates/deployment.yaml b/charts/fission-core/templates/deployment.yaml index 9214bca5..13f49a1e 100644 --- a/charts/fission-core/templates/deployment.yaml +++ b/charts/fission-core/templates/deployment.yaml @@ -172,6 +172,7 @@ spec: containers: - name: controller image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--controllerPort", "8888"] serviceAccount: fission-svc @@ -193,8 +194,9 @@ spec: containers: - name: router image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--routerPort", "8888"] + args: ["--routerPort", "8888", "--poolmgrUrl", "http://poolmgr.{{ .Release.Namespace }}"] serviceAccount: fission-svc --- @@ -230,6 +232,7 @@ spec: containers: - name: poolmgr image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--poolmgrPort", "8888", "--namespace", "{{ .Values.functionNamespace }}", "--fission-namespace", "{{ .Release.Namespace }}"] env: @@ -254,6 +257,7 @@ spec: containers: - name: kubewatcher image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--kubewatcher"] serviceAccount: fission-svc @@ -275,6 +279,7 @@ spec: containers: - name: timer image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] args: ["--timer"] serviceAccount: fission-svc diff --git a/charts/fission-core/values.yaml b/charts/fission-core/values.yaml index fe674346..b7ba41c7 100644 --- a/charts/fission-core/values.yaml +++ b/charts/fission-core/values.yaml @@ -10,13 +10,16 @@ serviceType: LoadBalancer image: fission/fission-bundle ## Fission image version -imageTag: alpha20170124 +imageTag: v0.2.0-20170822 + +## Image pull policy +pullPolicy: ifNotPresent ## Fission fetcher repository fetcherImage: fission/fetcher ## Fission fetcher image version -fetcherImageTag: latest +fetcherImageTag: v0.2.0-20170822 ## Port at which Fission controller service should be exposed controllerPort: 31313 @@ -29,4 +32,4 @@ routerPort: 31314 functionNamespace: fission-function ## Set up openshift RBAC rule -openshift: false \ No newline at end of file +openshift: false diff --git a/hack/runtests.sh b/hack/runtests.sh index 943cbbd3..c13a4290 100755 --- a/hack/runtests.sh +++ b/hack/runtests.sh @@ -1,12 +1,21 @@ #!/bin/bash -# The poolmgr unit test only works with NodePort-type services for -# now. So disable it for our travis ci tests. if [ ! -f ${KUBECONFIG} ] then unset KUBECONFIG +else + K="kubectl --kubeconfig $KUBECONFIG" + if $K get configmap ok-to-destroy + then + $K get function.fission.io -o name | cut -f2 -d'/' | xargs $K delete function.fission.io + $K get environment.fission.io -o name | cut -f2 -d'/' | xargs $K delete environment.fission.io + $K get httptrigger.fission.io -o name | cut -f2 -d'/' | xargs $K delete httptrigger.fission.io + fi fi go test -v -i $(go list ./... | grep -v '/vendor/' | grep -v 'examples/go') + +# The poolmgr unit test only works with NodePort-type services for +# now. So disable it for our travis ci tests. go test -v $(go list ./... | grep -v '/vendor/' | grep -v 'examples/go' | grep -v poolmgr) diff --git a/test/build_and_test.sh b/test/build_and_test.sh index 98b2f1d2..39a99a07 100755 --- a/test/build_and_test.sh +++ b/test/build_and_test.sh @@ -11,10 +11,13 @@ fi source $(dirname $0)/test_utils.sh IMAGE=gcr.io/fission-ci/fission-bundle +FETCHER_IMAGE=gcr.io/fission-ci/fetcher TAG=test build_and_push_fission_bundle $IMAGE:$TAG +build_and_push_fetcher $FETCHER_IMAGE:$TAG + build_fission_cli -install_and_test $IMAGE $TAG +install_and_test $IMAGE $TAG $FETCHER_IMAGE $TAG diff --git a/test/test_utils.sh b/test/test_utils.sh index dfbfc9a6..2146d4e7 100755 --- a/test/test_utils.sh +++ b/test/test_utils.sh @@ -37,6 +37,20 @@ build_and_push_fission_bundle() { popd } +build_and_push_fetcher() { + image_tag=$1 + + pushd $ROOT/environments/fetcher/cmd + ./build.sh + docker build -t $image_tag . + + gcloud_login + + gcloud docker -- push $image_tag + popd +} + + build_fission_cli() { pushd $ROOT/fission go build . @@ -51,13 +65,15 @@ helm_install_fission() { id=$1 image=$2 imageTag=$3 - controllerNodeport=$4 - routerNodeport=$5 + fetcherImage=$4 + fetcherImageTag=$5 + controllerNodeport=$6 + routerNodeport=$7 ns=f-$id fns=f-func-$id - helmVars=image=$image,imageTag=$imageTag,functionNamespace=$fns,controllerPort=$controllerNodeport,routerPort=$routerNodeport,pullPolicy=alwaysPull + helmVars=image=$image,imageTag=$imageTag,fetcherImage=$fetcherImage,fetcherImageTag=$fetcherImageTag,functionNamespace=$fns,controllerPort=$controllerNodeport,routerPort=$routerNodeport,pullPolicy=Always helm_setup @@ -115,29 +131,107 @@ set_environment() { export PATH=$ROOT/fission:$PATH } +dump_function_pod_logs() { + ns=$1 + fns=$2 + + functionPods=$(kubectl -n $fns get pod -o name -l functionName) + for p in $functionPods + do + echo "--- function pod logs $p ---" + containers=$(kubectl -n $fns get $p -o jsonpath={.spec.containers[*].name}) + for c in $containers + do + echo "--- function pod logs $p: container $c ---" + kubectl -n $fns logs $p $c + echo "--- end function pod logs $p: container $c ---" + done + echo "--- end function pod logs $p ---" + done +} + +dump_fission_logs() { + ns=$1 + fns=$2 + component=$3 + + echo --- $component logs --- + kubectl -n $ns get pod -o name | grep $component | xargs kubectl -n $ns logs + echo --- end $component logs --- +} + +dump_fission_resource() { + type=$1 + echo --- All objects of type $type --- + kubectl --all-namespaces=true get $type -o yaml + echo --- End objects of type $type --- +} + +dump_fission_resources() { + dump_fission_resource function.fission.io + dump_fission_resource httptrigger.fission.io + dump_fission_resource environment.fission.io +} + +dump_logs() { + id=$1 + + ns=f-$id + fns=f-func-$id + + dump_fission_logs $ns $fns router + dump_fission_logs $ns $fns poolmgr + + dump_function_pod_logs $ns $fns + + dump_fission_resources +} + +export FAILURES=0 + run_all_tests() { + id=$1 + + export FISSION_NAMESPACE=f-$id + export FUNCTION_NAMESPACE=f-func-$id + for file in $ROOT/test/tests/test_*.sh do echo ------- Running $file ------- - $file + if $file + then + echo SUCCESS: $file + else + echo FAILED: $file + export FAILURES=$(($FAILURES+1)) + fi done } install_and_test() { image=$1 imageTag=$2 + fetcherImage=$3 + fetcherImageTag=$4 controllerPort=31234 routerPort=31235 id=$(generate_test_id) trap "helm_uninstall_fission $id" EXIT - helm_install_fission $id $image $imageTag $controllerPort $routerPort + helm_install_fission $id $image $imageTag $fetcherImage $fetcherImageTag $controllerPort $routerPort wait_for_services $id set_environment $id - run_all_tests + run_all_tests $id + + dump_logs $id + + if [ $FAILURES -ne 0 ] + then + exit 1 + fi } diff --git a/test/tests/test_node_hello_http.sh b/test/tests/test_node_hello_http.sh new file mode 100755 index 00000000..9e8caaf1 --- /dev/null +++ b/test/tests/test_node_hello_http.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -euo pipefail + +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" +fission env delete --name nodejs || true + +echo "Creating nodejs env" +fission env create --name nodejs --image fission/node-env +trap "fission env delete --name nodejs" EXIT + +echo "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" +fission route create --function $fn --url /$fn --method GET + +echo "Waiting for router to catch up" +sleep 3 + +echo "Doing an HTTP GET on the function's route" +response=$(curl http://$FISSION_ROUTER/$fn) + +echo "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." diff --git a/tpr/tpr_test.go b/tpr/tpr_test.go index cda5646b..6e6b8026 100644 --- a/tpr/tpr_test.go +++ b/tpr/tpr_test.go @@ -177,7 +177,7 @@ func environmentTests(tprClient *rest.RESTClient) { el, err := ei.List(api.ListOptions{}) panicIf(err) if len(el.Items) != 1 { - log.Panicf("wrong count from list: %v", el) + log.Panicf("wrong count from list: %v", len(el.Items)) } if el.Items[0].Spec.Runtime.Image != environment.Spec.Runtime.Image { log.Panicf("bad object from list: %v", el.Items[0])