|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -eux -o pipefail |
| 4 | + |
| 5 | +REPO_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")/..") |
| 6 | +cd "${REPO_ROOT}" || exit 1 |
| 7 | + |
| 8 | +CLUSTER_TYPE="${CLUSTER_TYPE:-kind}" |
| 9 | +CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-docker}" |
| 10 | +IRONIC_CUSTOM_IMAGE="${IRONIC_CUSTOM_IMAGE:-localhost/ironic:bmo-e2e}" |
| 11 | +BMO_ROOT="${REPO_ROOT}/../baremetal-operator" |
| 12 | + |
| 13 | +# Build the ironic image |
| 14 | +echo "Building ironic image: ${IRONIC_CUSTOM_IMAGE}" |
| 15 | +"${CONTAINER_RUNTIME}" build -t "${IRONIC_CUSTOM_IMAGE}" . |
| 16 | + |
| 17 | +# Create a custom kustomize overlay in BMO that uses our image. |
| 18 | +# This avoids duplicating BMO's entire e2e config - we only override the ironic image. |
| 19 | +# TODO: Propose to BMO to accept IRONIC_IMAGE_OVERRIDE env var to simplify this further. |
| 20 | +# See: https://github.com/metal3-io/baremetal-operator/commit/b35cccb8 for their |
| 21 | +# recent refactoring that moved image overrides to kustomize overlays. |
| 22 | +CUSTOM_OVERLAY="${BMO_ROOT}/test/e2e/data/ironic-standalone-operator/ironic/overlays/ironic-image-custom" |
| 23 | +mkdir -p "${CUSTOM_OVERLAY}" |
| 24 | + |
| 25 | +cat > "${CUSTOM_OVERLAY}/kustomization.yaml" <<EOF |
| 26 | +apiVersion: kustomize.config.k8s.io/v1beta1 |
| 27 | +kind: Kustomization |
| 28 | +resources: |
| 29 | +- ../e2e |
| 30 | +patches: |
| 31 | +- target: |
| 32 | + kind: Ironic |
| 33 | + patch: |- |
| 34 | + - op: replace |
| 35 | + path: /spec/images/ironic |
| 36 | + value: ${IRONIC_CUSTOM_IMAGE} |
| 37 | +EOF |
| 38 | + |
| 39 | +# Patch BMO's e2e config to add our custom image and use our overlay. |
| 40 | +# We only modify what's necessary - everything else uses BMO's defaults. |
| 41 | +BMO_CONFIG="${BMO_ROOT}/test/e2e/config/ironic.yaml" |
| 42 | +cp "${BMO_CONFIG}" "${BMO_CONFIG}.bak" |
| 43 | + |
| 44 | +# Add our custom image to the images list (after the BMO e2e image loadBehavior line) |
| 45 | +sed -i '/name: quay.io\/metal3-io\/baremetal-operator:e2e/,/loadBehavior:/{ |
| 46 | + /loadBehavior:/a\ |
| 47 | +# Use custom ironic-image build\ |
| 48 | +- name: '"${IRONIC_CUSTOM_IMAGE}"'\ |
| 49 | + loadBehavior: tryLoad |
| 50 | +}' "${BMO_CONFIG}" |
| 51 | + |
| 52 | +# Add our custom kustomization path to the variables section |
| 53 | +sed -i '/NAMESPACE_SCOPED:/a\ |
| 54 | + # Use custom ironic-image overlay\ |
| 55 | + IRONIC_KUSTOMIZATION: "data/ironic-standalone-operator/ironic/overlays/ironic-image-custom"' "${BMO_CONFIG}" |
| 56 | + |
| 57 | +# Run the BMO e2e tests |
| 58 | +cd "${BMO_ROOT}" || exit 1 |
| 59 | +echo "Running BMO e2e tests with custom ironic image: ${IRONIC_CUSTOM_IMAGE}" |
| 60 | +export GINKGO_FOCUS="" |
| 61 | +./hack/ci-e2e.sh |
0 commit comments