Skip to content

Commit

Permalink
chore: enable e2e basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelvillard committed Dec 4, 2018
1 parent d8edaaf commit 7a1d73b
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 69 deletions.
21 changes: 15 additions & 6 deletions .travis.yml
@@ -1,35 +1,44 @@
language: go
go:
- "1.11.x"
dist: trusty
dist: xenial
sudo: required
services:
- docker

go_import_path: github.com/ibm/openwhisk-operator

before_install:
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- ./tools/travis/start-kubeadm-dind.sh
- ./tools/travis/k8s-tools.sh
- ./tools/travis/minikube-install.sh
- ./tools/travis/bx-install.sh
- ./tools/travis/bx-setup.sh
- if [ ! -z "$RUN_DEP" ]; then curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh ; fi
- go get -v github.com/onsi/ginkgo/ginkgo

install:
- dep ensure -v
- if [ ! -z "$RUN_DEP" ]; then dep ensure -v; fi

jobs:
include:
- stage: test
script: make test
env:
- KB_VERSION=1.0.5
# - script: test/e2e/install-local.sh
- KB_VERSION=1.0.5 REMOTE_OPENWHISK=1 INSTALL_IBMCLOUD=1 INSTALL_K8S_TOOLS=1 RUN_DEP=1
# - script: test/e2e/test-install.sh
# env:
# - INSTALL_DIND=1 INSTALL_K8S_TOOLS=1
#- script: test/e2e/test.sh
# env:
# INSTALL_MINIKUBE=true
# - INSTALL_DIND=1 INSTALL_K8S_TOOLS=1
- script: test/e2e/test.sh
env:
- INSTALL_MINIKUBE=1 INSTALL_K8S_TOOLS=1
- stage: deploy
script: bash tools/travis/docker.sh
env:
- RUN_DEP=1
skip_cleanup: true
if: branch = master OR env(TRAVIS_TAG)

2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# Apache OpenWhisk Operators

