Skip to content

Commit

Permalink
Integrate sushy-tools and Redfish into e2e testing
Browse files Browse the repository at this point in the history
Extended the e2e testing framework to include sushy-tools and Redfish
alongside existing VBMC and IPMI tests.
  • Loading branch information
Max Rantil committed Nov 3, 2023
1 parent 3dccd97 commit 728b6cf
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 39 deletions.
110 changes: 73 additions & 37 deletions hack/ci-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#!/usr/bin/env bash

# -----------------------------------------------------------------------------
# Description: This script sets up the environment and runs E2E tests for the
# BMO project. It uses either vbmc or sushy-tools based on
# the BMO_E2E_EMULATOR environment variable.
# Usage: export BMO_E2E_EMULATOR="vbmc" # Or "sushy-tools"
# ./ci-e2e.sh
# -----------------------------------------------------------------------------

set -eux

REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
cd "${REPO_ROOT}" || exit 1

# BMO_E2E_EMULATOR can be set to either "vbmc" or "sushy-tools"
BMO_E2E_EMULATOR=${BMO_E2E_EMULATOR:-"sushy-tools"}

# Ensure requirements are installed
"${REPO_ROOT}/hack/e2e/ensure_go.sh"
export PATH="${PATH}:/usr/local/go/bin"
Expand Down Expand Up @@ -32,58 +43,83 @@ minikube start
# Load the BMO e2e image into it
minikube image load quay.io/metal3-io/baremetal-operator:e2e

# Start VBMC
docker run --name vbmc --network host -d \
-v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \
-v /var/run/libvirt/libvirt-sock-ro:/var/run/libvirt/libvirt-sock-ro \
quay.io/metal3-io/vbmc

# Create libvirt domain
VM_NAME="bmo-e2e-0"
BOOT_MAC_ADDRESS="00:60:2f:31:81:01"
VBMC_PORT="16230"
virt-install --connect qemu:///system -n "${VM_NAME}" --description "Virtualized BareMetalHost" --osinfo=ubuntu-lts-latest \
--ram=4096 --vcpus=2 --disk size=20 --graphics=none --console pty --serial pty --pxe \
--network network=baremetal-e2e,mac="${BOOT_MAC_ADDRESS}" --noautoconsole
export BOOT_MAC_ADDRESS="00:60:2f:31:81:01"

virt-install \
--connect qemu:///system \
--name "${VM_NAME}" \
--description "Virtualized BareMetalHost" \
--osinfo=ubuntu-lts-latest \
--ram=4096 \
--vcpus=2 \
--disk size=20 \
--graphics=none \
--console pty \
--serial pty \
--pxe \
--network network=baremetal-e2e,mac="${BOOT_MAC_ADDRESS}" \
--noautoconsole

# Add BMH VM to VBMC
docker exec vbmc vbmc add "${VM_NAME}" --port "${VBMC_PORT}"
docker exec vbmc vbmc start "${VM_NAME}"
docker exec vbmc vbmc list

# These variables are used by the tests. They override variables in the config file.
# This IP is defined by the network we created above.
# Together with the VBMC_PORT this becomes the BMC_ADDRESS used by the BMH in the test.
IP_ADDRESS="192.168.222.1"
export BMC_ADDRESS="ipmi://${IP_ADDRESS}:${VBMC_PORT}"
export BOOT_MAC_ADDRESS

# These variables are used by the tests. They override variables in the config file.
# These are the VBMC defaults (used since we did not specify anything else for `vbmc add`).
export BMC_USER=admin
export BMC_PASSWORD=password
CIRROS_VERSION="0.6.2"
IMAGE_FILE="cirros-${CIRROS_VERSION}-x86_64-disk.img"
export IMAGE_CHECKSUM="c8fc807773e5354afe61636071771906"
export IMAGE_URL="http://${IP_ADDRESS}/${IMAGE_FILE}"
IMAGE_FOLDER="${REPO_ROOT}/test/e2e/images"

## Setup image server
# Create a directory for images
if [[ "${BMO_E2E_EMULATOR}" == "vbmc" ]]; then
# VBMC variables
VBMC_PORT="16230"
export BMC_ADDRESS="ipmi://${IP_ADDRESS}:${VBMC_PORT}"

# Start VBMC
docker run --name vbmc --network host -d \
-v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \
-v /var/run/libvirt/libvirt-sock-ro:/var/run/libvirt/libvirt-sock-ro \
quay.io/metal3-io/vbmc

# Add BMH VM to VBMC
docker exec vbmc vbmc add "${VM_NAME}" --port "${VBMC_PORT}"
docker exec vbmc vbmc start "${VM_NAME}"
docker exec vbmc vbmc list

elif [[ "${BMO_E2E_EMULATOR}" == "sushy-tools" ]]; then
# Sushy-tools variables
SUSHY_EMULATOR_FILE="${REPO_ROOT}"/test/e2e/sushy-tools/sushy-emulator.conf
SUSHY_PORT="8000"
export BMC_ADDRESS="redfish+http://${IP_ADDRESS}:${SUSHY_PORT}/redfish/v1/Systems/${VM_NAME}"

