|
1 | 1 | # Runs the Selenium suite against a DEPLOYED debugger site (default: |
2 | 2 | # https://test.idptools.com) while talking to a throwaway Keycloak spun up |
3 | | -# locally. This is the same stack as docker-compose-run-tests.yml (postgres + |
4 | | -# keycloak + tests on the "keycloak" bridge network) MINUS the containerized |
5 | | -# api/client — the debugger under test is the hosted site instead. |
| 3 | +# locally. Same idea as docker-compose-run-tests.yml, but the debugger under |
| 4 | +# test is the hosted site instead of a containerized client — only Keycloak and |
| 5 | +# the test runner are started here. |
6 | 6 | # |
7 | | -# The browser inside the tests container reaches the local Keycloak at |
8 | | -# http://keycloak:8080 (compose DNS), exactly as the containerized suite does. |
9 | | -# It drives the public HTTPS site and makes its OIDC/OAuth calls to that local |
10 | | -# Keycloak; the suite's Chrome flags (--allow-running-insecure-content + |
11 | | -# private-network overrides) permit the HTTPS-page -> http://keycloak calls. |
| 7 | +# HOST NETWORKING is required (not the bridge network the containerized suite |
| 8 | +# uses): the browser drives the public HTTPS site and must call the local |
| 9 | +# Keycloak from that HTTPS page. Chrome treats http://localhost (loopback) as |
| 10 | +# potentially-trustworthy and exempt from mixed-content / private-network |
| 11 | +# blocking, but a private-IP host (e.g. a bridge service name) is blocked. So |
| 12 | +# both containers share the host network and Keycloak is reached at |
| 13 | +# http://localhost:8080 — exactly the scenario remote-run-tests.sh proves. |
12 | 14 | # |
13 | | -# Keycloak's clients are (re)created at run time by common.sh configureKeycloak |
14 | | -# with redirectUris/webOrigins matching DEBUGGER_BASE_URL, so the deployed |
15 | | -# site's redirect back to <site>/callback validates. |
16 | | -# |
17 | | -# Compose format 2.x for `depends_on: condition: service_healthy` support. |
| 15 | +# Readiness: instead of a Docker healthcheck (flaky under host networking), the |
| 16 | +# tests container waits for Keycloak itself (docker-run-tests.sh waitForKeycloak). |
18 | 17 | # |
19 | 18 | # Override the target via the environment: |
20 | 19 | # LIVE_DEBUGGER_BASE_URL (default https://test.idptools.com) |
21 | 20 | # LIVE_CONFIG_FILE (default ./env/test-idptools-com.js) |
22 | 21 | services: |
23 | | - postgres: |
24 | | - image: postgres:18 |
25 | | - volumes: |
26 | | - - postgres_data:/var/lib/postgresql/data |
27 | | - environment: |
28 | | - POSTGRES_USER: keycloak |
29 | | - POSTGRES_PASSWORD: keycloak |
30 | | - POSTGRES_DB: keycloak |
31 | | - # postgres:18 refuses to start on a data dir initialized by an older |
32 | | - # major version. Initialize into a fresh subdirectory of the volume so |
33 | | - # the upgrade starts cleanly (test data is disposable and recreated each |
34 | | - # run); any legacy PG17 files at the volume root are ignored. |
35 | | - PGDATA: /var/lib/postgresql/data/pgdata |
36 | | - healthcheck: |
37 | | - test: pg_isready |
38 | | - interval: 10s |
39 | | - timeout: 60s |
40 | | - retries: 5 |
41 | | - start_period: 45s |
42 | | - networks: |
43 | | - - keycloak |
44 | | - |
45 | 22 | keycloak: |
46 | 23 | image: quay.io/keycloak/keycloak:26.6.4 |
47 | 24 | command: ["start-dev"] |
| 25 | + hostname: keycloak |
| 26 | + network_mode: "host" |
48 | 27 | environment: |
49 | | - KC_DB: postgres |
50 | | - KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak |
51 | | - KC_DB_USERNAME: keycloak |
52 | | - KC_DB_PASSWORD: keycloak |
| 28 | + KC_HTTP_PORT: "8080" |
| 29 | + KC_BOOTSTRAP_ADMIN_USERNAME: keycloak |
| 30 | + KC_BOOTSTRAP_ADMIN_PASSWORD: keycloak |
53 | 31 | KEYCLOAK_ADMIN: keycloak |
54 | 32 | KEYCLOAK_ADMIN_PASSWORD: keycloak |
55 | 33 | KC_HEALTH_ENABLED: "true" |
56 | | - hostname: keycloak |
57 | | - healthcheck: |
58 | | - test: [ |
59 | | - "CMD-SHELL", |
60 | | - "exec 3<>/dev/tcp/localhost/9000; \ |
61 | | - echo -en 'GET /health/ready' >&3; \ |
62 | | - # Give the server a moment to respond, then search for 'UP' |
63 | | - if timeout 3 cat <&3 | grep -m 1 'UP'; then \ |
64 | | - exec 3<&-; exec 3>&-; exit 0; \ |
65 | | - else \ |
66 | | - exec 3<&-; exec 3>&-; exit 1; \ |
67 | | - fi" |
68 | | - ] |
69 | | - interval: 10s |
70 | | - timeout: 60s |
71 | | - retries: 5 |
72 | | - start_period: 30s |
73 | | - depends_on: |
74 | | - postgres: |
75 | | - condition: service_healthy |
76 | | - networks: |
77 | | - - keycloak |
78 | 34 |
|
79 | 35 | tests: |
80 | 36 | image: rcbj/test-live |
81 | 37 | build: |
82 | 38 | context: . |
83 | 39 | dockerfile: tests/Dockerfile |
| 40 | + network_mode: "host" |
84 | 41 | environment: |
85 | | - # Target the deployed site; talk to the local Keycloak by service name. |
| 42 | + # Target the deployed site; talk to the local Keycloak over loopback. |
86 | 43 | - DEBUGGER_BASE_URL=${LIVE_DEBUGGER_BASE_URL:-https://test.idptools.com} |
87 | | - - KEYCLOAK_BASE_URL=http://keycloak:8080 |
88 | | - - KEYCLOAK_LOCALHOST_BASE_URL=http://keycloak:8080 |
| 44 | + - KEYCLOAK_BASE_URL=http://localhost:8080 |
| 45 | + - KEYCLOAK_LOCALHOST_BASE_URL=http://localhost:8080 |
89 | 46 | - CONFIG_FILE=${LIVE_CONFIG_FILE:-./env/test-idptools-com.js} |
90 | 47 | # Persist the generated report/logs to the host (gitignored). |
91 | 48 | volumes: |
92 | 49 | - ./tests/report:/usr/src/app/report |
| 50 | + # Start-order only (host networking healthchecks are unreliable); the test |
| 51 | + # runner waits for Keycloak to answer before configuring it. |
93 | 52 | depends_on: |
94 | | - keycloak: |
95 | | - condition: service_healthy |
96 | | - networks: |
97 | 53 | - keycloak |
98 | | - |
99 | | -volumes: |
100 | | - postgres_data: |
101 | | - |
102 | | -networks: |
103 | | - keycloak: |
0 commit comments