[![Build Status](https://travis-ci.org/IBM/openwhisk-operator.svg?branch=master)](https://travis-ci.org/IBM/openwhisk-operator)
[![Build Status](https://travis-ci.com/IBM/openwhisk-operator.svg?branch=master)](https://travis-ci.com/IBM/openwhisk-operator)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)

This project provides a collection of Kubernetes operators for managing [Apache OpenWhisk](https://openwhisk.apache.org/) resources namely actions, packages, rules and triggers.
Expand Down
83 changes: 83 additions & 0 deletions hack/lib/object.sh
@@ -0,0 +1,83 @@
#!/usr/bin/env bash
#
# Copyright 2017-2018 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# wait for the operator to be ready
function object::wait_operator_ready() {
printf "Checking operator status .."
until [ "$(kubectl -n openwhisk-system get po | grep 'Running' | awk '{print $3}')" == "Running" ]; do
printf "."
sleep 2
done
printf $CHECKMARK
echo ""
}

# wait for resource to be online
function object::wait_resource_online() {
local kind="$1"
local name="$2"
local retries="$3"

printf "waiting for $kind $name to be online ."
local i
for i in $(seq 1 "$retries"); do
if [ "$(kubectl get $kind $name -o=jsonpath='{.status.state}')" == "Online" ]; then
printf $CHECKMARK
echo ""
return 0
fi
printf "."
sleep 2
done

printf "timeout $CROSSMARK"
echo ""
return 1
}

# wait for function to be online
function object::wait_function_online() {
local name="$1"
local retries="$2"

object::wait_resource_online "functions.openwhisk.seed.ibm.com" $name $retries
}

# wait for package to be online
function object::wait_package_online() {
local name="$1"
local retries="$2"

object::wait_resource_online "packages.openwhisk.seed.ibm.com" $name $retries
}

# wait for trigger to be online
function object::wait_trigger_online() {
local name="$1"
local retries="$2"

object::wait_resource_online "triggers.openwhisk.seed.ibm.com" $name $retries
}


# wait for rule to be online
function object::wait_rule_online() {
local name="$1"
local retries="$2"

object::wait_resource_online "rules.openwhisk.seed.ibm.com" $name $retries
}
39 changes: 39 additions & 0 deletions hack/lib/utils.sh
@@ -0,0 +1,39 @@

#!/bin/bash
#
# Copyright 2017-2018 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

COLOR_RESET="\e[00m"
COLOR_GREEN="\e[1;32m"
COLOR_RED="\e[00;31m"

BOLD=$(tput bold)
NORMAL=$(tput sgr0)

CHECKMARK="${COLOR_GREEN}${COLOR_RESET}"
CROSSMARK="${COLOR_RED}${COLOR_RESET}"

# print header in bold
function u::header() {
echo ""
echo ${BOLD}${1}${NORMAL}
}

# print test suite name
function u::testsuite() {
u::header "$1"
u::header "${BOLD}====${NORMAL}"
}
8 changes: 2 additions & 6 deletions test/e2e/install-local.sh → test/e2e/test-install.sh
Expand Up @@ -17,9 +17,5 @@

set -e

ROOT=$(realpath $(dirname ${BASH_SOURCE})/../..)

cd $ROOT

kustomize build config/crds | kubectl apply -f -
kustomize build config/default | kubectl apply -f -
# kustomize build github.com/IBM/openwhisk-operator//config/crds | kubectl apply -f -
# kustomize build github.com/IBM/openwhisk-operator//config/default | kubectl apply -f -
13 changes: 11 additions & 2 deletions test/e2e/install.sh → test/e2e/test.sh
Expand Up @@ -17,6 +17,15 @@

set -e

kustomize build github.com/IBM/openwhisk-operator//config/crds | kubectl apply -f -
kustomize build github.com/IBM/openwhisk-operator//config/default | kubectl apply -f -
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)
cd $ROOT

source hack/lib/object.sh
source hack/lib/utils.sh

u::header "installing CRDs and operator"

# kustomize build config/crds | kubectl apply -f -
# kustomize build config/default | kubectl apply -f -

# object::wait_operator_ready
4 changes: 4 additions & 0 deletions tools/travis/bx-install.sh
Expand Up @@ -17,6 +17,10 @@

set -e

if [ -z "${INSTALL_IBMCLOUD}" ]; then
exit 0
fi

echo "installing ibmcloud"
curl -fsSL https://clis.ng.bluemix.net/install/linux | sh

Expand Down
96 changes: 48 additions & 48 deletions tools/travis/bx-setup.sh
Expand Up @@ -17,61 +17,61 @@

set -e

if [ -z ${LOCAL_OPENWHISK} ]; then
if [ -z "${REMOTE_OPENWHISK}" ]; then
exit 0
fi

if [[ $BLUEMIX_API_KEY == "" ]]; then
echo "missing BLUEMIX_API_KEY. Aborting"
exit 1
fi
if [[ $BLUEMIX_API_KEY == "" ]]; then
echo "missing BLUEMIX_API_KEY. Aborting"
exit 1
fi

if [[ $BLUEMIX_ORG == "" ]]; then
echo "missing BLUEMIX_ORG. Aborting"
exit 1
fi
if [[ $BLUEMIX_ORG == "" ]]; then
echo "missing BLUEMIX_ORG. Aborting"
exit 1
fi

if [[ $BLUEMIX_SPACE == "" ]]; then
echo "missing BLUEMIX_SPACE. Aborting"
exit 1
fi
if [[ $BLUEMIX_SPACE == "" ]]; then
echo "missing BLUEMIX_SPACE. Aborting"
exit 1
fi

if [[ $BLUEMIX_REGION == "" ]]; then
echo "missing BLUEMIX_REGION. Aborting"
exit 1
fi

bx login -a api.ng.bluemix.net --apikey ${BLUEMIX_API_KEY} -o $BLUEMIX_ORG
bx account space-create $BLUEMIX_SPACE
bx target -s $BLUEMIX_SPACE
if [[ $BLUEMIX_REGION == "" ]]; then
echo "missing BLUEMIX_REGION. Aborting"
exit 1
fi

# set +e
bx login -a api.ng.bluemix.net --apikey ${BLUEMIX_API_KEY} -o $BLUEMIX_ORG
bx account space-create $BLUEMIX_SPACE
bx target -s $BLUEMIX_SPACE

actions=($(bx wsk action list))

len=${#actions[@]}
for (( i=1; i<len; i+=3 ))
do
bx wsk action delete ${actions[$i]}
done
# set +e

pkgs=($(bx wsk package list))
len=${#pkgs[@]}
for (( i=1; i<len; i+=2 ))
do
bx wsk package delete ${pkgs[$i]}
done
actions=($(bx wsk action list))

rules=($(bx wsk rule list))
len=${#rules[@]}
for (( i=1; i<len; i+=3 ))
do
bx wsk rule delete ${rules[$i]}
done
len=${#actions[@]}
for (( i=1; i<len; i+=3 ))
do
bx wsk action delete ${actions[$i]}
done

triggers=($(bx wsk trigger list))
len=${#triggers[@]}
for (( i=1; i<len; i+=2 ))
do
bx wsk trigger delete ${triggers[$i]}
done
pkgs=($(bx wsk package list))
len=${#pkgs[@]}
for (( i=1; i<len; i+=2 ))
do
bx wsk package delete ${pkgs[$i]}
done

fi
rules=($(bx wsk rule list))
len=${#rules[@]}
for (( i=1; i<len; i+=3 ))
do
bx wsk rule delete ${rules[$i]}
done

triggers=($(bx wsk trigger list))
len=${#triggers[@]}
for (( i=1; i<len; i+=2 ))
do
bx wsk trigger delete ${triggers[$i]}
done
4 changes: 4 additions & 0 deletions tools/travis/k8s-tools.sh
Expand Up @@ -17,6 +17,10 @@

set -e

if [ -z "${INSTALL_K8S_TOOLS}" ]; then
exit 0
fi

if [ -z ${KUBECTL_VERSION+x} ]; then
KUBECTL_VERSION=v1.10.0
fi
Expand Down
18 changes: 12 additions & 6 deletions tools/travis/minikube-install.sh
Expand Up @@ -17,28 +17,34 @@

set -e

if [ "${MINIKUBE_INSTALL}" != "true" ]; then
if [ -z "${INSTALL_MINIKUBE}" ]; then
exit 0
fi

if [ -z ${MINIKUBE_VERSION+x} ]; then
MINIKUBE_VERSION=latest
fi
MINIKUBE_VERSION=${MINIKUBE_VERSION:-0.30.0}
BOOTSTRAPPER=${BOOTSTRAPPER:-kubeadm}
KUBE_VERSION=${KUBE_VERSION:-1.11}

export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
export CHANGE_MINIKUBE_NONE_USER=true
export MINIKUBE_HOME=$HOME

echo "installing nsenter"
if ! which nsenter; then
curl -L https://github.com/minrk/git-crypt-bin/releases/download/trusty/nsenter > nsenter
chmod +x nsenter
sudo mv nsenter /usr/local/bin/
fi

echo "installing minikube"
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
chmod +x minikube
sudo mv minikube /usr/local/bin/

echo "starting minikube"
export KUBECONFIG=$HOME/.kube/config
sudo -E minikube start --vm-driver=none --bootstrapper=localkube --kubernetes-version=${KUBECTL_VERSION}

sudo -E minikube start --vm-driver=none --bootstrapper=${BOOTSTRAPPER} --extra-config=apiserver.authorization-mode=RBAC --kubernetes-version=${KUBECTL_VERSION}
echo "update context"
# minikube update-context

Expand Down

0 comments on commit 7a1d73b

Please sign in to comment.