From e1573e11ddf3c7719393d85aebbdaae4c2238f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Thu, 17 Sep 2026 10:25:19 +0200 Subject: [PATCH 01/11] feat: upgrade default PostgreSQL to 18 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update operator profiles, related images, generated manifests, and restricted-environment mirrors for PostgreSQL 18. Existing local database migration remains a documented manual procedure. Refs: RHIDP-13959 Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- .rhdh/scripts/prepare-restricted-environment.sh | 4 ++-- .../manifests/backstage-default-config_v1_configmap.yaml | 4 ++-- .../backstage-operator.clusterserviceversion.yaml | 4 ++-- .../rhdh/manifests/rhdh-default-config_v1_configmap.yaml | 4 ++-- bundle/rhdh/manifests/rhdh-plugin-deps_v1_configmap.yaml | 2 +- .../backstage.io/default-config/db-statefulset.yaml | 4 ++-- config/profile/rhdh/default-config/db-statefulset.yaml | 4 ++-- config/profile/rhdh/patches/deployment-patch.yaml | 2 +- config/profile/rhdh/plugin-deps/sonataflow.yaml | 2 +- dist/backstage.io/install.yaml | 4 ++-- dist/rhdh/install.yaml | 8 ++++---- pkg/model/db-statefulset_test.go | 4 ++-- pkg/model/testdata/default-config/db-statefulset.yaml | 4 ++-- pkg/model/testdata/ips-db-statefulset.yaml | 3 +-- pkg/model/testdata/rhdh-db-statefulset.yaml | 4 ++-- 15 files changed, 28 insertions(+), 29 deletions(-) diff --git a/.rhdh/scripts/prepare-restricted-environment.sh b/.rhdh/scripts/prepare-restricted-environment.sh index 7c5eec063..6aa622a0f 100755 --- a/.rhdh/scripts/prepare-restricted-environment.sh +++ b/.rhdh/scripts/prepare-restricted-environment.sh @@ -1481,8 +1481,8 @@ EOF spec: imageDigestMirrors: - mirrors: - - ${registry_url_internal}/rhel9/postgresql-15 - source: registry.redhat.io/rhel9/postgresql-15 + - ${registry_url_internal}/rhel10/postgresql-18 + source: registry.redhat.io/rhel10/postgresql-18 - mirrors: - ${registry_url_internal}/rhdh source: registry.redhat.io/rhdh diff --git a/bundle/backstage.io/manifests/backstage-default-config_v1_configmap.yaml b/bundle/backstage.io/manifests/backstage-default-config_v1_configmap.yaml index 50e5a6676..c3f505d08 100644 --- a/bundle/backstage.io/manifests/backstage-default-config_v1_configmap.yaml +++ b/bundle/backstage.io/manifests/backstage-default-config_v1_configmap.yaml @@ -48,7 +48,7 @@ data: clusterIP: None ports: - port: 5432 - db-statefulset.yaml: |- + db-statefulset.yaml: | apiVersion: apps/v1 kind: StatefulSet metadata: @@ -84,7 +84,7 @@ data: value: /var/lib/pgsql/data - name: PGDATA value: /var/lib/pgsql/data/userdata - image: quay.io/fedora/postgresql-15:latest # will be replaced with the actual image + image: quay.io/fedora/postgresql-18:latest # will be replaced with the actual image imagePullPolicy: IfNotPresent securityContext: # runAsUser:26 does not work for Openshift but looks work for AKS/EKS diff --git a/bundle/rhdh/manifests/backstage-operator.clusterserviceversion.yaml b/bundle/rhdh/manifests/backstage-operator.clusterserviceversion.yaml index a4a79bcd1..dc58a3671 100644 --- a/bundle/rhdh/manifests/backstage-operator.clusterserviceversion.yaml +++ b/bundle/rhdh/manifests/backstage-operator.clusterserviceversion.yaml @@ -342,7 +342,7 @@ spec: - name: OPERATOR_DP_PROCESSING value: "true" - name: RELATED_IMAGE_postgresql - value: quay.io/fedora/postgresql-15:latest + value: quay.io/fedora/postgresql-18:latest - name: RELATED_IMAGE_backstage value: quay.io/rhdh-community/rhdh:next - name: RELATED_IMAGE_plugin_installer @@ -486,7 +486,7 @@ spec: name: Red Hat Inc. url: https://www.redhat.com/ relatedImages: - - image: quay.io/fedora/postgresql-15:latest + - image: quay.io/fedora/postgresql-18:latest name: postgresql - image: quay.io/rhdh-community/rhdh:next name: backstage diff --git a/bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml b/bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml index b348fc2df..cbd99ba73 100644 --- a/bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml +++ b/bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml @@ -33,7 +33,7 @@ data: clusterIP: None ports: - port: 5432 - db-statefulset.yaml: |- + db-statefulset.yaml: | apiVersion: apps/v1 kind: StatefulSet metadata: @@ -69,7 +69,7 @@ data: value: /var/lib/pgsql/data - name: PGDATA value: /var/lib/pgsql/data/userdata - image: quay.io/fedora/postgresql-15:latest # will be replaced with the actual image + image: quay.io/fedora/postgresql-18:latest # will be replaced with the actual image imagePullPolicy: IfNotPresent securityContext: # runAsUser:26 does not work for Openshift but looks work for AKS/EKS diff --git a/bundle/rhdh/manifests/rhdh-plugin-deps_v1_configmap.yaml b/bundle/rhdh/manifests/rhdh-plugin-deps_v1_configmap.yaml index 6fe7f72fb..e361e618f 100644 --- a/bundle/rhdh/manifests/rhdh-plugin-deps_v1_configmap.yaml +++ b/bundle/rhdh/manifests/rhdh-plugin-deps_v1_configmap.yaml @@ -25,7 +25,7 @@ data: spec: containers: - name: psql - image: quay.io/fedora/postgresql-15:latest + image: quay.io/fedora/postgresql-18:latest resources: limits: cpu: "100m" diff --git a/config/profile/backstage.io/default-config/db-statefulset.yaml b/config/profile/backstage.io/default-config/db-statefulset.yaml index 232a7b8f2..3332f6074 100644 --- a/config/profile/backstage.io/default-config/db-statefulset.yaml +++ b/config/profile/backstage.io/default-config/db-statefulset.yaml @@ -33,7 +33,7 @@ spec: value: /var/lib/pgsql/data - name: PGDATA value: /var/lib/pgsql/data/userdata - image: quay.io/fedora/postgresql-15:latest # will be replaced with the actual image + image: quay.io/fedora/postgresql-18:latest # will be replaced with the actual image imagePullPolicy: IfNotPresent securityContext: # runAsUser:26 does not work for Openshift but looks work for AKS/EKS @@ -108,4 +108,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi \ No newline at end of file + storage: 1Gi diff --git a/config/profile/rhdh/default-config/db-statefulset.yaml b/config/profile/rhdh/default-config/db-statefulset.yaml index 232a7b8f2..3332f6074 100644 --- a/config/profile/rhdh/default-config/db-statefulset.yaml +++ b/config/profile/rhdh/default-config/db-statefulset.yaml @@ -33,7 +33,7 @@ spec: value: /var/lib/pgsql/data - name: PGDATA value: /var/lib/pgsql/data/userdata - image: quay.io/fedora/postgresql-15:latest # will be replaced with the actual image + image: quay.io/fedora/postgresql-18:latest # will be replaced with the actual image imagePullPolicy: IfNotPresent securityContext: # runAsUser:26 does not work for Openshift but looks work for AKS/EKS @@ -108,4 +108,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi \ No newline at end of file + storage: 1Gi diff --git a/config/profile/rhdh/patches/deployment-patch.yaml b/config/profile/rhdh/patches/deployment-patch.yaml index 9aade9d1c..bd06cd861 100644 --- a/config/profile/rhdh/patches/deployment-patch.yaml +++ b/config/profile/rhdh/patches/deployment-patch.yaml @@ -23,7 +23,7 @@ spec: - name: OPERATOR_DP_PROCESSING value: "{{OPERATOR_DP_PROCESSING}}" - name: RELATED_IMAGE_postgresql - value: quay.io/fedora/postgresql-15:latest + value: quay.io/fedora/postgresql-18:latest - name: RELATED_IMAGE_backstage value: quay.io/rhdh-community/rhdh:next - name: RELATED_IMAGE_plugin_installer diff --git a/config/profile/rhdh/plugin-deps/sonataflow.yaml b/config/profile/rhdh/plugin-deps/sonataflow.yaml index 5fffa3b9c..098063252 100644 --- a/config/profile/rhdh/plugin-deps/sonataflow.yaml +++ b/config/profile/rhdh/plugin-deps/sonataflow.yaml @@ -9,7 +9,7 @@ spec: spec: containers: - name: psql - image: quay.io/fedora/postgresql-15:latest + image: quay.io/fedora/postgresql-18:latest resources: limits: cpu: "100m" diff --git a/dist/backstage.io/install.yaml b/dist/backstage.io/install.yaml index 9f72f6bb0..a81f612b2 100644 --- a/dist/backstage.io/install.yaml +++ b/dist/backstage.io/install.yaml @@ -2808,7 +2808,7 @@ data: clusterIP: None ports: - port: 5432 - db-statefulset.yaml: |- + db-statefulset.yaml: | apiVersion: apps/v1 kind: StatefulSet metadata: @@ -2844,7 +2844,7 @@ data: value: /var/lib/pgsql/data - name: PGDATA value: /var/lib/pgsql/data/userdata - image: quay.io/fedora/postgresql-15:latest # will be replaced with the actual image + image: quay.io/fedora/postgresql-18:latest # will be replaced with the actual image imagePullPolicy: IfNotPresent securityContext: # runAsUser:26 does not work for Openshift but looks work for AKS/EKS diff --git a/dist/rhdh/install.yaml b/dist/rhdh/install.yaml index 4aacb1469..ea991b70a 100644 --- a/dist/rhdh/install.yaml +++ b/dist/rhdh/install.yaml @@ -2856,7 +2856,7 @@ data: clusterIP: None ports: - port: 5432 - db-statefulset.yaml: |- + db-statefulset.yaml: | apiVersion: apps/v1 kind: StatefulSet metadata: @@ -2892,7 +2892,7 @@ data: value: /var/lib/pgsql/data - name: PGDATA value: /var/lib/pgsql/data/userdata - image: quay.io/fedora/postgresql-15:latest # will be replaced with the actual image + image: quay.io/fedora/postgresql-18:latest # will be replaced with the actual image imagePullPolicy: IfNotPresent securityContext: # runAsUser:26 does not work for Openshift but looks work for AKS/EKS @@ -3931,7 +3931,7 @@ data: spec: containers: - name: psql - image: quay.io/fedora/postgresql-15:latest + image: quay.io/fedora/postgresql-18:latest resources: limits: cpu: "100m" @@ -4486,7 +4486,7 @@ spec: - name: OPERATOR_DP_PROCESSING value: 'true' - name: RELATED_IMAGE_postgresql - value: quay.io/fedora/postgresql-15:latest + value: quay.io/fedora/postgresql-18:latest - name: RELATED_IMAGE_backstage value: quay.io/rhdh-community/rhdh:next - name: RELATED_IMAGE_plugin_installer diff --git a/pkg/model/db-statefulset_test.go b/pkg/model/db-statefulset_test.go index f01e44b99..d5a09b961 100644 --- a/pkg/model/db-statefulset_test.go +++ b/pkg/model/db-statefulset_test.go @@ -2,7 +2,6 @@ package model import ( "context" - "os" "testing" "github.com/redhat-developer/rhdh-operator/pkg/platform" @@ -41,6 +40,7 @@ func TestDefault(t *testing.T) { dbStatefulSet := model.GetRuntimeObject(DbStatefulSetKey).(*DbStatefulSet) assert.Equal(t, dbService.service.Name, dbStatefulSet.statefulSet.Spec.ServiceName) assert.Equal(t, corev1.ClusterIPNone, dbService.service.Spec.ClusterIP) + assert.Equal(t, "quay.io/fedora/postgresql-18:latest", dbStatefulSet.statefulSet.Spec.Template.Spec.Containers[0].Image) } // It tests the overriding image feature @@ -52,7 +52,7 @@ func TestOverrideDbImage(t *testing.T) { testObj := createBackstageTest(bs).withDefaultConfig(true). addToDefaultConfig("db-statefulset.yaml", "rhdh-db-statefulset.yaml").withLocalDb(true) - _ = os.Setenv(LocalDbImageEnvVar, "dummy") + t.Setenv(LocalDbImageEnvVar, "dummy") model, err := InitObjects(context.TODO(), bs, testObj.externalConfig, platform.Default, testObj.scheme) assert.NoError(t, err) diff --git a/pkg/model/testdata/default-config/db-statefulset.yaml b/pkg/model/testdata/default-config/db-statefulset.yaml index f95020ab6..fdd329151 100644 --- a/pkg/model/testdata/default-config/db-statefulset.yaml +++ b/pkg/model/testdata/default-config/db-statefulset.yaml @@ -24,7 +24,7 @@ spec: value: /var/lib/pgsql/data - name: PGDATA value: /var/lib/pgsql/data/userdata - image: quay.io/fedora/postgresql-15:latest + image: quay.io/fedora/postgresql-18:latest imagePullPolicy: IfNotPresent securityContext: runAsNonRoot: true @@ -98,4 +98,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi \ No newline at end of file + storage: 1Gi diff --git a/pkg/model/testdata/ips-db-statefulset.yaml b/pkg/model/testdata/ips-db-statefulset.yaml index 462060584..bee76ddf6 100644 --- a/pkg/model/testdata/ips-db-statefulset.yaml +++ b/pkg/model/testdata/ips-db-statefulset.yaml @@ -18,6 +18,5 @@ spec: - name: ips-db2 automountServiceAccountToken: false containers: - - image: quay.io/fedora/postgresql-15:latest + - image: quay.io/fedora/postgresql-18:latest name: postgres - diff --git a/pkg/model/testdata/rhdh-db-statefulset.yaml b/pkg/model/testdata/rhdh-db-statefulset.yaml index df262551d..283781056 100644 --- a/pkg/model/testdata/rhdh-db-statefulset.yaml +++ b/pkg/model/testdata/rhdh-db-statefulset.yaml @@ -23,7 +23,7 @@ spec: value: /var/lib/pgsql/data - name: PGDATA value: /var/lib/pgsql/data/userdata - image: quay.io/fedora/postgresql-15:latest # will be replaced with the actual image + image: quay.io/fedora/postgresql-18:latest # will be replaced with the actual image imagePullPolicy: IfNotPresent securityContext: runAsNonRoot: true @@ -95,4 +95,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi \ No newline at end of file + storage: 1Gi From 4f5a4862ebb49379908e4f49da5a6c1a14f9e5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 18 Sep 2026 10:06:32 +0200 Subject: [PATCH 02/11] test: cover PostgreSQL 15 to 18 upgrades MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- .github/workflows/nightly-upgrade-test.yaml | 1 + .../workflows/pr-postgresql-upgrade-test.yaml | 119 +++++++ tests/e2e/README.md | 19 + tests/e2e/e2e_suite_test.go | 9 + tests/e2e/e2e_upgrade_test.go | 43 ++- tests/e2e/postgresql_upgrade_restore_test.go | 51 +++ tests/e2e/postgresql_upgrade_test.go | 336 ++++++++++++++++++ 7 files changed, 575 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/pr-postgresql-upgrade-test.yaml create mode 100644 tests/e2e/postgresql_upgrade_restore_test.go create mode 100644 tests/e2e/postgresql_upgrade_test.go diff --git a/.github/workflows/nightly-upgrade-test.yaml b/.github/workflows/nightly-upgrade-test.yaml index 112ccea6f..3af18b462 100644 --- a/.github/workflows/nightly-upgrade-test.yaml +++ b/.github/workflows/nightly-upgrade-test.yaml @@ -158,4 +158,5 @@ jobs: TO_OPERATOR_MANIFEST: ${{ env.TO_OPERATOR_MANIFEST }} OPERATOR_MANIFEST: ${{ env.TO_OPERATOR_MANIFEST }} IMG: ${{ env.TO_OPERATOR_IMAGE }} + BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE: ${{ matrix.to_branch == 'main' }} run: make test-e2e-upgrade diff --git a/.github/workflows/pr-postgresql-upgrade-test.yaml b/.github/workflows/pr-postgresql-upgrade-test.yaml new file mode 100644 index 000000000..57fd3c086 --- /dev/null +++ b/.github/workflows/pr-postgresql-upgrade-test.yaml @@ -0,0 +1,119 @@ +name: PR PostgreSQL Upgrade Test + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + branches: + - 'main' + paths: + - '.github/workflows/pr-postgresql-upgrade-test.yaml' + - '.github/workflows/nightly-upgrade-test.yaml' + - '**/*.go' + - 'config/**' + - 'dist/rhdh/install.yaml' + - 'Dockerfile' + - 'go.mod' + - 'go.sum' + - 'Makefile' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number }} + cancel-in-progress: true + +jobs: + postgresql-upgrade: + name: E2E PostgreSQL 15 to 18 + runs-on: ubuntu-latest + timeout-minutes: 90 + permissions: + contents: read + env: + CONTAINER_ENGINE: docker + FROM_OPERATOR_MANIFEST: https://raw.githubusercontent.com/redhat-developer/rhdh-operator/refs/heads/release-1.10/dist/rhdh/install.yaml + TO_OPERATOR_MANIFEST: ${{ github.workspace }}/dist/rhdh/install.yaml + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Setup Go + uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7 + with: + go-version-file: 'go.mod' + + - name: Resolve source operator image + run: | + FROM_OPERATOR_IMAGE=$(curl -fsSL "$FROM_OPERATOR_MANIFEST" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image') + test -n "$FROM_OPERATOR_IMAGE" + skopeo inspect "docker://$FROM_OPERATOR_IMAGE" > /dev/null + echo "FROM_OPERATOR_IMAGE=$FROM_OPERATOR_IMAGE" >> "$GITHUB_ENV" + + - name: Remove unnecessary files to free up disk space + uses: endersonmenezes/free-disk-space@2a22f8c59cae9cddae7194b33e6b92d023b2b4b8 # v4 + with: + remove_android: true + remove_dotnet: true + remove_haskell: true + rm_cmd: "rmz" + + - name: Build target operator image and manifest + env: + TO_OPERATOR_IMAGE: localhost/rhdh-operator:pr-${{ github.event.pull_request.head.sha }} + run: | + make image-build build-installer PROFILE=rhdh IMG="$TO_OPERATOR_IMAGE" + MANIFEST_IMAGE=$(yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image' "$TO_OPERATOR_MANIFEST") + test "$MANIFEST_IMAGE" = "$TO_OPERATOR_IMAGE" + echo "TO_OPERATOR_IMAGE=$TO_OPERATOR_IMAGE" >> "$GITHUB_ENV" + + - name: Generate Kind config + run: | + cat < "$RUNNER_TEMP/kind-config.yaml" + apiVersion: kind.x-k8s.io/v1alpha4 + kind: Cluster + nodes: + - role: control-plane + extraPortMappings: + - containerPort: 80 + hostPort: 80 + protocol: TCP + - containerPort: 443 + hostPort: 443 + protocol: TCP + kubeadmConfigPatches: + - | + apiVersion: kubelet.config.k8s.io/v1beta1 + kind: KubeletConfiguration + imageGCHighThresholdPercent: 70 + imageGCLowThresholdPercent: 50 + imageMinimumGCAge: 2m + EOF + + - name: Create Kind cluster + uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0 + with: + cluster_name: test-cluster + config: ${{ runner.temp }}/kind-config.yaml + ignore_failed_clean: true + + - name: Load target operator image + run: kind load docker-image --name test-cluster "$TO_OPERATOR_IMAGE" + + - name: Install Ingress Controller + run: | + kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml + kubectl wait --namespace ingress-nginx \ + --for=condition=ready pod \ + --selector=app.kubernetes.io/component=controller \ + --timeout=90s + + - name: Run PostgreSQL upgrade E2E test + env: + BACKSTAGE_OPERATOR_TESTS_PLATFORM: kind + BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE: 'true' + PROFILE: 'rhdh' + OPERATOR_MANIFEST: ${{ env.TO_OPERATOR_MANIFEST }} + IMG: ${{ env.TO_OPERATOR_IMAGE }} + run: make test-e2e-upgrade diff --git a/tests/e2e/README.md b/tests/e2e/README.md index 89a4e8235..a972d8455 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -33,6 +33,7 @@ The behavior is configurable using the following environment variables: | `BACKSTAGE_OPERATOR_TESTS_AIRGAP_MIRROR_REGISTRY` | string | Existing mirror registry to use in the airgap scenario.
Relevant if `BACKSTAGE_OPERATOR_TEST_MODE` is `rhdh-airgap`. | | `my-registry.example.com` | | `BACKSTAGE_OPERATOR_TESTS_K8S_CREATE_INGRESS` | bool | Whether to test access using an Ingress resource on K8s | | `true` | | `BACKSTAGE_OPERATOR_TESTS_K8S_INGRESS_DOMAIN` | string | Ingress domain. Relevant only if `BACKSTAGE_OPERATOR_TESTS_K8S_CREATE_INGRESS` is `true`. | | `$(minikube ip).nip.io` | +| `BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE` | bool | Enables the PostgreSQL 15 to 18 dump, volume replacement, and restore flow in the Operator upgrade test. Requires `FROM_OPERATOR_MANIFEST` and `TO_OPERATOR_MANIFEST`. | `false` | `true` | ### Examples @@ -109,6 +110,24 @@ This requires OLM to be installed in the cluster. $ make test-e2e BACKSTAGE_OPERATOR_TEST_MODE=olm ``` +#### Testing the PostgreSQL 15 to 18 Operator upgrade + +The upgrade test can validate the local PostgreSQL major-version migration while upgrading an existing Operator installation. It stops Backstage, creates a logical dump with `pg_dumpall`, deletes the test instance's generated PostgreSQL StatefulSet and PVC, restores the dump into PostgreSQL 18, and verifies that the test data remains available. The generated PostgreSQL Secret is preserved. + +The command below uses RHDH 1.10 as the PostgreSQL 15 source and the current working tree's generated manifest as the PostgreSQL 18 target: + +```shell +$ BACKSTAGE_OPERATOR_TESTS_PLATFORM=kind \ + BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE=true \ + PROFILE=rhdh \ + FROM_OPERATOR_MANIFEST=https://raw.githubusercontent.com/redhat-developer/rhdh-operator/refs/heads/release-1.10/dist/rhdh/install.yaml \ + TO_OPERATOR_MANIFEST="$(pwd)/dist/rhdh/install.yaml" \ + OPERATOR_MANIFEST="$(pwd)/dist/rhdh/install.yaml" \ + make test-e2e-upgrade +``` + +Run this only against a disposable cluster. The upgrade suite replaces the Operator installation and its cluster-scoped resources, and this test permanently deletes the generated PVC in its temporary namespace. + #### Testing a downstream build of Red Hat Developer Hub (RHDH) In this scenario, you want to run the E2E tests against a downstream build of RHDH. diff --git a/tests/e2e/e2e_suite_test.go b/tests/e2e/e2e_suite_test.go index 421e2080c..b62cc5463 100644 --- a/tests/e2e/e2e_suite_test.go +++ b/tests/e2e/e2e_suite_test.go @@ -48,6 +48,15 @@ func installRhdhOperatorManifest(operatorManifest string) { cmd := exec.Command(helper.GetPlatformTool(), "apply", "-f", p) _, err := helper.Run(cmd) + if err != nil { + GinkgoWriter.Printf("Initial manifest apply failed; waiting for CRDs before retrying: %v\n", err) + cmd = exec.Command(helper.GetPlatformTool(), "wait", "--for=condition=Established", "crd", "--all", "--timeout=2m") + _, waitErr := helper.Run(cmd) + Expect(waitErr).ShouldNot(HaveOccurred()) + + cmd = exec.Command(helper.GetPlatformTool(), "apply", "-f", p) + _, err = helper.Run(cmd) + } Expect(err).ShouldNot(HaveOccurred()) } diff --git a/tests/e2e/e2e_upgrade_test.go b/tests/e2e/e2e_upgrade_test.go index 3751dc8ce..fc53e1602 100644 --- a/tests/e2e/e2e_upgrade_test.go +++ b/tests/e2e/e2e_upgrade_test.go @@ -5,6 +5,7 @@ import ( "io" "os" "os/exec" + "strings" "time" "github.com/redhat-developer/rhdh-operator/tests/helper" @@ -18,6 +19,11 @@ var _ = Describe("Operator upgrade with existing instances", func() { var ns string BeforeEach(func() { + if isEnvEnabled("BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE") { + suiteConfig, _ := GinkgoConfiguration() + Expect(suiteConfig.ParallelTotal).To(Equal(1), + "the PostgreSQL upgrade test scales the shared Operator deployment and must run with one Ginkgo process") + } ns = fmt.Sprintf("e2e-test-%d-%s", GinkgoParallelProcess(), helper.RandString(5)) helper.CreateNamespace(ns) }) @@ -40,6 +46,7 @@ var _ = Describe("Operator upgrade with existing instances", func() { // Uninstall the current version of the operator (which was installed in the SynchronizedBeforeSuite), // because this test needs to start from a previous version, then perform the upgrade. uninstallOperator() + waitForNamespaceDeletion(_namespace) fromDeploymentManifest = os.Getenv("FROM_OPERATOR_MANIFEST") Expect(fromDeploymentManifest).NotTo(BeEmpty(), "The FROM_OPERATOR_MANIFEST env var must not be empty") @@ -97,18 +104,26 @@ metadata: }) It("should successfully reconcile existing CR when upgrading the operator", func() { + var postgresqlUpgrade *postgresqlUpgradeState + if isEnvEnabled("BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE") { + postgresqlUpgrade = preparePostgresqlUpgrade(ns, crName) + } + By("Upgrading the operator", func() { if toOperatorManifest := os.Getenv("TO_OPERATOR_MANIFEST"); toOperatorManifest != "" { - cmd := exec.Command(helper.GetPlatformTool(), "apply", "-f", toOperatorManifest) - _, err := helper.Run(cmd) - Expect(err).ShouldNot(HaveOccurred()) + installRhdhOperatorManifest(toOperatorManifest) } else { installOperatorWithMakeDeploy(false) } + waitForOperatorRollout() EventuallyWithOffset(1, verifyControllerUp, 5*time.Minute, 10*time.Second). WithArguments(managerPodLabel).Should(Succeed()) }) + if postgresqlUpgrade != nil { + completePostgresqlUpgrade(ns, crName, postgresqlUpgrade) + } + crLabel := fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName) // TODO(rm3l): this might never work because the Deployment may not necessarily @@ -164,3 +179,25 @@ metadata: }) }) + +func waitForOperatorRollout() { + cmd := exec.Command(helper.GetPlatformTool(), "-n", _namespace, "rollout", "status", "deployment/rhdh-operator", "--timeout=5m") + _, err := helper.Run(cmd) + ExpectWithOffset(1, err).NotTo(HaveOccurred()) + + if expectedImage := os.Getenv("IMG"); expectedImage != "" { + cmd = exec.Command(helper.GetPlatformTool(), "-n", _namespace, "get", "deployment", "rhdh-operator", + "-o", "jsonpath={.spec.template.spec.containers[0].image}") + out, err := helper.Run(cmd) + ExpectWithOffset(1, err).NotTo(HaveOccurred()) + ExpectWithOffset(1, string(out)).To(Equal(expectedImage)) + } +} + +func waitForNamespaceDeletion(namespace string) { + EventuallyWithOffset(1, func() bool { + cmd := exec.Command(helper.GetPlatformTool(), "get", "namespace", namespace) + _, err := helper.Run(cmd) + return err != nil && strings.Contains(strings.ToLower(err.Error()), "not found") + }, 5*time.Minute, 5*time.Second).Should(BeTrue()) +} diff --git a/tests/e2e/postgresql_upgrade_restore_test.go b/tests/e2e/postgresql_upgrade_restore_test.go new file mode 100644 index 000000000..31a9df777 --- /dev/null +++ b/tests/e2e/postgresql_upgrade_restore_test.go @@ -0,0 +1,51 @@ +package e2e + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestValidatePostgresqlRestoreErrors(t *testing.T) { + tests := []struct { + name string + stderr string + wantErr string + }{ + { + name: "accepts bootstrap role conflict", + stderr: "ERROR: role \"postgres\" already exists\n", + }, + { + name: "rejects an unexpected SQL error", + stderr: "ERROR: role \"postgres\" already exists\nERROR: relation \"example\" already exists\n", + wantErr: "unexpected PostgreSQL restore errors", + }, + { + name: "rejects a fatal connection error", + stderr: "ERROR: role \"postgres\" already exists\nFATAL: database \"backstage\" does not exist\n", + wantErr: "unexpected PostgreSQL restore errors", + }, + { + name: "rejects a psql connection error", + stderr: "ERROR: role \"postgres\" already exists\npsql: error: connection to server was lost\n", + wantErr: "unexpected PostgreSQL restore errors", + }, + { + name: "rejects a restore without the expected bootstrap conflict", + stderr: "", + wantErr: "expected one bootstrap role conflict", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := validatePostgresqlRestoreErrors(tt.stderr) + if tt.wantErr == "" { + assert.NoError(t, err) + return + } + assert.ErrorContains(t, err, tt.wantErr) + }) + } +} diff --git a/tests/e2e/postgresql_upgrade_test.go b/tests/e2e/postgresql_upgrade_test.go new file mode 100644 index 000000000..76b77a991 --- /dev/null +++ b/tests/e2e/postgresql_upgrade_test.go @@ -0,0 +1,336 @@ +package e2e + +import ( + "bytes" + "fmt" + "io" + "os" + "os/exec" + "regexp" + "strings" + "time" + + "github.com/redhat-developer/rhdh-operator/tests/helper" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +const ( + postgresqlSourceImage = "postgresql-15" + postgresqlSourceVersion = "15." + postgresqlTargetImage = "postgresql-18" + postgresqlTargetVersion = "18." + postgresqlProofValue = "postgresql-15-to-18" +) + +type postgresqlUpgradeState struct { + dumpPath string + postgresPodUID string + pvcUID string + secretUID string + backstagePodUID string + databaseNames []string +} + +func preparePostgresqlUpgrade(namespace, crName string) *postgresqlUpgradeState { + state := &postgresqlUpgradeState{} + postgresPod := waitForPostgresql(namespace, crName, postgresqlSourceImage, postgresqlSourceVersion) + + By("seeding data that must survive the PostgreSQL upgrade") + _, err := runPostgresqlSQL(namespace, postgresPod, ` +CREATE TABLE public.rhdh_postgresql_upgrade_test (marker text PRIMARY KEY); +INSERT INTO public.rhdh_postgresql_upgrade_test VALUES ('`+postgresqlProofValue+`');`) + Expect(err).NotTo(HaveOccurred()) + Expect(queryPostgresqlUpgradeProof(namespace, postgresPod)).To(Equal(postgresqlProofValue)) + + state.postgresPodUID = resourceUID(namespace, "pod", postgresPod) + state.pvcUID = resourceUID(namespace, "pvc", postgresqlPVCName(crName)) + state.secretUID = resourceUID(namespace, "secret", postgresqlSecretName(crName)) + state.backstagePodUID = readyPodUID(namespace, fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName)) + state.databaseNames = postgresqlDatabaseNames(namespace, postgresPod) + + By("stopping Backstage before taking the PostgreSQL dump") + setBackstageReplicas(namespace, crName, 0) + waitForNoPods(namespace, fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName)) + + By("dumping all PostgreSQL 15 databases and roles") + state.dumpPath = dumpPostgresql(namespace, postgresPod) + + return state +} + +func completePostgresqlUpgrade(namespace, crName string, state *postgresqlUpgradeState) { + statefulSetName := postgresqlStatefulSetName(crName) + + By("waiting for the upgraded operator to select the PostgreSQL 18 image") + Eventually(func(g Gomega) { + out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "get", "statefulset", + statefulSetName, "-o", "jsonpath={.spec.template.spec.containers[0].image}")) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(strings.TrimSpace(string(out))).To(ContainSubstring(postgresqlTargetImage)) + }, 5*time.Minute, 5*time.Second).Should(Succeed()) + + operatorScaledDown := false + DeferCleanup(func() { + if operatorScaledDown { + if err := scaleDeploymentCommand(_namespace, "rhdh-operator", 1); err != nil { + GinkgoWriter.Printf("Warning: failed to restore the operator replica: %v\n", err) + } + } + }) + + By("stopping the operator while replacing the PostgreSQL volume") + scaleDeployment(_namespace, "rhdh-operator", 0) + operatorScaledDown = true + waitForNoPods(_namespace, managerPodLabel) + + By("deleting the PostgreSQL 15 StatefulSet and persistent volume") + deleteResource(namespace, "statefulset", statefulSetName) + deleteResource(namespace, "pvc", postgresqlPVCName(crName)) + Expect(resourceUID(namespace, "secret", postgresqlSecretName(crName))).To(Equal(state.secretUID)) + + By("restarting the operator to provision a fresh PostgreSQL 18 database") + scaleDeployment(_namespace, "rhdh-operator", 1) + operatorScaledDown = false + waitForOperatorRollout() + EventuallyWithOffset(1, verifyControllerUp, 5*time.Minute, 5*time.Second). + WithArguments(managerPodLabel).Should(Succeed()) + + postgresPod := waitForPostgresql(namespace, crName, postgresqlTargetImage, postgresqlTargetVersion) + Expect(resourceUID(namespace, "pod", postgresPod)).NotTo(Equal(state.postgresPodUID)) + Expect(resourceUID(namespace, "pvc", postgresqlPVCName(crName))).NotTo(Equal(state.pvcUID)) + Expect(resourceUID(namespace, "secret", postgresqlSecretName(crName))).To(Equal(state.secretUID)) + + By("restoring the PostgreSQL 15 dump into PostgreSQL 18") + restorePostgresql(namespace, postgresPod, state.dumpPath) + Expect(postgresqlDatabaseNames(namespace, postgresPod)).To(Equal(state.databaseNames)) + refreshPostgresqlCollations(namespace, postgresPod) + Expect(queryPostgresqlUpgradeProof(namespace, postgresPod)).To(Equal(postgresqlProofValue)) + + By("starting Backstage against the restored PostgreSQL 18 database") + setBackstageReplicas(namespace, crName, 1) + waitForBackstagePodReplacement(namespace, crName, state.backstagePodUID) +} + +func waitForPostgresql(namespace, crName, imageSubstring, versionPrefix string) string { + var podName string + label := fmt.Sprintf("rhdh.redhat.com/app=%s", postgresqlStatefulSetName(crName)) + + Eventually(func(g Gomega) { + out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "get", "pods", "-l", label, + "-o", "go-template={{ range .items }}{{ if not .metadata.deletionTimestamp }}{{ .metadata.name }}{{ \"\\n\" }}{{ end }}{{ end }}")) + g.Expect(err).NotTo(HaveOccurred()) + podNames := helper.GetNonEmptyLines(string(out)) + g.Expect(podNames).To(HaveLen(1)) + podName = podNames[0] + + out, err = helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "get", "pod", podName, + "-o", `jsonpath={.status.conditions[?(@.type=="Ready")].status}`)) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(strings.TrimSpace(string(out))).To(Equal("True")) + + out, err = helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "get", "pod", podName, + "-o", "jsonpath={.spec.containers[0].image}")) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(strings.TrimSpace(string(out))).To(ContainSubstring(imageSubstring)) + + out, err = helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", + "psql", "-X", "-U", "postgres", "-d", "postgres", "-tA", "-c", "SHOW server_version;")) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(strings.TrimSpace(string(out))).To(HavePrefix(versionPrefix)) + }, 10*time.Minute, 10*time.Second).Should(Succeed()) + + return podName +} + +func runPostgresqlSQL(namespace, podName, sql string) ([]byte, error) { + return helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", + "psql", "-X", "-U", "postgres", "-d", "postgres", "-v", "ON_ERROR_STOP=1", "-c", sql)) +} + +func queryPostgresqlUpgradeProof(namespace, podName string) string { + out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", + "psql", "-X", "-U", "postgres", "-d", "postgres", "-tA", "-v", "ON_ERROR_STOP=1", "-c", + "SELECT marker FROM public.rhdh_postgresql_upgrade_test;")) + Expect(err).NotTo(HaveOccurred()) + return strings.TrimSpace(string(out)) +} + +func dumpPostgresql(namespace, podName string) string { + dumpFile, err := os.CreateTemp("", "rhdh-postgresql-15-*.sql") + Expect(err).NotTo(HaveOccurred()) + dumpPath := dumpFile.Name() + DeferCleanup(func() { + Expect(os.Remove(dumpPath)).To(Succeed()) + }) + + var stderr bytes.Buffer + cmd := exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", "pg_dumpall", "-U", "postgres") + err = runCommand(cmd, nil, dumpFile, io.MultiWriter(GinkgoWriter, &stderr)) + closeErr := dumpFile.Close() + Expect(err).NotTo(HaveOccurred(), stderr.String()) + Expect(closeErr).NotTo(HaveOccurred()) + + info, err := os.Stat(dumpPath) + Expect(err).NotTo(HaveOccurred()) + Expect(info.Size()).To(BeNumerically(">", 0)) + return dumpPath +} + +func restorePostgresql(namespace, podName, dumpPath string) { + dumpFile, err := os.Open(dumpPath) + Expect(err).NotTo(HaveOccurred()) + defer func() { + Expect(dumpFile.Close()).To(Succeed()) + }() + + var stdout, stderr bytes.Buffer + cmd := exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", "-i", podName, "--", + "psql", "-X", "-U", "postgres", "-d", "postgres", "-v", "ON_ERROR_STOP=0", "--quiet") + err = runCommand(cmd, dumpFile, io.MultiWriter(GinkgoWriter, &stdout), io.MultiWriter(GinkgoWriter, &stderr)) + Expect(err).NotTo(HaveOccurred(), stderr.String()) + + Expect(validatePostgresqlRestoreErrors(stderr.String())).To(Succeed()) +} + +func validatePostgresqlRestoreErrors(stderr string) error { + errorLines := make([]string, 0) + for _, line := range strings.Split(stderr, "\n") { + lowerLine := strings.ToLower(line) + if strings.Contains(line, "ERROR:") || strings.Contains(line, "FATAL:") || strings.Contains(lowerLine, "psql: error:") { + errorLines = append(errorLines, strings.TrimSpace(line)) + } + } + if len(errorLines) != 1 { + if len(errorLines) == 0 { + return fmt.Errorf("expected one bootstrap role conflict, got none") + } + return fmt.Errorf("unexpected PostgreSQL restore errors: %s", strings.Join(errorLines, "; ")) + } + if !regexp.MustCompile(`^ERROR:\s+role "postgres" already exists$`).MatchString(errorLines[0]) { + return fmt.Errorf("unexpected PostgreSQL restore errors: %s", errorLines[0]) + } + return nil +} + +func postgresqlDatabaseNames(namespace, podName string) []string { + out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", + "psql", "-X", "-U", "postgres", "-d", "postgres", "-tA", "-v", "ON_ERROR_STOP=1", "-c", + "SELECT datname FROM pg_database WHERE datistemplate = false ORDER BY datname;")) + Expect(err).NotTo(HaveOccurred()) + return helper.GetNonEmptyLines(strings.TrimSpace(string(out))) +} + +func refreshPostgresqlCollations(namespace, podName string) { + out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", + "psql", "-X", "-U", "postgres", "-d", "postgres", "-tA", "-v", "ON_ERROR_STOP=1", "-c", + "SELECT format('ALTER DATABASE %I REFRESH COLLATION VERSION;', datname) FROM pg_database WHERE datallowconn AND datname <> 'template0' ORDER BY datname;")) + Expect(err).NotTo(HaveOccurred()) + + for _, statement := range helper.GetNonEmptyLines(string(out)) { + _, err = runPostgresqlSQL(namespace, podName, statement) + Expect(err).NotTo(HaveOccurred()) + } +} + +func runCommand(cmd *exec.Cmd, stdin io.Reader, stdout, stderr io.Writer) error { + projectDir, err := helper.GetProjectDir() + if err != nil { + return err + } + cmd.Dir = projectDir + cmd.Env = os.Environ() + cmd.Stdin = stdin + cmd.Stdout = stdout + cmd.Stderr = stderr + GinkgoWriter.Printf("running: %s\n", strings.Join(cmd.Args, " ")) + return cmd.Run() +} + +func setBackstageReplicas(namespace, crName string, replicas int) { + patch := fmt.Sprintf(`{"spec":{"deployment":{"patch":{"spec":{"replicas":%d}}}}}`, replicas) + _, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "patch", "backstage", crName, + "--type=merge", "--patch", patch)) + Expect(err).NotTo(HaveOccurred()) +} + +func scaleDeployment(namespace, name string, replicas int) { + err := scaleDeploymentCommand(namespace, name, replicas) + Expect(err).NotTo(HaveOccurred()) +} + +func scaleDeploymentCommand(namespace, name string, replicas int) error { + _, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "scale", "deployment", name, + fmt.Sprintf("--replicas=%d", replicas))) + return err +} + +func waitForNoPods(namespace, label string) { + Eventually(func(g Gomega) { + out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "get", "pods", "-l", label, + "-o", "name")) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(strings.TrimSpace(string(out))).To(BeEmpty()) + }, 5*time.Minute, 5*time.Second).Should(Succeed()) +} + +func deleteResource(namespace, kind, name string) { + _, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "delete", kind, name, + "--wait=true", "--timeout=5m")) + Expect(err).NotTo(HaveOccurred()) +} + +func resourceUID(namespace, kind, name string) string { + out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "get", kind, name, + "-o", "jsonpath={.metadata.uid}")) + Expect(err).NotTo(HaveOccurred()) + uid := strings.TrimSpace(string(out)) + Expect(uid).NotTo(BeEmpty()) + return uid +} + +func readyPodUID(namespace, label string) string { + var uid string + Eventually(func(g Gomega) { + out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "get", "pods", "-l", label, + "-o", `jsonpath={range .items[?(@.status.phase=="Running")]}{.metadata.uid}{" "}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}`)) + g.Expect(err).NotTo(HaveOccurred()) + lines := helper.GetNonEmptyLines(string(out)) + g.Expect(lines).To(HaveLen(1)) + fields := strings.Fields(lines[0]) + g.Expect(fields).To(HaveLen(2)) + g.Expect(fields[1]).To(Equal("True")) + uid = fields[0] + }, 10*time.Minute, 10*time.Second).Should(Succeed()) + return uid +} + +func waitForBackstagePodReplacement(namespace, crName, previousUID string) { + label := fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName) + Eventually(func(g Gomega) { + out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "get", "pods", "-l", label, + "-o", `jsonpath={range .items[*]}{.metadata.uid}{" "}{.status.phase}{" "}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}`)) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(string(out)).NotTo(ContainSubstring(previousUID)) + lines := helper.GetNonEmptyLines(string(out)) + g.Expect(lines).To(HaveLen(1)) + fields := strings.Fields(lines[0]) + g.Expect(fields).To(HaveLen(3)) + g.Expect(fields[0]).NotTo(Equal(previousUID)) + g.Expect(fields[1]).To(Equal("Running")) + g.Expect(fields[2]).To(Equal("True")) + }, 15*time.Minute, 10*time.Second).Should(Succeed()) +} + +func postgresqlStatefulSetName(crName string) string { + return fmt.Sprintf("backstage-psql-%s", crName) +} + +func postgresqlPVCName(crName string) string { + return fmt.Sprintf("data-%s-0", postgresqlStatefulSetName(crName)) +} + +func postgresqlSecretName(crName string) string { + return fmt.Sprintf("backstage-psql-secret-%s", crName) +} From 2cdecc102be7d37ed2f3fe04248c29c8db9b20c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 18 Sep 2026 10:27:16 +0200 Subject: [PATCH 03/11] fix: require HTTPS for source manifest redirects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- .github/workflows/pr-postgresql-upgrade-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-postgresql-upgrade-test.yaml b/.github/workflows/pr-postgresql-upgrade-test.yaml index 57fd3c086..e30459348 100644 --- a/.github/workflows/pr-postgresql-upgrade-test.yaml +++ b/.github/workflows/pr-postgresql-upgrade-test.yaml @@ -46,7 +46,7 @@ jobs: - name: Resolve source operator image run: | - FROM_OPERATOR_IMAGE=$(curl -fsSL "$FROM_OPERATOR_MANIFEST" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image') + FROM_OPERATOR_IMAGE=$(curl --proto '=https' --proto-redir '=https' -fsSL "$FROM_OPERATOR_MANIFEST" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image') test -n "$FROM_OPERATOR_IMAGE" skopeo inspect "docker://$FROM_OPERATOR_IMAGE" > /dev/null echo "FROM_OPERATOR_IMAGE=$FROM_OPERATOR_IMAGE" >> "$GITHUB_ENV" From 6943a387745201002db68a2e471f78155b268549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 18 Sep 2026 11:35:03 +0200 Subject: [PATCH 04/11] fix: preserve operator logs during upgrade teardown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- tests/e2e/e2e_suite_test.go | 24 ++++++++++++++++++++++-- tests/e2e/e2e_upgrade_test.go | 15 --------------- tests/e2e/operator_cleanup_test.go | 28 ++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 tests/e2e/operator_cleanup_test.go diff --git a/tests/e2e/e2e_suite_test.go b/tests/e2e/e2e_suite_test.go index b62cc5463..a6b71f558 100644 --- a/tests/e2e/e2e_suite_test.go +++ b/tests/e2e/e2e_suite_test.go @@ -220,8 +220,14 @@ var _ = SynchronizedAfterSuite(func() { }, // the function below *only* on process #1 func() { - defer uninstallOperator() - fmt.Println(fetchOperatorLogs(managerPodLabel, false)()) + fmt.Println(captureOperatorLogsBeforeCleanup( + fetchOperatorLogs(managerPodLabel, false), + func() { + uninstallOperator() + deleteOperatorManifest(os.Getenv("FROM_OPERATOR_MANIFEST")) + deleteOperatorManifest(os.Getenv("TO_OPERATOR_MANIFEST")) + }, + )) }, ) @@ -296,6 +302,12 @@ func fetchOperatorLogs(managerPodLabel string, raw bool) func() string { } } +func captureOperatorLogsBeforeCleanup(fetchLogs func() string, cleanup func()) string { + logs := fetchLogs() + cleanup() + return logs +} + func fetchOperandLogs(ns string, crLabel string, raw bool) func() string { return func() string { logs := getPodLogs(ns, "", crLabel) @@ -333,6 +345,14 @@ func uninstallOperator() { } } +func deleteOperatorManifest(operatorManifest string) { + if operatorManifest == "" { + return + } + cmd := exec.Command(helper.GetPlatformTool(), "delete", "-f", operatorManifest, "--ignore-not-found=true") + _, _ = helper.Run(cmd) +} + func uninstallRhdhOperator(withAirgap bool) { cmd := exec.Command( helper.GetPlatformTool(), "delete", "subscription", "rhdh", "-n", _namespace, "--ignore-not-found=true") diff --git a/tests/e2e/e2e_upgrade_test.go b/tests/e2e/e2e_upgrade_test.go index fc53e1602..91381e2e9 100644 --- a/tests/e2e/e2e_upgrade_test.go +++ b/tests/e2e/e2e_upgrade_test.go @@ -88,21 +88,6 @@ metadata: Should(Succeed()) }) - AfterEach(func() { - for _, m := range []string{"FROM", "TO"} { - if manifest := os.Getenv(m + "_OPERATOR_MANIFEST"); manifest != "" { - cmd := exec.Command(helper.GetPlatformTool(), "delete", "-f", manifest, "--ignore-not-found=true") - _, _ = helper.Run(cmd) - } - } - uninstallOperator() - - if fromDeploymentManifest != "" { - cmd := exec.Command(helper.GetPlatformTool(), "delete", "-f", fromDeploymentManifest, "--ignore-not-found=true") - _, _ = helper.Run(cmd) - } - }) - It("should successfully reconcile existing CR when upgrading the operator", func() { var postgresqlUpgrade *postgresqlUpgradeState if isEnvEnabled("BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE") { diff --git a/tests/e2e/operator_cleanup_test.go b/tests/e2e/operator_cleanup_test.go new file mode 100644 index 000000000..14cf1e3ee --- /dev/null +++ b/tests/e2e/operator_cleanup_test.go @@ -0,0 +1,28 @@ +package e2e + +import "testing" + +func TestCaptureOperatorLogsBeforeCleanup(t *testing.T) { + var events []string + + logs := captureOperatorLogsBeforeCleanup( + func() string { + events = append(events, "logs") + return "operator logs" + }, + func() { + events = append(events, "cleanup") + }, + ) + + if logs != "operator logs" { + t.Fatalf("captured logs = %q, want %q", logs, "operator logs") + } + + if got, want := len(events), 2; got != want { + t.Fatalf("events = %v, want %d events", events, want) + } + if events[0] != "logs" || events[1] != "cleanup" { + t.Fatalf("events = %v, want logs followed by cleanup", events) + } +} From a704054167f83e8fb0bfa7331dc15eb06ce7f3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 18 Sep 2026 11:59:17 +0200 Subject: [PATCH 05/11] chore: remove incidental YAML formatting changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- .../manifests/backstage-default-config_v1_configmap.yaml | 2 +- bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml | 2 +- config/profile/backstage.io/default-config/db-statefulset.yaml | 2 +- config/profile/rhdh/default-config/db-statefulset.yaml | 2 +- dist/backstage.io/install.yaml | 2 +- dist/rhdh/install.yaml | 2 +- pkg/model/testdata/default-config/db-statefulset.yaml | 2 +- pkg/model/testdata/ips-db-statefulset.yaml | 1 + pkg/model/testdata/rhdh-db-statefulset.yaml | 2 +- 9 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bundle/backstage.io/manifests/backstage-default-config_v1_configmap.yaml b/bundle/backstage.io/manifests/backstage-default-config_v1_configmap.yaml index c3f505d08..1a9c1d003 100644 --- a/bundle/backstage.io/manifests/backstage-default-config_v1_configmap.yaml +++ b/bundle/backstage.io/manifests/backstage-default-config_v1_configmap.yaml @@ -48,7 +48,7 @@ data: clusterIP: None ports: - port: 5432 - db-statefulset.yaml: | + db-statefulset.yaml: |- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml b/bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml index cbd99ba73..e31d08943 100644 --- a/bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml +++ b/bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml @@ -33,7 +33,7 @@ data: clusterIP: None ports: - port: 5432 - db-statefulset.yaml: | + db-statefulset.yaml: |- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/config/profile/backstage.io/default-config/db-statefulset.yaml b/config/profile/backstage.io/default-config/db-statefulset.yaml index 3332f6074..f18219757 100644 --- a/config/profile/backstage.io/default-config/db-statefulset.yaml +++ b/config/profile/backstage.io/default-config/db-statefulset.yaml @@ -108,4 +108,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 1Gi \ No newline at end of file diff --git a/config/profile/rhdh/default-config/db-statefulset.yaml b/config/profile/rhdh/default-config/db-statefulset.yaml index 3332f6074..f18219757 100644 --- a/config/profile/rhdh/default-config/db-statefulset.yaml +++ b/config/profile/rhdh/default-config/db-statefulset.yaml @@ -108,4 +108,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 1Gi \ No newline at end of file diff --git a/dist/backstage.io/install.yaml b/dist/backstage.io/install.yaml index a81f612b2..b6b8d4a29 100644 --- a/dist/backstage.io/install.yaml +++ b/dist/backstage.io/install.yaml @@ -2808,7 +2808,7 @@ data: clusterIP: None ports: - port: 5432 - db-statefulset.yaml: | + db-statefulset.yaml: |- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/dist/rhdh/install.yaml b/dist/rhdh/install.yaml index ea991b70a..1d59b4184 100644 --- a/dist/rhdh/install.yaml +++ b/dist/rhdh/install.yaml @@ -2856,7 +2856,7 @@ data: clusterIP: None ports: - port: 5432 - db-statefulset.yaml: | + db-statefulset.yaml: |- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/pkg/model/testdata/default-config/db-statefulset.yaml b/pkg/model/testdata/default-config/db-statefulset.yaml index fdd329151..bd79b3f50 100644 --- a/pkg/model/testdata/default-config/db-statefulset.yaml +++ b/pkg/model/testdata/default-config/db-statefulset.yaml @@ -98,4 +98,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 1Gi \ No newline at end of file diff --git a/pkg/model/testdata/ips-db-statefulset.yaml b/pkg/model/testdata/ips-db-statefulset.yaml index bee76ddf6..2044454dd 100644 --- a/pkg/model/testdata/ips-db-statefulset.yaml +++ b/pkg/model/testdata/ips-db-statefulset.yaml @@ -20,3 +20,4 @@ spec: containers: - image: quay.io/fedora/postgresql-18:latest name: postgres + diff --git a/pkg/model/testdata/rhdh-db-statefulset.yaml b/pkg/model/testdata/rhdh-db-statefulset.yaml index 283781056..f415eb856 100644 --- a/pkg/model/testdata/rhdh-db-statefulset.yaml +++ b/pkg/model/testdata/rhdh-db-statefulset.yaml @@ -95,4 +95,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 1Gi \ No newline at end of file From 74a6bee86cea5b6088f6022801cdfa283dcd243b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 18 Sep 2026 13:54:29 +0200 Subject: [PATCH 06/11] test(e2e): reuse Backstage patch helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- tests/e2e/postgresql_upgrade_restore_test.go | 20 +++++++ tests/e2e/postgresql_upgrade_test.go | 57 +++++++++++++------- 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/tests/e2e/postgresql_upgrade_restore_test.go b/tests/e2e/postgresql_upgrade_restore_test.go index 31a9df777..e53cd870b 100644 --- a/tests/e2e/postgresql_upgrade_restore_test.go +++ b/tests/e2e/postgresql_upgrade_restore_test.go @@ -3,9 +3,29 @@ package e2e import ( "testing" + "github.com/redhat-developer/rhdh-operator/tests/helper" "github.com/stretchr/testify/assert" ) +func TestPostgresqlSQLCommandUsesRequestedDatabase(t *testing.T) { + cmd := postgresqlSQLCommand("test-namespace", "postgres-0", "backstage_plugin_catalog", "-c", "SELECT 1") + + assert.Equal(t, helper.GetPlatformTool(), cmd.Args[0]) + assert.Equal(t, []string{ + "-n", "test-namespace", "exec", "postgres-0", "--", + "psql", "-X", "-U", "postgres", "-d", "backstage_plugin_catalog", "-c", "SELECT 1", + }, cmd.Args[1:]) +} + +func TestPostgresqlSQLCommandWithStdinEnablesInteractiveExec(t *testing.T) { + cmd := postgresqlSQLCommandWithStdin("test-namespace", "postgres-0", "postgres", "--quiet") + + assert.Equal(t, []string{ + "-n", "test-namespace", "exec", "-i", "postgres-0", "--", + "psql", "-X", "-U", "postgres", "-d", "postgres", "--quiet", + }, cmd.Args[1:]) +} + func TestValidatePostgresqlRestoreErrors(t *testing.T) { tests := []struct { name string diff --git a/tests/e2e/postgresql_upgrade_test.go b/tests/e2e/postgresql_upgrade_test.go index 76b77a991..38af56224 100644 --- a/tests/e2e/postgresql_upgrade_test.go +++ b/tests/e2e/postgresql_upgrade_test.go @@ -21,6 +21,7 @@ const ( postgresqlSourceVersion = "15." postgresqlTargetImage = "postgresql-18" postgresqlTargetVersion = "18." + postgresqlProofDatabase = "backstage_plugin_catalog" postgresqlProofValue = "postgresql-15-to-18" ) @@ -36,9 +37,11 @@ type postgresqlUpgradeState struct { func preparePostgresqlUpgrade(namespace, crName string) *postgresqlUpgradeState { state := &postgresqlUpgradeState{} postgresPod := waitForPostgresql(namespace, crName, postgresqlSourceImage, postgresqlSourceVersion) + state.databaseNames = postgresqlDatabaseNames(namespace, postgresPod) + Expect(state.databaseNames).To(ContainElement(postgresqlProofDatabase)) By("seeding data that must survive the PostgreSQL upgrade") - _, err := runPostgresqlSQL(namespace, postgresPod, ` + _, err := runPostgresqlSQL(namespace, postgresPod, postgresqlProofDatabase, ` CREATE TABLE public.rhdh_postgresql_upgrade_test (marker text PRIMARY KEY); INSERT INTO public.rhdh_postgresql_upgrade_test VALUES ('`+postgresqlProofValue+`');`) Expect(err).NotTo(HaveOccurred()) @@ -48,7 +51,6 @@ INSERT INTO public.rhdh_postgresql_upgrade_test VALUES ('`+postgresqlProofValue+ state.pvcUID = resourceUID(namespace, "pvc", postgresqlPVCName(crName)) state.secretUID = resourceUID(namespace, "secret", postgresqlSecretName(crName)) state.backstagePodUID = readyPodUID(namespace, fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName)) - state.databaseNames = postgresqlDatabaseNames(namespace, postgresPod) By("stopping Backstage before taking the PostgreSQL dump") setBackstageReplicas(namespace, crName, 0) @@ -135,8 +137,7 @@ func waitForPostgresql(namespace, crName, imageSubstring, versionPrefix string) g.Expect(err).NotTo(HaveOccurred()) g.Expect(strings.TrimSpace(string(out))).To(ContainSubstring(imageSubstring)) - out, err = helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", - "psql", "-X", "-U", "postgres", "-d", "postgres", "-tA", "-c", "SHOW server_version;")) + out, err = helper.Run(postgresqlSQLCommand(namespace, podName, "postgres", "-tA", "-c", "SHOW server_version;")) g.Expect(err).NotTo(HaveOccurred()) g.Expect(strings.TrimSpace(string(out))).To(HavePrefix(versionPrefix)) }, 10*time.Minute, 10*time.Second).Should(Succeed()) @@ -144,15 +145,35 @@ func waitForPostgresql(namespace, crName, imageSubstring, versionPrefix string) return podName } -func runPostgresqlSQL(namespace, podName, sql string) ([]byte, error) { - return helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", - "psql", "-X", "-U", "postgres", "-d", "postgres", "-v", "ON_ERROR_STOP=1", "-c", sql)) +func postgresqlSQLCommand(namespace, podName, database string, args ...string) *exec.Cmd { + return buildPostgresqlSQLCommand(namespace, podName, database, false, args...) +} + +func postgresqlSQLCommandWithStdin(namespace, podName, database string, args ...string) *exec.Cmd { + return buildPostgresqlSQLCommand(namespace, podName, database, true, args...) +} + +func buildPostgresqlSQLCommand(namespace, podName, database string, withStdin bool, args ...string) *exec.Cmd { + commandArgs := []string{"-n", namespace, "exec"} + if withStdin { + commandArgs = append(commandArgs, "-i") + } + commandArgs = append(commandArgs, + podName, "--", + "psql", "-X", "-U", "postgres", "-d", database, + ) + commandArgs = append(commandArgs, args...) + return exec.Command(helper.GetPlatformTool(), commandArgs...) +} + +func runPostgresqlSQL(namespace, podName, database, sql string) ([]byte, error) { + return helper.Run(postgresqlSQLCommand(namespace, podName, database, + "-v", "ON_ERROR_STOP=1", "-c", sql)) } func queryPostgresqlUpgradeProof(namespace, podName string) string { - out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", - "psql", "-X", "-U", "postgres", "-d", "postgres", "-tA", "-v", "ON_ERROR_STOP=1", "-c", - "SELECT marker FROM public.rhdh_postgresql_upgrade_test;")) + out, err := helper.Run(postgresqlSQLCommand(namespace, podName, postgresqlProofDatabase, + "-tA", "-v", "ON_ERROR_STOP=1", "-c", "SELECT marker FROM public.rhdh_postgresql_upgrade_test;")) Expect(err).NotTo(HaveOccurred()) return strings.TrimSpace(string(out)) } @@ -186,8 +207,7 @@ func restorePostgresql(namespace, podName, dumpPath string) { }() var stdout, stderr bytes.Buffer - cmd := exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", "-i", podName, "--", - "psql", "-X", "-U", "postgres", "-d", "postgres", "-v", "ON_ERROR_STOP=0", "--quiet") + cmd := postgresqlSQLCommandWithStdin(namespace, podName, "postgres", "-v", "ON_ERROR_STOP=0", "--quiet") err = runCommand(cmd, dumpFile, io.MultiWriter(GinkgoWriter, &stdout), io.MultiWriter(GinkgoWriter, &stderr)) Expect(err).NotTo(HaveOccurred(), stderr.String()) @@ -215,21 +235,21 @@ func validatePostgresqlRestoreErrors(stderr string) error { } func postgresqlDatabaseNames(namespace, podName string) []string { - out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", - "psql", "-X", "-U", "postgres", "-d", "postgres", "-tA", "-v", "ON_ERROR_STOP=1", "-c", + out, err := helper.Run(postgresqlSQLCommand(namespace, podName, "postgres", + "-tA", "-v", "ON_ERROR_STOP=1", "-c", "SELECT datname FROM pg_database WHERE datistemplate = false ORDER BY datname;")) Expect(err).NotTo(HaveOccurred()) return helper.GetNonEmptyLines(strings.TrimSpace(string(out))) } func refreshPostgresqlCollations(namespace, podName string) { - out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "exec", podName, "--", - "psql", "-X", "-U", "postgres", "-d", "postgres", "-tA", "-v", "ON_ERROR_STOP=1", "-c", + out, err := helper.Run(postgresqlSQLCommand(namespace, podName, "postgres", + "-tA", "-v", "ON_ERROR_STOP=1", "-c", "SELECT format('ALTER DATABASE %I REFRESH COLLATION VERSION;', datname) FROM pg_database WHERE datallowconn AND datname <> 'template0' ORDER BY datname;")) Expect(err).NotTo(HaveOccurred()) for _, statement := range helper.GetNonEmptyLines(string(out)) { - _, err = runPostgresqlSQL(namespace, podName, statement) + _, err = runPostgresqlSQL(namespace, podName, "postgres", statement) Expect(err).NotTo(HaveOccurred()) } } @@ -250,8 +270,7 @@ func runCommand(cmd *exec.Cmd, stdin io.Reader, stdout, stderr io.Writer) error func setBackstageReplicas(namespace, crName string, replicas int) { patch := fmt.Sprintf(`{"spec":{"deployment":{"patch":{"spec":{"replicas":%d}}}}}`, replicas) - _, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "patch", "backstage", crName, - "--type=merge", "--patch", patch)) + err := helper.PatchBackstageCR(namespace, crName, patch, "merge") Expect(err).NotTo(HaveOccurred()) } From b49834d4b027e780a03d22cc73234326b5df4b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 18 Sep 2026 14:36:33 +0200 Subject: [PATCH 07/11] test(e2e): add upgrade checkpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- tests/e2e/e2e_upgrade_test.go | 6 ++ tests/e2e/postgresql_upgrade_restore_test.go | 21 +++++ tests/e2e/postgresql_upgrade_test.go | 84 ++++++++++++++++++-- 3 files changed, 106 insertions(+), 5 deletions(-) diff --git a/tests/e2e/e2e_upgrade_test.go b/tests/e2e/e2e_upgrade_test.go index 91381e2e9..aad65c1f2 100644 --- a/tests/e2e/e2e_upgrade_test.go +++ b/tests/e2e/e2e_upgrade_test.go @@ -88,6 +88,12 @@ metadata: Should(Succeed()) }) + JustAfterEach(func() { + if isEnvEnabled("BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE") && CurrentSpecReport().Failed() { + GinkgoWriter.Println(postgresqlUpgradeDiagnostics(ns, crName)) + } + }) + It("should successfully reconcile existing CR when upgrading the operator", func() { var postgresqlUpgrade *postgresqlUpgradeState if isEnvEnabled("BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE") { diff --git a/tests/e2e/postgresql_upgrade_restore_test.go b/tests/e2e/postgresql_upgrade_restore_test.go index e53cd870b..b4af22c77 100644 --- a/tests/e2e/postgresql_upgrade_restore_test.go +++ b/tests/e2e/postgresql_upgrade_restore_test.go @@ -7,6 +7,27 @@ import ( "github.com/stretchr/testify/assert" ) +func TestPostgresqlUpgradeCheckpoint(t *testing.T) { + assert.Equal(t, + "postgresql-upgrade: dump-created bytes=42", + postgresqlUpgradeCheckpoint("dump-created", "bytes=42"), + ) +} + +func TestFormatPostgresqlUpgradeDiagnostics(t *testing.T) { + assert.Equal(t, + "=== PostgreSQL upgrade diagnostics ===\n"+ + "=== Operator and operand logs ===\noperator and operand\n"+ + "=== PostgreSQL logs ===\npostgresql\n"+ + "=== PostgreSQL description ===\npostgresql description\n", + formatPostgresqlUpgradeDiagnostics( + "operator and operand\n", + "postgresql\n", + "postgresql description\n", + ), + ) +} + func TestPostgresqlSQLCommandUsesRequestedDatabase(t *testing.T) { cmd := postgresqlSQLCommand("test-namespace", "postgres-0", "backstage_plugin_catalog", "-c", "SELECT 1") diff --git a/tests/e2e/postgresql_upgrade_test.go b/tests/e2e/postgresql_upgrade_test.go index 38af56224..dc695e399 100644 --- a/tests/e2e/postgresql_upgrade_test.go +++ b/tests/e2e/postgresql_upgrade_test.go @@ -34,6 +34,40 @@ type postgresqlUpgradeState struct { databaseNames []string } +func postgresqlUpgradeCheckpoint(name string, fields ...string) string { + checkpoint := "postgresql-upgrade: " + name + if len(fields) > 0 { + checkpoint += " " + strings.Join(fields, " ") + } + return checkpoint +} + +func logPostgresqlUpgradeCheckpoint(name string, fields ...string) { + fmt.Println(postgresqlUpgradeCheckpoint(name, fields...)) +} + +func formatPostgresqlUpgradeDiagnostics(operatorAndOperandLogs, postgresqlLogs, postgresqlDescription string) string { + return fmt.Sprintf( + "=== PostgreSQL upgrade diagnostics ===\n"+ + "=== Operator and operand logs ===\n%s"+ + "=== PostgreSQL logs ===\n%s"+ + "=== PostgreSQL description ===\n%s", + operatorAndOperandLogs, + postgresqlLogs, + postgresqlDescription, + ) +} + +func postgresqlUpgradeDiagnostics(namespace, crName string) string { + crLabel := fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName) + postgresqlLabel := fmt.Sprintf("rhdh.redhat.com/app=%s", postgresqlStatefulSetName(crName)) + return formatPostgresqlUpgradeDiagnostics( + fetchOperatorAndOperandLogs(managerPodLabel, namespace, crLabel), + getPodLogs(namespace, "", postgresqlLabel), + describePod(namespace, postgresqlLabel), + ) +} + func preparePostgresqlUpgrade(namespace, crName string) *postgresqlUpgradeState { state := &postgresqlUpgradeState{} postgresPod := waitForPostgresql(namespace, crName, postgresqlSourceImage, postgresqlSourceVersion) @@ -51,6 +85,17 @@ INSERT INTO public.rhdh_postgresql_upgrade_test VALUES ('`+postgresqlProofValue+ state.pvcUID = resourceUID(namespace, "pvc", postgresqlPVCName(crName)) state.secretUID = resourceUID(namespace, "secret", postgresqlSecretName(crName)) state.backstagePodUID = readyPodUID(namespace, fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName)) + logPostgresqlUpgradeCheckpoint("source-ready", + fmt.Sprintf("pod=%s", postgresPod), + fmt.Sprintf("podUID=%s", state.postgresPodUID), + fmt.Sprintf("pvcUID=%s", state.pvcUID), + fmt.Sprintf("secretUID=%s", state.secretUID), + fmt.Sprintf("backstagePodUID=%s", state.backstagePodUID), + fmt.Sprintf("databases=%d", len(state.databaseNames)), + fmt.Sprintf("imageContains=%s", postgresqlSourceImage), + fmt.Sprintf("versionPrefix=%s", postgresqlSourceVersion), + fmt.Sprintf("proofDatabase=%s", postgresqlProofDatabase), + ) By("stopping Backstage before taking the PostgreSQL dump") setBackstageReplicas(namespace, crName, 0) @@ -100,15 +145,35 @@ func completePostgresqlUpgrade(namespace, crName string, state *postgresqlUpgrad WithArguments(managerPodLabel).Should(Succeed()) postgresPod := waitForPostgresql(namespace, crName, postgresqlTargetImage, postgresqlTargetVersion) - Expect(resourceUID(namespace, "pod", postgresPod)).NotTo(Equal(state.postgresPodUID)) - Expect(resourceUID(namespace, "pvc", postgresqlPVCName(crName))).NotTo(Equal(state.pvcUID)) - Expect(resourceUID(namespace, "secret", postgresqlSecretName(crName))).To(Equal(state.secretUID)) + targetPostgresPodUID := resourceUID(namespace, "pod", postgresPod) + targetPVCUID := resourceUID(namespace, "pvc", postgresqlPVCName(crName)) + targetSecretUID := resourceUID(namespace, "secret", postgresqlSecretName(crName)) + Expect(targetPostgresPodUID).NotTo(Equal(state.postgresPodUID)) + Expect(targetPVCUID).NotTo(Equal(state.pvcUID)) + Expect(targetSecretUID).To(Equal(state.secretUID)) + logPostgresqlUpgradeCheckpoint("target-ready", + fmt.Sprintf("pod=%s", postgresPod), + fmt.Sprintf("previousPodUID=%s", state.postgresPodUID), + fmt.Sprintf("podUID=%s", targetPostgresPodUID), + fmt.Sprintf("previousPVCUID=%s", state.pvcUID), + fmt.Sprintf("pvcUID=%s", targetPVCUID), + fmt.Sprintf("secretUID=%s", targetSecretUID), + "secretPreserved=true", + fmt.Sprintf("imageContains=%s", postgresqlTargetImage), + fmt.Sprintf("versionPrefix=%s", postgresqlTargetVersion), + ) By("restoring the PostgreSQL 15 dump into PostgreSQL 18") restorePostgresql(namespace, postgresPod, state.dumpPath) - Expect(postgresqlDatabaseNames(namespace, postgresPod)).To(Equal(state.databaseNames)) + restoredDatabaseNames := postgresqlDatabaseNames(namespace, postgresPod) + Expect(restoredDatabaseNames).To(Equal(state.databaseNames)) refreshPostgresqlCollations(namespace, postgresPod) Expect(queryPostgresqlUpgradeProof(namespace, postgresPod)).To(Equal(postgresqlProofValue)) + logPostgresqlUpgradeCheckpoint("restore-verified", + fmt.Sprintf("databases=%d", len(restoredDatabaseNames)), + fmt.Sprintf("proofDatabase=%s", postgresqlProofDatabase), + fmt.Sprintf("proofValue=%s", postgresqlProofValue), + ) By("starting Backstage against the restored PostgreSQL 18 database") setBackstageReplicas(namespace, crName, 1) @@ -196,6 +261,7 @@ func dumpPostgresql(namespace, podName string) string { info, err := os.Stat(dumpPath) Expect(err).NotTo(HaveOccurred()) Expect(info.Size()).To(BeNumerically(">", 0)) + logPostgresqlUpgradeCheckpoint("dump-created", fmt.Sprintf("bytes=%d", info.Size())) return dumpPath } @@ -248,10 +314,12 @@ func refreshPostgresqlCollations(namespace, podName string) { "SELECT format('ALTER DATABASE %I REFRESH COLLATION VERSION;', datname) FROM pg_database WHERE datallowconn AND datname <> 'template0' ORDER BY datname;")) Expect(err).NotTo(HaveOccurred()) - for _, statement := range helper.GetNonEmptyLines(string(out)) { + statements := helper.GetNonEmptyLines(string(out)) + for _, statement := range statements { _, err = runPostgresqlSQL(namespace, podName, "postgres", statement) Expect(err).NotTo(HaveOccurred()) } + logPostgresqlUpgradeCheckpoint("collations-refreshed", fmt.Sprintf("databases=%d", len(statements))) } func runCommand(cmd *exec.Cmd, stdin io.Reader, stdout, stderr io.Writer) error { @@ -327,6 +395,7 @@ func readyPodUID(namespace, label string) string { func waitForBackstagePodReplacement(namespace, crName, previousUID string) { label := fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName) + var replacementUID string Eventually(func(g Gomega) { out, err := helper.Run(exec.Command(helper.GetPlatformTool(), "-n", namespace, "get", "pods", "-l", label, "-o", `jsonpath={range .items[*]}{.metadata.uid}{" "}{.status.phase}{" "}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}`)) @@ -339,7 +408,12 @@ func waitForBackstagePodReplacement(namespace, crName, previousUID string) { g.Expect(fields[0]).NotTo(Equal(previousUID)) g.Expect(fields[1]).To(Equal("Running")) g.Expect(fields[2]).To(Equal("True")) + replacementUID = fields[0] }, 15*time.Minute, 10*time.Second).Should(Succeed()) + logPostgresqlUpgradeCheckpoint("backstage-ready", + fmt.Sprintf("previousPodUID=%s", previousUID), + fmt.Sprintf("podUID=%s", replacementUID), + ) } func postgresqlStatefulSetName(crName string) string { From 1ce4a59e6199d2588f84258a45bfb6b58ca67238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 18 Sep 2026 15:27:03 +0200 Subject: [PATCH 08/11] fix(ci): secure nightly manifest fetches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- .github/workflows/nightly-upgrade-test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-upgrade-test.yaml b/.github/workflows/nightly-upgrade-test.yaml index 3af18b462..f2706cba3 100644 --- a/.github/workflows/nightly-upgrade-test.yaml +++ b/.github/workflows/nightly-upgrade-test.yaml @@ -79,12 +79,12 @@ jobs: FROM_OPERATOR_MANIFEST="https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/${{ matrix.from_branch }}/${distLocation}" echo "FROM_OPERATOR_MANIFEST=${FROM_OPERATOR_MANIFEST}" >> $GITHUB_ENV - FROM_OPERATOR_IMAGE=$(curl -s "${FROM_OPERATOR_MANIFEST}" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image') + FROM_OPERATOR_IMAGE=$(curl --proto '=https' --proto-redir '=https' -fsSL "${FROM_OPERATOR_MANIFEST}" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image') echo "FROM_OPERATOR_IMAGE=${FROM_OPERATOR_IMAGE}" >> $GITHUB_ENV TO_OPERATOR_MANIFEST="https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/${{ matrix.to_branch }}/${distLocation}" echo "TO_OPERATOR_MANIFEST=${TO_OPERATOR_MANIFEST}" >> $GITHUB_ENV - TO_OPERATOR_IMAGE=$(curl -s "${TO_OPERATOR_MANIFEST}" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image') + TO_OPERATOR_IMAGE=$(curl --proto '=https' --proto-redir '=https' -fsSL "${TO_OPERATOR_MANIFEST}" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image') echo "TO_OPERATOR_IMAGE=${TO_OPERATOR_IMAGE}" >> $GITHUB_ENV - name: Check if operator images exist in remote registry From 71ecbb62d90a7fb7a377d58fc61064ea8d33077e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Mon, 21 Sep 2026 12:25:54 +0200 Subject: [PATCH 09/11] test(e2e): address review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Limit the expensive migration path to selected release pairs and remove unit coverage for helpers exercised by the E2E flow. Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- ...l => nightly-postgresql-upgrade-test.yaml} | 39 ++++---- .github/workflows/nightly-upgrade-test.yaml | 1 - tests/e2e/e2e_suite_test.go | 20 ++-- tests/e2e/operator_cleanup_test.go | 28 ------ tests/e2e/postgresql_upgrade_restore_test.go | 92 ------------------- tests/e2e/postgresql_upgrade_test.go | 27 ++---- 6 files changed, 29 insertions(+), 178 deletions(-) rename .github/workflows/{pr-postgresql-upgrade-test.yaml => nightly-postgresql-upgrade-test.yaml} (83%) delete mode 100644 tests/e2e/operator_cleanup_test.go delete mode 100644 tests/e2e/postgresql_upgrade_restore_test.go diff --git a/.github/workflows/pr-postgresql-upgrade-test.yaml b/.github/workflows/nightly-postgresql-upgrade-test.yaml similarity index 83% rename from .github/workflows/pr-postgresql-upgrade-test.yaml rename to .github/workflows/nightly-postgresql-upgrade-test.yaml index e30459348..85f91dbf2 100644 --- a/.github/workflows/pr-postgresql-upgrade-test.yaml +++ b/.github/workflows/nightly-postgresql-upgrade-test.yaml @@ -1,41 +1,36 @@ -name: PR PostgreSQL Upgrade Test +name: Nightly PostgreSQL Upgrade Test on: - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - branches: - - 'main' - paths: - - '.github/workflows/pr-postgresql-upgrade-test.yaml' - - '.github/workflows/nightly-upgrade-test.yaml' - - '**/*.go' - - 'config/**' - - 'dist/rhdh/install.yaml' - - 'Dockerfile' - - 'go.mod' - - 'go.sum' - - 'Makefile' - -concurrency: - group: ${{ github.workflow }}-${{ github.event.number }} - cancel-in-progress: true + workflow_dispatch: + schedule: + - cron: "25 0 * * *" jobs: postgresql-upgrade: - name: E2E PostgreSQL 15 to 18 + name: E2E PostgreSQL ${{ matrix.from_branch }} to ${{ matrix.to_branch }} + concurrency: + group: ${{ github.workflow }}-${{ matrix.from_branch }}-${{ matrix.to_branch }} + cancel-in-progress: true runs-on: ubuntu-latest timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + include: + - from_branch: release-1.10 + to_branch: main permissions: contents: read env: CONTAINER_ENGINE: docker - FROM_OPERATOR_MANIFEST: https://raw.githubusercontent.com/redhat-developer/rhdh-operator/refs/heads/release-1.10/dist/rhdh/install.yaml + FROM_OPERATOR_MANIFEST: https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/${{ matrix.from_branch }}/dist/rhdh/install.yaml TO_OPERATOR_MANIFEST: ${{ github.workspace }}/dist/rhdh/install.yaml steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + ref: ${{ matrix.to_branch }} fetch-depth: 0 persist-credentials: false @@ -61,7 +56,7 @@ jobs: - name: Build target operator image and manifest env: - TO_OPERATOR_IMAGE: localhost/rhdh-operator:pr-${{ github.event.pull_request.head.sha }} + TO_OPERATOR_IMAGE: localhost/rhdh-operator:nightly-${{ matrix.from_branch }}-to-${{ matrix.to_branch }}-${{ github.run_id }} run: | make image-build build-installer PROFILE=rhdh IMG="$TO_OPERATOR_IMAGE" MANIFEST_IMAGE=$(yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image' "$TO_OPERATOR_MANIFEST") diff --git a/.github/workflows/nightly-upgrade-test.yaml b/.github/workflows/nightly-upgrade-test.yaml index f2706cba3..d9be68b0f 100644 --- a/.github/workflows/nightly-upgrade-test.yaml +++ b/.github/workflows/nightly-upgrade-test.yaml @@ -158,5 +158,4 @@ jobs: TO_OPERATOR_MANIFEST: ${{ env.TO_OPERATOR_MANIFEST }} OPERATOR_MANIFEST: ${{ env.TO_OPERATOR_MANIFEST }} IMG: ${{ env.TO_OPERATOR_IMAGE }} - BACKSTAGE_OPERATOR_TESTS_POSTGRESQL_UPGRADE: ${{ matrix.to_branch == 'main' }} run: make test-e2e-upgrade diff --git a/tests/e2e/e2e_suite_test.go b/tests/e2e/e2e_suite_test.go index a6b71f558..f5665f0e0 100644 --- a/tests/e2e/e2e_suite_test.go +++ b/tests/e2e/e2e_suite_test.go @@ -220,14 +220,12 @@ var _ = SynchronizedAfterSuite(func() { }, // the function below *only* on process #1 func() { - fmt.Println(captureOperatorLogsBeforeCleanup( - fetchOperatorLogs(managerPodLabel, false), - func() { - uninstallOperator() - deleteOperatorManifest(os.Getenv("FROM_OPERATOR_MANIFEST")) - deleteOperatorManifest(os.Getenv("TO_OPERATOR_MANIFEST")) - }, - )) + defer func() { + uninstallOperator() + deleteOperatorManifest(os.Getenv("FROM_OPERATOR_MANIFEST")) + deleteOperatorManifest(os.Getenv("TO_OPERATOR_MANIFEST")) + }() + fmt.Println(fetchOperatorLogs(managerPodLabel, false)()) }, ) @@ -302,12 +300,6 @@ func fetchOperatorLogs(managerPodLabel string, raw bool) func() string { } } -func captureOperatorLogsBeforeCleanup(fetchLogs func() string, cleanup func()) string { - logs := fetchLogs() - cleanup() - return logs -} - func fetchOperandLogs(ns string, crLabel string, raw bool) func() string { return func() string { logs := getPodLogs(ns, "", crLabel) diff --git a/tests/e2e/operator_cleanup_test.go b/tests/e2e/operator_cleanup_test.go deleted file mode 100644 index 14cf1e3ee..000000000 --- a/tests/e2e/operator_cleanup_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package e2e - -import "testing" - -func TestCaptureOperatorLogsBeforeCleanup(t *testing.T) { - var events []string - - logs := captureOperatorLogsBeforeCleanup( - func() string { - events = append(events, "logs") - return "operator logs" - }, - func() { - events = append(events, "cleanup") - }, - ) - - if logs != "operator logs" { - t.Fatalf("captured logs = %q, want %q", logs, "operator logs") - } - - if got, want := len(events), 2; got != want { - t.Fatalf("events = %v, want %d events", events, want) - } - if events[0] != "logs" || events[1] != "cleanup" { - t.Fatalf("events = %v, want logs followed by cleanup", events) - } -} diff --git a/tests/e2e/postgresql_upgrade_restore_test.go b/tests/e2e/postgresql_upgrade_restore_test.go deleted file mode 100644 index b4af22c77..000000000 --- a/tests/e2e/postgresql_upgrade_restore_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package e2e - -import ( - "testing" - - "github.com/redhat-developer/rhdh-operator/tests/helper" - "github.com/stretchr/testify/assert" -) - -func TestPostgresqlUpgradeCheckpoint(t *testing.T) { - assert.Equal(t, - "postgresql-upgrade: dump-created bytes=42", - postgresqlUpgradeCheckpoint("dump-created", "bytes=42"), - ) -} - -func TestFormatPostgresqlUpgradeDiagnostics(t *testing.T) { - assert.Equal(t, - "=== PostgreSQL upgrade diagnostics ===\n"+ - "=== Operator and operand logs ===\noperator and operand\n"+ - "=== PostgreSQL logs ===\npostgresql\n"+ - "=== PostgreSQL description ===\npostgresql description\n", - formatPostgresqlUpgradeDiagnostics( - "operator and operand\n", - "postgresql\n", - "postgresql description\n", - ), - ) -} - -func TestPostgresqlSQLCommandUsesRequestedDatabase(t *testing.T) { - cmd := postgresqlSQLCommand("test-namespace", "postgres-0", "backstage_plugin_catalog", "-c", "SELECT 1") - - assert.Equal(t, helper.GetPlatformTool(), cmd.Args[0]) - assert.Equal(t, []string{ - "-n", "test-namespace", "exec", "postgres-0", "--", - "psql", "-X", "-U", "postgres", "-d", "backstage_plugin_catalog", "-c", "SELECT 1", - }, cmd.Args[1:]) -} - -func TestPostgresqlSQLCommandWithStdinEnablesInteractiveExec(t *testing.T) { - cmd := postgresqlSQLCommandWithStdin("test-namespace", "postgres-0", "postgres", "--quiet") - - assert.Equal(t, []string{ - "-n", "test-namespace", "exec", "-i", "postgres-0", "--", - "psql", "-X", "-U", "postgres", "-d", "postgres", "--quiet", - }, cmd.Args[1:]) -} - -func TestValidatePostgresqlRestoreErrors(t *testing.T) { - tests := []struct { - name string - stderr string - wantErr string - }{ - { - name: "accepts bootstrap role conflict", - stderr: "ERROR: role \"postgres\" already exists\n", - }, - { - name: "rejects an unexpected SQL error", - stderr: "ERROR: role \"postgres\" already exists\nERROR: relation \"example\" already exists\n", - wantErr: "unexpected PostgreSQL restore errors", - }, - { - name: "rejects a fatal connection error", - stderr: "ERROR: role \"postgres\" already exists\nFATAL: database \"backstage\" does not exist\n", - wantErr: "unexpected PostgreSQL restore errors", - }, - { - name: "rejects a psql connection error", - stderr: "ERROR: role \"postgres\" already exists\npsql: error: connection to server was lost\n", - wantErr: "unexpected PostgreSQL restore errors", - }, - { - name: "rejects a restore without the expected bootstrap conflict", - stderr: "", - wantErr: "expected one bootstrap role conflict", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := validatePostgresqlRestoreErrors(tt.stderr) - if tt.wantErr == "" { - assert.NoError(t, err) - return - } - assert.ErrorContains(t, err, tt.wantErr) - }) - } -} diff --git a/tests/e2e/postgresql_upgrade_test.go b/tests/e2e/postgresql_upgrade_test.go index dc695e399..10e6691b3 100644 --- a/tests/e2e/postgresql_upgrade_test.go +++ b/tests/e2e/postgresql_upgrade_test.go @@ -34,34 +34,22 @@ type postgresqlUpgradeState struct { databaseNames []string } -func postgresqlUpgradeCheckpoint(name string, fields ...string) string { +func logPostgresqlUpgradeCheckpoint(name string, fields ...string) { checkpoint := "postgresql-upgrade: " + name if len(fields) > 0 { checkpoint += " " + strings.Join(fields, " ") } - return checkpoint -} - -func logPostgresqlUpgradeCheckpoint(name string, fields ...string) { - fmt.Println(postgresqlUpgradeCheckpoint(name, fields...)) + fmt.Println(checkpoint) } -func formatPostgresqlUpgradeDiagnostics(operatorAndOperandLogs, postgresqlLogs, postgresqlDescription string) string { +func postgresqlUpgradeDiagnostics(namespace, crName string) string { + crLabel := fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName) + postgresqlLabel := fmt.Sprintf("rhdh.redhat.com/app=%s", postgresqlStatefulSetName(crName)) return fmt.Sprintf( "=== PostgreSQL upgrade diagnostics ===\n"+ "=== Operator and operand logs ===\n%s"+ "=== PostgreSQL logs ===\n%s"+ "=== PostgreSQL description ===\n%s", - operatorAndOperandLogs, - postgresqlLogs, - postgresqlDescription, - ) -} - -func postgresqlUpgradeDiagnostics(namespace, crName string) string { - crLabel := fmt.Sprintf("rhdh.redhat.com/app=backstage-%s", crName) - postgresqlLabel := fmt.Sprintf("rhdh.redhat.com/app=%s", postgresqlStatefulSetName(crName)) - return formatPostgresqlUpgradeDiagnostics( fetchOperatorAndOperandLogs(managerPodLabel, namespace, crLabel), getPodLogs(namespace, "", postgresqlLabel), describePod(namespace, postgresqlLabel), @@ -92,9 +80,8 @@ INSERT INTO public.rhdh_postgresql_upgrade_test VALUES ('`+postgresqlProofValue+ fmt.Sprintf("secretUID=%s", state.secretUID), fmt.Sprintf("backstagePodUID=%s", state.backstagePodUID), fmt.Sprintf("databases=%d", len(state.databaseNames)), - fmt.Sprintf("imageContains=%s", postgresqlSourceImage), - fmt.Sprintf("versionPrefix=%s", postgresqlSourceVersion), fmt.Sprintf("proofDatabase=%s", postgresqlProofDatabase), + fmt.Sprintf("proofValue=%s", postgresqlProofValue), ) By("stopping Backstage before taking the PostgreSQL dump") @@ -159,8 +146,6 @@ func completePostgresqlUpgrade(namespace, crName string, state *postgresqlUpgrad fmt.Sprintf("pvcUID=%s", targetPVCUID), fmt.Sprintf("secretUID=%s", targetSecretUID), "secretPreserved=true", - fmt.Sprintf("imageContains=%s", postgresqlTargetImage), - fmt.Sprintf("versionPrefix=%s", postgresqlTargetVersion), ) By("restoring the PostgreSQL 15 dump into PostgreSQL 18") From 935a0352f75fc7168b12ce7f4f9b4a72b3a3dc1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Mon, 21 Sep 2026 13:12:43 +0200 Subject: [PATCH 10/11] ci: trigger PostgreSQL upgrade test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Temporarily enable the PR event so the nightly workflow can validate the current pull request head before merge. Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- .github/workflows/nightly-postgresql-upgrade-test.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly-postgresql-upgrade-test.yaml b/.github/workflows/nightly-postgresql-upgrade-test.yaml index 85f91dbf2..b6c7d305e 100644 --- a/.github/workflows/nightly-postgresql-upgrade-test.yaml +++ b/.github/workflows/nightly-postgresql-upgrade-test.yaml @@ -1,6 +1,8 @@ name: Nightly PostgreSQL Upgrade Test on: + pull_request: + types: [synchronize] workflow_dispatch: schedule: - cron: "25 0 * * *" @@ -30,7 +32,7 @@ jobs: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - ref: ${{ matrix.to_branch }} + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || matrix.to_branch }} fetch-depth: 0 persist-credentials: false From 28ccc963daffe200b4366aa0e0c5e8d77263ab71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Mon, 21 Sep 2026 13:27:45 +0200 Subject: [PATCH 11/11] ci: restore PostgreSQL nightly trigger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the temporary pull-request event used to validate the nightly workflow before merge. Assisted-by: OpenCode Signed-off-by: Zbyněk Drápela --- .github/workflows/nightly-postgresql-upgrade-test.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/nightly-postgresql-upgrade-test.yaml b/.github/workflows/nightly-postgresql-upgrade-test.yaml index b6c7d305e..85f91dbf2 100644 --- a/.github/workflows/nightly-postgresql-upgrade-test.yaml +++ b/.github/workflows/nightly-postgresql-upgrade-test.yaml @@ -1,8 +1,6 @@ name: Nightly PostgreSQL Upgrade Test on: - pull_request: - types: [synchronize] workflow_dispatch: schedule: - cron: "25 0 * * *" @@ -32,7 +30,7 @@ jobs: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || matrix.to_branch }} + ref: ${{ matrix.to_branch }} fetch-depth: 0 persist-credentials: false