From 0befaf5a3c6515056070e1a9c5e9e58b75f87e33 Mon Sep 17 00:00:00 2001 From: Yanming Sun Date: Sat, 11 May 2024 20:31:20 +0800 Subject: [PATCH] Add presubmit jobs on pull request checking for rosacli (#51427) update update update update update update update update update --- ...openshift-rosa-master__e2e-presubmits.yaml | 58 ++++++++ .../openshift-rosa-master-presubmits.yaml | 140 ++++++++++++++++++ .../rosa/test/e2e/pull-request/OWNERS | 1 + .../rosa-test-e2e-pull-request-commands.sh | 54 +++++++ ...sa-test-e2e-pull-request-ref.metadata.json | 25 ++++ .../rosa-test-e2e-pull-request-ref.yaml | 22 +++ 6 files changed, 300 insertions(+) create mode 100644 ci-operator/config/openshift/rosa/openshift-rosa-master__e2e-presubmits.yaml create mode 120000 ci-operator/step-registry/rosa/test/e2e/pull-request/OWNERS create mode 100755 ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-commands.sh create mode 100644 ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-ref.metadata.json create mode 100644 ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-ref.yaml diff --git a/ci-operator/config/openshift/rosa/openshift-rosa-master__e2e-presubmits.yaml b/ci-operator/config/openshift/rosa/openshift-rosa-master__e2e-presubmits.yaml new file mode 100644 index 000000000000..51b553b40c1b --- /dev/null +++ b/ci-operator/config/openshift/rosa/openshift-rosa-master__e2e-presubmits.yaml @@ -0,0 +1,58 @@ +base_images: + cli-ocm: + name: cli-ocm + namespace: ci + tag: latest + ocp_builder_rhel-8-golang-1.21-openshift-4.16: + name: builder + namespace: ocp + tag: rhel-8-golang-1.21-openshift-4.16 + origin_4.16_cli: + name: "4.16" + namespace: origin + tag: cli +build_root: + image_stream_tag: + name: builder + namespace: ocp + tag: rhel-8-golang-1.21-openshift-4.16 +images: +- dockerfile_path: images/Dockerfile.e2e + from: origin_4.16_cli + inputs: + cli-ocm: + as: + - registry.ci.openshift.org/ci/cli-ocm:latest + ocp_builder_rhel-8-golang-1.21-openshift-4.16: + as: + - registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.21-openshift-4.16 + to: rosa-aws-cli +releases: + latest: + integration: + name: "4.16" + namespace: ocp +resources: + '*': + requests: + cpu: 150m + memory: 300Mi +tests: +- always_run: false + as: pr-rosa-hcp + optional: true + steps: + cluster_profile: aws-sd-qe + env: + ENABLE_AUTOSCALING: "true" + MAX_REPLICAS: "6" + MIN_REPLICAS: "3" + TEST_LABEL_FILTERS: (day1-post,day2)&&!NonHCPCluster&&!Exclude + test: + - ref: rosa-test-e2e-pull-request + workflow: rosa-aws-sts-hcp-byo-kms-oidc-auditlog +zz_generated_metadata: + branch: master + org: openshift + repo: rosa + variant: e2e-presubmits diff --git a/ci-operator/jobs/openshift/rosa/openshift-rosa-master-presubmits.yaml b/ci-operator/jobs/openshift/rosa/openshift-rosa-master-presubmits.yaml index 8e3a13fddab7..860a24eb175e 100644 --- a/ci-operator/jobs/openshift/rosa/openshift-rosa-master-presubmits.yaml +++ b/ci-operator/jobs/openshift/rosa/openshift-rosa-master-presubmits.yaml @@ -172,6 +172,146 @@ presubmits: secret: secretName: rosa-codecov-token trigger: (?m)^/test( | .* )coverage,?($|\s.*) + - agent: kubernetes + always_run: true + branches: + - ^master$ + - ^master- + cluster: build04 + context: ci/prow/e2e-presubmits-images + decorate: true + decoration_config: + skip_cloning: true + labels: + ci-operator.openshift.io/variant: e2e-presubmits + ci.openshift.io/generator: prowgen + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: pull-ci-openshift-rosa-master-e2e-presubmits-images + rerun_command: /test e2e-presubmits-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=e2e-presubmits + 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( | .* )e2e-presubmits-images,?($|\s.*) + - agent: kubernetes + always_run: false + branches: + - ^master$ + - ^master- + cluster: build05 + context: ci/prow/e2e-presubmits-pr-rosa-hcp + decorate: true + decoration_config: + skip_cloning: true + labels: + ci-operator.openshift.io/cloud: aws + ci-operator.openshift.io/cloud-cluster-profile: aws-sd-qe + ci-operator.openshift.io/variant: e2e-presubmits + ci.openshift.io/generator: prowgen + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: pull-ci-openshift-rosa-master-e2e-presubmits-pr-rosa-hcp + optional: true + rerun_command: /test e2e-presubmits-pr-rosa-hcp + 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 + - --secret-dir=/usr/local/pr-rosa-hcp-cluster-profile + - --target=pr-rosa-hcp + - --variant=e2e-presubmits + 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: /usr/local/pr-rosa-hcp-cluster-profile + name: cluster-profile + - 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: cluster-profile + secret: + secretName: cluster-secrets-aws-sd-qe + - 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( | .* )e2e-presubmits-pr-rosa-hcp,?($|\s.*) - agent: kubernetes always_run: true branches: diff --git a/ci-operator/step-registry/rosa/test/e2e/pull-request/OWNERS b/ci-operator/step-registry/rosa/test/e2e/pull-request/OWNERS new file mode 120000 index 000000000000..ec405d65a79d --- /dev/null +++ b/ci-operator/step-registry/rosa/test/e2e/pull-request/OWNERS @@ -0,0 +1 @@ +../OWNERS \ No newline at end of file diff --git a/ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-commands.sh b/ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-commands.sh new file mode 100755 index 000000000000..3c0d8c262fa6 --- /dev/null +++ b/ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-commands.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -o nounset +set -o errexit +set -o pipefail + +trap 'CHILDREN=$(jobs -p); if test -n "${CHILDREN}"; then kill ${CHILDREN} && wait; fi' TERM + +log(){ + echo -e "\033[1m$(date "+%d-%m-%YT%H:%M:%S") " "${*}" +} + +TEST_LABEL_FILTERS=${TEST_LABEL_FILTERS:-} +CLUSTER_ID=$(cat "${SHARED_DIR}/cluster-id") +log "Working on the cluster: $CLUSTER_ID" +export CLUSTER_ID # maybe we should get cluster_id by TEST_PROFILE + + +# Configure aws +REGION=${REGION:-${LEASED_RESOURCE}} +AWSCRED="${CLUSTER_PROFILE_DIR}/.awscred" +export AWS_SHARED_CREDENTIALS_FILE="${AWSCRED}" +export AWS_DEFAULT_REGION="${REGION}" + +# Log in +OCM_TOKEN=$(cat "${CLUSTER_PROFILE_DIR}/ocm-token") +rosa login --env "${OCM_LOGIN_ENV}" --token "${OCM_TOKEN}" + +# Variables +COMMIT_FOCUS="/rosa/tests/ci/data/commit-focus" +FOCUS=$(cat "${COMMIT_FOCUS}") +FOCUS_LABEL_FILTER="" +FOCUS_SWITCH="--ginkgo.focus ${FOCUS}" +if [[ -z "$FOCUS" ]]; then + echo "Warning: No TC updated, focus on Critial" + FOCUS_LABEL_FILTER="Critical" + FOCUS_SWITCH="" +fi + +LABEL_FILTER_SWITCH="" +if [[ ! -z "$FOCUS_LABEL_FILTER" ]]; then + if [[ -z "$TEST_LABEL_FILTERS" ]]; then + TEST_LABEL_FILTERS=${FOCUS_LABEL_FILTER} + else + TEST_LABEL_FILTERS="${TEST_LABEL_FILTERS}&&$FOCUS_LABEL_FILTER" + fi +fi +if [[ ! -z "$TEST_LABEL_FILTERS" ]]; then + echo "Label Filter: $TEST_LABEL_FILTERS" + LABEL_FILTER_SWITCH="--ginkgo.label-filter ${TEST_LABEL_FILTERS}" +fi + +log "INFO: Start pull reqeust testing ..." +rosatest --ginkgo.v --ginkgo.no-color ${FOCUS_SWITCH} ${LABEL_FILTER_SWITCH} diff --git a/ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-ref.metadata.json b/ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-ref.metadata.json new file mode 100644 index 000000000000..0ad38201bc3f --- /dev/null +++ b/ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-ref.metadata.json @@ -0,0 +1,25 @@ +{ + "path": "rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-ref.yaml", + "owners": { + "approvers": [ + "yasun1", + "xueli181114", + "yuwang-RH", + "yufchang", + "jtaleric", + "svetsa-rh", + "radtriste" + ], + "reviewers": [ + "yasun1", + "xueli181114", + "yuwang-RH", + "tzhou5", + "yingzhanredhat", + "yufchang", + "jtaleric", + "svetsa-rh", + "radtriste" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-ref.yaml b/ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-ref.yaml new file mode 100644 index 000000000000..bb0214c47728 --- /dev/null +++ b/ci-operator/step-registry/rosa/test/e2e/pull-request/rosa-test-e2e-pull-request-ref.yaml @@ -0,0 +1,22 @@ +ref: + as: rosa-test-e2e-pull-request + from: rosa-aws-cli + grace_period: 10m + commands: rosa-test-e2e-pull-request-commands.sh + resources: + requests: + cpu: 100m + memory: 300Mi + env: + - name: OCM_LOGIN_ENV + default: "staging" + documentation: The environment for rosa login. The supported values are [production, staging, integration]. + - name: REGION + default: "" + documentation: Use a specific AWS region, overriding the LEASED_RESOURCE environment variable in the cluster_profile. + - name: TEST_LABEL_FILTERS + default: "" + documentation: The filters for picking up the test scenarios. + + documentation: |- + Do rosacli pull request presubmit testing .