Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Switch e2e to kind #2209

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/e2e-fixture-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:

- name: Install libvirt
run: |
sudo apt-get update
sudo apt-get install -y libvirt-dev
sudo apt-get update
sudo apt-get install -y libvirt-dev

- name: Build BMO e2e Docker Image
env:
Expand All @@ -40,6 +40,7 @@ jobs:
run: make test-e2e

- name: Upload artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: artifacts-fixture.tar.gz
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ go.work.sum
*~
*.tmp
.DS_Store
.zed*

# Tilt files.
.tiltbuild
Expand Down
4 changes: 0 additions & 4 deletions config/overlays/e2e-release-0.4/ironic.env

This file was deleted.

38 changes: 0 additions & 38 deletions config/overlays/e2e-release-0.4/kustomization.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions config/overlays/e2e-release-0.5/ironic.env

This file was deleted.

36 changes: 0 additions & 36 deletions config/overlays/e2e-release-0.5/kustomization.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions config/overlays/e2e-release-0.6/ironic.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DEPLOY_KERNEL_URL=http://192.168.222.199:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.199:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.199:6385/v1/
DEPLOY_KERNEL_URL=http://192.168.222.1:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.1:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.1:6385/v1/
6 changes: 3 additions & 3 deletions config/overlays/e2e-release-0.8/ironic.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DEPLOY_KERNEL_URL=http://192.168.222.199:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.199:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.199:6385/v1/
DEPLOY_KERNEL_URL=http://192.168.222.1:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.1:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.1:6385/v1/
6 changes: 3 additions & 3 deletions config/overlays/e2e-release-0.9/ironic.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DEPLOY_KERNEL_URL=http://192.168.222.199:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.199:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.199:6385/v1/
DEPLOY_KERNEL_URL=http://192.168.222.1:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.1:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.1:6385/v1/
6 changes: 3 additions & 3 deletions config/overlays/e2e/ironic.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DEPLOY_KERNEL_URL=http://192.168.222.199:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.199:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.199:6385/v1/
DEPLOY_KERNEL_URL=http://192.168.222.1:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.1:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.1:6385/v1/
21 changes: 0 additions & 21 deletions config/overlays/fixture-release-0.4/kustomization.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions config/overlays/fixture-release-0.5/kustomization.yaml

This file was deleted.

55 changes: 3 additions & 52 deletions hack/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ echo "BMO_E2E_EMULATOR=${BMO_E2E_EMULATOR}"
export E2E_CONF_FILE="${REPO_ROOT}/test/e2e/config/ironic.yaml"
export E2E_BMCS_CONF_FILE="${REPO_ROOT}/test/e2e/config/bmcs-${BMC_PROTOCOL}.yaml"

LOAD_LOCAL_IRONIC="${LOAD_LOCAL_IRONIC:-false}"

case "${GINKGO_FOCUS:-}" in
*upgrade*)
export DEPLOY_IRONIC="false"
Expand All @@ -46,12 +44,11 @@ case "${GINKGO_FOCUS:-}" in
export GINKGO_SKIP="${GINKGO_SKIP:-upgrade}"
;;
esac
export USE_EXISTING_CLUSTER="true"

# Ensure requirements are installed
"${REPO_ROOT}/hack/e2e/ensure_go.sh"
export PATH="/usr/local/go/bin:${PATH}"
"${REPO_ROOT}/hack/e2e/ensure_minikube.sh"
"${REPO_ROOT}/hack/e2e/ensure_kind.sh"
"${REPO_ROOT}/hack/e2e/ensure_htpasswd.sh"
# CAPI test framework uses kubectl in the background
"${REPO_ROOT}/hack/e2e/ensure_kubectl.sh"
Expand All @@ -60,42 +57,15 @@ export PATH="/usr/local/go/bin:${PATH}"
# Build the container image with e2e tag (used in tests)
IMG=quay.io/metal3-io/baremetal-operator:e2e make docker

# Set up minikube
minikube start --driver=kvm2

virsh -c qemu:///system net-define "${REPO_ROOT}/hack/e2e/net.xml"
virsh -c qemu:///system net-start baremetal-e2e
# Attach baremetal-e2e interface to minikube with specific mac.
# This will give minikube a known reserved IP address that we can use for Ironic
virsh -c qemu:///system attach-interface --domain minikube --mac="52:54:00:6c:3c:01" \
--model virtio --source baremetal-e2e --type network --config

# Restart minikube to apply the changes
minikube stop
## Following loop is to avoid minikube restart issue
## https://github.com/kubernetes/minikube/issues/14456
while ! minikube start; do sleep 30; done

# Load the BMO e2e image into it
# minikube image load quay.io/metal3-io/baremetal-operator:e2e
# Temporary workaround for https://github.com/kubernetes/minikube/issues/18021
docker image save -o /tmp/bmo-e2e.tar quay.io/metal3-io/baremetal-operator:e2e
minikube image load /tmp/bmo-e2e.tar
rm /tmp/bmo-e2e.tar
if [[ "${LOAD_LOCAL_IRONIC}" == "true" ]]; then
echo "Saving local ironic image!"
docker image save -o \
"/tmp/ironic-e2e.tar" "quay.io/metal3-io/ironic:local"
minikube image load /tmp/ironic-e2e.tar
rm /tmp/ironic-e2e.tar
fi

# This IP is defined by the network we created above.
IP_ADDRESS="192.168.222.1"

# This IP is also defined by the network above, and is used consistently in all of
# our e2e overlays
export IRONIC_PROVISIONING_IP="192.168.222.199"
export IRONIC_PROVISIONING_IP="${IP_ADDRESS}"

