-
Notifications
You must be signed in to change notification settings - Fork 526
[WIP] CNTRLPLANE-3846: Bring UI E2E infra into Hypershift repo #9065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
georgelipceanu
wants to merge
1
commit into
openshift:main
Choose a base branch
from
georgelipceanu:mce-ui-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # HyperShift UI E2E Test Environment Configuration | ||
| # Copy this file to .env and fill in your values | ||
|
|
||
| # Hub cluster configuration | ||
| HUB_URL=https://api.your-cluster.example.com:6443 | ||
| HUB_PASSWORD=your-kubeadmin-password | ||
|
|
||
| # Console URL (optional - derived from HUB_URL if not set) | ||
| # CONSOLE_URL=https://console-openshift-console.apps.your-cluster.example.com | ||
|
|
||
| # Console authentication (optional overrides) | ||
| CONSOLE_USERNAME=kubeadmin | ||
| CONSOLE_IDP=kube:admin | ||
|
|
||
| # Test configuration | ||
| CI=false | ||
| TEST_MODE=integration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Dependencies | ||
| node_modules/ | ||
|
|
||
| # Build output | ||
| dist/ | ||
|
|
||
| # Playwright | ||
| test-results/ | ||
| playwright-report/ | ||
| playwright/.cache/ | ||
|
|
||
| # Auth state (contains session cookies - DO NOT COMMIT) | ||
| .auth/ | ||
|
|
||
| # IDE | ||
| .idea/ | ||
| .vscode/ | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Logs | ||
| *.log | ||
| npm-debug.log* | ||
|
|
||
| # Environment variables | ||
| .env | ||
| .env.local | ||
| .env.*.local | ||
| *.local.env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| node_modules/ | ||
| test-results/ | ||
| playwright-report/ | ||
| .auth/ | ||
| dist/ | ||
| package-lock.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "semi": true, | ||
| "singleQuote": true, | ||
| "trailingComma": "es5", | ||
| "printWidth": 100 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| # HyperShift UI E2E Tests | ||
|
|
||
| Playwright-based E2E test framework for HyperShift MCE console integration following console E2E patterns. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 1. **Node.js** 20+ | ||
| 2. oc CLI installed and logged into your cluster | ||
| 3. Playwright browsers installed | ||
| ```bash | ||
| # Install dependencies and Playwright browsers | ||
| make test-ui-install | ||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| **Recommended:** Copy `.env.example` when making `.env` (gitignored). Playwright loads it via `src/config/index.ts`. | ||
|
|
||
| **Hub cluster + console authentication:** | ||
|
|
||
| | Variable | Required | Default | Description | | ||
| | ------------------ | -------- | ------------ | ------------------------------------------------------------------- | | ||
| | `HUB_URL` | **Yes** | - | Hub cluster API URL (e.g., `https://api.cluster.com:6443`) | | ||
| | `HUB_PASSWORD` | **Yes** | - | Password for `oc login` and console UI authentication | | ||
| | `CONSOLE_URL` | No | (derived) | Console URL (derived from `HUB_URL` if not set) | | ||
| | `CONSOLE_USERNAME` | No | `kubeadmin` | Username for console login form | | ||
| | `CONSOLE_IDP` | No | `kube:admin` | Identity provider link text on console login page | | ||
|
|
||
| **Test configuration (optional):** | ||
|
|
||
| | Variable | Required | Default | Description | | ||
| | ----------- | -------- | ------------- | ----------------------------------------------------- | | ||
| | `CI` | No | `false` | Set to `true` to enable CI mode (retries, forbidOnly) | | ||
| | `TEST_MODE` | No | `integration` | Test mode (`integration`, `e2e`, etc.) | | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| > **Note:** `CI` is parsed as a boolean. Only the string `"true"` enables CI mode; any other value (including `"false"` or unset) disables it. | ||
| > | ||
| > **Typical kubeadmin setup:** `.env` with just `HUB_URL` and `HUB_PASSWORD`. | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| ### Example `.env` | ||
|
|
||
| ```bash | ||
| HUB_URL=https://api.my-hub-cluster.example.com:6443 | ||
| HUB_PASSWORD=my-kubeadmin-password | ||
| CONSOLE_USERNAME=kubeadmin | ||
| CONSOLE_IDP=kube:admin | ||
| ``` | ||
|
|
||
| ## Playwright Projects | ||
|
|
||
| | Project | Scope | Test Path | | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| | -------- | ------------------------------------------------------------------------------- | --------------------- | | ||
| | `setup` | Authentication setup → saves session to `.auth/admin.json` | `src/auth.setup.ts` | | ||
| | `common` | Platform-agnostic tests (smoke tests, infrastructure validation) | `src/tests/common/**` | | ||
| | `agent` | Agent-platform HyperShift tests (InfraEnv, discovery ISO, bare metal workflows) | `src/tests/agent/**` | | ||
|
|
||
| Projects depend on `setup` for authentication and run with a saved console session. | ||
|
|
||
| **Note**: All tests migrated from stolostron/clc-ui-e2e (CNTRLPLANE-2104) are Agent platform tests. AWS and other platform tests are not in the initial migration scope. | ||
|
|
||
| ## Running Tests | ||
| ### All Tests | ||
| ```bash | ||
| make test-ui | ||
| ``` | ||
| ### Platform-Specific Tests | ||
| ```bash | ||
| # Common tests (smoke tests, infrastructure) | ||
| make test-ui-common | ||
|
|
||
| # Agent platform tests | ||
| make test-ui-agent | ||
| ``` | ||
| ### Development Mode | ||
| ```bash | ||
| # Headed mode (see browser) | ||
| make test-ui-headed | ||
| ``` | ||
| ### Direct Playwright CLI | ||
| ```bash | ||
| cd test/ui | ||
|
|
||
| # Run all tests | ||
| npm test | ||
|
|
||
| # Run specific project | ||
| npm run test:common | ||
| npm run test:agent | ||
|
|
||
| # Run specific test file | ||
| npx playwright test src/tests/common/smoke.spec.ts | ||
|
|
||
| # UI mode (interactive) | ||
| npx playwright test --ui | ||
|
|
||
| # Debug mode (step through with inspector) | ||
| npx playwright test --debug | ||
| ``` | ||
|
|
||
| ## Architecture | ||
| - **Playwright** for browser automation | ||
| - **TypeScript** with path aliases (`@config`, `@pages`, `@services`, etc.) | ||
| - **Page Object Model** pattern for UI interactions | ||
| - **Fixtures** for dependency injection (`oc` CLI service, unique name generator, cleanup tracker) | ||
|
|
||
| This directory maps to it as follows: | ||
| ```text | ||
| test/ui/ | ||
| ├── src/ | ||
| │ ├── auth.setup.ts # OpenShift console authentication | ||
| │ ├── global-setup.ts # Pre-test cleanup (.auth/ directory) | ||
| │ ├── config/ # Environment configuration | ||
| │ ├── constants/ # Selectors and constants | ||
| │ ├── services/ # CLI services (OcCliService, etc.) | ||
| │ ├── pages/ # Page Object Model classes | ||
| │ │ └── ... | ||
| │ ├── fixtures/ # Playwright test fixtures (oc, uniqueName, cleanup) | ||
| │ │ └── hypershift-test.ts # Base fixture extending Playwright test | ||
| │ ├── utils/ # Helper utilities | ||
| │ └── tests/ # Test specifications | ||
| │ ├── common/ # Platform-agnostic smoke tests | ||
| │ └── agent/ # Agent platform tests | ||
| ├── .env.example # Environment variable template | ||
| ├── playwright.config.ts # Playwright configuration | ||
| ├── tsconfig.json # TypeScript configuration | ||
| └── package.json # Dependencies and scripts | ||
| ``` | ||
|
|
||
| ## Writing New Tests | ||
| 1. **Create a test file** in `src/tests/common/` or `src/tests/agent/` | ||
| 2. **Use the HyperShift fixture:** | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| ```typescript | ||
| import { test, expect } from '@fixtures/hypershift-test'; | ||
|
|
||
| test.describe('My Feature', () => { | ||
| test('should do something', async ({ page, oc, uniqueName, cleanup }) => { | ||
| // page: Playwright Page object | ||
| // oc: OcCliService for running oc commands | ||
| // uniqueName: Unique test resource name (hypershift-ci-xxxxx) | ||
| // cleanup: Automatic cleanup tracker for HostedClusters and namespaces | ||
| // Your test logic here | ||
| }); | ||
| }); | ||
| ``` | ||
| 1. **Create page objects** in `src/pages/` following the Page Object Model pattern | ||
| 2. **Add cleanup** for any resources created: | ||
| ```typescript | ||
| cleanup.trackHostedCluster('my-cluster', 'clusters'); | ||
| cleanup.trackNamespace('my-test-namespace'); | ||
| ``` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import eslint from '@eslint/js'; | ||
| import eslintConfigPrettier from 'eslint-config-prettier'; | ||
| import playwright from 'eslint-plugin-playwright'; | ||
| import tseslint from 'typescript-eslint'; | ||
|
|
||
| export default tseslint.config( | ||
| { | ||
| ignores: [ | ||
| '**/node_modules/**', | ||
| '**/.auth/**', | ||
| '**/test-results/**', | ||
| '**/playwright-report/**', | ||
| ], | ||
| }, | ||
| { | ||
| files: ['**/*.ts'], | ||
| extends: [ | ||
| eslint.configs.recommended, | ||
| ...tseslint.configs.recommended, | ||
| playwright.configs['flat/recommended'], | ||
| eslintConfigPrettier, | ||
| ], | ||
| rules: { | ||
| 'playwright/expect-expect': 'warn', | ||
| }, | ||
| } | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.