blob: fe56603cfc9a5af1fbd26dd389f9f552c429cce2 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
version: '3'
vars:
KUBE:
sh: ./detect.sh
# taken from the tag
OPERATOR_TAG:
sh: git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD
# taken from the Dockerfile - ovverdable with MY_OPERATOR_IMAGE
OPERATOR_IMAGE:
sh: awk -F= '/ARG OPERATOR_IMAGE_DEFAULT=/ { print $2 ; exit }' Dockerfile
WHISK: '{{default "whisk" .WHISK}}'
CONFIG: "tests/{{.KUBE}}/{{.WHISK}}.yaml"
REDIS_URI: "redis://s0meP%40ass4@redis:6379"
REDIS_PASSWORD: s0meP@ass4
MINIO_HOST: "nuvolaris-minio"
MINIO_PORT: 9000
MINIO_USER: "minioadmin"
MINIO_PWD : "minioadmin"
APIKUBE:
sh: kubectl config view -o json | jq -r '.clusters[0].cluster.server'
T: ""
env:
APIHOST:
sh: echo {{.APIKUBE}} | sed -e 's|^.*//\(.*\):.*$|\1|'
APIHOST_OSH:
sh: echo {{.APIKUBE}} | sed -e 's|^.*//\(.*\):.*$|\1|' | sed -e 's/^api./nuvolaris.apps./'
tasks:
kustomization:
cmds:
- |
cat <<__EOF__ >deploy/nuvolaris-operator/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: ghcr.io/nuvolaris/nuvolaris-operator:latest
newName: ${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}
newTag: {{.OPERATOR_TAG}}
resources:
- operator-pod.yaml
__EOF__
permission:
- kubectl apply -f deploy/nuvolaris-permissions
operator:
- task: kustomization
- kubectl apply -k deploy/nuvolaris-operator
- |
while ! kubectl -n nuvolaris wait --for=condition=ready pod/nuvolaris-operator
do echo still waiting...
done
destroy-operator:
- task: kustomization
- kubectl delete -k deploy/nuvolaris-operator
instance:
silent: false
cmds:
- kubectl config set-context --current --namespace nuvolaris
- >
cat tests/{{.KUBE}}/{{.WHISK}}.yaml | envsubst | kubectl apply -f -
- |
while ! kubectl -n nuvolaris wait --for=condition=ready pod/couchdb-0 2>/dev/null
do sleep 5 ; echo $((N++)) waiting couchdb...
done
- |
while ! kubectl -n nuvolaris wait --for=condition=complete job/couchdb-init 2>/dev/null
do sleep 5 ; echo $((N++)) waiting couchdb init...
done
- |
N=1
while ! kubectl -n nuvolaris wait --for=condition=ready pod/controller-0 2>/dev/null
do sleep 5 ; echo $((N++)) waiting controller...
done
destroy-instance:
- (sleep 5 ; task defin) &
- kubectl -n nuvolaris delete wsk/controller
destroy:
- task: destroy-instance
- task: destroy-operator
cleanup: kubectl -n nuvolaris delete pvc --all
config: |-
rm -f ~/.wskprops
while true
do APIHOST=$(kubectl -n nuvolaris get cm/config -o yaml | awk '/apihost:/ {print $2}')
if [[ `echo $APIHOST | grep pending` || -z "$APIHOST" ]];
then sleep 5 ; echo "$((N++)) apihost still pending..."
else break
fi
done
echo "*** $APIHOST ***"
AUTH=$(kubectl -n nuvolaris get wsk/controller -o jsonpath='{.spec.openwhisk.namespaces.nuvolaris}')
echo $AUTH
echo ops -wsk property set --apihost $APIHOST --auth $AUTH
ops -wsk property set --apihost $APIHOST --auth $AUTH
while ! ops action list
do echo $(( N++)) "waiting for the load balancer to be ready..." ; sleep 10
done
hello:
- ops -wsk -i action update hello tests/hello.js --web=true
- ops -wsk -i action invoke hello -r | grep "hello"
- |
URL=$(ops -wsk -i action get hello --url | tail +2)
curl -skL $URL | grep hello
redis:
cmds:
- ops -wsk -i package update redis -p redis_url "{{.REDIS_NUV_URL}}" -p redis_prefix "{{.REDIS_NUV_PREFIX}}" -p password "{{.REDIS_PASSWORD}}"
- ops -wsk -i action update redis/ping tests/ping.js
- ops -wsk -i action invoke redis/ping -r | grep "PONG"
- ops -wsk -i action update redis/redis tests/redis.js
- ops -wsk -i action invoke redis/redis -r | grep "world"
vars:
REDIS_NUV_PREFIX:
sh: kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.redis_prefix}'
REDIS_NUV_URL:
sh: kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.redis_url}'
echo:
- ops -wsk -i action update echo tests/echo.js -a provide-api-key true
- ops -wsk -i action invoke echo -r | grep "__OW_API_KEY"
- ops -wsk -i action invoke echo -r | grep "__OW_API_HOST"
api:
- ops -wsk -i action update api tests/api.js -a provide-api-key true
- ops -wsk -i action invoke api -r | grep '"api"'
mongo:
- |
MONGODB_URL=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.mongodb_url}')
wsk -i package update mongo -p dburi "$MONGODB_URL"
- ops -wsk -i action update mongo/mongo tests/mongo.js
- ops -wsk -i action invoke mongo/mongo -r | grep "hello"
minio:
- ops -wsk -i package update minio -p minio_host {{.MINIO_HOST}} -p minio_port {{.MINIO_PORT}} -p minio_user {{.MINIO_USER}} -p minio_pwd {{.MINIO_PWD}}
- ops -wsk -i action update minio/minio tests/minio.js
- ops -wsk -i action invoke minio/minio -r
mongo2:
- ops -wsk -i project deploy --manifest tests/mongo.yaml
postgres:
- |
PG_URL=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.postgres_url}')
ops -wsk -i package update postgres -p dburi "$PG_URL"
- ops -wsk -i action update postgres/postgres tests/postgres.js
- ops -wsk -i action invoke postgres/postgres -r | grep "Nuvolaris Postgres is up and running!"
minio2:
silent: true
desc: minio test
cmds:
- |
MINIO_ACCESS_KEY=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.s3_access_key}')
MINIO_SECRET_KEY=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.s3_secret_key}')
MINIO_HOST=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.s3_host}')
MINIO_PORT=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.s3_port}')
MINIO_BUCKET_DATA=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.s3_bucket_data}')
MINIO_BUCKET_WEB=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.s3_bucket_static}')
ops -wsk -i action update minio/minio-nuv tests/minio-nuv.js \
-p minio_access "$MINIO_ACCESS_KEY" \
-p minio_secret "$MINIO_SECRET_KEY" \
-p minio_host "$MINIO_HOST" \
-p minio_port "$MINIO_PORT" \
-p minio_data "$MINIO_BUCKET_DATA"
- ops -wsk -i action invoke minio/minio-nuv -r