From b7578a68787930f9014432ae20398d4e803417ca Mon Sep 17 00:00:00 2001 From: Philip Gough Date: Wed, 24 Apr 2024 15:24:02 +0100 Subject: [PATCH] test: Try to use build from PR in e2e tests (#1410) * test: Try to use build from PR in e2e tests Signed-off-by: Philip Gough * ci: Try to read env from bash script if kind test Signed-off-by: Philip Gough * test: Split PR functionality from snapshot Signed-off-by: Philip Gough --------- Signed-off-by: Philip Gough --- cicd-scripts/customize-mco.sh | 4 ++++ scripts/test-utils.sh | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cicd-scripts/customize-mco.sh b/cicd-scripts/customize-mco.sh index 1167eb037..68e7c4130 100755 --- a/cicd-scripts/customize-mco.sh +++ b/cicd-scripts/customize-mco.sh @@ -16,6 +16,10 @@ SED_COMMAND=${SED}' -i-e -e' source ./scripts/test-utils.sh LATEST_SNAPSHOT=${LATEST_SNAPSHOT:-$(get_latest_snapshot)} +if [[ -n ${IS_KIND_ENV} ]]; then + source ./tests/run-in-kind/env.sh +fi + # list all components need to do test. CHANGED_COMPONENTS="" GINKGO_FOCUS="" diff --git a/scripts/test-utils.sh b/scripts/test-utils.sh index 4eed44d16..0ff07c84f 100755 --- a/scripts/test-utils.sh +++ b/scripts/test-utils.sh @@ -2,16 +2,33 @@ # Copyright (c) 2024 Red Hat, Inc. # Copyright Contributors to the Open Cluster Management project +VERSION="2.11.0" + +# Use the PR mirror image for PRs against main branch. +get_pr_image() { + BRANCH="" + LATEST_SNAPSHOT="" + + if [[ ${PULL_BASE_REF} == "main" ]]; then + LATEST_SNAPSHOT="${VERSION}-PR${PULL_NUMBER}-${PULL_PULL_SHA}" + fi + + # trim the leading and tailing quotes + LATEST_SNAPSHOT="${LATEST_SNAPSHOT#\"}" + LATEST_SNAPSHOT="${LATEST_SNAPSHOT%\"}" + echo ${LATEST_SNAPSHOT} +} + # Use snapshot for target release. # Use latest if no branch info detected, or not a release branch. get_latest_snapshot() { BRANCH="" LATEST_SNAPSHOT="" - SNAPSHOT_RELEASE=${SNAPSHOT_RELEASE:=2.10} + SNAPSHOT_RELEASE=${SNAPSHOT_RELEASE:=$VERSION} MATCH=$SNAPSHOT_RELEASE".*-SNAPSHOT" if [[ ${PULL_BASE_REF} == "release-"* ]]; then BRANCH=${PULL_BASE_REF#"release-"} - LATEST_SNAPSHOT=$(curl https://quay.io//api/v1/repository/open-cluster-management/multicluster-observability-operator | jq '.tags|with_entries(select(.key|test("'${BRANCH}'.*-SNAPSHOT-*")))|keys[length-1]') + LATEST_SNAPSHOT=$(curl https://quay.io/api/v1/repository/open-cluster-management/multicluster-observability-operator | jq '.tags|with_entries(select(.key|test("'${BRANCH}'.*-SNAPSHOT-*")))|keys[length-1]') fi if [[ ${LATEST_SNAPSHOT} == "null" ]] || [[ ${LATEST_SNAPSHOT} == "" ]]; then LATEST_SNAPSHOT=$(curl https://quay.io/api/v1/repository/stolostron/multicluster-observability-operator/tag/ | jq --arg MATCH "$MATCH" '.tags[] | select(.name | match($MATCH; "i") ).name' | sort -r --version-sort | head -n 1)