Commit 036635a
authored
refactor(e2e): refactor runtime tests into TypeScript (#4809)
* fix(e2e): consolidate SHOWCASE_RUNTIME_DB into SHOWCASE_RUNTIME project
Merge the SHOWCASE_RUNTIME_DB Playwright project into SHOWCASE_RUNTIME
to simplify runtime test execution. All runtime tests now run
sequentially in a single project (workers: 1) with no inter-project
dependencies.
Key changes:
- Deploy runtime with internal PostgreSQL (Helm sub-chart / operator-
managed) instead of external Crunchy DB
- External DB tests (RDS, Azure) switch to external DB at runtime via
prepareForExternalDatabase() which patches ConfigMap + adds env vars
- Operator uses separate rhdh-runtime-config secret for RHDH_RUNTIME_URL
to avoid POSTGRES_* env var conflicts with internal DB
- schema-mode-env.sh and schema-mode-setup.ts support operator-specific
service/secret naming (backstage-psql-*) and POSTGRESQL_ADMIN_PASSWORD
preservation
- SSL connection conditionally applied (skip for internal DB, enable for
external DB)
- Added waitForRuntimeDeploymentReady() for config-map tests
- Added restartWithRetry() for operator reconciliation resilience
- Removed old resource files (values-showcase-postgres.yaml,
rds-app-config.yaml, rhdh-start-runtime.yaml)
Assisted-by: OpenCode
* refactor(e2e): extract shared utilities and eliminate duplication
- Extract resolveInstallMethod(), base64Encode/Decode to helper.ts
- Deduplicate AppConfigYaml interface into runtime-config.ts
- Add patchAppConfig(), restartDeploymentWithRetry(), jsonPatchDeployment()
to KubeClient — eliminates repeated ConfigMap patch + deployment restart
patterns across postgres-config.ts and schema-mode-setup.ts
- Export getKubeApiErrorMessage, run(), discoverRouterBase() for reuse
- Deduplicate getDeploymentName() via getRhdhDeploymentName()
- Handle @sha256: digest refs in parseCatalogIndexImage()
- Type BackstageCR return value
Assisted-by: OpenCode
* fix(e2e): address review findings
- Fix parseCatalogIndexImage digest reconstruction: add ImageRef.separator
field (':' for tags, '@' for digests) and imageRefToString() helper so
downstream consumers reconstruct refs correctly
- Fix patchAppConfig no-op detection: compare YAML before/after mutator
to skip unnecessary ConfigMap writes and misleading log messages
- Fix removeSchemaModePatchedEnvVars: add explicit backstageIdx === -1
guard with warning log (consistent with ensurePostgresCredEnvVars)
Assisted-by: OpenCode
* refactor(e2e): unify KubeClient with rhdh-deployment.ts patterns
- KubeClient constructor: switch from loadFromOptions() with explicit
K8S_CLUSTER_URL/K8S_CLUSTER_TOKEN env vars to loadFromDefault() which
reads the kubeconfig file (set by oc login / kubectl config). This
aligns with how rhdh-deployment.ts (auth-providers) connects.
- Extract waitForBackstageCrd() as standalone function in kube-client.ts,
used by both runtime-deploy.ts and rhdh-deployment.ts — eliminates
duplicated CRD polling loops.
- rhdh-deployment.ts: adopt base64Encode() from helper.ts,
getKubeApiErrorMessage() from kube-client.ts for safe error logging.
Assisted-by: OpenCode
* refactor(e2e): standardize on js-yaml, drop yaml package
Migrate rhdh-deployment.ts from the `yaml` npm package to `js-yaml`
which is already used by kube-client.ts and runtime-config.ts. The two
packages have incompatible APIs (`yaml.parse/stringify` vs
`yaml.load/dump`) despite being imported under the same alias,
creating a copy-paste trap for developers.
Changes:
- rhdh-deployment.ts: yaml.parse() -> yaml.load(),
yaml.stringify() -> yaml.dump()
- package.json: remove direct `yaml` dependency from e2e-tests
Assisted-by: OpenCode
* refactor(e2e): adopt shared helpers and fix createConfigMap typo
- Replace 8 inline Buffer.from() base64 calls with base64Encode/Decode
from helper.ts (keycloak.ts, api-helper.ts, annotator.spec.ts,
scaffolder-relation-processor.spec.ts)
- Fix method name typo: createCongifmap -> createConfigMap in KubeClient
- Use kubeClient.createConfigMap() in runtime-deploy.ts instead of
inline coreV1Api.createNamespacedConfigMap() calls
Assisted-by: OpenCode
* refactor(e2e): extract shared utilities from runtime-*.ts
Move reusable utilities out of runtime-deploy.ts and
runtime-config.ts into shared modules:
helper.ts:
- run() — shell command execution with stdout/stderr capture
- discoverRouterBase() — OpenShift cluster router base discovery
- ImageRef interface, imageRefToString(), parseCatalogIndexImage()
— image reference parsing utilities
kube-client.ts (KubeClient class):
- createNamespace() — 409-safe namespace creation
- deleteNamespaceIfExists() — 404-safe deletion wrapping
deleteNamespaceAndWait()
runtime-config.ts re-exports ImageRef, imageRefToString, and
parseCatalogIndexImage from helper.ts so existing callers are
unaffected.
runtime-deploy.ts now imports all shared utilities instead of
defining them locally, reducing file size by ~100 lines.
Assisted-by: OpenCode
* fix(e2e): address review findings in runtime test refactor
- Guard against undefined host in RDS/Azure DB test loops by skipping
individual DB versions when their host env var is not set, instead of
crashing with a TypeError in clearDatabase/configurePostgresCredentials
- Fix RELEASE_NAME default mismatch in verify-schema-mode.spec.ts
('developer-hub' -> 'rhdh') to match runtime-config.ts and kube-client.ts
- Use resolveInstallMethod() in getRhdhDeploymentName() instead of
duplicating install method detection logic
- Rewrite updateConfigMapTitle as a thin wrapper around patchAppConfig,
eliminating ~65 lines of duplicated read-modify-write ConfigMap logic
- Extract deployment env var manipulation from postgres-config.ts into
KubeClient methods (removeContainerEnvVars, addContainerEnvVarsFromSecret)
so postgres-config.ts stays at the 'what' level while KubeClient handles
'how' to patch deployments
Assisted-by: OpenCode
* fix(e2e): extract API version constant and clarify assumptions
- Extract BACKSTAGE_CR_API_VERSION constant in runtime-config.ts and
import it in runtime-deploy.ts, so there is a single place to update
when the CRD version bumps
- Document the workers:1 assumption on the module-level deployed flag
in runtime-deploy.ts to help future readers
- Add comment explaining why the operator path uses a computed route URL
rather than cluster discovery (deterministic naming convention)
Assisted-by: OpenCode
* fix(e2e): call ensureRuntimeDeployed in every runtime spec
Each runtime spec now calls ensureRuntimeDeployed() in its own
beforeAll instead of relying on alphabetical file discovery order
(configuration-test/ running before external-database/ and
plugin-division-mode-schema/). The call is idempotent — when tests
run in order it detects the existing ready deployment and returns
immediately. When a spec is run standalone via --grep, it deploys
RHDH first.
This removes the hidden ordering dependency that the old explicit
`dependencies: [SHOWCASE_RUNTIME_DB]` used to make visible.
Assisted-by: OpenCode
* fix(e2e): drop stale K8S_CLUSTER_URL/TOKEN from header comment
KubeClient now uses loadFromDefault() so these env vars are no
longer consumed by runtime-deploy.ts. Remove them from the header
to keep the documentation accurate.
Assisted-by: OpenCode
* refactor(e2e): use ImageRef for main container image
Change config.image from a plain {registry, repository, tag} object
to ImageRef which includes a separator field (':' for tags, '@' for
digests). This fixes digest-pinned images (e.g. repo@sha256:...)
being incorrectly joined with ':' in generateBackstageCR().
The same ImageRef/imageRefToString() is already used for
catalogIndex — this unifies both image references under the same
type and construction logic.
Assisted-by: OpenCode
* refactor(e2e): extract BACKSTAGE_BACKEND_CONTAINER constant
Centralize the backstage-backend container name as a named constant
in kube-client.ts alongside getRhdhDeploymentName(). Replace
hardcoded strings in runtime-config.ts, postgres-config.ts, and
schema-mode-setup.ts.
rhdh-deployment.ts (auth-providers) also uses the same string but
is left for a future PR to avoid expanding scope.
Assisted-by: OpenCode
* refactor(e2e): extract buildImageRef helper for separator detection
Extract the duplicated `tag.startsWith("sha256:") ? "@" : ":"
separator logic into a buildImageRef() helper in helper.ts. Used by
both runtime-config.ts and rhdh-deployment.ts to construct ImageRef
from individual registry/repository/tag env vars.
Assisted-by: OpenCode
* refactor(e2e): extract shared POSTGRES_ENV_KEYS constant
Deduplicate the overlapping POSTGRES_* env var key lists across
postgres-config.ts and schema-mode-setup.ts into a shared
POSTGRES_ENV_KEYS constant. The external-DB function extends it
with PGSSLMODE and NODE_EXTRA_CA_CERTS via POSTGRES_CRED_ENV_KEYS.
Assisted-by: OpenCode
* refactor(e2e): move schema-mode config to schema-mode-db.ts
Move configureSchemaMode() and the default DB user/password constants
from runtime-deploy.ts to schema-mode-db.ts where the rest of the
schema-mode database utilities live. runtime-deploy.ts imports and
calls the function — it no longer owns any schema-mode-specific logic.
Assisted-by: OpenCode
* refactor(e2e): remove updateConfigMapTitle, use patchAppConfig directly
updateConfigMapTitle was a thin wrapper around patchAppConfig with
an unused _configMapName parameter and a single caller. Inline the
title-update logic into config-map.spec.ts and remove the method
from KubeClient.
Assisted-by: OpenCode
* fix(e2e): fix naming convention lint error for private constant
Rename POSTGRES_CRED_ENV_KEYS to postgresCredEnvKeys — private
(non-exported) const must be camelCase per the eslint
@typescript-eslint/naming-convention rule.
Assisted-by: OpenCode
* fix(e2e): don't inject POSTGRES_DB env var in external DB tests
The placeholder postgres-cred secret doesn't contain a POSTGRES_DB key,
causing CreateContainerConfigError when prepareForExternalDatabase()
adds a secretKeyRef for it. External DB tests don't need POSTGRES_DB —
Backstage auto-creates per-plugin databases when it's unset.
Schema-mode tests are unaffected; they manage env vars via their own
configureSchemaMode() / schema-mode-setup.ts mechanism.
Assisted-by: OpenCode
* fix(e2e): adapt new KubeClient methods to modular kube-client structure
After rebasing onto main, the kube-client.ts monolith was split into
kube-client/ directory modules. Add methods and constants that our PR
introduced to the new modular structure:
- BACKSTAGE_BACKEND_CONTAINER constant
- patchAppConfig, jsonPatchDeployment, restartDeploymentWithRetry
- removeContainerEnvVars, addContainerEnvVarsFromSecret
- waitForBackstageCrd, createConfigMap, deleteNamespaceIfExists, createNamespace
- getRhdhDeploymentName: use resolveInstallMethod() for INSTALL_METHOD env var
Fix all oxlint violations to comply with strict + pedantic linting:
- Replace || with ?? for nullish coalescing
- Add explicit nullish/empty checks for strict-boolean-expressions
- Fix setTimeout in Promise executors for strict-void-return
- Move inline comments to separate lines
- Add type annotations and safe type assertions
- Swap negated conditions to positive form
Assisted-by: OpenCode
* fix(e2e): fix inverted pod failure detection for transient container states
The checkWaitingContainerState function had inverted logic — it treated
transient states like PodInitializing and ContainerCreating as failures
while silently ignoring actual failure states like CrashLoopBackOff and
ImagePullBackOff.
This caused the runtime tests to fail immediately during operator
deployment because the init container (install-dynamic-plugins) triggers
PodInitializing state, which was incorrectly flagged as a pod failure.
Assisted-by: OpenCode
* fix(e2e): fix runtime test timeouts caused by WebSocket teardown hang
Runtime tests that navigate to the RHDH UI establish WebSocket
connections (event-stream). When the test body completes, Playwright's
page fixture teardown hangs for up to 10 minutes waiting for the browser
context to close because the WebSocket connections are never dropped.
Fix: navigate to about:blank at the end of each test that uses the page
fixture to close all active connections before Playwright tears down the
context.
Also add a 10-minute project-level timeout for the SHOWCASE_RUNTIME
project — runtime tests restart the RHDH deployment (ConfigMap changes,
external DB reconfiguration, schema-mode setup) which takes 60-90s per
restart.
Assisted-by: OpenCode1 parent 8ba9f0e commit 036635a
29 files changed
Lines changed: 1685 additions & 503 deletions
File tree
- .ci/pipelines
- jobs
- lib
- resources
- postgres-db
- rhdh-operator
- e2e-tests
- playwright
- e2e
- audit-log
- configuration-test
- external-database
- plugin-division-mode-schema
- plugins
- scaffolder-backend-module-annotator
- scaffolder-relation-processor
- utils
- keycloak
- kube-client
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 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 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
77 | 60 | | |
78 | | - | |
79 | 61 | | |
80 | 62 | | |
81 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
75 | 79 | | |
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 | 80 | | |
114 | 81 | | |
115 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| 47 | + | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| |||
This file was deleted.
Lines changed: 0 additions & 90 deletions
This file was deleted.
Lines changed: 0 additions & 51 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | 653 | | |
670 | 654 | | |
671 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
43 | | - | |
44 | | - | |
| 42 | + | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | 174 | | |
183 | 175 | | |
184 | 176 | | |
185 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
186 | 182 | | |
187 | 183 | | |
188 | 184 | | |
| 185 | + | |
| 186 | + | |
189 | 187 | | |
190 | 188 | | |
191 | 189 | | |
| |||
0 commit comments