Skip to content

CONSOLE-5197: Improve Playwright artifact collection and add safety checks#16463

Open
vikram-raj wants to merge 2 commits into
openshift:mainfrom
vikram-raj:playwright-artifact
Open

CONSOLE-5197: Improve Playwright artifact collection and add safety checks#16463
vikram-raj wants to merge 2 commits into
openshift:mainfrom
vikram-raj:playwright-artifact

Conversation

@vikram-raj
Copy link
Copy Markdown
Member

@vikram-raj vikram-raj commented May 19, 2026

Analysis / Root cause:
The Playwright E2E test infrastructure needed improvements in artifact collection for CI environments:

  1. Limited artifact collection - only copied test-results, missing JUnit XML and HTML reports
  2. Shell scripts lacked defensive programming practices for path operations
  3. No validation of ARTIFACT_DIR environment variable before use
  4. Risk of accidental deletion with unchecked rm -rf operations

Solution description:
This PR implements comprehensive artifact collection and safety improvements:

  1. Enhanced Artifact Collection (commit 9a99fd0):

    • Copies test-results directory (traces, screenshots, videos)
    • Extracts JUnit XML to $ARTIFACT_DIR/junit-playwright.xml for CI reporting
    • Generates HTML report at $ARTIFACT_DIR/playwright-report for debugging
    • Added clear console output showing what was copied and where
    • Uses cp -a to preserve file attributes
  2. Safety Improvements (commit 1a716b7):

    • Validates ARTIFACT_DIR is set and is an absolute path before use
    • Adds safety checks before rm -rf operations to prevent accidental deletion
    • Returns errors gracefully if validation fails
    • Protects against misconfigured environment variables in CI

Screenshots / screen recording:
N/A - Infrastructure/CI changes only

Test setup:
Set up Playwright E2E test environment:

cd frontend
yarn install
npx playwright install

Test cases:

  • Run ARTIFACT_DIR=/tmp/test-artifacts ./integration-tests/test-playwright-e2e.sh and verify artifacts are copied
  • Verify JUnit XML is created at $ARTIFACT_DIR/junit-playwright.xml
  • Verify HTML report is created at $ARTIFACT_DIR/playwright-report/index.html
  • Test with invalid ARTIFACT_DIR (relative path) - should fail with clear error
  • Test with empty ARTIFACT_DIR - should fail with clear error
  • Shell script syntax validation passes (bash -n)

Browser conformance:
N/A - Infrastructure changes only

Additional info:

  • These changes improve CI artifact collection for OpenShift Prow jobs
  • HTML reports make it easier to debug test failures in CI
  • Safety checks follow shell scripting best practices
  • No functional changes to test execution, only artifact handling

Summary by CodeRabbit

  • Chores
    • Enhanced test artifact collection with improved validation and error handling
    • Expanded Playwright test reporting to include HTML reports alongside existing formats

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 19, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented May 19, 2026

@vikram-raj: This pull request references CONSOLE-5197 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Analysis / Root cause:
The Playwright E2E test infrastructure needed improvements in artifact collection for CI environments:

  1. Limited artifact collection - only copied test-results, missing JUnit XML and HTML reports
  2. Shell scripts lacked defensive programming practices for path operations
  3. No validation of ARTIFACT_DIR environment variable before use
  4. Risk of accidental deletion with unchecked rm -rf operations

Solution description:
This PR implements comprehensive artifact collection and safety improvements:

  1. Enhanced Artifact Collection (commit 9a99fd0):
  • Copies test-results directory (traces, screenshots, videos)
  • Extracts JUnit XML to $ARTIFACT_DIR/junit-playwright.xml for CI reporting
  • Generates HTML report at $ARTIFACT_DIR/playwright-report for debugging
  • Added clear console output showing what was copied and where
  • Uses cp -a to preserve file attributes
  1. Safety Improvements (commit 1a716b7):
  • Validates ARTIFACT_DIR is set and is an absolute path before use
  • Adds safety checks before rm -rf operations to prevent accidental deletion
  • Returns errors gracefully if validation fails
  • Protects against misconfigured environment variables in CI

Screenshots / screen recording:
N/A - Infrastructure/CI changes only

Test setup:
Set up Playwright E2E test environment:

cd frontend
yarn install
npx playwright install

Test cases:

  • Run ARTIFACT_DIR=/tmp/test-artifacts ./integration-tests/test-playwright-e2e.sh and verify artifacts are copied
  • Verify JUnit XML is created at $ARTIFACT_DIR/junit-playwright.xml
  • Verify HTML report is created at $ARTIFACT_DIR/playwright-report/index.html
  • Test with invalid ARTIFACT_DIR (relative path) - should fail with clear error
  • Test with empty ARTIFACT_DIR - should fail with clear error
  • Shell script syntax validation passes (bash -n)

