From 9142a693f12755bd44cd80eff900aab32f75de79 Mon Sep 17 00:00:00 2001 From: Vibhu Prashar Date: Tue, 4 Feb 2025 08:09:38 +0530 Subject: [PATCH] feat: add support to testing operator on disconnected env Signed-off-by: Vibhu Prashar --- ...rator-v1alpha1__ocp-4.17-disconnected.yaml | 47 ++++ ...nitoring-operator-v1alpha1-presubmits.yaml | 136 +++++++++++ .../install/disconnected/OWNERS | 0 ...onitoring-install-disconnected-commands.sh | 226 ++++++++++++++++++ ...ing-install-disconnected-ref.metadata.json | 4 + ...r-monitoring-install-disconnected-ref.yaml | 18 ++ 6 files changed, 431 insertions(+) create mode 100644 ci-operator/config/openshift-power-monitoring/power-monitoring-operator/openshift-power-monitoring-power-monitoring-operator-v1alpha1__ocp-4.17-disconnected.yaml create mode 100644 ci-operator/step-registry/openshift-power-monitoring/install/disconnected/OWNERS create mode 100644 ci-operator/step-registry/openshift-power-monitoring/install/disconnected/openshift-power-monitoring-install-disconnected-commands.sh create mode 100644 ci-operator/step-registry/openshift-power-monitoring/install/disconnected/openshift-power-monitoring-install-disconnected-ref.metadata.json create mode 100644 ci-operator/step-registry/openshift-power-monitoring/install/disconnected/openshift-power-monitoring-install-disconnected-ref.yaml diff --git a/ci-operator/config/openshift-power-monitoring/power-monitoring-operator/openshift-power-monitoring-power-monitoring-operator-v1alpha1__ocp-4.17-disconnected.yaml b/ci-operator/config/openshift-power-monitoring/power-monitoring-operator/openshift-power-monitoring-power-monitoring-operator-v1alpha1__ocp-4.17-disconnected.yaml new file mode 100644 index 000000000000..8a969762a94d --- /dev/null +++ b/ci-operator/config/openshift-power-monitoring/power-monitoring-operator/openshift-power-monitoring-power-monitoring-operator-v1alpha1__ocp-4.17-disconnected.yaml @@ -0,0 +1,47 @@ +base_images: + cli: + name: "4.17" + namespace: ocp + tag: cli + tools: + name: "4.17" + namespace: ocp + tag: tools + upi-installer: + name: "4.17" + namespace: ocp + tag: upi-installer +build_root: + image_stream_tag: + name: release + namespace: openshift + tag: rhel-8-release-golang-1.21-openshift-4.16 +images: +- context_dir: . + dockerfile_path: tests/Dockerfile + to: power-monitoring-operator-tests-runner +releases: + latest: + candidate: + product: ocp + stream: nightly + version: "4.17" +resources: + '*': + requests: + cpu: 100m + memory: 200Mi +tests: +- always_run: false + as: powermonitoring-tests-disconnected + cluster: build01 + steps: + cluster_profile: gcp-qe + test: + - ref: openshift-power-monitoring-install-disconnected + workflow: cucushift-installer-rehearse-gcp-ipi-disconnected +zz_generated_metadata: + branch: v1alpha1 + org: openshift-power-monitoring + repo: power-monitoring-operator + variant: ocp-4.17-disconnected diff --git a/ci-operator/jobs/openshift-power-monitoring/power-monitoring-operator/openshift-power-monitoring-power-monitoring-operator-v1alpha1-presubmits.yaml b/ci-operator/jobs/openshift-power-monitoring/power-monitoring-operator/openshift-power-monitoring-power-monitoring-operator-v1alpha1-presubmits.yaml index f0fc8885f4e4..4cdfc42c99a4 100644 --- a/ci-operator/jobs/openshift-power-monitoring/power-monitoring-operator/openshift-power-monitoring-power-monitoring-operator-v1alpha1-presubmits.yaml +++ b/ci-operator/jobs/openshift-power-monitoring/power-monitoring-operator/openshift-power-monitoring-power-monitoring-operator-v1alpha1-presubmits.yaml @@ -112,6 +112,142 @@ presubmits: secret: secretName: result-aggregator trigger: (?m)^/test( | .* )images,?($|\s.*) + - agent: kubernetes + always_run: true + branches: + - ^v1alpha1$ + - ^v1alpha1- + cluster: build10 + context: ci/prow/ocp-4.17-disconnected-images + decorate: true + decoration_config: + skip_cloning: true + labels: + ci-operator.openshift.io/variant: ocp-4.17-disconnected + ci.openshift.io/generator: prowgen + job-release: "4.17" + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: pull-ci-openshift-power-monitoring-power-monitoring-operator-v1alpha1-ocp-4.17-disconnected-images + rerun_command: /test ocp-4.17-disconnected-images + spec: + containers: + - args: + - --gcs-upload-secret=/secrets/gcs/service-account.json + - --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson + - --report-credentials-file=/etc/report/credentials + - --target=[images] + - --variant=ocp-4.17-disconnected + command: + - ci-operator + image: ci-operator:latest + imagePullPolicy: Always + name: "" + resources: + requests: + cpu: 10m + volumeMounts: + - mountPath: /secrets/gcs + name: gcs-credentials + readOnly: true + - mountPath: /secrets/manifest-tool + name: manifest-tool-local-pusher + readOnly: true + - mountPath: /etc/pull-secret + name: pull-secret + readOnly: true + - mountPath: /etc/report + name: result-aggregator + readOnly: true + serviceAccountName: ci-operator + volumes: + - name: manifest-tool-local-pusher + secret: + secretName: manifest-tool-local-pusher + - name: pull-secret + secret: + secretName: registry-pull-credentials + - name: result-aggregator + secret: + secretName: result-aggregator + trigger: (?m)^/test( | .* )ocp-4.17-disconnected-images,?($|\s.*) + - agent: kubernetes + always_run: false + branches: + - ^v1alpha1$ + - ^v1alpha1- + cluster: build01 + context: ci/prow/ocp-4.17-disconnected-powermonitoring-tests-disconnected + decorate: true + decoration_config: + skip_cloning: true + labels: + ci-operator.openshift.io/cloud: gcp + ci-operator.openshift.io/cloud-cluster-profile: gcp-qe + ci-operator.openshift.io/cluster: build01 + ci-operator.openshift.io/variant: ocp-4.17-disconnected + ci.openshift.io/generator: prowgen + job-release: "4.17" + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: pull-ci-openshift-power-monitoring-power-monitoring-operator-v1alpha1-ocp-4.17-disconnected-powermonitoring-tests-disconnected + rerun_command: /test ocp-4.17-disconnected-powermonitoring-tests-disconnected + spec: + containers: + - args: + - --gcs-upload-secret=/secrets/gcs/service-account.json + - --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson + - --lease-server-credentials-file=/etc/boskos/credentials + - --report-credentials-file=/etc/report/credentials + - --secret-dir=/secrets/ci-pull-credentials + - --target=powermonitoring-tests-disconnected + - --variant=ocp-4.17-disconnected + command: + - ci-operator + image: ci-operator:latest + imagePullPolicy: Always + name: "" + resources: + requests: + cpu: 10m + volumeMounts: + - mountPath: /etc/boskos + name: boskos + readOnly: true + - mountPath: /secrets/ci-pull-credentials + name: ci-pull-credentials + readOnly: true + - mountPath: /secrets/gcs + name: gcs-credentials + readOnly: true + - mountPath: /secrets/manifest-tool + name: manifest-tool-local-pusher + readOnly: true + - mountPath: /etc/pull-secret + name: pull-secret + readOnly: true + - mountPath: /etc/report + name: result-aggregator + readOnly: true + serviceAccountName: ci-operator + volumes: + - name: boskos + secret: + items: + - key: credentials + path: credentials + secretName: boskos-credentials + - name: ci-pull-credentials + secret: + secretName: ci-pull-credentials + - name: manifest-tool-local-pusher + secret: + secretName: manifest-tool-local-pusher + - name: pull-secret + secret: + secretName: registry-pull-credentials + - name: result-aggregator + secret: + secretName: result-aggregator + trigger: (?m)^/test( | .* )(ocp-4.17-disconnected-powermonitoring-tests-disconnected|remaining-required),?($|\s.*) - agent: kubernetes always_run: false branches: diff --git a/ci-operator/step-registry/openshift-power-monitoring/install/disconnected/OWNERS b/ci-operator/step-registry/openshift-power-monitoring/install/disconnected/OWNERS new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci-operator/step-registry/openshift-power-monitoring/install/disconnected/openshift-power-monitoring-install-disconnected-commands.sh b/ci-operator/step-registry/openshift-power-monitoring/install/disconnected/openshift-power-monitoring-install-disconnected-commands.sh new file mode 100644 index 000000000000..4f5b0f086930 --- /dev/null +++ b/ci-operator/step-registry/openshift-power-monitoring/install/disconnected/openshift-power-monitoring-install-disconnected-commands.sh @@ -0,0 +1,226 @@ +#!/bin/bash + +set -eu -o pipefail + +export HOME=/tmp/home +export XDG_RUNTIME_DIR="${HOME}/run" +export REGISTRY_AUTH_PREFERENCE=podman +mkdir -p "${XDG_RUNTIME_DIR}/containers" +cd "$HOME" || exit 1 + +# constants +declare -r LOGS_DIR="/$ARTIFACT_DIR/test-run-logs" + +declare OPERATOR_CHANNEL=${OPERATOR_CHANNEL:-"tech-preview"} +declare OPERATOR=${OPERATOR:-"power-monitoring-operator"} +declare OPERATOR_NS=${OPERATOR_NS:-"openshift-operators"} +declare CATALOG_SOURCE=${CATALOG_SOURCE:-"redhat-operators"} +declare MIRROR_KEPLER_IMAGE=${MIRROR_KEPLER_IMAGE:-"quay.io/redhat-user-workloads/rhpm-tenant/kepler"} +declare SOURCE_KEPLER_IMAGE=${SOURCE_KEPLER_IMAGE:-"registry.redhat.io/openshift-power-monitoring/kepler-rhel9"} +declare MIRROR_OPERATOR_IMAGE=${MIRROR_OPERATOR_IMAGE:-"quay.io/redhat-user-workloads/rhpm-tenant/power-monitoring-operator"} +declare SOURCE_OPERATOR_IMAGE=${SOURCE_OPERATOR_IMAGE:-"registry.redhat.io/openshift-power-monitoring/power-monitoring-rhel9-operator"} +declare BREW_REGISTRY=${BREW_REGISTRY:-"brew.registry.redhat.io"} +declare REGISTRY_PROXY=${REGISTRY_PROXY:-"registry-proxy.engineering.redhat.com"} +declare MIRROR_BUNDLE_IMAGE=${MIRROR_BUNDLE_IMAGE:-"quay.io/redhat-user-workloads/rhpm-tenant/power-monitoring-operator-bundle"} +declare SOURCE_BUNDLE_IMAGE=${SOURCE_BUNDLE_IMAGE:-"registry.redhat.io/openshift-power-monitoring/power-monitoring-operator-bundle"} +declare INDEX=${INDEX:-"926635"} + +run_command() { + local CMD="$1" + echo "Running Command: ${CMD}" + eval "${CMD}" +} + +create_catalogsource() { + echo "Creating CatalogSource for iib index $INDEX" + oc apply -f - <${XDG_RUNTIME_DIR}/containers/auth.json + export REG_CREDS=${XDG_RUNTIME_DIR}/containers/auth.json + else + echo "!!! fail to extract the auth of the cluster" + return 1 + fi + + local kepler="" + local operator="" + local bundle="" + cd /tmp + curl -L -o opm https://github.com/operator-framework/operator-registry/releases/download/v1.51.0/linux-amd64-opm && chmod +x opm + kepler=$(./opm render "$BREW_REGISTRY/rh-osbs/iib:$INDEX" | grep "$MIRROR_KEPLER_IMAGE" | tail -n 1 | awk -F'@sha256:' '{print $2}' | tr -d '"') + operator=$(./opm render "$BREW_REGISTRY/rh-osbs/iib:$INDEX" | grep "$MIRROR_OPERATOR_IMAGE" | tail -n 1 | awk -F'@sha256:' '{print $2}' | tr -d '"') + bundle=$(./opm render "$BREW_REGISTRY/rh-osbs/iib:$INDEX" | grep "$MIRROR_BUNDLE_IMAGE" | tail -n 1 | awk -F'@sha256:' '{print $2}' | tr -d '"') + + echo "Kepler: $kepler" + echo "Operator: $operator" + echo "Bundle: $bundle" + + # prepare ImageSetConfiguration + run_command "mkdir /tmp/images" + cat </tmp/image-set.yaml + kind: ImageSetConfiguration + apiVersion: mirror.openshift.io/v1alpha2 + archiveSize: 30 + storageConfig: + local: + path: /tmp/images + mirror: + operators: + - catalog: "$BREW_REGISTRY/rh-osbs/iib:$INDEX" + targetCatalog: rh-osbs/tempo + packages: + - name: tempo-product + channels: + - name: stable + additionalImages: + # Used for running disconnected tests + - name: "$MIRROR_KEPLER_IMAGE@sha256:$kepler" + - name: "$MIRROR_OPERATOR_IMAGE@sha256:$operator" + - name: "$MIRROR_BUNDLE_IMAGE@sha256:$bundle" +EOF + + run_command "curl -L -o oc-mirror.tar.gz https://mirror.openshift.com/pub/openshift-v4/amd64/clients/ocp/latest/oc-mirror.tar.gz && tar -xvzf oc-mirror.tar.gz && chmod +x oc-mirror" + run_command "./oc-mirror --config=/tmp/image-set.yaml docker://${MIRROR_REGISTRY_HOST} --continue-on-error --ignore-history --source-skip-tls --dest-skip-tls || true" + run_command "cp oc-mirror-workspace/results-*/mapping.txt ." + # run_command "sed -e 's|registry.redhat.io|registry.stage.redhat.io|g' -e 's|brew.registry.stage.redhat.io/rh-osbs/tempo|brew.registry.redhat.io/rh-osbs/iib|g' -e 's|brew.registry.stage.redhat.io/rh-osbs/otel|brew.registry.redhat.io/rh-osbs/iib|g' -e 's|brew.registry.stage.redhat.io/rh-osbs/jaeger|brew.registry.redhat.io/rh-osbs/iib|g' mapping.txt > mapping-stage.txt" + run_command "oc image mirror -a ${REG_CREDS} -f mapping.txt --insecure --filter-by-os='.*'" + + echo "Creating Image Content Source Policy" + oc apply -f - <