Skip to content
28 changes: 24 additions & 4 deletions .ci/pipelines/jobs/ocp-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ source "$DIR"/install-methods/operator.sh
source "$DIR"/lib/testing.sh
# shellcheck source=.ci/pipelines/playwright-projects.sh
source "$DIR"/playwright-projects.sh
# shellcheck source=.ci/pipelines/lib/schema-mode-env.sh
source "$DIR"/lib/schema-mode-env.sh

initiate_operator_deployments() {
log::info "Initiating Operator-backed deployments on OCP"
Expand Down Expand Up @@ -85,20 +87,38 @@ initiate_operator_deployments_osd_gcp() {
run_operator_runtime_config_change_tests() {
# Deploy `showcase-runtime` to run tests that require configuration changes at runtime
namespace::configure "${NAME_SPACE_RUNTIME}"

# Deploy external PostgreSQL (Crunchy) and create real secrets in the runtime namespace
namespace::configure "${NAME_SPACE_POSTGRES_DB}"
configure_external_postgres_db "${NAME_SPACE_RUNTIME}"

config::create_app_config_map "$DIR/resources/postgres-db/rds-app-config.yaml" "${NAME_SPACE_RUNTIME}"
# Pre-create placeholder secrets so the operator accepts the Backstage CR (enableLocalDb=false).
# The E2E tests (RDS/Azure DB) will overwrite these with real credentials at runtime.

# Add RHDH_RUNTIME_URL to postgres-cred (configure_external_postgres_db doesn't include it,
# but rds-app-config.yaml references it for app/backend baseUrl)
local runtime_url="https://backstage-${RELEASE_NAME}-${NAME_SPACE_RUNTIME}.${K8S_CLUSTER_ROUTER_BASE}"
create_postgres_cred_secret "${NAME_SPACE_RUNTIME}" "tmp" "tmp" "RHDH_RUNTIME_URL=${runtime_url}"
oc apply -f "$DIR/resources/postgres-db/postgres-crt.yaml" -n "${NAME_SPACE_RUNTIME}"
oc patch secret postgres-cred -n "${NAME_SPACE_RUNTIME}" --type merge \
-p "{\"stringData\":{\"RHDH_RUNTIME_URL\":\"${runtime_url}\"}}"

deploy_rhdh_operator "${NAME_SPACE_RUNTIME}" "${DIR}/resources/rhdh-operator/rhdh-start-runtime.yaml" "true"

export INSTALL_METHOD=operator

# Configure schema-mode environment (opt-in: tests skip if env not configured)
if configure_schema_mode_runtime_env "${NAME_SPACE_RUNTIME}" "${RELEASE_NAME}" operator; then
log::info "Schema-mode environment configured successfully; schema-mode tests will run"
else
log::warn "Schema-mode environment not configured; schema-mode tests will skip (this is expected if PostgreSQL is not available)"
fi

testing::run_tests "${RELEASE_NAME}" "${NAME_SPACE_RUNTIME}" "${PW_PROJECT_SHOWCASE_RUNTIME}" "${runtime_url}" || true
}

handle_ocp_operator() {
export NAME_SPACE="${NAME_SPACE:-showcase}"
export NAME_SPACE_RBAC="${NAME_SPACE_RBAC:-showcase-rbac}"
export NAME_SPACE_RUNTIME="${NAME_SPACE_RUNTIME:-showcase-runtime}"
export NAME_SPACE_POSTGRES_DB="${NAME_SPACE_POSTGRES_DB:-postgress-external-db}"

common::oc_login

Expand Down
13 changes: 7 additions & 6 deletions .ci/pipelines/lib/schema-mode-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ readonly SCHEMA_MODE_ENV_LIB_SOURCED=1
configure_schema_mode_runtime_env() {
local runtime_namespace=$1
local release_name=$2
local install_method=${3:-helm}

if [[ -z "${runtime_namespace}" || -z "${release_name}" ]]; then
log::error "configure_schema_mode_runtime_env: runtime_namespace and release_name are required"
Expand Down Expand Up @@ -60,32 +61,32 @@ configure_schema_mode_runtime_env() {
local crunchy_cluster="${SCHEMA_MODE_CRUNCHY_CLUSTER_NAME:-postgress-external-db}"
if oc get svc postgress-external-db-primary -n "${pdb}" &> /dev/null; then
forward_namespace="${pdb}"
log::info "Schema-mode (helm): no in-cluster Postgres Service in ${runtime_namespace}; using Crunchy cluster in ${pdb}"
log::info "Schema-mode (${install_method}): no in-cluster Postgres Service in ${runtime_namespace}; using Crunchy cluster in ${pdb}"
local crunchy_admin_secret="${crunchy_cluster}-pguser-janus-idp"
if oc get secret "${crunchy_admin_secret}" -n "${pdb}" &> /dev/null; then
admin_password=$(oc get secret "${crunchy_admin_secret}" -n "${pdb}" -o jsonpath='{.data.password}' 2> /dev/null | base64 -d || true)
fi
if [[ -z "${admin_password}" ]]; then
log::warn "Schema-mode (helm): could not read ${crunchy_admin_secret} password in ${pdb}; schema tests remain opt-in."
log::warn "Schema-mode (${install_method}): could not read ${crunchy_admin_secret} password in ${pdb}; schema tests remain opt-in."
return 1
fi
postgres_service=$(oc get pods -n "${pdb}" \
-l "postgres-operator.crunchydata.com/cluster=${crunchy_cluster},postgres-operator.crunchydata.com/data=postgres" \
--field-selector=status.phase=Running \
-o jsonpath='{.items[0].metadata.name}' 2> /dev/null)
if [[ -z "${postgres_service}" ]]; then
log::warn "Schema-mode (helm): no Running Postgres pod in ${pdb} for cluster ${crunchy_cluster}; schema tests remain opt-in."
log::warn "Schema-mode (${install_method}): no Running Postgres pod in ${pdb} for cluster ${crunchy_cluster}; schema tests remain opt-in."
return 1
fi
forward_via_pod=1
else
log::warn "Schema-mode (helm): PostgreSQL service not found in ${runtime_namespace} and no postgress-external-db-primary in ${pdb}; schema tests remain opt-in."
log::warn "Schema-mode (${install_method}): PostgreSQL service not found in ${runtime_namespace} and no postgress-external-db-primary in ${pdb}; schema tests remain opt-in."
return 1
fi
fi

if [[ -z "${admin_password}" ]]; then
log::warn "Schema-mode (helm): unable to resolve PostgreSQL admin password; schema tests remain opt-in."
log::warn "Schema-mode (${install_method}): unable to resolve PostgreSQL admin password; schema tests remain opt-in."
return 1
fi

Expand All @@ -109,5 +110,5 @@ configure_schema_mode_runtime_env() {
export SCHEMA_MODE_DB_PASSWORD="${SCHEMA_MODE_DB_PASSWORD:-test_password_123}"
export SCHEMA_MODE_DB_USER="${SCHEMA_MODE_DB_USER:-bn_backstage}"

log::info "Schema-mode env configured (helm): Playwright will port-forward ${pf_target} in ${forward_namespace}"
log::info "Schema-mode env configured (${install_method}): Playwright will port-forward ${pf_target} in ${forward_namespace}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Tests skip when:
### CI Behavior

- **OCP Helm nightly jobs**: Tests run (env auto-configured by `schema-mode-env.sh`)
- **OCP Operator nightly jobs**: Tests skip (operator runtime tests disabled, tracked by [RHDHBUGS-2608](https://issues.redhat.com/browse/RHDHBUGS-2608))
- **OCP Operator nightly jobs**: Tests run (env auto-configured by `schema-mode-env.sh` with `INSTALL_METHOD=operator`)
- **PR jobs**: Tests skip (env not configured by default)
- **Non-OCP jobs (AKS, EKS, GKE)**: Tests skip (no PostgreSQL deployment)

Expand All @@ -57,7 +57,7 @@ Set `DEBUG_SCHEMA_MODE_PF=1` to log port-forward output.

Tests run in the `showcase-runtime` Playwright project together with `config-map.spec.ts` (see [`playwright.config.ts`](../../../playwright.config.ts)).

**Pipeline entrypoint**: [`.ci/pipelines/openshift-ci-tests.sh`](../../../../.ci/pipelines/openshift-ci-tests.sh) → `jobs/ocp-nightly.sh`
**Pipeline entrypoint**: [`.ci/pipelines/openshift-ci-tests.sh`](../../../../.ci/pipelines/openshift-ci-tests.sh) → `jobs/ocp-nightly.sh` (Helm) or `jobs/ocp-operator.sh` (Operator)

**Environment baseline**: [`.ci/pipelines/env_variables.sh`](../../../../.ci/pipelines/env_variables.sh)

Expand Down
Loading