Skip to content

Commit

Permalink
add mce snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Thibault Mange <[email protected]>
  • Loading branch information
thibaultmg committed Jan 15, 2025
1 parent 09d061c commit f6361d7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cicd-scripts/customize-mco.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cicd-scripts/run-e2e-in-kind-via-prow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 11 additions & 10 deletions cicd-scripts/setup-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 -
Expand Down
17 changes: 16 additions & 1 deletion scripts/test-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}"
}

0 comments on commit f6361d7

Please sign in to comment.