-
Notifications
You must be signed in to change notification settings - Fork 16
203 lines (173 loc) · 8.44 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
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
- 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 -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
kubectl get pods -n baseline
# Check the right services are running.
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 "ERRO"
then
echo "Errors found in the kardinal manager"
kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | 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 -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 for errors in the kardinal manager logs
if kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep "ERRO"
then
echo "Errors found in the kardinal manager"
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 -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 for errors in the kardinal manager logs
if kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep "ERRO"
then
echo "Errors found in the kardinal manager"
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 "ERRO"
then
echo "Errors found in the kardinal manager"
kubectl logs -n default -l dev.kardinal.app-id=kardinal-manager | grep "ERRO"
fi