Skip to content

Commit 2d50d1c

Browse files
Merge pull request #901 from abhibongale/feat/bmoe2e-test
✨ Add BMO e2e test integration
2 parents 5dd13b7 + 49cef5f commit 2d50d1c

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

.github/workflows/bmo-e2e.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: BMO E2E Tests
2+
3+
on:
4+
pull_request:
5+
types: [ opened, edited, reopened, synchronize, ready_for_review ]
6+
7+
jobs:
8+
test:
9+
runs-on: oracle-vm-4cpu-16gb-x86-64
10+
permissions:
11+
contents: read
12+
actions: read
13+
env:
14+
CLUSTER_TYPE: kind
15+
CONTAINER_RUNTIME: docker
16+
IRONIC_CUSTOM_IMAGE: localhost/ironic:bmo-e2e
17+
# Use latest stable BMO release - update this when new releases are available
18+
BMO_VERSION: v0.12.1
19+
steps:
20+
- name: Check docker version
21+
run: docker --version
22+
23+
- name: Checkout ironic-image
24+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
25+
with:
26+
path: ironic-image
27+
persist-credentials: false
28+
29+
- name: Checkout BMO at release version
30+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
31+
with:
32+
repository: metal3-io/baremetal-operator
33+
ref: ${{ env.BMO_VERSION }}
34+
path: baremetal-operator
35+
persist-credentials: false
36+
37+
- name: Calculate go version
38+
id: vars
39+
run: echo "go_version=$(make -sC baremetal-operator go-version)" >> $GITHUB_OUTPUT
40+
41+
- name: Set up Go
42+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
43+
with:
44+
go-version: ${{ steps.vars.outputs.go_version }}
45+
46+
- name: Install system dependencies
47+
run: sudo apt-get update && sudo apt-get install -y libvirt-clients libvirt-daemon-system xorriso
48+
49+
- name: Configure libvirt permissions
50+
run: |
51+
# Start libvirtd service
52+
sudo systemctl start libvirtd
53+
sudo systemctl enable libvirtd
54+
# Add current user to libvirt group for socket access
55+
sudo usermod -aG libvirt $USER
56+
57+
- name: Prepare and run BMO e2e tests
58+
run: sg libvirt -c "ironic-image/hack/prepare-bmo-tests.sh"
59+
60+
- name: Upload test artifacts
61+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
62+
with:
63+
name: bmo-e2e-artifacts
64+
path: baremetal-operator/test/e2e/_artifacts
65+
if: always()

hack/prepare-bmo-tests.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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

Comments
 (0)