Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ dynamic-plugins-root/*
**/__pycache__/
**/.pytest_cache/
**/.venv/

# rhdh-local clone for e2e testing
rhdh-local/
85 changes: 84 additions & 1 deletion docs/e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# README for End-to-End Automation Framework

**Stack**: [Playwright](https://playwright.dev/) over TypeScript
**Stack**: [Playwright](https://playwright.dev/) over TypeScript
**Repository Location**: [GitHub Repository](https://github.com/redhat-developer/rhdh/tree/main/e2e-tests)

## File Structure of the Testing Framework
Expand Down Expand Up @@ -49,6 +49,7 @@ To run the tests, ensure you have:
- [Playwright browsers installed](#install-playwright-browsers)

#### macOS Users

**Important**: If you're using macOS, you need to install GNU `grep` and GNU `sed` to avoid compatibility issues with scripts and CI/CD pipelines:

```bash
Expand Down Expand Up @@ -116,6 +117,88 @@ All Playwright project names are defined in [`e2e-tests/playwright/projects.json

See the [CI documentation](CI.md#playwright-project-names-single-source-of-truth) for more details.

## Running Tests Locally with rhdh-local

For quick local testing without a Kubernetes cluster, you can use the `run-e2e-tests.sh` script which automatically sets up [rhdh-local](https://github.com/redhat-developer/rhdh-local) and runs tests against it.

### Prerequisites

- **Podman** (v5.4.1+)
- **Node.js** (v18+)
- **Git**

### Quick Start

From the repository root:

```bash
# Run basic sanity tests with the latest community image
./scripts/run-e2e-tests.sh --project showcase-sanity-plugins

# Run RBAC tests
./scripts/run-e2e-tests.sh --profile rbac --project showcase-rbac

# Build and test local changes
./scripts/run-e2e-tests.sh --build --project showcase-sanity-plugins
```

### Available Options

| Option | Description |
|--------|-------------|
| `--profile <name>` | Test profile: `basic` (default) or `rbac` |
| `--project <name>` | Playwright project (default: `showcase-sanity-plugins`) |
| `--build` | Build local RHDH image from `docker/Dockerfile` |
| `--image <url>` | Use a specific registry image |
| `--fresh` | Force re-clone rhdh-local |
| `--skip-setup` | Skip setup, use existing running RHDH instance |
| `--skip-teardown` | Leave RHDH running after tests |

### How It Works

1. The script clones [rhdh-local](https://github.com/redhat-developer/rhdh-local) into `./rhdh-local/` (gitignored)
2. Copies local configs from `e2e-tests/local/` (these work without external services)
3. Starts RHDH using podman/docker compose
4. Waits for the health check endpoint
5. Runs Playwright tests with `CI=true BASE_URL=http://localhost:7007`
6. Tears down the environment (unless `--skip-teardown`)

### Test Profiles

| Profile | Config File | Use Case |
|---------|-------------|----------|
| `basic` | `e2e-tests/local/config-basic.yaml` | General testing with guest auth |
| `rbac` | `e2e-tests/local/config-rbac.yaml` | RBAC/permissions testing |

> **Note**: These are minimal configs designed for local testing without external services (GitHub Apps, Keycloak, etc.). They differ from the CI configs in `.ibm/pipelines/resources/config_map/` which require a fully-configured environment. See `e2e-tests/local/README.md` for more details.

### Test Compatibility

Not all tests work with local rhdh-local. Here's a compatibility matrix:

| Test Project | Compatible | Notes |
|--------------|------------|-------|
| `showcase-sanity-plugins` | ✅ Yes | Quick sanity checks |
| `showcase` | ⚠️ Partial | Some tests require GitHub integration |
| `showcase-rbac` | ✅ Yes | Use `--profile rbac` |
| `showcase-k8s` | ❌ No | Requires Kubernetes cluster |
| `showcase-auth-providers` | ❌ No | Requires Keycloak/external auth |

### Debugging

To keep RHDH running after tests for debugging:

```bash
./scripts/run-e2e-tests.sh --project showcase-sanity-plugins --skip-teardown
```

Then access RHDH at <http://localhost:7007> and run tests manually:

```bash
cd e2e-tests
BASE_URL=http://localhost:7007 yarn playwright test --ui
```

## Setting Up Backstage Configuration During the Pipeline

[app-config-rhdh.yaml](../../.ibm/pipelines/resources/config_map/app-config-rhdh.yaml) is the configuration file used to add plugins or any other kind of configuration into Backstage during pipeline execution.
Expand Down
11 changes: 11 additions & 0 deletions e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@
The readme for the e2e framework is located [here](../docs/e2e-tests/README.md)
The contribution guidelines are [here](../docs/e2e-tests/CONTRIBUTING.MD)
The example and bootstraps to create tests are [here](../docs/e2e-tests/examples.md)

## Quick Start: Local Testing

Run e2e tests locally without a Kubernetes cluster:

```bash
# From repository root
./scripts/run-e2e-tests.sh --project showcase-sanity-plugins
```

See [Local Testing Documentation](../docs/e2e-tests/README.md#running-tests-locally-with-rhdh-local) for more options.
40 changes: 40 additions & 0 deletions e2e-tests/local/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Local E2E Testing Configuration

This folder contains configuration files for running e2e tests locally using [rhdh-local](https://github.com/redhat-developer/rhdh-local).

## Files

| File | Description |
|------|-------------|
| `config-basic.yaml` | Minimal config for basic testing with guest auth |
| `config-rbac.yaml` | Config with RBAC/permissions enabled |
| `defaults.env` | Environment variable defaults (not currently used) |

## Usage

From the repository root:

```bash
# Basic tests
./scripts/run-e2e-tests.sh --project showcase-sanity-plugins

# RBAC tests
./scripts/run-e2e-tests.sh --profile rbac --project showcase-rbac

# Build and test local changes
./scripts/run-e2e-tests.sh --build --project showcase-sanity-plugins
```

## Profiles

| Profile | Config File | Use Case |
|---------|-------------|----------|
| `basic` | `config-basic.yaml` | General testing with guest auth |
| `rbac` | `config-rbac.yaml` | RBAC/permissions testing |

## Notes

- These configs are designed for local testing without external services
- Guest user identity is `user:development/guest` in development mode
- RBAC profile grants admin access to the guest user for testing

37 changes: 37 additions & 0 deletions e2e-tests/local/config-basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Minimal local config for e2e testing with rhdh-local
# This config works without external services (GitHub Apps, Keycloak, etc.)

app:
baseUrl: http://localhost:7007
title: Red Hat Developer Hub (Local E2E)

backend:
baseUrl: http://localhost:7007
cors:
origin: http://localhost:7007
auth:
dangerouslyDisableDefaultAuthPolicy: true
externalAccess:
- type: static
options:
token: test-token
subject: test-user

auth:
environment: development
session:
secret: super-secret-session-key-for-local-testing
providers:
guest:
dangerouslyAllowOutsideDevelopment: true

catalog:
import:
entityFilename: catalog-info.yaml
pullRequestBranchName: backstage-integration
rules:
- allow: [API, Component, Group, Location, Resource, System, Template, User]
locations:
- type: url
target: https://github.com/redhat-developer/rhdh/blob/main/catalog-entities/all.yaml

51 changes: 51 additions & 0 deletions e2e-tests/local/config-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# RBAC local config for e2e testing with rhdh-local
# This config enables RBAC/permissions without external services

app:
baseUrl: http://localhost:7007
title: Red Hat Developer Hub (Local E2E - RBAC)

backend:
baseUrl: http://localhost:7007
cors:
origin: http://localhost:7007
auth:
dangerouslyDisableDefaultAuthPolicy: true
externalAccess:
- type: static
options:
token: test-token
subject: test-user

auth:
environment: development
session:
secret: super-secret-session-key-for-local-testing
providers:
guest:
dangerouslyAllowOutsideDevelopment: true

permission:
enabled: true
rbac:
maxDepth: 1
policyFileReload: true
policies-csv-file: /opt/app-root/src/configs/rbac/rbac-policy.csv
pluginsWithPermission:
- catalog
- permission
- scaffolder
admin:
users:
- name: user:development/guest

catalog:
import:
entityFilename: catalog-info.yaml
pullRequestBranchName: backstage-integration
rules:
- allow: [API, Component, Group, Location, Resource, System, Template, User]
locations:
- type: url
target: https://github.com/redhat-developer/rhdh/blob/main/catalog-entities/all.yaml

53 changes: 53 additions & 0 deletions e2e-tests/local/defaults.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Local defaults for e2e testing with rhdh-local
# These values are substituted into CI configs when running locally.

# Base URLs
export RHDH_BASE_URL="http://localhost:7007"
export RHDH_BASE_URL_HTTP="http://localhost:7007"
export DH_TARGET_URL="localhost"

# Backend
export BACKEND_SECRET="test-secret-for-local-e2e-testing"

# Redis (disabled for local testing - uses in-memory)
export REDIS_USERNAME=""
export REDIS_PASSWORD=""

# GitHub App Integration (disabled for local testing)
export GITHUB_APP_APP_ID=""
export GITHUB_APP_CLIENT_ID=""
export GITHUB_APP_CLIENT_SECRET=""
export GITHUB_APP_WEBHOOK_URL=""
export GITHUB_APP_WEBHOOK_SECRET=""
export GITHUB_APP_PRIVATE_KEY=""

# GitHub Janus Test App (disabled for local testing)
export GITHUB_APP_JANUS_TEST_APP_ID=""
export GITHUB_APP_JANUS_TEST_CLIENT_ID=""
export GITHUB_APP_JANUS_TEST_CLIENT_SECRET=""
export GITHUB_APP_JANUS_TEST_PRIVATE_KEY=""

# GitHub OAuth (disabled for local testing)
export GITHUB_OAUTH_APP_ID=""
export GITHUB_OAUTH_APP_SECRET=""
export GITHUB_URL="https://github.com"
export GITHUB_ORG=""
export GITHUB_ORG_2=""

# GitLab (disabled for local testing)
export GITLAB_TOKEN=""

# Google Auth (disabled for local testing)
export GOOGLE_CLIENT_ID=""
export GOOGLE_CLIENT_SECRET=""

# Keycloak/OIDC (disabled for local testing)
export KEYCLOAK_AUTH_BASE_URL=""
export KEYCLOAK_AUTH_REALM=""
export KEYCLOAK_AUTH_LOGIN_REALM=""
export KEYCLOAK_AUTH_CLIENTID=""
export KEYCLOAK_AUTH_CLIENT_SECRET=""

# Azure Container Registry (disabled for local testing)
export ACR_SECRET=""

Loading
Loading