# Start sushy-tools
docker run --name sushy-tools -d --network host \
-v "${SUSHY_EMULATOR_FILE}":/etc/sushy/sushy-emulator.conf:Z \
-v /var/run/libvirt:/var/run/libvirt:Z \
-e SUSHY_EMULATOR_CONFIG=/etc/sushy/sushy-emulator.conf \
quay.io/metal3-io/sushy-tools:latest sushy-emulator

mkdir -p "${IMAGE_FOLDER}"
pushd "${IMAGE_FOLDER}"

## Setup image server
# Check if IMAGE_FILE already exists
if [[ ! -f "${IMAGE_FILE}" ]]; then
wget "https://download.cirros-cloud.net/${CIRROS_VERSION}/${IMAGE_FILE}"
else
echo "${IMAGE_FILE} already exists. Skipping download."
echo "Invalid e2e emulator specified: ${BMO_E2E_EMULATOR}"
exit 1
fi

# Image server variables
CIRROS_VERSION="0.6.2"
IMAGE_FILE="cirros-${CIRROS_VERSION}-x86_64-disk.img"
export IMAGE_CHECKSUM="c8fc807773e5354afe61636071771906"
export IMAGE_URL="http://${IP_ADDRESS}/${IMAGE_FILE}"
IMAGE_DIR="${REPO_ROOT}/test/e2e/images"

## Download and run image server
mkdir -p "${IMAGE_DIR}"
pushd "${IMAGE_DIR}"
wget --quiet "https://download.cirros-cloud.net/${CIRROS_VERSION}/${IMAGE_FILE}"
popd

# Run image server
docker run --rm --name image-server-e2e -d -p 80:8080 -v "${IMAGE_FOLDER}:/usr/share/nginx/html" nginxinc/nginx-unprivileged
docker run --name image-server-e2e -d \
-p 80:8080 \
-v "${IMAGE_DIR}:/usr/share/nginx/html" nginxinc/nginx-unprivileged

# We need to gather artifacts/logs before exiting also if there are errors
set +e
Expand Down
1 change: 1 addition & 0 deletions hack/clean-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cd "${REPO_ROOT}" || exit 1
minikube delete
docker rm -f vbmc
docker rm -f image-server-e2e
docker rm -f sushy-tools
virsh -c qemu:///system destroy --domain bmo-e2e-0
virsh -c qemu:///system undefine --domain bmo-e2e-0 --remove-all-storage
virsh -c qemu:///system net-destroy baremetal-e2e
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/config/ironic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ variables:
# Test credentials. The tests will create a BMH with these.
BMC_USER: admin
BMC_PASSWORD: password
BMC_ADDRESS: ipmi://192.168.222.1:16230
BMC_ADDRESS: "ipmi://192.168.222.1:16230"
BOOT_MAC_ADDRESS: "00:60:2f:31:81:01"
IMAGE_URL: "http://192.168.222.1/cirros-0.6.2-x86_64-disk.img"
IMAGE_CHECKSUM: "c8fc807773e5354afe61636071771906"
Expand All @@ -33,7 +33,7 @@ intervals:
inspection/wait-registration-error: ["1m", "5s"]
external-inspection/wait-available: ["20s", "1s"]
default/wait-inspecting: ["2m", "10s"]
default/wait-available: ["10m", "10s"]
default/wait-available: ["10m", "1s"]
default/wait-deployment: ["5m", "1s"]
default/wait-namespace-deleted: ["10m", "1s"]
ironic/wait-deployment: ["10m", "2s"]
Expand Down
36 changes: 36 additions & 0 deletions test/e2e/sushy-tools/sushy-emulator.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Listen on the local IP address 192.168.222.1
SUSHY_EMULATOR_LISTEN_IP = u'192.168.222.1'

# Bind to TCP port 8000
SUSHY_EMULATOR_LISTEN_PORT = 8000

# Serve this SSL certificate to the clients
SUSHY_EMULATOR_SSL_CERT = None

# If SSL certificate is being served, this is its RSA private key
SUSHY_EMULATOR_SSL_KEY = None

# The OpenStack cloud ID to use. This option enables OpenStack driver.
SUSHY_EMULATOR_OS_CLOUD = None
# The libvirt URI to use. This option enables libvirt driver.
SUSHY_EMULATOR_LIBVIRT_URI = u'qemu:///system'

# Instruct the libvirt driver to ignore any instructions to
# set the boot device. Allowing the UEFI firmware to instead
# rely on the EFI Boot Manager
# Note: This sets the legacy boot element to dev="fd"
# and relies on the floppy not existing, it likely wont work
# your VM has a floppy drive.
SUSHY_EMULATOR_IGNORE_BOOT_DEVICE = False

# The map of firmware loaders dependant on the boot mode and
# system architecture. Ideally the x86_64 loader will be capable
# of secure boot or not based on the chosen nvram.
SUSHY_EMULATOR_BOOT_LOADER_MAP = {
u'UEFI': {
u'x86_64': u'/usr/share/OVMF/OVMF_CODE.secboot.fd'
},
u'Legacy': {
u'x86_64': None
}
}

0 comments on commit 728b6cf

Please sign in to comment.