-
Notifications
You must be signed in to change notification settings - Fork 3
456 lines (380 loc) · 14.1 KB
/
functional.yml
File metadata and controls
456 lines (380 loc) · 14.1 KB
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
---
name: Functional and interoperability testing
on:
workflow_dispatch:
pull_request:
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/functional.yml'
- 'tests/**'
- 'loadtest/**'
- 'crates/**'
- 'policy/**'
env:
DATABASE_URL: postgresql://keystone:1234@127.0.0.1:5432/keystone
KEYSTONE_URL: http://localhost:8080
OPA_URL: http://localhost:8181
OS_KEYSTONE_CONFIG_DIR: ${{ github.workspace }}/etc
REGISTRY: ghcr.io
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Enable cache
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: |
~/.cache/pip
~/.cargo
key: ${{ runner.os }}-integration
- name: Rust Cache
uses: swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Install protobuf-compiler
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Build Keystone
run: cargo build --release
- name: Move artifacts to the root
run: mv target/release/keystone* ./
- name: Setup OPA
uses: open-policy-agent/setup-opa@v2
with:
version: latest
- name: Upload built binaries
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: keystone
path: |
keystone
keystone-db
interop:
runs-on: ubuntu-latest
needs:
- build
env:
OS_AUTH_URL: http://localhost:8080
OS_USERNAME: admin
OS_PASSWORD: password
OS_USER_DOMAIN_ID: default
OS_PROJECT_NAME: admin
OS_PROJECT_DOMAIN_ID: default
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: keystone
POSTGRES_PASSWORD: '1234'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ./.github/actions/deploy_keystone
- name: Wait for py-keystone to bootstrap
run: sleep 5
- name: Test python keystone availability
run: curl http://localhost:5001/v3
- name: Test rust keystone availability
run: curl http://localhost:8080/v3
- name: Basic test using token validation
run: |
TOKEN1=$(osc --os-cloud admin auth login)
TOKEN2=$(osc --os-cloud admin-rust auth login)
echo "Use rust Keystone token against both Keystones"
curl http://localhost:8080/v3/auth/tokens -H "X-Auth-Token: ${TOKEN1}" -H "X-Subject-Token: ${TOKEN1}" | jq
curl http://localhost:5001/v3/auth/tokens -H "X-Auth-Token: ${TOKEN1}" -H "X-Subject-Token: ${TOKEN1}" | jq
echo "Use python Keystone token against both Keystones"
curl http://localhost:8080/v3/auth/tokens -H "X-Auth-Token: ${TOKEN2}" -H "X-Subject-Token: ${TOKEN2}" | jq
curl http://localhost:5001/v3/auth/tokens -H "X-Auth-Token: ${TOKEN2}" -H "X-Subject-Token: ${TOKEN2}" | jq
- name: Run api tests
run: cargo test --test api
# - name: Run interop tests
# run: cargo test --test interop
- name: Dump py-keystone logs
if: failure()
run: docker logs keystone
- name: Dump rust keystone log
if: failure()
run: cat rust.log
- name: Dump OPA log
if: failure()
run: docker logs opa
federation:
runs-on: ubuntu-latest
if: "github.actor != 'openstack-experimental-release-plz'"
needs:
- build
env:
KEYCLOAK_URL: http://localhost:8082
BROWSERDRIVER_PORT: 4444
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: keystone
POSTGRES_PASSWORD: '1234'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
keycloak:
image: ghcr.io/openstack-experimental/keystone/keycloak-ci-service:26.2
env:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: password
ports:
- 8082:8080
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install browser
# This is crucial for Selenium to interact with a browser
run: |
sudo apt-get update
sudo apt-get install -y firefox
- uses: ./.github/actions/deploy_keystone
- name: Start geckodriver for selenium
run: /snap/bin/geckodriver --port=4444 > seleniumdriver.log 2>&1 &
- name: Start DexIDP container
run:
docker run -d -p 5556:5556 -d -v $PWD/tools/dex.config.yaml:/etc/dex/config.docker.yaml --name dex ghcr.io/dexidp/dex:latest
- name: Run keycloak tests
working-directory: "tests/federation"
env:
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: password
run: cargo test --test keycloak
- name: Run dex tests
working-directory: "tests/federation"
env:
DEX_URL: http://localhost:5556
run: cargo test --test dex
- name: Dump seleniumdriver log
if: failure()
run: cat seleniumdriver.log
- name: Dump py-keystone logs
if: failure()
run: docker logs keystone
- name: Dump rust keystone log
if: failure()
run: cat rust.log
- name: Dump dex log
if: failure()
run: docker logs dex
- name: Dump OPA log
if: failure()
run: docker logs opa
federation-github:
runs-on: ubuntu-latest
if: "github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'openstack-experimental-release-plz'"
needs:
- build
permissions:
id-token: write
contents: read
packages: read
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: keystone
POSTGRES_PASSWORD: '1234'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
keycloak:
image: ghcr.io/openstack-experimental/keystone/keycloak-ci-service:26.2
env:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: password
ports:
- 8082:8080
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ./.github/actions/deploy_keystone
- name: Get GitHub JWT token
id: get_token
run: |
TOKEN_JSON=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://github.com")
TOKEN=$(echo $TOKEN_JSON | jq -r .value)
echo "token=$TOKEN" >> $GITHUB_OUTPUT
- name: Run github tests
working-directory: "tests/federation"
env:
GITHUB_JWT: ${{ steps.get_token.outputs.token }}
GITHUB_SUB: "repo:openstack-experimental/keystone:pull_request"
run: cargo test --test github -- --nocapture
- name: Dump py-keystone logs
if: failure()
run: docker logs keystone
- name: Dump rust keystone log
if: failure()
run: cat rust.log
- name: Dump OPA log
if: failure()
run: docker logs opa
loadtest:
runs-on: ubuntu-latest
if: "github.actor != 'openstack-experimental-release-plz'"
needs:
- build
permissions:
contents: read
packages: read
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: keystone
POSTGRES_PASSWORD: '1234'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ./.github/actions/deploy_keystone
- name: Build Load test binary
working-directory: tests/loadtest
run: cargo build --release
- name: Run load test
working-directory: tests/loadtest
env:
OS_CLOUD: admin
run: |
mkdir -p reports
./target/release/load_test \
--host http://localhost:8080 \
--hatch-rate 2 \
--run-time 30s \
--report-file reports/loadtest-report-rust.html \
--report-file reports/loadtest-report-rust.md
./target/release/load_test \
--host http://localhost:5001 \
--hatch-rate 2 \
--run-time 30s \
--report-file reports/loadtest-report-python.html \
--report-file reports/loadtest-report-python.md
- name: Upload report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: loadtest-report
path: tests/loadtest/reports/
- name: Dump py-keystone logs
if: failure()
run: docker logs keystone
- name: Dump rust keystone log
if: failure()
run: cat rust.log
- name: Dump OPA log
if: failure()
run: docker logs opa
loadtest-track:
if: "github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'openstack-experimental-release-plz'"
runs-on: ubuntu-latest
needs:
- loadtest
permissions:
pull-requests: write
steps:
- name: Fetch pre-built artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v5.0.0
with:
name: loadtest-report
- name: Extract report
id: metrics
run: |
SUMMARY=$(cat loadtest-report-rust.md || echo "No summary found")
echo "summary<<EOF" >> $GITHUB_OUTPUT
echo "$SUMMARY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Post Loadtest results to PR
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: loadtest
message: |
🦢 **Load Test Results**
${{ steps.metrics.outputs.summary }}
[View full report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
k3s-test:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # Required to push to GHCR
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install K3s
run: |
# Install k3s without the heavy default components (Traefik/ServiceLB)
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable traefik --disable servicelb --write-kubeconfig-mode 644" sh -s -
# Export KUBECONFIG for the next steps
echo "KUBECONFIG=/etc/rancher/k3s/k3s.yaml" >> $GITHUB_ENV
- name: Install Skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/builds/latest/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
- name: Log in to GHCR
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
with:
driver: docker-container
- name: Wait for Cluster Ready
run: |
# Wait up to 60 seconds for the node to be ready
timeout 60s bash -c 'until kubectl get nodes | grep -w "Ready"; do sleep 2; done'
kubectl get nodes
- name: Create GHCR Pull Secret
run: |
# Use --dry-run and pipe to 'apply' to make this step idempotent
kubectl create secret docker-registry ghcr-pull-secret \
--docker-server=ghcr.io \
--docker-username=${{ github.actor }} \
--docker-password=${{ secrets.GITHUB_TOKEN }} \
--namespace=default \
--dry-run=client -o yaml | kubectl apply -f -
- name: Patch ServiceAccount for Automatic Pulling
run: |
# This ensures all pods in the namespace can pull from GHCR
# without you needing to edit every deployment.yaml
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "ghcr-pull-secret"}]}'
- name: Deploy the development stack
env:
# This tells the underlying Docker Buildx to use GHA for cache
# mode=max ensures all intermediate layers (like Cargo dependencies) are saved
BUILDKIT_STEP_LOG_MAX_SIZE: 10485760
run: |
export BUILDX_NO_DEFAULT_ATTESTATIONS=1
# first build artifacts preparing metadata file
skaffold build --profile github-ci --default-repo ghcr.io/openstack-experimental/keystone --file-output build.artifacts
# deploy built artifacts
skaffold deploy -a build.artifacts --status-check
- name: Run tests
run: |
# run tests referring to the artifacts metadata file
skaffold verify -a build.artifacts -v debug
- name: Dump K8 pods
if: failure()
run: kubectl get pods
- name: Dump K8 pods - extended
if: failure()
run: kubectl get pods -o custom-columns="NAMESPACE:.metadata.namespace,POD:.metadata.name,STATUS:.status.phase,CONTAINER:.spec.containers[*].name,IMAGE:.spec.containers[*].image"
- name: Dump skaffold images
if: failure()
run: cat build.artifacts
- name: Dump keystone-rs logs
if: failure()
run: kubectl logs deployment/keystone-rs -c keystone