diff --git a/.gitignore b/.gitignore index 2543051b..1622302f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ data/ *.tgz /fission-workflows-bundle -/wfcli \ No newline at end of file +/wfcli +__pycache__/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index e621f9c0..99390d0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ cache: apt: true directories: - ${HOME}/.helm/ - - ${HOME}/testbin/ + - /tmp/fission-workflow-ci/testbin/ - ${GOPATH}/bin/ - ${GOPATH}/pkg/ @@ -30,6 +30,7 @@ install: - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - sudo apt-get -y install google-cloud-sdk - sudo apt-get -y install coreutils +- test/e2e/cleanup.sh - test/e2e/travis-setup.sh # Needed for some integration tests - glide -h > /dev/null || go get github.com/Masterminds/glide diff --git a/build/docker.sh b/build/docker.sh index 2d421705..cfa72a23 100755 --- a/build/docker.sh +++ b/build/docker.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -euo pipefail +set -eo pipefail # # Builds all docker images. Usage docker.sh [] [] diff --git a/charts/fission-workflows/templates/deployment.yaml b/charts/fission-workflows/templates/deployment.yaml index 724d8cd3..d8e87376 100644 --- a/charts/fission-workflows/templates/deployment.yaml +++ b/charts/fission-workflows/templates/deployment.yaml @@ -48,6 +48,7 @@ spec: port: 8080 initialDelaySeconds: 30 periodSeconds: 5 + serviceAccount: fission-svc --- # TODO remove this service once all functionality is accessible through Fission apiVersion: v1 diff --git a/cmd/fission-workflows-bundle/bundle/bundle.go b/cmd/fission-workflows-bundle/bundle/bundle.go index d59b0d83..bdf6e8d0 100644 --- a/cmd/fission-workflows-bundle/bundle/bundle.go +++ b/cmd/fission-workflows-bundle/bundle/bundle.go @@ -79,9 +79,6 @@ func Run(ctx context.Context, opts *Options) error { es = natsEs esPub = natsEs } - if es == nil { - panic("no event store provided") - } // Caches wfiCache := getWorkflowInvocationCache(ctx, esPub) @@ -290,14 +287,14 @@ func runHttpGateway(ctx context.Context, gwSrv *http.Server, adminApiAddr string mux := grpcruntime.NewServeMux() grpcOpts := []grpc.DialOption{grpc.WithInsecure()} if adminApiAddr != "" { - err := apiserver.RegisterWorkflowAPIHandlerFromEndpoint(ctx, mux, adminApiAddr, grpcOpts) + err := apiserver.RegisterAdminAPIHandlerFromEndpoint(ctx, mux, adminApiAddr, grpcOpts) if err != nil { panic(err) } } if wfApiAddr != "" { - err := apiserver.RegisterAdminAPIHandlerFromEndpoint(ctx, mux, wfApiAddr, grpcOpts) + err := apiserver.RegisterWorkflowAPIHandlerFromEndpoint(ctx, mux, wfApiAddr, grpcOpts) if err != nil { panic(err) } diff --git a/cmd/wfcli/invocation.go b/cmd/wfcli/invocation.go index a1104c41..74eca6ce 100644 --- a/cmd/wfcli/invocation.go +++ b/cmd/wfcli/invocation.go @@ -25,7 +25,7 @@ var cmdInvocation = cli.Command{ Usage: "get ", Flags: []cli.Flag{ cli.DurationFlag{ - Name: "history, h", + Name: "history", Usage: "Amount history (non-active invocations) to show.", Value: time.Duration(1) * time.Hour, }, diff --git a/cmd/wfcli/main.go b/cmd/wfcli/main.go index 928e8ec0..4cebeb25 100644 --- a/cmd/wfcli/main.go +++ b/cmd/wfcli/main.go @@ -22,6 +22,7 @@ func main() { kubeConfig := getKubeConfigPath() localPort := setupPortForward(kubeConfig, fissionNamespace, "application=fission-api") value = "http://127.0.0.1:" + localPort + fmt.Printf("Forwarded Fission API to %s.\n", value) } else { value = fissionUrl } diff --git a/test/e2e/buildtest.sh b/test/e2e/buildtest.sh index b255c9a8..d392ed58 100755 --- a/test/e2e/buildtest.sh +++ b/test/e2e/buildtest.sh @@ -13,17 +13,22 @@ DOCKER_REPO=gcr.io/fission-ci WORKFLOWS_ENV_IMAGE=${DOCKER_REPO}/workflow-env WORKFLOWS_BUILD_ENV_IMAGE=${DOCKER_REPO}/workflow-build-env WORKFLOWS_BUNDLE_IMAGE=${DOCKER_REPO}/fission-workflows-bundle +TAG=test NS=fission NS_FUNCTION=fission-function NS_BUILDER=fission-builder fissionHelmId=fission fissionWorkflowsHelmId=fission-workflows FISSION_VERSION=0.6.0 -TAG=test TEST_STATUS=0 TEST_LOGFILE_PATH=tests.log BIN_DIR="${BIN_DIR:-$HOME/testbin}" +on_exit() { + emph "[Buildtest exited]" +} + +trap on_exit EXIT # # Build diff --git a/test/e2e/cleanup.sh b/test/e2e/cleanup.sh index ed164dd3..77aeee82 100755 --- a/test/e2e/cleanup.sh +++ b/test/e2e/cleanup.sh @@ -16,17 +16,17 @@ BIN_DIR="${BIN_DIR:-$HOME/testbin}" cleanup() { emph "Removing Fission and Fission Workflow deployments..." - helm_uninstall_release ${fissionWorkflowsHelmId} & - helm_uninstall_release ${fissionHelmId} & + helm_uninstall_release ${fissionWorkflowsHelmId} + helm_uninstall_release ${fissionHelmId} emph "Removing custom resources..." clean_tpr_crd_resources || true # Trigger deletion of all namespaces before waiting - for concurrency of deletion emph "Forcing deletion of namespaces..." - kubectl delete ns/${NS} > /dev/null 2>&1 & # Sometimes it is not deleted by helm delete - kubectl delete ns/${NS_BUILDER} > /dev/null 2>&1 & # Sometimes it is not deleted by helm delete - kubectl delete ns/${NS_FUNCTION} > /dev/null 2>&1 & # Sometimes it is not deleted by helm delete + kubectl delete ns/${NS} > /dev/null 2>&1 # Sometimes it is not deleted by helm delete + kubectl delete ns/${NS_BUILDER} > /dev/null 2>&1 # Sometimes it is not deleted by helm delete + kubectl delete ns/${NS_FUNCTION} > /dev/null 2>&1 # Sometimes it is not deleted by helm delete # Wait until all namespaces are actually deleted! emph "Awaiting deletion of namespaces..." diff --git a/test/e2e/travis-setup.sh b/test/e2e/travis-setup.sh index 4b44f857..1e7e67ce 100755 --- a/test/e2e/travis-setup.sh +++ b/test/e2e/travis-setup.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -euo pipefail +set -eu . $(dirname $0)/utils.sh @@ -9,6 +9,7 @@ HELM_VERSION=2.8.2 KUBECTL_VERSION=1.9.6 FISSION_VERSION=0.6.0 fissionHelmId=fission +fissionWorkflowsHelmId=fission-workflows NS=fission NS_FUNCTION=fission-function NS_BUILDER=fission-builder @@ -29,7 +30,6 @@ else emph "Kubectl ${KUBECTL_VERSION} already present." fi mkdir -p ${HOME}/.kube -kubectl version # Get helm binary if ! helm version 2>/dev/null | grep ${HELM_VERSION} >/dev/null; then @@ -41,8 +41,6 @@ if ! helm version 2>/dev/null | grep ${HELM_VERSION} >/dev/null; then else emph "Helm ${HELM_VERSION} already present." fi -helm version - # Setup gcloud CI if [ -z "${FISSION_WORKFLOWS_CI_SERVICE_ACCOUNT:-}" ] @@ -60,7 +58,10 @@ else fi # get kube config -gcloud container clusters get-credentials fission-workflows-ci-1 --zone us-central1-a --project fission-ci +if ! cat ${HOME}/.kube/config | grep "current-context: gke_fission-ci_us-central1-a_fission-workflows-ci-1" ; then + emph "Connecting to gcloud cluster..." + gcloud container clusters get-credentials fission-workflows-ci-1 --zone us-central1-a --project fission-ci +fi # Get Fission binary if ! fission --version 2>/dev/null | grep ${FISSION_VERSION} >/dev/null; then @@ -71,7 +72,6 @@ if ! fission --version 2>/dev/null | grep ${FISSION_VERSION} >/dev/null; then else emph "Fission ${FISSION_VERSION} already present." fi -#fission --version # Is Kubernetes setup correctly? if [ ! -f ${HOME}/.kube/config ] @@ -108,47 +108,18 @@ fi helm repo update # Check if Fission -if ! helm list | grep fission-all-${FISSION_VERSION} ; then - # Clean up existing - emph "Removing existing Fission and Fission Workflow deployments..." - helm_uninstall_release ${fissionWorkflowsHelmId} & - helm_uninstall_release ${fissionHelmId} & - - emph "Removing custom resources..." - clean_tpr_crd_resources || true - - # Trigger deletion of all namespaces before waiting - for concurrency of deletion - emph "Forcing deletion of namespaces..." - kubectl delete ns/${NS} > /dev/null 2>&1 & # Sometimes it is not deleted by helm delete - kubectl delete ns/${NS_BUILDER} > /dev/null 2>&1 & # Sometimes it is not deleted by helm delete - kubectl delete ns/${NS_FUNCTION} > /dev/null 2>&1 & # Sometimes it is not deleted by helm delete - - # Wait until all namespaces are actually deleted! - emph "Awaiting deletion of namespaces..." - retry kubectl delete ns/${NS} 2>&1 | grep -qv "Error from server (Conflict):" - retry kubectl delete ns/${NS_BUILDER} 2>&1 | grep -qv "Error from server (Conflict):" - retry kubectl delete ns/${NS_FUNCTION} 2>&1 | grep -qv "Error from server (Conflict):" - - emph "Cleaning up local filesystem..." - rm -f ./fission-workflows-bundle ./wfcli - sleep 5 - - # Deploy Fission - # TODO use test specific namespace - emph "Deploying Fission: helm chart '${fissionHelmId}' in namespace '${NS}'..." - controllerPort=31234 - routerPort=31235 - helm_install_fission ${fissionHelmId} ${NS} ${FISSION_VERSION} \ - "controllerPort=${controllerPort},routerPort=${routerPort},pullPolicy=Always,analytics=false" - - # Wait for Fission to get ready - emph "Waiting for fission to be ready..." - sleep 5 - retry fission fn list - echo - emph "Fission deployed!" -else - emph "Reusing existing Fission ${FISSION_VERSION} deployment" - emph "Removing custom resources..." - clean_tpr_crd_resources || true -fi +# Deploy Fission +# TODO use test specific namespace +emph "Deploying Fission: helm chart '${fissionHelmId}' in namespace '${NS}'..." +controllerPort=31234 +routerPort=31235 +helm_install_fission ${fissionHelmId} ${NS} ${FISSION_VERSION} \ + "controllerPort=${controllerPort},routerPort=${routerPort},pullPolicy=Always,analytics=false" + +# Wait for Fission to get ready +emph "Waiting for fission to be ready..." +sleep 5 +retry fission fn list +echo +fission --version +emph "Fission deployed!" diff --git a/test/e2e/utils.sh b/test/e2e/utils.sh index 84206553..2bc47279 100644 --- a/test/e2e/utils.sh +++ b/test/e2e/utils.sh @@ -27,43 +27,15 @@ gcloud_login() { } generate_test_id() { - echo $(date|md5sum|cut -c1-6) || echo $(date|md5|cut -c1-6) -} - -set_environment() { - ns=$1 - port=$2 - -# export FISSION_ROUTER=$(kubectl -n ${ns} get svc router -o jsonpath='{...ip}') - - # Port forawrd the router to the local port which is the default of the `fission` - kubectl get pods -l svc="router" -o name --namespace $ns | \ - sed 's/^.*\///' | \ - xargs -I{} kubectl port-forward {} $port:$port -n $ns & - - export FISSION_ROUTER="127.0.0.1:{$port}" + if command md5sum 2>/dev/null ; then + # Linux + date|md5sum|cut -c1-6 + else + # Mac OS X + date|md5|cut -c1-6 + fi } -#run_all_tests() { -# id=$1 -# -# export FISSION_NAMESPACE=f-${id} -# export FUNCTION_NAMESPACE=f-func-${id} -# -# for file in ${ROOT}/test/tests/test_* -# do -# TEST_ID=$(generate_test_id) -# echo ------- Running ${file} ------- -# if ${file} -# then -# echo SUCCESS: ${file} -# else -# echo FAILED: ${file} -# export FAILURES=$(($FAILURES+1)) -# fi -# done -#} - dump_all_resources_in_ns() { ns=$1