Skip to content

Latest commit

 

History

History
191 lines (133 loc) · 4.76 KB

File metadata and controls

191 lines (133 loc) · 4.76 KB

RHDHDeployment

Class for managing RHDH deployments in OpenShift.

Import

import { RHDHDeployment } from "@red-hat-developer-hub/e2e-test-utils/rhdh";

Constructor

new RHDHDeployment(namespace: string)
Parameter Type Description
namespace string Kubernetes namespace for deployment

Properties

rhdhUrl

get rhdhUrl(): string

The URL of the deployed RHDH instance.

deploymentConfig

get deploymentConfig(): DeploymentConfig

Current deployment configuration. See Deployment Types.

k8sClient

get k8sClient(): KubernetesClientHelper

Kubernetes client instance for direct cluster operations.

Methods

configure()

async configure(options?: DeploymentOptions): Promise<void>

Configure deployment options and create namespace.

Parameter Type Description
options DeploymentOptions Optional deployment configuration
await rhdh.configure({
  version: "1.5",
  method: "helm",
  auth: "keycloak",
  appConfig: "tests/config/app-config.yaml",
});

deploy()

async deploy(options?: { timeout?: number | null; force?: boolean }): Promise<void>

Deploy RHDH to the cluster. This:

  1. Merges configuration files
  2. Injects plugin metadata into dynamic plugins config
  3. Applies ConfigMaps and Secrets
  4. Installs RHDH via Helm or Operator
  5. Waits for deployment to be ready
Parameter Type Default Description
options.timeout number | null 600_000 Playwright test timeout (ms) for the deployment. Pass a custom number to override, 0 for no timeout, or null to skip and let the consumer control the timeout.
options.force boolean false Force redeployment even if already deployed. Bypasses the built-in runOnce protection. Useful for complex test scenarios where multiple describe sections need different RHDH configurations.
// Default (600s timeout)
await rhdh.deploy();

// Custom timeout (15 minutes)
await rhdh.deploy({ timeout: 900_000 });

// No timeout (infinite)
await rhdh.deploy({ timeout: 0 });

// Skip — consumer controls the timeout
test.setTimeout(900_000);
await rhdh.deploy({ timeout: null });

// Force redeploy with new configuration
await rhdh.configure({ dynamicPlugins: "tests/config/new-plugins.yaml" });
await rhdh.deploy({ force: true });

waitUntilReady()

async waitUntilReady(timeout?: number): Promise<void>

Wait for RHDH deployment to be ready. Performs two checks:

  1. Pod readiness — Waits for all pods to have Ready=True, with early failure detection for CrashLoopBackOff, ImagePullBackOff, etc.
  2. Route readiness — HTTP health check against the RHDH route URL using Playwright's request.newContext({ ignoreHTTPSErrors: true }). This closes the gap between pod Ready=True and the OpenShift Router/HAProxy actually serving traffic.

The remaining timeout after pod readiness is used for the route check (minimum 30 seconds).

Parameter Type Default Description
timeout number 500 Timeout in seconds
await rhdh.waitUntilReady(600); // 10 minutes

rolloutRestart()

async rolloutRestart(): Promise<void>

Restart the RHDH deployment.

await rhdh.rolloutRestart();

scaleDownAndRestart()

async scaleDownAndRestart(): Promise<void>

Scale down to 0, wait for pod termination, then scale back to 1 replica. Prevents MigrationLocked errors when two backstage instances try to run database migrations simultaneously.

::: info Called automatically during deploy() only on helm upgrades (when an existing deployment is detected). Skipped on fresh installs to avoid unnecessary pod cycling. :::

await rhdh.scaleDownAndRestart();

teardown()

async teardown(): Promise<void>

Delete the namespace and all resources.

await rhdh.teardown();

Example

import { RHDHDeployment } from "@red-hat-developer-hub/e2e-test-utils/rhdh";

const rhdh = new RHDHDeployment("my-namespace");

await rhdh.configure({
  version: "1.5",
  method: "helm",
  auth: "keycloak",
  appConfig: "tests/config/app-config.yaml",
  secrets: "tests/config/secrets.yaml",
  dynamicPlugins: "tests/config/plugins.yaml",
  valueFile: "tests/config/values.yaml",
});

await rhdh.deploy();

console.log(`RHDH deployed at: ${rhdh.rhdhUrl}`);

// After tests
await rhdh.teardown();