-
Notifications
You must be signed in to change notification settings - Fork 14
/
TaskfileTest.yml
197 lines (173 loc) · 7.18 KB
/
TaskfileTest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# 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://default:s0meP@ass3@redis:6379"
MINIO_HOST: "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 wsk property set --apihost $APIHOST --auth $AUTH
wsk property set --apihost $APIHOST --auth $AUTH
while ! wsk action list
do echo $(( N++)) "waiting for the load balancer to be ready..." ; sleep 10
done
hello:
- wsk -i action update hello tests/hello.js --web=true
- wsk -i action invoke hello -r | grep "hello"
- |
URL=$(wsk -i action get hello --url | tail +2)
curl -skL $URL | grep hello
redis:
cmds:
- wsk -i package update redis -p redis "{{.REDIS_URI}}"
- wsk -i action update redis/ping tests/ping.js
- wsk -i action invoke redis/ping -r | grep "PONG"
- wsk -i action invoke redis/ping -p redis "{{.REDIS_NUV_URL}}" -r | grep "PONG"
- wsk -i action update redis/redis tests/redis.js -p redis_url "{{.REDIS_NUV_URL}}" -p redis_prefix "{{.REDIS_NUV_PREFIX}}"
- 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:
- wsk -i action update echo tests/echo.js -a provide-api-key true
- wsk -i action invoke echo -r | grep "__OW_API_KEY"
- wsk -i action invoke echo -r | grep "__OW_API_HOST"
api:
- wsk -i action update api tests/api.js -a provide-api-key true
- 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"
- wsk -i action update mongo/mongo tests/mongo.js
- wsk -i action invoke mongo/mongo -r | grep "hello"
minio:
- 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}}
- wsk -i action update minio/minio tests/minio.js
- wsk -i action invoke minio/minio -r
mongo2:
- wsk -i project deploy --manifest tests/mongo.yaml
postgres:
- |
PG_URL=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.postgres_url}')
wsk -i package update postgres -p dburi "$PG_URL"
- wsk -i action update postgres/postgres tests/postgres.js
- 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.minio_access_key}')
MINIO_SECRET_KEY=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.minio_secret_key}')
MINIO_HOST=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.minio_host}')
MINIO_PORT=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.minio_port}')
MINIO_BUCKET_DATA=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.minio_bucket_data}')
MINIO_BUCKET_WEB=$(kubectl -n nuvolaris get cm/config -o jsonpath='{.metadata.annotations.minio_bucket_static}')
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"
- wsk -i action invoke minio/minio-nuv -r