Skip to content

Commit

Permalink
Improved travis build script
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinvaneyk committed Mar 23, 2018
1 parent f5ed948 commit 899b33f
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 100 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ data/

*.tgz
/fission-workflows-bundle
/wfcli
/wfcli
__pycache__/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cache:
apt: true
directories:
- ${HOME}/.helm/
- ${HOME}/testbin/
- /tmp/fission-workflow-ci/testbin/
- ${GOPATH}/bin/
- ${GOPATH}/pkg/

Expand Down
2 changes: 1 addition & 1 deletion build/docker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -euo pipefail
set -eo pipefail

#
# Builds all docker images. Usage docker.sh [<repo>] [<tag>]
Expand Down
1 change: 1 addition & 0 deletions charts/fission-workflows/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions cmd/fission-workflows-bundle/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/wfcli/invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var cmdInvocation = cli.Command{
Usage: "get <workflow-invocation-id> <task-invocation-id>",
Flags: []cli.Flag{
cli.DurationFlag{
Name: "history, h",
Name: "history",
Usage: "Amount history (non-active invocations) to show.",
Value: time.Duration(1) * time.Hour,
},
Expand Down
1 change: 1 addition & 0 deletions cmd/wfcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/buildtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
73 changes: 23 additions & 50 deletions test/e2e/travis-setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -euo pipefail
set -eu

. $(dirname $0)/utils.sh

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:-}" ]
Expand All @@ -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
Expand All @@ -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 ]
Expand Down Expand Up @@ -107,48 +107,21 @@ if ! helm repo list | grep fission-charts >/dev/null 2>&1 ; then
fi
helm repo update

. $(dirname $0)/cleanupsh

# 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!"
42 changes: 7 additions & 35 deletions test/e2e/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 899b33f

Please sign in to comment.