diff --git a/.ci/pipelines/jobs/ocp-operator.sh b/.ci/pipelines/jobs/ocp-operator.sh index 4942b3fef6..b7122a732b 100644 --- a/.ci/pipelines/jobs/ocp-operator.sh +++ b/.ci/pipelines/jobs/ocp-operator.sh @@ -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" @@ -85,13 +87,30 @@ 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 } @@ -99,6 +118,7 @@ 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 diff --git a/.ci/pipelines/lib/schema-mode-env.sh b/.ci/pipelines/lib/schema-mode-env.sh index 14f1a7741e..4011d8ac7a 100755 --- a/.ci/pipelines/lib/schema-mode-env.sh +++ b/.ci/pipelines/lib/schema-mode-env.sh @@ -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" @@ -60,13 +61,13 @@ 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}" \ @@ -74,18 +75,18 @@ configure_schema_mode_runtime_env() { --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 @@ -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}" } diff --git a/e2e-tests/playwright/e2e/plugin-division-mode-schema/README.md b/e2e-tests/playwright/e2e/plugin-division-mode-schema/README.md index 14e49524c7..5fc4788749 100644 --- a/e2e-tests/playwright/e2e/plugin-division-mode-schema/README.md +++ b/e2e-tests/playwright/e2e/plugin-division-mode-schema/README.md @@ -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) @@ -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)