Skip to content

Commit ade4324

Browse files
authored
chore(ci): decouple namespace from Playwright project name (#3796)
* Fix status saving for showcase-runtime for the fine-grained reporter * chore(ci): decouple namespace from Playwright project name * Add check for playwright project * Update docs and rules * Define PW projects in json file * Update docs and rules again * Fix log * Removing check for project as redundant * Update projects.ts * Use yarn instead of npx * Prettier * Update utils.sh * Update utils.sh
1 parent 8d6c219 commit ade4324

28 files changed

+365
-145
lines changed

.claude/memories/ci-e2e-testing.md

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ test.beforeAll(async ({ }, testInfo) => {
6969
- Basic functionality verification
7070
- Health checks and core features
7171

72-
2. **Showcase Tests** (defined in `playwright.config.ts`)
72+
2. **Showcase Tests** (defined in `e2e-tests/playwright/projects.json`)
7373
- `showcase`: General functionality tests with base deployment using Helm chart
7474
- `showcase-rbac`: General functionality tests with RBAC-enabled deployment using Helm chart
7575
- `showcase-k8s`: Kubernetes integration tests with base deployment
@@ -81,6 +81,10 @@ test.beforeAll(async ({ }, testInfo) => {
8181
- `showcase-upgrade`: Upgrade scenario tests
8282
- `any-test`: Use for debugging when you need to run a specific tests
8383

84+
**Note**: All project names are defined in `e2e-tests/playwright/projects.json` as the single source of truth. This file is consumed by:
85+
- `playwright.config.ts` via TypeScript import (`e2e-tests/playwright/projects.ts`)
86+
- CI/CD scripts via `.ibm/pipelines/playwright-projects.sh` (exports as `$PW_PROJECT_*` variables)
87+
8488
3. **Authentication Provider Tests** (`showcase-auth-providers`)
8589
- OIDC (Red Hat Backstage Keycloak)
8690
- Microsoft OAuth2
@@ -106,28 +110,44 @@ test.beforeAll(async ({ }, testInfo) => {
106110
- Audit logging functionality
107111
- Compliance verification
108112

109-
### Test Execution Scripts
113+
### Test Execution
114+
115+
#### CI/CD Pipeline Execution
116+
117+
In the CI/CD pipeline, tests are executed directly using Playwright's `--project` flag via the `run_tests()` function in `.ibm/pipelines/utils.sh`:
118+
119+
```bash
120+
yarn playwright test --project="${playwright_project}"
121+
```
110122

111-
Available yarn scripts in `e2e-tests/package.json`:
123+
The namespace and Playwright project are decoupled, allowing flexible reuse. The `check_and_test()` and `run_tests()` functions accept an explicit `playwright_project` argument:
112124

113125
```bash
114-
# Showcase tests - OpenShift deployments
126+
# Function signatures:
127+
check_and_test "${RELEASE_NAME}" "${NAMESPACE}" "${PLAYWRIGHT_PROJECT}" "${URL}" [max_attempts] [wait_seconds]
128+
run_tests "${RELEASE_NAME}" "${NAMESPACE}" "${PLAYWRIGHT_PROJECT}" "${URL}"
129+
```
130+
131+
#### Local Development Scripts
132+
133+
Available yarn scripts in `e2e-tests/package.json` for local development:
134+
135+
```bash
136+
# Showcase tests - OpenShift deployments (Helm)
115137
yarn showcase # General showcase tests
116-
yarn showcase-ci-nightly # General showcase tests (nightly CI alias)
117138
yarn showcase-rbac # General showcase tests with RBAC
118-
yarn showcase-rbac-nightly # General showcase tests with RBAC (nightly CI alias)
119139

120140
# Showcase tests - Kubernetes deployments
121-
yarn showcase-k8s-ci-nightly # Kubernetes showcase tests
122-
yarn showcase-rbac-k8s-ci-nightly # Kubernetes showcase tests with RBAC
141+
yarn showcase-k8s # Kubernetes showcase tests
142+
yarn showcase-rbac-k8s # Kubernetes showcase tests with RBAC
123143

124144
# Showcase tests - Operator deployments
125-
yarn showcase-operator-nightly # Operator showcase tests
126-
yarn showcase-operator-rbac-nightly # Operator showcase tests with RBAC
145+
yarn showcase-operator # Operator showcase tests
146+
yarn showcase-operator-rbac # Operator showcase tests with RBAC
127147

128148
# Showcase tests - Other scenarios
129149
yarn showcase-runtime # Runtime configuration tests
130-
yarn showcase-upgrade-nightly # Upgrade scenario tests
150+
yarn showcase-upgrade # Upgrade scenario tests
131151

132152
# Authentication provider tests
133153
yarn showcase-auth-providers # Auth provider tests
@@ -143,6 +163,8 @@ yarn prettier:check # Prettier checking
143163
yarn prettier:fix # Prettier fixing
144164
```
145165

166+
**Note**: The CI pipeline no longer uses yarn script aliases. Instead, it runs Playwright directly with `yarn playwright test --project=<project-name>`. This decouples the namespace from the test project name, enabling more flexible namespace and test project reuse.
167+
146168
### Environment Variables
147169

148170
All the important environment variables are sourced in `.ibm/pipelines/env_variables.sh`
@@ -283,6 +305,7 @@ For CI/CD pipeline execution, tests run in a containerized environment using the
283305
- **`.ibm/pipelines/utils.sh`**: Utility functions
284306
- **`.ibm/pipelines/reporting.sh`**: Reporting and notifications
285307
- **`.ibm/pipelines/env_variables.sh`**: Environment variable management
308+
- **`.ibm/pipelines/playwright-projects.sh`**: Loads Playwright project names from `projects.json` as `$PW_PROJECT_*` variables
286309

287310
#### CI Infrastructure Package Configuration
288311

@@ -347,7 +370,7 @@ export ISRUNNINGLOCAL=true
347370
export ISRUNNINGLOCALDEBUG=true
348371

349372
# Run tests locally
350-
npx playwright test --project showcase-auth-providers --workers 1
373+
yarn playwright test --project showcase-auth-providers --workers 1
351374
```
352375

353376
#### CI Debugging
@@ -357,8 +380,8 @@ npx playwright test --project showcase-auth-providers --workers 1
357380
4. **Test Failures**: Review test reports and screenshots
358381

359382
#### Common Debugging Tools
360-
- **Playwright Inspector**: `npx playwright test --debug`
361-
- **Trace Viewer**: `npx playwright show-trace`
383+
- **Playwright Inspector**: `yarn playwright test --debug`
384+
- **Trace Viewer**: `yarn playwright show-trace`
362385
- **Screenshots**: Automatic on failure
363386
- **Video Recording**: Available for all tests
364387

@@ -423,6 +446,7 @@ brew install gnu-sed
423446
- [OpenShift CI Pipeline README](.ibm/pipelines/README.md)
424447

425448
### Configuration Files
449+
- [Playwright Project Names (Single Source of Truth)](e2e-tests/playwright/projects.json)
426450
- [Playwright Configuration](e2e-tests/playwright.config.ts)
427451
- [Package Configuration](e2e-tests/package.json)
428452
- [Dynamic Plugins Config](dynamic-plugins/package.json)

.claude/memories/playwright-locators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ class CatalogPage {
141141

142142
```bash
143143
# Generate locators automatically
144-
npx playwright codegen http://localhost:7007
144+
yarn playwright codegen http://localhost:7007
145145

146146
# Debug tests step-by-step
147-
npx playwright test --debug
147+
yarn playwright test --debug
148148

149149
# Or pause in test
150150
await page.pause();

.cursor/rules/ci-e2e-testing.mdc

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test.beforeAll(async ({ }, testInfo) => {
7575
- Basic functionality verification
7676
- Health checks and core features
7777

78-
2. **Showcase Tests** (defined in `playwright.config.ts`)
78+
2. **Showcase Tests** (defined in `e2e-tests/playwright/projects.json`)
7979
- `showcase`: General functionality tests with base deployment using Helm chart
8080
- `showcase-rbac`: General functionality tests with RBAC-enabled deployment using Helm chart
8181
- `showcase-k8s`: Kubernetes integration tests with base deployment
@@ -87,6 +87,10 @@ test.beforeAll(async ({ }, testInfo) => {
8787
- `showcase-upgrade`: Upgrade scenario tests
8888
- `any-test`: Use for debugging when you need to run a specific tests
8989

90+
**Note**: All project names are defined in `e2e-tests/playwright/projects.json` as the single source of truth. This file is consumed by:
91+
- `playwright.config.ts` via TypeScript import (`e2e-tests/playwright/projects.ts`)
92+
- CI/CD scripts via `.ibm/pipelines/playwright-projects.sh` (exports as `$PW_PROJECT_*` variables)
93+
9094
3. **Authentication Provider Tests** (`showcase-auth-providers`)
9195
- OIDC (Red Hat Backstage Keycloak)
9296
- Microsoft OAuth2
@@ -112,28 +116,44 @@ test.beforeAll(async ({ }, testInfo) => {
112116
- Audit logging functionality
113117
- Compliance verification
114118

115-
### Test Execution Scripts
119+
### Test Execution
120+
121+
#### CI/CD Pipeline Execution
122+
123+
In the CI/CD pipeline, tests are executed directly using Playwright's `--project` flag via the `run_tests()` function in `.ibm/pipelines/utils.sh`:
124+
125+
```bash
126+
yarn playwright test --project="${playwright_project}"
127+
```
116128

117-
Available yarn scripts in `e2e-tests/package.json`:
129+
The namespace and Playwright project are decoupled, allowing flexible reuse. The `check_and_test()` and `run_tests()` functions accept an explicit `playwright_project` argument:
118130

119131
```bash
120-
# Showcase tests - OpenShift deployments
132+
# Function signatures:
133+
check_and_test "${RELEASE_NAME}" "${NAMESPACE}" "${PLAYWRIGHT_PROJECT}" "${URL}" [max_attempts] [wait_seconds]
134+
run_tests "${RELEASE_NAME}" "${NAMESPACE}" "${PLAYWRIGHT_PROJECT}" "${URL}"
135+
```
136+
137+
#### Local Development Scripts
138+
139+
Available yarn scripts in `e2e-tests/package.json` for local development:
140+
141+
```bash
142+
# Showcase tests - OpenShift deployments (Helm)
121143
yarn showcase # General showcase tests
122-
yarn showcase-ci-nightly # General showcase tests (nightly CI alias)
123144
yarn showcase-rbac # General showcase tests with RBAC
124-
yarn showcase-rbac-nightly # General showcase tests with RBAC (nightly CI alias)
125145

126146
# Showcase tests - Kubernetes deployments
127-
yarn showcase-k8s-ci-nightly # Kubernetes showcase tests
128-
yarn showcase-rbac-k8s-ci-nightly # Kubernetes showcase tests with RBAC
147+
yarn showcase-k8s # Kubernetes showcase tests
148+
yarn showcase-rbac-k8s # Kubernetes showcase tests with RBAC
129149

130150
# Showcase tests - Operator deployments
131-
yarn showcase-operator-nightly # Operator showcase tests
132-
yarn showcase-operator-rbac-nightly # Operator showcase tests with RBAC
151+
yarn showcase-operator # Operator showcase tests
152+
yarn showcase-operator-rbac # Operator showcase tests with RBAC
133153

134154
# Showcase tests - Other scenarios
135155
yarn showcase-runtime # Runtime configuration tests
136-
yarn showcase-upgrade-nightly # Upgrade scenario tests
156+
yarn showcase-upgrade # Upgrade scenario tests
137157

138158
# Authentication provider tests
139159
yarn showcase-auth-providers # Auth provider tests
@@ -149,6 +169,8 @@ yarn prettier:check # Prettier checking
149169
yarn prettier:fix # Prettier fixing
150170
```
151171

172+
**Note**: The CI pipeline no longer uses yarn script aliases. Instead, it runs Playwright directly with `yarn playwright test --project=<project-name>`. This decouples the namespace from the test project name, enabling more flexible namespace and test project reuse.
173+
152174
### Environment Variables
153175

154176
All the important environment variables are sourced in `.ibm/pipelines/env_variables.sh`
@@ -289,6 +311,7 @@ For CI/CD pipeline execution, tests run in a containerized environment using the
289311
- **`.ibm/pipelines/utils.sh`**: Utility functions
290312
- **`.ibm/pipelines/reporting.sh`**: Reporting and notifications
291313
- **`.ibm/pipelines/env_variables.sh`**: Environment variable management
314+
- **`.ibm/pipelines/playwright-projects.sh`**: Loads Playwright project names from `projects.json` as `$PW_PROJECT_*` variables
292315

293316
#### CI Infrastructure Package Configuration
294317

@@ -353,7 +376,7 @@ export ISRUNNINGLOCAL=true
353376
export ISRUNNINGLOCALDEBUG=true
354377

355378
# Run tests locally
356-
npx playwright test --project showcase-auth-providers --workers 1
379+
yarn playwright test --project showcase-auth-providers --workers 1
357380
```
358381

359382
#### CI Debugging
@@ -363,8 +386,8 @@ npx playwright test --project showcase-auth-providers --workers 1
363386
4. **Test Failures**: Review test reports and screenshots
364387

365388
#### Common Debugging Tools
366-
- **Playwright Inspector**: `npx playwright test --debug`
367-
- **Trace Viewer**: `npx playwright show-trace`
389+
- **Playwright Inspector**: `yarn playwright test --debug`
390+
- **Trace Viewer**: `yarn playwright show-trace`
368391
- **Screenshots**: Automatic on failure
369392
- **Video Recording**: Available for all tests
370393

@@ -429,6 +452,7 @@ brew install gnu-sed
429452
- [OpenShift CI Pipeline README](.ibm/pipelines/README.md)
430453

431454
### Configuration Files
455+
- [Playwright Project Names (Single Source of Truth)](e2e-tests/playwright/projects.json)
432456
- [Playwright Configuration](e2e-tests/playwright.config.ts)
433457
- [Package Configuration](e2e-tests/package.json)
434458
- [Dynamic Plugins Config](dynamic-plugins/package.json)

.cursor/rules/playwright-locators.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ class CatalogPage {
146146

147147
```bash
148148
# Generate locators automatically
149-
npx playwright codegen http://localhost:7007
149+
yarn playwright codegen http://localhost:7007
150150

151151
# Debug tests step-by-step
152-
npx playwright test --debug
152+
yarn playwright test --debug
153153

154154
# Or pause in test
155155
await page.pause();

.ibm/pipelines/jobs/aks-helm.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ source "$DIR"/lib/log.sh
66
source "$DIR"/utils.sh
77
# shellcheck source=.ibm/pipelines/cluster/aks/aks-helm-deployment.sh
88
source "$DIR"/cluster/aks/aks-helm-deployment.sh
9+
# shellcheck source=.ibm/pipelines/playwright-projects.sh
10+
source "$DIR"/playwright-projects.sh
911

1012
handle_aks_helm() {
1113
log::info "Starting AKS Helm deployment"
@@ -19,10 +21,10 @@ handle_aks_helm() {
1921
cluster_setup_k8s_helm
2022

2123
initiate_aks_helm_deployment
22-
check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
24+
check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "${PW_PROJECT_SHOWCASE_K8S}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
2325
delete_namespace "${NAME_SPACE}"
2426

2527
initiate_rbac_aks_helm_deployment
26-
check_and_test "${RELEASE_NAME_RBAC}" "${NAME_SPACE_RBAC}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
28+
check_and_test "${RELEASE_NAME_RBAC}" "${NAME_SPACE_RBAC}" "${PW_PROJECT_SHOWCASE_RBAC_K8S}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
2729
delete_namespace "${NAME_SPACE_RBAC}"
2830
}

.ibm/pipelines/jobs/aks-operator.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ source "$DIR"/install-methods/operator.sh
88
source "$DIR"/cluster/aks/aks-operator-deployment.sh
99
# shellcheck source=.ibm/pipelines/cluster/k8s/k8s-utils.sh
1010
source "$DIR"/cluster/k8s/k8s-utils.sh
11+
# shellcheck source=.ibm/pipelines/playwright-projects.sh
12+
source "$DIR"/playwright-projects.sh
1113

1214
handle_aks_operator() {
1315
log::info "Starting AKS Operator deployment"
@@ -23,10 +25,10 @@ handle_aks_operator() {
2325
prepare_operator "3"
2426

2527
initiate_aks_operator_deployment "${NAME_SPACE}" "https://${K8S_CLUSTER_ROUTER_BASE}"
26-
check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
28+
check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "${PW_PROJECT_SHOWCASE_K8S}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
2729
cleanup_aks_deployment "${NAME_SPACE}"
2830

2931
initiate_rbac_aks_operator_deployment "${NAME_SPACE_RBAC}" "https://${K8S_CLUSTER_ROUTER_BASE}"
30-
check_and_test "${RELEASE_NAME}" "${NAME_SPACE_RBAC}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
32+
check_and_test "${RELEASE_NAME}" "${NAME_SPACE_RBAC}" "${PW_PROJECT_SHOWCASE_RBAC_K8S}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
3133
cleanup_aks_deployment "${NAME_SPACE_RBAC}"
3234
}

.ibm/pipelines/jobs/auth-providers.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ source "$DIR"/lib/log.sh
66
source "$DIR"/utils.sh
77
# shellcheck source=.ibm/pipelines/install-methods/operator.sh
88
source "$DIR"/install-methods/operator.sh
9+
# shellcheck source=.ibm/pipelines/playwright-projects.sh
10+
source "$DIR"/playwright-projects.sh
911

1012
handle_auth_providers() {
1113
local retry_operator_installation="${1:-1}"
@@ -23,5 +25,5 @@ handle_auth_providers() {
2325
export LOGS_FOLDER
2426

2527
log::info "Running tests ${AUTH_PROVIDERS_RELEASE} in ${AUTH_PROVIDERS_NAMESPACE}"
26-
run_tests "${AUTH_PROVIDERS_RELEASE}" "${AUTH_PROVIDERS_NAMESPACE}"
28+
run_tests "${AUTH_PROVIDERS_RELEASE}" "${AUTH_PROVIDERS_NAMESPACE}" "${PW_PROJECT_SHOWCASE_AUTH_PROVIDERS}" "https://${K8S_CLUSTER_ROUTER_BASE}"
2729
}

.ibm/pipelines/jobs/eks-helm.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ source "$DIR"/cluster/eks/eks-helm-deployment.sh
1010
source "$DIR"/cluster/eks/aws.sh
1111
# shellcheck source=.ibm/pipelines/cluster/k8s/k8s-utils.sh
1212
source "$DIR"/cluster/k8s/k8s-utils.sh
13+
# shellcheck source=.ibm/pipelines/playwright-projects.sh
14+
source "$DIR"/playwright-projects.sh
1315

1416
handle_eks_helm() {
1517
log::info "Starting EKS Helm deployment"
@@ -33,7 +35,7 @@ handle_eks_helm() {
3335

3436
initiate_eks_helm_deployment
3537
configure_eks_ingress_and_dns "${NAME_SPACE}" "${RELEASE_NAME}-developer-hub"
36-
check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
38+
check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "${PW_PROJECT_SHOWCASE_K8S}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
3739
cleanup_eks_dns_record "${EKS_INSTANCE_DOMAIN_NAME}"
3840
delete_namespace "${NAME_SPACE}"
3941

@@ -44,7 +46,7 @@ handle_eks_helm() {
4446

4547
initiate_rbac_eks_helm_deployment
4648
configure_eks_ingress_and_dns "${NAME_SPACE_RBAC}" "${RELEASE_NAME_RBAC}-developer-hub"
47-
check_and_test "${RELEASE_NAME_RBAC}" "${NAME_SPACE_RBAC}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
49+
check_and_test "${RELEASE_NAME_RBAC}" "${NAME_SPACE_RBAC}" "${PW_PROJECT_SHOWCASE_RBAC_K8S}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
4850
cleanup_eks_dns_record "${EKS_INSTANCE_DOMAIN_NAME}"
4951
delete_namespace "${NAME_SPACE_RBAC}"
5052
}

.ibm/pipelines/jobs/eks-operator.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ source "$DIR"/cluster/eks/eks-operator-deployment.sh
1010
source "$DIR"/cluster/k8s/k8s-utils.sh
1111
# shellcheck source=.ibm/pipelines/cluster/eks/aws.sh
1212
source "$DIR"/cluster/eks/aws.sh
13+
# shellcheck source=.ibm/pipelines/playwright-projects.sh
14+
source "$DIR"/playwright-projects.sh
1315

1416
handle_eks_operator() {
1517
log::info "Starting EKS Operator deployment"
@@ -34,7 +36,7 @@ handle_eks_operator() {
3436

3537
initiate_eks_operator_deployment "${NAME_SPACE}" "https://${K8S_CLUSTER_ROUTER_BASE}"
3638
configure_eks_ingress_and_dns "${NAME_SPACE}" "dh-ingress"
37-
check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
39+
check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "${PW_PROJECT_SHOWCASE_K8S}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
3840
cleanup_eks_dns_record "${EKS_INSTANCE_DOMAIN_NAME}"
3941
cleanup_eks_deployment "${NAME_SPACE}"
4042

@@ -45,7 +47,7 @@ handle_eks_operator() {
4547

4648
initiate_rbac_eks_operator_deployment "${NAME_SPACE_RBAC}" "https://${K8S_CLUSTER_ROUTER_BASE}"
4749
configure_eks_ingress_and_dns "${NAME_SPACE_RBAC}" "dh-ingress"
48-
check_and_test "${RELEASE_NAME}" "${NAME_SPACE_RBAC}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
50+
check_and_test "${RELEASE_NAME}" "${NAME_SPACE_RBAC}" "${PW_PROJECT_SHOWCASE_RBAC_K8S}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
4951
cleanup_eks_dns_record "${EKS_INSTANCE_DOMAIN_NAME}"
5052
cleanup_eks_deployment "${NAME_SPACE_RBAC}"
5153
}

0 commit comments

Comments
 (0)