diff --git a/cicd-scripts/customize-mco.sh b/cicd-scripts/customize-mco.sh index 35c3c9f1d..f03d4ec25 100755 --- a/cicd-scripts/customize-mco.sh +++ b/cicd-scripts/customize-mco.sh @@ -14,7 +14,7 @@ SED_COMMAND=${SED}' -i-e -e' # Set the latest snapshot if it is not set source ./scripts/test-utils.sh -LATEST_SNAPSHOT=${LATEST_SNAPSHOT:-$(get_latest_snapshot)} +LATEST_SNAPSHOT=${LATEST_SNAPSHOT:-$(get_latest_acm_snapshot)} if [[ -n ${IS_KIND_ENV} ]]; then source ./tests/run-in-kind/env.sh diff --git a/cicd-scripts/run-e2e-in-kind-via-prow.sh b/cicd-scripts/run-e2e-in-kind-via-prow.sh index 75e21b5d6..ba5e5721f 100755 --- a/cicd-scripts/run-e2e-in-kind-via-prow.sh +++ b/cicd-scripts/run-e2e-in-kind-via-prow.sh @@ -18,7 +18,7 @@ OPT=(-q -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -i "${KE SED_COMMAND='sed -i-e -e' source ./scripts/test-utils.sh -${SED_COMMAND} "$ a\export LATEST_SNAPSHOT=$(get_latest_snapshot)" ./tests/run-in-kind/env.sh +${SED_COMMAND} "$ a\export LATEST_SNAPSHOT=$(get_latest_acm_snapshot)" ./tests/run-in-kind/env.sh if [ "${OPENSHIFT_CI}" == "true" ]; then ${SED_COMMAND} "$ a\export OPENSHIFT_CI=${OPENSHIFT_CI}" ./tests/run-in-kind/env.sh diff --git a/cicd-scripts/setup-e2e-tests.sh b/cicd-scripts/setup-e2e-tests.sh index 6a86b5bcd..99b59ca4b 100755 --- a/cicd-scripts/setup-e2e-tests.sh +++ b/cicd-scripts/setup-e2e-tests.sh @@ -28,19 +28,20 @@ SED_COMMAND=${SED}' -i-e -e' # Set the latest snapshot if it is not set source ./scripts/test-utils.sh -LATEST_SNAPSHOT=${LATEST_SNAPSHOT:-$(get_latest_snapshot)} +LATEST_ACM_SNAPSHOT=${LATEST_ACM_SNAPSHOT:-$(get_latest_acm_snapshot)} +LATEST_MCE_SNAPSHOT=${LATEST_MCE_SNAPSHOT:-$(get_latest_mce_snapshot)} # deploy the hub and spoke core via OLM deploy_hub_spoke_core() { cd ${ROOTDIR} export OCM_BRANCH=main - export IMAGE_NAME=quay.io/stolostron/registration-operator:$LATEST_SNAPSHOT - export REGISTRATION_OPERATOR_IMAGE=quay.io/stolostron/registration-operator:$LATEST_SNAPSHOT - export REGISTRATION_IMAGE=quay.io/stolostron/registration:$LATEST_SNAPSHOT - export WORK_IMAGE=quay.io/stolostron/work:$LATEST_SNAPSHOT - export PLACEMENT_IMAGE=quay.io/stolostron/placement:$LATEST_SNAPSHOT - export ADDON_MANAGER_IMAGE=quay.io/stolostron/addon-manager:$LATEST_SNAPSHOT + export IMAGE_NAME=quay.io/stolostron/registration-operator:$LATEST_MCE_SNAPSHOT + export OPERATOR_IMAGE_NAME=quay.io/stolostron/registration-operator:$LATEST_MCE_SNAPSHOT + export REGISTRATION_IMAGE=quay.io/stolostron/registration:$LATEST_MCE_SNAPSHOT + export WORK_IMAGE=quay.io/stolostron/work:$LATEST_MCE_SNAPSHOT + export PLACEMENT_IMAGE=quay.io/stolostron/placement:$LATEST_MCE_SNAPSHOT + export ADDON_MANAGER_IMAGE=quay.io/stolostron/addon-manager:$LATEST_MCE_SNAPSHOT if [[ ! -d "_repo_ocm" ]]; then git clone --depth 1 --branch $OCM_BRANCH https://github.com/stolostron/ocm.git ./_repo_ocm @@ -109,8 +110,8 @@ approve_csr_joinrequest() { deploy_grafana_test() { cd ${ROOTDIR} ${SED_COMMAND} "s~name: grafana$~name: grafana-test~g; s~app: multicluster-observability-grafana$~app: multicluster-observability-grafana-test~g; s~secretName: grafana-config$~secretName: grafana-config-test~g; s~secretName: grafana-datasources$~secretName: grafana-datasources-test~g; /MULTICLUSTEROBSERVABILITY_CR_NAME/d" operators/multiclusterobservability/manifests/base/grafana/deployment.yaml - ${SED_COMMAND} "s~image: quay.io/stolostron/grafana-dashboard-loader:.*$~image: ${IMAGE_REPO}/grafana-dashboard-loader:${LATEST_SNAPSHOT}~g" operators/multiclusterobservability/manifests/base/grafana/deployment.yaml - ${SED_COMMAND} "s~image: quay.io/stolostron/grafana:.*$~image: ${IMAGE_REPO}/grafana:${LATEST_SNAPSHOT}~g" operators/multiclusterobservability/manifests/base/grafana/deployment.yaml + ${SED_COMMAND} "s~image: quay.io/stolostron/grafana-dashboard-loader:.*$~image: ${IMAGE_REPO}/grafana-dashboard-loader:${LATEST_ACM_SNAPSHOT}~g" operators/multiclusterobservability/manifests/base/grafana/deployment.yaml + ${SED_COMMAND} "s~image: quay.io/stolostron/grafana:.*$~image: ${IMAGE_REPO}/grafana:${LATEST_ACM_SNAPSHOT}~g" operators/multiclusterobservability/manifests/base/grafana/deployment.yaml ${SED_COMMAND} "s~replicas: 2$~replicas: 1~g" operators/multiclusterobservability/manifests/base/grafana/deployment.yaml kubectl apply -f operators/multiclusterobservability/manifests/base/grafana/deployment.yaml kubectl apply -f ${ROOTDIR}/tests/run-in-kind/grafana # create grafana-test svc, grafana-test config and datasource configmaps @@ -148,7 +149,7 @@ deploy_mco_operator() { if [[ -n ${MULTICLUSTER_OBSERVABILITY_OPERATOR_IMAGE_REF} ]]; then cd ${ROOTDIR}/operators/multiclusterobservability/config/manager && kustomize edit set image quay.io/stolostron/multicluster-observability-operator=${MULTICLUSTER_OBSERVABILITY_OPERATOR_IMAGE_REF} else - cd ${ROOTDIR}/operators/multiclusterobservability/config/manager && kustomize edit set image quay.io/stolostron/multicluster-observability-operator="${IMAGE_REPO}/multicluster-observability-operator:${LATEST_SNAPSHOT}" + cd ${ROOTDIR}/operators/multiclusterobservability/config/manager && kustomize edit set image quay.io/stolostron/multicluster-observability-operator="${IMAGE_REPO}/multicluster-observability-operator:${LATEST_ACM_SNAPSHOT}" fi cd ${ROOTDIR} kustomize build ${ROOTDIR}/operators/multiclusterobservability/config/default | kubectl apply -n ${OCM_DEFAULT_NS} --server-side=true --force-conflicts -f - diff --git a/scripts/test-utils.sh b/scripts/test-utils.sh index c59b4d471..948adb493 100755 --- a/scripts/test-utils.sh +++ b/scripts/test-utils.sh @@ -14,7 +14,7 @@ VERSION=$(awk -F '.' '{ print $1"."$2 }' <"$WORKDIR"/../COMPONENT_VERSION) # Note if there are more than 100 snapshots per release # we might not get the latest as the quay API can only return # 100 results, and we only look at the first page. -get_latest_snapshot() { +get_latest_acm_snapshot() { SNAPSHOT_RELEASE=${SNAPSHOT_RELEASE:=$VERSION} # matches: # version number (i.e 2.11) @@ -28,3 +28,18 @@ get_latest_snapshot() { LATEST_SNAPSHOT="${LATEST_SNAPSHOT%\"}" echo "${LATEST_SNAPSHOT}" } + +get_latest_mce_snapshot() { + SNAPSHOT_RELEASE=${SNAPSHOT_RELEASE:=$VERSION} + # matches: + # version number (i.e 2.11) + # z version 1-2 digits + # -SNAPSHOT + MATCH=$SNAPSHOT_RELEASE".\d{1,2}-SNAPSHOT" + LATEST_SNAPSHOT=$(curl "https://quay.io/api/v1/repository/stolostron/registration/tag/?filter_tag_name=like:$SNAPSHOT_RELEASE&limit=100" | jq --arg MATCH "$MATCH" '.tags[] | select(.name | match($MATCH; "i") ).name' | sort -r --version-sort | head -n 1) + + # trim the leading and tailing quotes + LATEST_SNAPSHOT="${LATEST_SNAPSHOT#\"}" + LATEST_SNAPSHOT="${LATEST_SNAPSHOT%\"}" + echo "${LATEST_SNAPSHOT}" +}