This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
294 lines (279 loc) · 15.1 KB
/
business-tests.yaml
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
---
name: "Business Tests"
on:
pull_request:
paths-ignore:
- docs/**
branches:
- develop
- release/**
- main
workflow_dispatch:
jobs:
business-test:
runs-on: ubuntu-latest
steps:
##############
### Set-Up ###
##############
-
name: Checkout
uses: actions/checkout@v3
-
name: Set-Up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
cache: 'maven'
-
name: Cache ContainerD Image Layers
uses: actions/cache@v3
with:
path: /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs
key: ${{ runner.os }}-io.containerd.snapshotter.v1.overlayfs
-
name: Set-Up Kubectl
uses: azure/[email protected]
-
name: Helm Set-Up
uses: azure/[email protected]
with:
version: v3.8.1
-
name: Create k8s Kind Cluster configuration (kind.config.yaml)
run: |-
export MAVEN_REPOSITORY=$(./mvnw help:evaluate -Dexpression=settings.localRepository -q -DforceStdout)
cat << EOF > kind.config.yaml
---
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraMounts:
- hostPath: ${PWD}
containerPath: /srv/product-edc
- hostPath: ${MAVEN_REPOSITORY}
containerPath: /srv/m2-repository
- hostPath: /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs
containerPath: /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs
EOF
-
name: Create k8s Kind Cluster
uses: helm/[email protected]
with:
config: kind.config.yaml
##############################################
### Build and load recent images into KinD ###
##############################################
-
name: Init git submodule
run: git submodule update --init
-
name: Build edc with Gradle to get specific snapshot
run: ./gradlew publishToMavenLocal -Pskip.signing=true -PedcVersion=0.0.1-20220922-SNAPSHOT -xjavadoc
working-directory: edc
-
name: Build edc-controlplane-postgresql-hashicorp-vault
run: |-
./mvnw -s settings.xml -B -pl .,edc-controlplane/edc-controlplane-postgresql-hashicorp-vault -am package -Dmaven.test.skip=true -Pwith-docker-image
env:
GITHUB_PACKAGE_USERNAME: ${{ github.actor }}
GITHUB_PACKAGE_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
-
name: Build edc-dataplane-hashicorp-vault
run: |-
./mvnw -s settings.xml -B -pl .,edc-dataplane/edc-dataplane-hashicorp-vault -am package -Dmaven.test.skip=true -Pwith-docker-image
env:
GITHUB_PACKAGE_USERNAME: ${{ github.actor }}
GITHUB_PACKAGE_PASSWORD: ${{ secrets.CXNG_GHCR_PAT }}
-
name: Load images into KinD
run: |-
docker tag edc-controlplane-postgresql-hashicorp-vault:latest edc-controlplane-postgresql-hashicorp-vault:business-test
docker tag edc-dataplane-hashicorp-vault:latest edc-dataplane-hashicorp-vault:business-test
kind get clusters | xargs -n1 kind load docker-image edc-controlplane-postgresql-hashicorp-vault:business-test edc-dataplane-hashicorp-vault:business-test --name
############################################
### Prepare And Install Test Environment ###
############################################
-
name: Define test environment variables
run: |-
# Define endpoints
echo "SOKRATES_DATA_MANAGEMENT_API_AUTH_KEY=password" | tee -a ${GITHUB_ENV}
echo "SOKRATES_DATA_MANAGEMENT_URL=http://sokrates-edc-controlplane:8181/data" | tee -a ${GITHUB_ENV}
echo "SOKRATES_IDS_URL=http://sokrates-edc-controlplane:8282/api/v1/ids" | tee -a ${GITHUB_ENV}
echo "SOKRATES_DATA_PLANE_URL=http://sokrates-edc-dataplane:8185/api/public/" | tee -a ${GITHUB_ENV}
echo "SOKRATES_DATABASE_URL=jdbc:postgresql://plato-postgresql:5432/edc" | tee -a ${GITHUB_ENV}
echo "SOKRATES_DATABASE_USER=postgresql_sandbox_user" | tee -a ${GITHUB_ENV}
echo "SOKRATES_DATABASE_PASSWORD=psql_password" | tee -a ${GITHUB_ENV}
echo "PLATO_DATA_MANAGEMENT_API_AUTH_KEY=password" | tee -a ${GITHUB_ENV}
echo "PLATO_DATA_MANAGEMENT_URL=http://plato-edc-controlplane:8181/data" | tee -a ${GITHUB_ENV}
echo "PLATO_IDS_URL=http://plato-edc-controlplane:8282/api/v1/ids" | tee -a ${GITHUB_ENV}
echo "PLATO_DATA_PLANE_URL=http://plato-edc-dataplane:8185/api/public/" | tee -a ${GITHUB_ENV}
echo "PLATO_DATABASE_URL=jdbc:postgresql://plato-postgresql:5432/edc" | tee -a ${GITHUB_ENV}
echo "PLATO_DATABASE_USER=postgresql_sandbox_user" | tee -a ${GITHUB_ENV}
echo "PLATO_DATABASE_PASSWORD=psql_password" | tee -a ${GITHUB_ENV}
-
name: Install test environment via Helm
run: |-
# Update helm dependencies
helm dependency update edc-tests/src/main/resources/deployment/helm/all-in-one
# Install the all-in-one supporting infrastructure environment (daps, vault, pgsql)
helm install test-environment edc-tests/src/main/resources/deployment/helm/all-in-one \
--set platoedccontrolplane.image.repository=edc-controlplane-postgresql-hashicorp-vault \
--set platoedccontrolplane.image.tag=business-test \
--set platoedccontrolplane.image.pullPolicy=Never \
--set sokratesedccontrolplane.image.repository=edc-controlplane-postgresql-hashicorp-vault \
--set sokratesedccontrolplane.image.tag=business-test \
--set sokratesedccontrolplane.image.pullPolicy=Never \
--set platoedcdataplane.image.repository=edc-dataplane-hashicorp-vault \
--set platoedcdataplane.image.tag=business-test \
--set platoedcdataplane.image.pullPolicy=Never \
--set sokratesedcdataplane.image.repository=edc-dataplane-hashicorp-vault \
--set sokratesedcdataplane.image.tag=business-test \
--set sokratesedcdataplane.image.pullPolicy=Never \
--set idsdaps.enabled=true \
--set platovault.enabled=true \
--set platopostgresql.enabled=true \
--set sokratesvault.enabled=true \
--set sokratespostgresql.enabled=true \
--set platoedccontrolplane.enabled=false \
--set platoedcdataplane.enabled=false \
--set platobackendapplication.enabled=false \
--set sokratesedccontrolplane.enabled=false \
--set sokratesedcdataplane.enabled=false \
--set sokratesbackendapplication.enabled=false \
--set sokrates-backend-application.persistence.enabled=false \
--set plato-backend-application.persistence.enabled=false \
--wait-for-jobs --timeout=120s
# GH pipelines constrained by cpu, so give helm some time to register all resources \w k8s
sleep 5s
# Wait for supporting infrastructure to become ready (control-/data-plane, backend service)
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=idsdaps --timeout=120s || ( kubectl logs -l app.kubernetes.io/name=idsdaps --tail 500 && exit 1 )
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=sokratesvault --timeout=120s || ( kubectl logs -l app.kubernetes.io/name=sokratesvault --tail 500 && exit 1 )
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=platovault --timeout=120s || ( kubectl logs -l app.kubernetes.io/name=platovault --tail 500 && exit 1 )
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=sokratespostgresql --timeout=120s || ( kubectl logs -l app.kubernetes.io/name=sokratespostgresql --tail 500 && exit 1 )
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=platopostgresql --timeout=120s || ( kubectl logs -l app.kubernetes.io/name=platopostgresql --tail 500 && exit 1 )
# Install the all-in-one Control-/DataPlanes and backend-services
helm upgrade --install test-environment edc-tests/src/main/resources/deployment/helm/all-in-one \
--set platoedccontrolplane.image.repository=edc-controlplane-postgresql-hashicorp-vault \
--set platoedccontrolplane.image.tag=business-test \
--set platoedccontrolplane.image.pullPolicy=Never \
--set sokratesedccontrolplane.image.repository=edc-controlplane-postgresql-hashicorp-vault \
--set sokratesedccontrolplane.image.tag=business-test \
--set sokratesedccontrolplane.image.pullPolicy=Never \
--set platoedcdataplane.image.repository=edc-dataplane-hashicorp-vault \
--set platoedcdataplane.image.tag=business-test \
--set platoedcdataplane.image.pullPolicy=Never \
--set sokratesedcdataplane.image.repository=edc-dataplane-hashicorp-vault \
--set sokratesedcdataplane.image.tag=business-test \
--set sokratesedcdataplane.image.pullPolicy=Never \
--set idsdaps.enabled=true \
--set platovault.enabled=true \
--set platopostgresql.enabled=true \
--set sokratesvault.enabled=true \
--set sokratespostgresql.enabled=true \
--set platoedccontrolplane.enabled=true \
--set platoedcdataplane.enabled=true \
--set platobackendapplication.enabled=true \
--set sokratesedccontrolplane.enabled=true \
--set sokratesedcdataplane.enabled=true \
--set sokratesbackendapplication.enabled=true \
--set sokrates-backend-application.persistence.enabled=true \
--set plato-backend-application.persistence.enabled=true \
--wait-for-jobs --timeout=120s
# GH pipelines constrained by cpu, so give helm some time to register all resources \w k8s
sleep 5s
# Wait for Control-/DataPlane and backend-service to become ready
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=sokratesbackendapplication --timeout=120s || ( kubectl logs -l app.kubernetes.io/name=sokratesbackendapplication --tail 500 && exit 1 )
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=platobackendapplication --timeout=120s || ( kubectl logs -l app.kubernetes.io/name=platobackendapplication --tail 500 && exit 1 )
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=sokratesedcdataplane --timeout=120s || ( kubectl logs -l app.kubernetes.io/name=sokratesedcdataplane --tail 500 && exit 1 )
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=platoedcdataplane --timeout=120s || ( kubectl logs -l app.kubernetes.io/name=platoedcdataplane --tail 500 && exit 1 )
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=sokratesedccontrolplane --timeout=600s || ( kubectl logs -l app.kubernetes.io/name=sokratesedccontrolplane --tail 500 && exit 1 )
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=platoedccontrolplane --timeout=600s || ( kubectl logs -l app.kubernetes.io/name=platoedccontrolplane --tail 500 && exit 1 )
##############################################
### Run Business Tests inside kind cluster ###
##############################################
-
name: Run Business Tests
run: |-
cat << EOF >> pod.json
{
"apiVersion": "v1",
"kind": "Pod",
"spec": {
"containers": [
{
"args": [
"-c",
"cd /product-edc && ./mvnw -s settings.xml -B -Pbusiness-tests -pl edc-tests test -Dtest=net.catenax.edc.tests.features.RunCucumberTest"
],
"command": [
"/bin/sh"
],
EOF
# Ugly hack to get env vars passed into the k8s-run - if '--overrides' defined '--env' is ignored :(
cat << EOF >> pod.json
"env": [
{"name": "SOKRATES_DATA_MANAGEMENT_API_AUTH_KEY", "value": "${SOKRATES_DATA_MANAGEMENT_API_AUTH_KEY}"},
{"name": "PLATO_DATA_MANAGEMENT_API_AUTH_KEY", "value": "${PLATO_DATA_MANAGEMENT_API_AUTH_KEY}"},
{"name": "SOKRATES_DATA_MANAGEMENT_URL", "value": "${SOKRATES_DATA_MANAGEMENT_URL}"},
{"name": "SOKRATES_IDS_URL", "value": "${SOKRATES_IDS_URL}"},
{"name": "SOKRATES_DATA_PLANE_URL", "value": "${SOKRATES_DATA_PLANE_URL}"},
{"name": "SOKRATES_BACKEND_SERVICE_BACKEND_API_URL", "value": "http://sokrates-backend-application:8081" },
{"name": "SOKRATES_DATABASE_URL", "value": "${SOKRATES_DATABASE_URL}"},
{"name": "SOKRATES_DATABASE_USER", "value": "${SOKRATES_DATABASE_USER}"},
{"name": "SOKRATES_DATABASE_PASSWORD", "value": "${SOKRATES_DATABASE_PASSWORD}"},
{"name": "PLATO_DATA_MANAGEMENT_URL", "value": "${PLATO_DATA_MANAGEMENT_URL}"},
{"name": "PLATO_IDS_URL", "value": "${PLATO_IDS_URL}"},
{"name": "PLATO_DATA_PLANE_URL", "value": "${PLATO_DATA_PLANE_URL}"},
{"name": "PLATO_BACKEND_SERVICE_BACKEND_API_URL", "value": "http://plato-backend-application:8081"},
{"name": "PLATO_DATABASE_URL", "value": "${PLATO_DATABASE_URL}"},
{"name": "PLATO_DATABASE_USER", "value": "${PLATO_DATABASE_USER}"},
{"name": "PLATO_DATABASE_PASSWORD", "value": "${PLATO_DATABASE_PASSWORD}"}
],
EOF
cat << EOF >> pod.json
"image": "openjdk:11-jdk-slim",
"name": "edc-tests",
"volumeMounts": [
{
"mountPath": "/product-edc",
"name": "product-edc"
},
{
"mountPath": "/root/.m2/repository",
"name": "m2-repository"
}
]
}
],
"dnsPolicy": "ClusterFirst",
"restartPolicy": "Never",
"volumes": [
{
"hostPath": {
"path": "/srv/product-edc"
},
"name": "product-edc"
},
{
"hostPath": {
"path": "/srv/m2-repository"
},
"name": "m2-repository"
}
]
}
}
EOF
kubectl run -i --image=openjdk:11-jdk-slim --restart=Never --rm edc-tests --overrides="$(cat pod.json)"
#################
### Tear Down ###
#################
-
name: Destroy the kind cluster
if: always()
run: >-
kind get clusters | xargs -n1 kind delete cluster --name