-
Notifications
You must be signed in to change notification settings - Fork 16
301 lines (261 loc) · 12.9 KB
/
ci-e2e-tests.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
name: E2E tests
permissions:
id-token: write
contents: read
on:
push:
branches:
- main
tags:
- "v*.*.*"
paths-ignore:
- "website/**"
- "**/README.md"
pull_request:
branches:
- main
paths-ignore:
- "website/**"
- "**/README.md"
jobs:
e2e_tests:
name: E2E tests
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v27
- name: Magic cache
uses: DeterminateSystems/magic-nix-cache-action@v7
- name: Start Kardinal Kontrol service and Postgres
run: |
docker version
docker compose -f ci/docker-compose.yml up -d
docker ps
- name: Wait for docker network to be ready
run: sleep 10s
shell: bash
- name: Start minikube
uses: manusa/[email protected]
id: minikube
with:
minikube version: "v1.33.0"
kubernetes version: "v1.30.0"
driver: docker
start args: --embed-certs --addons=ingress,metrics-server
- name: Install Istio
run: |
ISTIO_VERSION="1.23.0"
echo "Installing Istio ..."
mkdir istio_tmp
pushd istio_tmp >/dev/null
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=${ISTIO_VERSION} sh -
cd istio-${ISTIO_VERSION}
export PATH=$PWD/bin:$PATH
istioctl install --set profile=demo -y
popd
- name: Build Kardinal manager and load image
run: |
eval $(minikube docker-env)
docker load < $(nix build ./#containers.x86_64-linux.kardinal-manager.amd64 --no-link --print-out-paths)
docker tag kurtosistech/kardinal-manager:latest-amd64 kurtosistech/kardinal-manager:latest
docker image ls
- name: Build Kardinal CLI
run: |
result=$(nix build ./#kardinal-cli --no-link --print-out-paths)
path=$(find $result -name 'kardinal.cli*' -type f | head -n 1)
binout="/tmp/kardinal-cli"
ln -s $path $binout
if /tmp/kardinal-cli | grep -q "Kardinal CLI"; then exit 0; else exit 1; fi
- name: Retrieve the tenant UUID
id: tenant
run: |
tenant_id=$(/tmp/kardinal-cli tenant show)
echo "id=${tenant_id}" >> "$GITHUB_OUTPUT"
- name: Deploy Kardinal manager
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli manager deploy local-kardinal-kontrol
# Check that the three kardinal manager service pods are running and ready
while [ $(kubectl get pods -n default --no-headers -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready | grep "true" | wc -l) -ne 3 ]
do
echo "Waiting for kardinal manager pods to run..."
kubectl get pods -n default -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready
((c++)) && ((c==12)) && exit 1
sleep 10
done
apps=$(kubectl get pods -n default -o custom-columns=:metadata.labels.app | tr " " "\n" | sort -g | tr "\n" " " | xargs)
echo ${apps}
if [ "${apps}" != "kardinal-manager trace-router trace-router-redis" ]; then exit 1; fi
# Check for errors in the kardinal manager logs
if kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep -q "ERRO"
then
echo "Errors found in the kardinal manager logs"
kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep "ERRO"
fi
- name: Deploy boutique demo manifest
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli deploy -k ci/obd-demo.yaml
- name: Validate that Kardinal manager applied the changes
run: |
# Check that the four baseline service pods are running and ready
while [ $(kubectl get pods -n baseline --no-headers -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready | grep "true,true" | wc -l) -ne 4 ]
do
echo "Waiting for baseline pods to run..."
kubectl get pods -n baseline -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready
((c++)) && ((c==12)) && exit 1
sleep 10
done
apps=$(kubectl get pods -n baseline -o custom-columns=:metadata.labels.app | tr " " "\n" | sort -g | tr "\n" " " | xargs)
echo ${apps}
if [ "${apps}" != "cartservice frontend postgres productcatalogservice" ]; then exit 1; fi
# Check for errors in the kardinal manager logs
if kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep -q "ERRO"
then
echo "Errors found in the kardinal manager logs"
kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep "ERRO"
fi
- name: Start gateway to the baseline flow and validate access
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli gateway baseline > kardinal.out &
cli_pid=$!
while ! grep "Proxy server for host" kardinal.out
do
echo "Waiting for gateway to start..."
cat kardinal.out
((c++)) && ((c==12)) && exit 1
sleep 10
done
flow_url=$(grep "http" kardinal.out | awk '{print $NF}')
status_code=$(curl -s -o /dev/null -w "%{http_code}" ${flow_url})
echo "${flow_url} returned status code ${status_code}"
if [ "${status_code}" != "200" ]; then exit 1; fi
kill ${cli_pid}
# Check for errors in the trace router logs
if kubectl logs -n default -l app=trace-router | grep -q "ERRO"
then
echo "Errors found in the trace router logs"
kubectl logs -n default -l app=trace-router | grep "ERRO"
fi
- name: Create, validate and delete flow
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli flow create frontend kurtosistech/frontend:demo-frontend > kardinal.out
cat kardinal.out
flow_id=$(grep "Flow.*created" kardinal.out | cut -d ' ' -f2 | tr -d "\"")
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli flow ls | grep ${flow_id}
# Check that the dev service pod is running and ready
while ! kubectl get pods -n baseline --no-headers -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready | grep true | grep "frontend-${flow_id}"
do
echo "Waiting for dev frontend pod to run..."
kubectl get pods -n baseline -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready
((c++)) && ((c==12)) && exit 1
sleep 10
done
kubectl get pods -n baseline
# Start gateway to the flow and validate access
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli gateway ${flow_id} > kardinal.out &
cli_pid=$!
while ! grep "Proxy server for host" kardinal.out
do
echo "Waiting for gateway to start..."
cat kardinal.out
((c++)) && ((c==12)) && exit 1
sleep 10
done
flow_url=$(grep "http" kardinal.out | awk '{print $NF}')
status_code=$(curl -s -o /dev/null -w "%{http_code}" ${flow_url})
echo "${flow_url} returned status code ${status_code}"
if [ "${status_code}" != "200" ]; then exit 1; fi
kill ${cli_pid}
# Check for errors in the trace router logs
if kubectl logs -n default -l app=trace-router | grep -q "ERRO"
then
echo "Errors found in the trace router logs"
kubectl logs -n default -l app=trace-router | grep "ERRO"
fi
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli flow delete ${flow_id}
# Check that the dev service pod is not running anymore
while kubectl get pods -n baseline | grep "frontend-${flow_id}"
do
echo "Waiting for dev frontend pod to terminate..."
kubectl get pods -n baseline
((c++)) && ((c==12)) && exit 1
sleep 10
done
kubectl get pods -n baseline
# Check for errors in the kardinal manager logs
if kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep -q "ERRO"
then
echo "Errors found in the kardinal manager logs"
kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep "ERRO"
fi
- name: Create template
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli template create extra-item-shared --template-yaml ci/template.yaml --description "Extra item and postgres is shared"
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli template ls | grep "extra-item-shared"
- name: Create flow with template and delete flow
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli flow create frontend kurtosistech/frontend:demo-frontend --template-args ci/template_args.yaml --template extra-item-shared > kardinal.out
cat kardinal.out
flow_id=$(grep "Flow.*created" kardinal.out | cut -d ' ' -f2 | tr -d "\"")
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli flow ls | grep ${flow_id}
# Check that the dev service pod is running and ready
while ! kubectl get pods -n baseline --no-headers -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready | grep true | grep "frontend-${flow_id}"
do
echo "Waiting for dev frontend pod to run..."
kubectl get pods -n baseline -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready
((c++)) && ((c==12)) && exit 1
sleep 10
done
kubectl get pods -n baseline
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli flow delete ${flow_id}
# Check that the dev service pod is not running anymore
while kubectl get pods -n baseline | grep "frontend-${flow_id}"
do
echo "Waiting for dev frontend pod to terminate..."
kubectl get pods -n baseline
((c++)) && ((c==12)) && exit 1
sleep 10
done
kubectl get pods -n baseline
# Check for errors in the kardinal manager logs
if kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep -q "ERRO"
then
echo "Errors found in the kardinal manager logs"
kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep "ERRO"
fi
- name: Delete template
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli template delete extra-item-shared
- name: Delete base topology and dev flows
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli flow delete baseline > kardinal.out
cat kardinal.out
if KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli flow ls | grep baseline; then echo "Topologies not deleted"; exit 1; fi
# Check that the services have been terminated
while [ "$(kubectl get pods -n baseline 2>&1 >/dev/null)" != "No resources found in baseline namespace." ]
do
echo "Waiting for the services to terminate..."
kubectl get pods -n baseline
((c++)) && ((c==12)) && exit 1
sleep 10
done
kubectl get pods -n baseline
# Check for errors in the kardinal manager logs
if kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep -q "ERRO"
then
echo "Errors found in the kardinal manager logs"
kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep "ERRO"
fi
- name: Remove kardinal manager
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli manager remove > kardinal.out
# Check that the services have been terminated
while [ "$(kubectl get pods -n default 2>&1 >/dev/null)" != "No resources found in default namespace." ]
do
echo "Waiting for the services to terminate..."
kubectl get pods -n default
((c++)) && ((c==12)) && exit 1
sleep 10
done
kubectl get pods -n default