# Build vbmctl
make build-vbmctl
Expand All @@ -114,7 +84,7 @@ if [[ "${BMO_E2E_EMULATOR}" == "vbmc" ]]; then
address=$(echo "${bmc}" | jq -r '.address')
hostName=$(echo "${bmc}" | jq -r '.hostName')
vbmc_port="${address##*:}"
"${REPO_ROOT}/tools/bmh_test/vm2vbmc.sh" "${hostName}" "${vbmc_port}"
"${REPO_ROOT}/tools/bmh_test/vm2vbmc.sh" "${hostName}" "${vbmc_port}" "${IP_ADDRESS}"
done

elif [[ "${BMO_E2E_EMULATOR}" == "sushy-tools" ]]; then
Expand Down Expand Up @@ -186,47 +156,28 @@ BMO_OVERLAYS=(
)
IRONIC_OVERLAYS=(
"${REPO_ROOT}/ironic-deployment/overlays/e2e"
"${REPO_ROOT}/ironic-deployment/overlays/e2e-with-inspector"
"${REPO_ROOT}/ironic-deployment/overlays/e2e-release-24.0-with-inspector"
"${REPO_ROOT}/ironic-deployment/overlays/e2e-release-24.1"
"${REPO_ROOT}/ironic-deployment/overlays/e2e-release-25.0"
"${REPO_ROOT}/ironic-deployment/overlays/e2e-release-26.0"
)

IRONIC_USERNAME="$(uuidgen)"
IRONIC_PASSWORD="$(uuidgen)"
IRONIC_INSPECTOR_USERNAME="$(uuidgen)"
IRONIC_INSPECTOR_PASSWORD="$(uuidgen)"

# These must be exported so that envsubst can pick them up below
export IRONIC_USERNAME
export IRONIC_PASSWORD
export IRONIC_INSPECTOR_USERNAME
export IRONIC_INSPECTOR_PASSWORD

for overlay in "${BMO_OVERLAYS[@]}"; do
echo "${IRONIC_USERNAME}" > "${overlay}/ironic-username"
echo "${IRONIC_PASSWORD}" > "${overlay}/ironic-password"
if [[ "${overlay}" =~ release-0\.[1-5]$ ]]; then
echo "${IRONIC_INSPECTOR_USERNAME}" > "${overlay}/ironic-inspector-username"
echo "${IRONIC_INSPECTOR_PASSWORD}" > "${overlay}/ironic-inspector-password"
fi
done

for overlay in "${IRONIC_OVERLAYS[@]}"; do
echo "IRONIC_HTPASSWD=$(htpasswd -n -b -B "${IRONIC_USERNAME}" "${IRONIC_PASSWORD}")" > \
"${overlay}/ironic-htpasswd"
envsubst < "${REPO_ROOT}/ironic-deployment/components/basic-auth/ironic-auth-config-tpl" > \
"${overlay}/ironic-auth-config"

if [[ "${overlay}" =~ -with-inspector ]]; then
IRONIC_INSPECTOR_AUTH_CONFIG_TPL="/tmp/ironic-inspector-auth-config-tpl"
curl -o "${IRONIC_INSPECTOR_AUTH_CONFIG_TPL}" https://raw.githubusercontent.com/metal3-io/baremetal-operator/release-0.5/ironic-deployment/components/basic-auth/ironic-inspector-auth-config-tpl
envsubst < "${IRONIC_INSPECTOR_AUTH_CONFIG_TPL}" > \
"${overlay}/ironic-inspector-auth-config"
echo "INSPECTOR_HTPASSWD=$(htpasswd -n -b -B "${IRONIC_INSPECTOR_USERNAME}" \
"${IRONIC_INSPECTOR_PASSWORD}")" > "${overlay}/ironic-inspector-htpasswd"
fi
done

# We need to gather artifacts/logs before exiting also if there are errors
Expand Down
2 changes: 1 addition & 1 deletion hack/clean-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
cd "${REPO_ROOT}" || exit 1

minikube delete
kind delete cluster
docker rm -f vbmc
docker rm -f image-server-e2e
docker rm -f sushy-tools
Expand Down
35 changes: 35 additions & 0 deletions hack/e2e/ensure_kind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

set -eux

USR_LOCAL_BIN="/usr/local/bin"
MINIMUM_KIND_VERSION=v0.26.0

# Ensure the kind tool exists and is a viable version, or installs it
verify_kind_version()
{
# If kind is not available on the path, get it
if ! [ -x "$(command -v kind)" ]; then
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
echo "kind not found, installing"
curl -LO "https://kind.sigs.k8s.io/dl/${MINIMUM_KIND_VERSION}/kind-linux-amd64"
sudo install kind "${USR_LOCAL_BIN}/kind"
else
echo "Missing required binary in path: kind"
return 2
fi
fi

local kind_version
IFS=" " read -ra kind_version <<< "$(kind version)"
if [[ "${MINIMUM_KIND_VERSION}" != $(echo -e "${MINIMUM_KIND_VERSION}\n${kind_version[1]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) ]]; then
cat << EOF
Detected kind version: ${kind_version[2]}.
Requires ${MINIMUM_KIND_VERSION} or greater.
Please install ${MINIMUM_KIND_VERSION} or later.
EOF
return 2
fi
}

verify_kind_version
33 changes: 0 additions & 33 deletions hack/e2e/ensure_minikube.sh

This file was deleted.

3 changes: 1 addition & 2 deletions hack/e2e/net.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<ip address='192.168.222.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.222.2' end='192.168.222.199'/>
<host mac='52:54:00:6c:3c:01' name='minikube' ip='192.168.222.199'/>
<bootp file='http://192.168.222.199:6180/boot.ipxe'/>
<bootp file='http://192.168.222.1:6180/boot.ipxe'/>
</dhcp>
</ip>
</network>
Loading
Loading