Browser conformance:
N/A - Infrastructure changes only

Additional info:

  • These changes improve CI artifact collection for OpenShift Prow jobs
  • HTML reports make it easier to debug test failures in CI
  • Safety checks follow shell scripting best practices
  • No functional changes to test execution, only artifact handling

Reviewers and assignees:
/cc @openshift/team-ux-review

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 19, 2026

@vikram-raj: GitHub didn't allow me to request PR reviews from the following users: openshift/team-ux-review.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

Analysis / Root cause:
The Playwright E2E test infrastructure needed improvements in artifact collection for CI environments:

  1. Limited artifact collection - only copied test-results, missing JUnit XML and HTML reports
  2. Shell scripts lacked defensive programming practices for path operations
  3. No validation of ARTIFACT_DIR environment variable before use
  4. Risk of accidental deletion with unchecked rm -rf operations

Solution description:
This PR implements comprehensive artifact collection and safety improvements:

  1. Enhanced Artifact Collection (commit 9a99fd0):
  • Copies test-results directory (traces, screenshots, videos)
  • Extracts JUnit XML to $ARTIFACT_DIR/junit-playwright.xml for CI reporting
  • Generates HTML report at $ARTIFACT_DIR/playwright-report for debugging
  • Added clear console output showing what was copied and where
  • Uses cp -a to preserve file attributes
  1. Safety Improvements (commit 1a716b7):
  • Validates ARTIFACT_DIR is set and is an absolute path before use
  • Adds safety checks before rm -rf operations to prevent accidental deletion
  • Returns errors gracefully if validation fails
  • Protects against misconfigured environment variables in CI

Screenshots / screen recording:
N/A - Infrastructure/CI changes only

Test setup:
Set up Playwright E2E test environment:

cd frontend
yarn install
npx playwright install

Test cases:

  • Run ARTIFACT_DIR=/tmp/test-artifacts ./integration-tests/test-playwright-e2e.sh and verify artifacts are copied
  • Verify JUnit XML is created at $ARTIFACT_DIR/junit-playwright.xml
  • Verify HTML report is created at $ARTIFACT_DIR/playwright-report/index.html
  • Test with invalid ARTIFACT_DIR (relative path) - should fail with clear error
  • Test with empty ARTIFACT_DIR - should fail with clear error
  • Shell script syntax validation passes (bash -n)

Browser conformance:
N/A - Infrastructure changes only

Additional info:

  • These changes improve CI artifact collection for OpenShift Prow jobs
  • HTML reports make it easier to debug test failures in CI
  • Safety checks follow shell scripting best practices
  • No functional changes to test execution, only artifact handling

Reviewers and assignees:
/cc @openshift/team-ux-review

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

The PR establishes a robust artifact handling pipeline for Playwright end-to-end tests. It adds HTML report generation to the Playwright configuration, introduces a new helper function in the integration test script that validates the artifact directory, safely copies Playwright outputs (test results and HTML reports), and renames the JUnit XML appropriately. The prow wrapper script now validates that ARTIFACT_DIR is set and absolute before running tests, ensuring artifacts are always collected in a known, valid location. Exit codes are preserved throughout to maintain test failure signals.

Suggested reviewers

  • cajieh
  • TheRealJon
  • logonoff
🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (11 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main changes: improving Playwright artifact collection and adding safety checks to shell scripts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed Custom check targets Ginkgo test names (Go tests with It(), Describe() patterns). PR modifies only shell scripts and TypeScript config—no Ginkgo tests present. Check not applicable to this PR.
Test Structure And Quality ✅ Passed This PR modifies shell scripts and TypeScript Playwright configuration only. The custom check targets Ginkgo Go test code, which is not present in this PR. Not applicable.
Microshift Test Compatibility ✅ Passed Check is not applicable. PR contains no new Ginkgo e2e tests—only Playwright infrastructure and shell script improvements. Custom check targets Ginkgo test additions, which are absent.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR adds no Ginkgo e2e tests—only modifies shell scripts for Playwright artifact collection and Playwright config. Custom check requires Ginkgo test definitions; none present. Check not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only test infrastructure (shell scripts and test config), not deployment manifests, operators, or controllers. No scheduling constraints or topology rules introduced.
Ote Binary Stdout Contract ✅ Passed Check not applicable. OTE Binary Stdout Contract applies to Go test files with Ginkgo. This PR modifies only shell scripts and TypeScript config—no Go code or test binaries.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Check applies only to Ginkgo e2e tests. This PR adds no Ginkgo tests—only Playwright CI infrastructure improvements (shell scripts and TypeScript config). Not applicable to PR.
Description check ✅ Passed The PR description comprehensively covers all required template sections with clear analysis, solution details, test cases, and validation results.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/integration-tests/test-playwright-e2e.sh`:
- Around line 94-97: The script currently accepts ARTIFACT_DIR="/" as valid
which is dangerous; update the validation around the case block handling
ARTIFACT_DIR to explicitly reject "/" (for example add a branch that checks
ARTIFACT_DIR = "/" and prints an error/returns non-zero before allowing absolute
paths, or add an explicit if [ "$ARTIFACT_DIR" = "/" ]; then echo "Error:
ARTIFACT_DIR must not be '/'" >&2; return 1; fi immediately after the case).
Apply the same explicit "/" rejection to the other validation sites referenced
(the other ARTIFACT_DIR checks at the locations noted).
- Around line 142-147: The copyArtifacts() helper currently preserves the
original test exit code unconditionally, so if copy_playwright_artifacts_to_dir
fails (e.g., invalid ARTIFACT_DIR) the script still exits 0; change
copyArtifacts() to capture the exit status of copy_playwright_artifacts_to_dir
(store its return value), and if that command fails (non-zero) exit with that
non-zero code (or a combined non-zero) instead of always exiting with the
original $exit_code; update references inside the copyArtifacts() function to
check the captured status of copy_playwright_artifacts_to_dir and use that for
the final exit when appropriate.

In `@test-prow-playwright-e2e.sh`:
- Around line 33-36: The current case allows ARTIFACT_DIR="/" which is unsafe;
update the guard around the ARTIFACT_DIR check (the case handling the
absolute-path check for ARTIFACT_DIR) to explicitly reject the root path: add a
check that if ARTIFACT_DIR is exactly "/" then print an error to stderr and exit
1 (same style/message as the other branch) — either by augmenting the existing
case arm for /* to perform this equality test and fail when equal to "/" or by
adding a separate conditional immediately after the case that tests [
"$ARTIFACT_DIR" = "/" ] and exits with an error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 90367705-7b97-4726-9bb2-5facc27942ab

📥 Commits

Reviewing files that changed from the base of the PR and between ed9a644 and 1a716b7.

📒 Files selected for processing (3)
  • frontend/integration-tests/test-playwright-e2e.sh
  • frontend/playwright.config.ts
  • test-prow-playwright-e2e.sh
📜 Review details
🧰 Additional context used
📓 Path-based instructions (10)
frontend/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

frontend/**/*.{ts,tsx,js,jsx}: Never import from package index files (e.g., @console/shared) in new code, as they can create circular dependencies and slow builds. Import from specific file paths instead.
Do not use backticks in t() calls for i18n strings, as the i18n parser cannot extract keys from template literals. Use single or double quotes instead.

Files:

  • frontend/playwright.config.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Never import from deprecated packages or use code with the @deprecated TSdoc tag in new code.

**/*.{ts,tsx}: Use React functional components with hooks instead of class components
State Management: Use React hooks and Context API (migrating away from legacy Redux/Immutable.js)
Hooks: Use existing hooks from console-shared when possible (useK8sWatchResource, useUserSettings, etc.)
API calls: Use k8s resource hooks for data fetching, consoleFetchJSON for HTTP requests
Extensions: Use console extension points for plugin integration
Types: Check existing types in console-shared before creating new ones
Dynamic Plugins: Use console extension points for plugin integration
Styling: Use SCSS modules co-located with components, PatternFly design system components, avoid any SCSS/CSS if possible
Accessibility: Follow WCAG 2.1 AA standards, use semantic HTML, ARIA labels where needed, ensure keyboard navigation, test with screen readers
i18n: Use useTranslation('namespace') hook with key format for translation keys
Error Handling: Use ErrorBoundary components and graceful degradation patterns
Optimize re-renders: Use useCallback for memoized callbacks to avoid function recreation every render
Optimize re-renders: Use useMemo for expensive computations to avoid recalculating on every render
Lazy loading: Use React.lazy() to lazy load heavy components
TypeScript type safety: Avoid using any type; suggest proper type definitions and verify null/undefined are handled properly
Type component props properly: Reuse existing component prop types instead of duplicating type definitions
Use proper hooks: Use specialized hooks like usePluginInfo for plugin data instead of generic data fetching patterns
Avoid deprecated components: Check for JSDoc @deprecated tags, import paths containing /deprecated, and DEPRECATED_ file name prefix before using components
Importing from barrel files and circular dependencies: Import directly from specific files instead...

Files:

  • frontend/playwright.config.ts
frontend/**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Never use absolute URLs or paths in the console code. The console runs behind a proxy under an arbitrary path.

Files:

  • frontend/playwright.config.ts
frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

When writing code for static plugins, ensure that all $codeRef reference the corresponding extension type from the @console/dynamic-plugin-sdk package.

Files:

  • frontend/playwright.config.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (TESTING.md)

**/*.{tsx,ts}: Always use page.getByTestId('x') for Playwright selectors which queries [data-test="x"]. If a React element only has a legacy test attribute, add data-test to the element. Never remove legacy attributes
Prefer data-test attributes in Cypress selectors (e.g., cy.get('[data-test="create-deployment"]')) over brittle CSS/ARIA selectors

File Naming: PascalCase for components, kebab-case for utilities, *.spec.ts(x) for tests

Files:

  • frontend/playwright.config.ts
**/*.{go,ts,tsx,js,jsx}

📄 CodeRabbit inference engine (STYLEGUIDE.md)

Use lowercase dash-separated names for all files to avoid git issues with case-insensitive file systems

Files:

  • frontend/playwright.config.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (STYLEGUIDE.md)

**/*.{ts,tsx,js,jsx}: New code MUST be written in TypeScript, not JavaScript
Prefer functional programming patterns and immutable data structures
Run the linter and follow all rules defined in .eslintrc
Never use absolute paths in code - the app should be able to run behind a proxy under an arbitrary path

Files:

  • frontend/playwright.config.ts
**/*.ts

📄 CodeRabbit inference engine (STYLEGUIDE.md)

Plugin SDK Changes: Any updates to console-dynamic-plugin-sdk should aim to maintain backward compatibility as it's a public API - use the plugin-api-review skill to vet changes for public API impact and ensure proper documentation updates

Files:

  • frontend/playwright.config.ts
frontend/**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (README.md)

frontend/**/*.{js,ts,tsx}: Support only the latest versions of Edge, Chrome, Safari, and Firefox browsers; IE 11 and earlier are not supported
CSP violations should be automatically reported to telemetry by parsing dynamic plugin names from securitypolicyviolation events, with throttling to prevent duplicate reports within a day

Files:

  • frontend/playwright.config.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (INTERNATIONALIZATION.md)

For dynamic translation keys that cannot be parsed by i18next-parser (t(key), t('key' + id), t(key${id})), specify possible static values in comments for the parser to extract

Files:

  • frontend/playwright.config.ts
🔇 Additional comments (1)
frontend/playwright.config.ts (1)

58-58: LGTM!

Comment thread frontend/integration-tests/test-playwright-e2e.sh
Comment thread frontend/integration-tests/test-playwright-e2e.sh Outdated
Comment thread test-prow-playwright-e2e.sh
- Validate ARTIFACT_DIR is set and is an absolute path before use
- Add safety checks before rm -rf to prevent accidental deletion of wrong directories
- Protect against misconfigured environment variables in CI

These defensive improvements ensure that:
1. ARTIFACT_DIR is always validated as an absolute path
2. rm -rf operations only proceed if the target path is valid and not "/"
3. Functions return errors gracefully if validation fails

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vikram-raj vikram-raj force-pushed the playwright-artifact branch from 1a716b7 to d05b024 Compare May 19, 2026 15:31
@vikram-raj
Copy link
Copy Markdown
Member Author

/cc @stefanonardo

@openshift-ci openshift-ci Bot requested a review from stefanonardo May 19, 2026 15:59
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 19, 2026

@vikram-raj: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@stefanonardo
Copy link
Copy Markdown
Contributor

/lgtm

@stefanonardo
Copy link
Copy Markdown
Contributor

/verified by CI

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 20, 2026
@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label May 20, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@stefanonardo: This PR has been marked as verified by CI.

Details

In response to this:

/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@vikram-raj
Copy link
Copy Markdown
Member Author

/label docs-approved
/label px-approved

@openshift-ci openshift-ci Bot added docs-approved Signifies that Docs has signed off on this PR px-approved Signifies that Product Support has signed off on this PR labels May 20, 2026
Copy link
Copy Markdown
Member

@jhadvig jhadvig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 20, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhadvig, stefanonardo, vikram-raj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants