-
Notifications
You must be signed in to change notification settings - Fork 3
284 lines (235 loc) · 8.1 KB
/
functional.yml
File metadata and controls
284 lines (235 loc) · 8.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
---
name: Functional and interoperability testing
on:
workflow_dispatch:
pull_request:
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/functional.yml'
- 'tests/**'
- 'loadtest/**'
- 'src/**'
- '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
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Enable cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
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@0f44b27771c32bda9f458f75a1e241b09791b331 # stable
with:
toolchain: stable
- 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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: keystone
path: |
keystone
keystone-db
interop:
runs-on: ubuntu-latest
needs:
- build
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- 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 functional tests
run: cargo test --test functional
- 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
needs:
- build
permissions:
id-token: write
contents: read
packages: read
env:
KEYCLOAK_URL: http://localhost:8082
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- 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: Run keycloak tests
env:
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: password
BROWSERDRIVER_PORT: 4444
run: cargo test --test keycloak
- 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
env:
GITHUB_JWT: ${{ steps.get_token.outputs.token }}
GITHUB_SUB: "repo:openstack-experimental/keystone:pull_request"
run: cargo test --test github -- --nocapture
- 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 OPA log
if: failure()
run: docker logs opa
loadtest:
runs-on: ubuntu-latest
needs:
- build
permissions:
pull-requests: write
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: ./.github/actions/deploy_keystone
- name: Build Load test binary
working-directory: loadtest
run: cargo build --release
- name: Run load test
working-directory: 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: Extract report
id: metrics
working-directory: loadtest
run: |
SUMMARY=$(cat reports/loadtest-report-rust.md || echo "No summary found")
echo "summary<<EOF" >> $GITHUB_OUTPUT
echo "$SUMMARY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Upload report
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: loadtest-report
path: loadtest/reports/
- 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 }})
- 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