From 63c6cc5ac1777ab0ef59354063513c1e337b1fc6 Mon Sep 17 00:00:00 2001 From: Lennart Jern Date: Tue, 21 Jan 2025 15:54:09 +0200 Subject: [PATCH] E2E: Use kind instead of minikube Minikube is having troubles starting sometimes. It was nice to work with since the VM could easily be attached to the same network as the BMH VMs, but it is possible to work around that also with kind. Signed-off-by: Lennart Jern --- .gitignore | 1 + config/overlays/e2e-release-0.5/ironic.env | 6 ++-- config/overlays/e2e-release-0.6/ironic.env | 6 ++-- config/overlays/e2e/ironic.env | 6 ++-- hack/ci-e2e.sh | 24 +------------ hack/clean-e2e.sh | 1 - hack/e2e/ensure_minikube.sh | 33 ------------------ hack/e2e/net.xml | 3 +- .../components/tls/certificate.yaml | 2 -- .../ironic_bmo_configmap.env | 6 ++-- .../e2e-release-24.1/ironic_bmo_configmap.env | 5 +-- .../e2e-release-24.1/kustomization.yaml | 34 ++++++++++--------- .../ironic_bmo_configmap.env | 6 ++-- .../e2e-with-inspector/kustomization.yaml | 32 +++++++++-------- .../overlays/e2e/ironic_bmo_configmap.env | 5 +-- .../overlays/e2e/kustomization.yaml | 27 ++++++--------- test/e2e/config/fixture.yaml | 3 ++ test/e2e/config/ironic.yaml | 29 ++++++++++++++-- test/e2e/e2e_config.go | 4 +++ test/e2e/e2e_suite_test.go | 5 +-- test/e2e/upgrade_test.go | 23 +++++++------ test/go.mod | 2 +- tools/bmh_test/vm2vbmc.sh | 3 +- 23 files changed, 123 insertions(+), 143 deletions(-) delete mode 100755 hack/e2e/ensure_minikube.sh diff --git a/.gitignore b/.gitignore index 8781fc91e7..acf2207368 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ go.work.sum *~ *.tmp .DS_Store +.zed* # Tilt files. .tiltbuild diff --git a/config/overlays/e2e-release-0.5/ironic.env b/config/overlays/e2e-release-0.5/ironic.env index 0187ae15e4..44147ae0f3 100644 --- a/config/overlays/e2e-release-0.5/ironic.env +++ b/config/overlays/e2e-release-0.5/ironic.env @@ -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/ diff --git a/config/overlays/e2e-release-0.6/ironic.env b/config/overlays/e2e-release-0.6/ironic.env index 0187ae15e4..44147ae0f3 100644 --- a/config/overlays/e2e-release-0.6/ironic.env +++ b/config/overlays/e2e-release-0.6/ironic.env @@ -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/ diff --git a/config/overlays/e2e/ironic.env b/config/overlays/e2e/ironic.env index 0187ae15e4..44147ae0f3 100644 --- a/config/overlays/e2e/ironic.env +++ b/config/overlays/e2e/ironic.env @@ -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/ diff --git a/hack/ci-e2e.sh b/hack/ci-e2e.sh index 5e266da672..d3c4d28152 100755 --- a/hack/ci-e2e.sh +++ b/hack/ci-e2e.sh @@ -44,12 +44,10 @@ 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_htpasswd.sh" # CAPI test framework uses kubectl in the background "${REPO_ROOT}/hack/e2e/ensure_kubectl.sh" @@ -58,28 +56,8 @@ 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 # This IP is defined by the network we created above. IP_ADDRESS="192.168.222.1" @@ -100,7 +78,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 diff --git a/hack/clean-e2e.sh b/hack/clean-e2e.sh index 17c8f7f010..af6700cb26 100755 --- a/hack/clean-e2e.sh +++ b/hack/clean-e2e.sh @@ -3,7 +3,6 @@ REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. cd "${REPO_ROOT}" || exit 1 -minikube delete docker rm -f vbmc docker rm -f image-server-e2e docker rm -f sushy-tools diff --git a/hack/e2e/ensure_minikube.sh b/hack/e2e/ensure_minikube.sh deleted file mode 100755 index c4c48f9938..0000000000 --- a/hack/e2e/ensure_minikube.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -USR_LOCAL_BIN="/usr/local/bin" -OS=$(go env GOOS) -ARCH=$(go env GOARCH) -MINIMUM_MINIKUBE_VERSION=v1.33.0 - -verify_minikube_version() { - if ! [ -x "$(command -v minikube)" ]; then - if [[ "${OSTYPE}" == "linux-gnu" ]]; then - echo "minikube not found, installing" - curl -LO "https://storage.googleapis.com/minikube/releases/${MINIMUM_MINIKUBE_VERSION}/minikube-${OS}-${ARCH}" - sudo install minikube-linux-amd64 "${USR_LOCAL_BIN}/minikube" - else - echo "Missing required binary in path: minikube" - return 2 - fi - fi - local minikube_version - minikube_version="$(minikube version --short)" - if [[ "${MINIMUM_MINIKUBE_VERSION}" != $(echo -e "${MINIMUM_MINIKUBE_VERSION}\n${minikube_version}" | sort -V | head -n1) ]]; then - cat << EOF -Detected minikube version: ${minikube_version}. -Requires ${MINIMUM_MINIKUBE_VERSION} or greater. -Please install ${MINIMUM_MINIKUBE_VERSION} or later. -EOF - return 2 - fi -} - -verify_minikube_version diff --git a/hack/e2e/net.xml b/hack/e2e/net.xml index 71fdad47e8..6039360a57 100644 --- a/hack/e2e/net.xml +++ b/hack/e2e/net.xml @@ -9,8 +9,7 @@ - - + diff --git a/ironic-deployment/components/tls/certificate.yaml b/ironic-deployment/components/tls/certificate.yaml index d8a83c7aa7..2e576873db 100644 --- a/ironic-deployment/components/tls/certificate.yaml +++ b/ironic-deployment/components/tls/certificate.yaml @@ -12,8 +12,6 @@ metadata: spec: commonName: ironic-ca isCA: true - ipAddresses: - - IRONIC_HOST_IP issuerRef: kind: Issuer name: selfsigned-issuer diff --git a/ironic-deployment/overlays/e2e-release-24.0-with-inspector/ironic_bmo_configmap.env b/ironic-deployment/overlays/e2e-release-24.0-with-inspector/ironic_bmo_configmap.env index cd099090c2..1ebbc040fc 100644 --- a/ironic-deployment/overlays/e2e-release-24.0-with-inspector/ironic_bmo_configmap.env +++ b/ironic-deployment/overlays/e2e-release-24.0-with-inspector/ironic_bmo_configmap.env @@ -1,6 +1,6 @@ HTTP_PORT=6180 -PROVISIONING_IP=192.168.222.199 -CACHEURL=http://192.168.222.199/images -IRONIC_FAST_TRACK=true +PROVISIONING_INTERFACE=eth0 +CACHEURL=http://192.168.222.1/images +IRONIC_EXTERNAL_CALLBACK_URL=https://192.168.222.1:6385 IRONIC_KERNEL_PARAMS=console=ttyS0 IRONIC_INSPECTOR_VLAN_INTERFACES=all diff --git a/ironic-deployment/overlays/e2e-release-24.1/ironic_bmo_configmap.env b/ironic-deployment/overlays/e2e-release-24.1/ironic_bmo_configmap.env index a0840f4859..9dc4c4bf68 100644 --- a/ironic-deployment/overlays/e2e-release-24.1/ironic_bmo_configmap.env +++ b/ironic-deployment/overlays/e2e-release-24.1/ironic_bmo_configmap.env @@ -1,6 +1,7 @@ HTTP_PORT=6180 -PROVISIONING_IP=192.168.222.199 -CACHEURL=http://192.168.222.199/images +PROVISIONING_INTERFACE=eth0 +CACHEURL=http://192.168.222.1/images +IRONIC_EXTERNAL_CALLBACK_URL=https://192.168.222.1:6385 IRONIC_KERNEL_PARAMS=console=ttyS0 IRONIC_INSPECTOR_VLAN_INTERFACES=all USE_IRONIC_INSPECTOR=false diff --git a/ironic-deployment/overlays/e2e-release-24.1/kustomization.yaml b/ironic-deployment/overlays/e2e-release-24.1/kustomization.yaml index 1936f375f6..0bf9aa3827 100644 --- a/ironic-deployment/overlays/e2e-release-24.1/kustomization.yaml +++ b/ironic-deployment/overlays/e2e-release-24.1/kustomization.yaml @@ -16,7 +16,24 @@ configMapGenerator: behavior: create patches: - - path: ironic-patch.yaml +- path: ironic-patch.yaml +# The TLS component adds certificates but it cannot know the exact IPs of our environment. +# Here we patch the certificates to have the correct IPs. +# - 192.168.222.1: management computer IP, forwarded to ironic inside kind +- patch: |- + - op: replace + path: /spec/ipAddresses/0 + value: 192.168.222.1 + target: + kind: Certificate + name: ironic-cert +- patch: |- + - op: replace + path: /spec/ipAddresses/0 + value: 192.168.222.1 + target: + kind: Certificate + name: ironic-cacert images: - name: quay.io/metal3-io/ironic @@ -28,18 +45,3 @@ secretGenerator: behavior: create envs: - ironic-htpasswd - -replacements: - # Replace IRONIC_HOST_IP in certificates with the PROVISIONING_IP from the configmap - - source: - kind: ConfigMap - name: ironic-bmo-configmap - fieldPath: .data.PROVISIONING_IP - targets: - - select: - version: v1 - group: cert-manager.io - kind: Certificate - name: - fieldPaths: - - .spec.ipAddresses.0 diff --git a/ironic-deployment/overlays/e2e-with-inspector/ironic_bmo_configmap.env b/ironic-deployment/overlays/e2e-with-inspector/ironic_bmo_configmap.env index 65624598de..171c452313 100644 --- a/ironic-deployment/overlays/e2e-with-inspector/ironic_bmo_configmap.env +++ b/ironic-deployment/overlays/e2e-with-inspector/ironic_bmo_configmap.env @@ -1,7 +1,7 @@ HTTP_PORT=6180 -PROVISIONING_IP=192.168.222.199 -CACHEURL=http://192.168.222.199/images -IRONIC_FAST_TRACK=true +PROVISIONING_INTERFACE=eth0 +CACHEURL=http://192.168.222.1/images +IRONIC_EXTERNAL_CALLBACK_URL=https://192.168.222.1:6385 IRONIC_KERNEL_PARAMS=console=ttyS0 IRONIC_INSPECTOR_VLAN_INTERFACES=all USE_IRONIC_INSPECTOR=true diff --git a/ironic-deployment/overlays/e2e-with-inspector/kustomization.yaml b/ironic-deployment/overlays/e2e-with-inspector/kustomization.yaml index d1009417ca..dcbf8ebd80 100644 --- a/ironic-deployment/overlays/e2e-with-inspector/kustomization.yaml +++ b/ironic-deployment/overlays/e2e-with-inspector/kustomization.yaml @@ -17,6 +17,23 @@ configMapGenerator: patches: - path: ironic-patch.yaml +# The TLS component adds certificates but it cannot know the exact IPs of our environment. +# Here we patch the certificates to have the correct IPs. +# - 192.168.222.1: management computer IP, forwarded to ironic inside kind +- patch: |- + - op: replace + path: /spec/ipAddresses/0 + value: 192.168.222.1 + target: + kind: Certificate + name: ironic-cert +- patch: |- + - op: replace + path: /spec/ipAddresses/0 + value: 192.168.222.1 + target: + kind: Certificate + name: ironic-cacert # NOTE: These credentials are generated automatically in hack/ci-e2e.sh secretGenerator: @@ -34,18 +51,3 @@ secretGenerator: - name: ironic-inspector-auth-config files: - auth-config=ironic-inspector-auth-config - -replacements: -# Replace IRONIC_HOST_IP in certificates with the PROVISIONING_IP from the configmap -- source: - kind: ConfigMap - name: ironic-bmo-configmap - fieldPath: .data.PROVISIONING_IP - targets: - - select: - version: v1 - group: cert-manager.io - kind: Certificate - name: - fieldPaths: - - .spec.ipAddresses.0 diff --git a/ironic-deployment/overlays/e2e/ironic_bmo_configmap.env b/ironic-deployment/overlays/e2e/ironic_bmo_configmap.env index a0840f4859..9dc4c4bf68 100644 --- a/ironic-deployment/overlays/e2e/ironic_bmo_configmap.env +++ b/ironic-deployment/overlays/e2e/ironic_bmo_configmap.env @@ -1,6 +1,7 @@ HTTP_PORT=6180 -PROVISIONING_IP=192.168.222.199 -CACHEURL=http://192.168.222.199/images +PROVISIONING_INTERFACE=eth0 +CACHEURL=http://192.168.222.1/images +IRONIC_EXTERNAL_CALLBACK_URL=https://192.168.222.1:6385 IRONIC_KERNEL_PARAMS=console=ttyS0 IRONIC_INSPECTOR_VLAN_INTERFACES=all USE_IRONIC_INSPECTOR=false diff --git a/ironic-deployment/overlays/e2e/kustomization.yaml b/ironic-deployment/overlays/e2e/kustomization.yaml index 4a1b0fdcb3..9602b5541c 100644 --- a/ironic-deployment/overlays/e2e/kustomization.yaml +++ b/ironic-deployment/overlays/e2e/kustomization.yaml @@ -16,7 +16,17 @@ configMapGenerator: behavior: create patches: - - path: ironic-patch.yaml +- path: ironic-patch.yaml +# The TLS component adds certificates but it cannot know the exact IPs of our environment. +# Here we patch the certificates to have the correct IPs. +# - 192.168.222.1: management computer IP, forwarded to ironic inside kind +- patch: |- + - op: replace + path: /spec/ipAddresses/0 + value: 192.168.222.1 + target: + kind: Certificate + name: ironic-cert # NOTE: These credentials are generated automatically in hack/ci-e2e.sh secretGenerator: @@ -25,18 +35,3 @@ secretGenerator: files: - htpasswd=ironic-htpasswd type: Opaque - -replacements: - # Replace IRONIC_HOST_IP in certificates with the PROVISIONING_IP from the configmap - - source: - kind: ConfigMap - name: ironic-bmo-configmap - fieldPath: .data.PROVISIONING_IP - targets: - - select: - version: v1 - group: cert-manager.io - kind: Certificate - name: - fieldPaths: - - .spec.ipAddresses.0 diff --git a/test/e2e/config/fixture.yaml b/test/e2e/config/fixture.yaml index bdf38e1aa0..6aa07177e3 100644 --- a/test/e2e/config/fixture.yaml +++ b/test/e2e/config/fixture.yaml @@ -21,6 +21,9 @@ variables: # This setting is for the separate cluster that are used for upgrade tests UPGRADE_DEPLOY_CERT_MANAGER: "true" + # We can create separate clusters for each upgrade test with fixture. + # Since there is no ironic involved, we do not risk having any port collisions. + UPGRADE_USE_EXISTING_CLUSTER: "false" IMAGE_URL: "http://192.168.222.1/cirros-0.6.2-x86_64-disk.img" ISO_IMAGE_URL: "http://192.168.222.1/cirros.iso" diff --git a/test/e2e/config/ironic.yaml b/test/e2e/config/ironic.yaml index 6c275faece..a2d30691c9 100644 --- a/test/e2e/config/ironic.yaml +++ b/test/e2e/config/ironic.yaml @@ -2,8 +2,8 @@ images: # Use locally built e2e images - name: quay.io/metal3-io/baremetal-operator:e2e loadBehavior: tryLoad -- name: quay.io/metal3-io/ironic:e2e - loadBehavior: tryLoad +# - name: quay.io/metal3-io/ironic:local +# loadBehavior: tryLoad # Save some time and network by using cached images if available - name: quay.io/metal3-io/baremetal-operator:release-0.4 loadBehavior: tryLoad @@ -25,6 +25,11 @@ variables: # This setting is for the separate cluster that are used for upgrade tests UPGRADE_DEPLOY_CERT_MANAGER: "true" + # We run upgrade tests separately, so they can use the default kind cluster + # since there are no other tests running at the same time. + # Creating separate upgrade clusters would cause port collisions with the default kind cluster. + # We also configure these jobs to not deploy BMO/Ironic so that can be handled by the upgrade test. + UPGRADE_USE_EXISTING_CLUSTER: "true" IMAGE_URL: "http://192.168.222.1/cirros-0.6.2-x86_64-disk.img" ISO_IMAGE_URL: "http://192.168.222.1/minimal_linux_live-v2.iso" @@ -53,31 +58,51 @@ intervals: default/wait-secret-deletion: ["1m", "1s"] default/wait-connect-ssh: ["2m", "10s"] +kindExtraPortMappings: +# Expose Ironic ports so they are reachable outside of kind +- containerPort: 6180 + hostPort: 6180 + listenAddress: "0.0.0.0" + protocol: TCP +- containerPort: 6385 + hostPort: 6385 + listenAddress: "0.0.0.0" + protocol: TCP +- containerPort: 5050 + hostPort: 5050 + listenAddress: "0.0.0.0" + protocol: TCP + bmoIronicUpgradeSpecs: +# Upgrade BMO 0.4 -> latest - deployIronic: true deployBMO: true initBMOKustomization: "../../config/overlays/e2e-release-0.4" initIronicKustomization: "../../ironic-deployment/overlays/e2e-with-inspector" upgradeEntityKustomization: "../../config/overlays/e2e" upgradeEntityName: "bmo" +# Upgrade BMO 0.5 -> latest - deployIronic: true deployBMO: true initBMOKustomization: "../../config/overlays/e2e-release-0.5" initIronicKustomization: "../../ironic-deployment/overlays/e2e" upgradeEntityKustomization: "../../config/overlays/e2e" upgradeEntityName: "bmo" +# Upgrade BMO 0.6 -> latest - deployIronic: true deployBMO: true initBMOKustomization: "../../config/overlays/e2e-release-0.6" initIronicKustomization: "../../ironic-deployment/overlays/e2e" upgradeEntityKustomization: "../../config/overlays/e2e" upgradeEntityName: "bmo" +# Upgrade Ironic 24.0-with-inspector -> latest | BMO 0.6 - deployIronic: true deployBMO: true initBMOKustomization: "../../config/overlays/e2e-release-0.6" initIronicKustomization: "../../ironic-deployment/overlays/e2e-release-24.0-with-inspector" upgradeEntityKustomization: "../../ironic-deployment/overlays/e2e" upgradeEntityName: "ironic" +# Upgrade Ironic 24.1 -> latest | BMO 0.6 - deployIronic: true deployBMO: true initBMOKustomization: "../../config/overlays/e2e-release-0.6" diff --git a/test/e2e/e2e_config.go b/test/e2e/e2e_config.go index a4b150807d..83cf3f28c4 100644 --- a/test/e2e/e2e_config.go +++ b/test/e2e/e2e_config.go @@ -11,6 +11,7 @@ import ( "github.com/pkg/errors" "gopkg.in/yaml.v2" "sigs.k8s.io/cluster-api/test/framework/clusterctl" + "sigs.k8s.io/kind/pkg/apis/config/v1alpha4" ) // LoadImageBehavior indicates the behavior when loading an image. @@ -60,6 +61,9 @@ type Config struct { // BMOIronicUpgradeSpecs BMOIronicUpgradeSpecs []BMOIronicUpgradeInput `yaml:"bmoIronicUpgradeSpecs,omitempty"` + + // Extra port mappings for the kind cluster + KindExtraPortMappings []v1alpha4.PortMapping `yaml:"kindExtraPortMappings,omitempty"` } // LoadE2EConfig loads the configuration for the e2e test environment. diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 82c02f2c37..b2a71bedd0 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -150,8 +150,9 @@ var _ = SynchronizedBeforeSuite(func() []byte { kubeconfigPath = GetKubeconfigPath() } else { clusterProvider = bootstrap.CreateKindBootstrapClusterAndLoadImages(ctx, bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{ - Name: "bmo-e2e", - Images: e2eConfig.Images, + Name: "bmo-e2e", + Images: e2eConfig.Images, + ExtraPortMappings: e2eConfig.KindExtraPortMappings, }) Expect(clusterProvider).ToNot(BeNil(), "Failed to create a cluster") kubeconfigPath = clusterProvider.GetKubeconfigPath() diff --git a/test/e2e/upgrade_test.go b/test/e2e/upgrade_test.go index 7c420290d8..e6c6a899c3 100644 --- a/test/e2e/upgrade_test.go +++ b/test/e2e/upgrade_test.go @@ -170,14 +170,14 @@ const hardwareDetailsRelease04 = ` ` // RunUpgradeTest tests upgrade from an older version of BMO or Ironic --> main branch version with the following steps: -// - Initiate the cluster with an the older version of either BMO or Ironic, and the latest Ironic/BMO version that is suitable with it -// - Create a new namespace, and in it a BMH object with "disabled" annotation. -// - Wait until the BMH gets to "available" state. Because of the "disabled" annotation, it won't get further provisioned. -// - Upgrade BMO/Ironic to latest version. -// - Patch the BMH object with proper specs, so that it could be provisioned. -// - If the BMH is successfully provisioned, it means the upgraded BMO/Ironic recognized that BMH, hence the upgrade succeeded. +// - Initiate the cluster with an the older version of either BMO or Ironic, and the latest Ironic/BMO version that is suitable with it +// - Create a new namespace, and in it a BMH object with "disabled" annotation. +// - Wait until the BMH gets to "available" state. Because of the "disabled" annotation, it won't get further provisioned. +// - Upgrade BMO/Ironic to latest version. +// - Patch the BMH object with proper specs, so that it could be provisioned. +// - If the BMH is successfully provisioned, it means the upgraded BMO/Ironic recognized that BMH, hence the upgrade succeeded. +// // The function returns the namespace object, with its cancelFunc. These can be used to clean up the created resources. - func RunUpgradeTest(ctx context.Context, input *BMOIronicUpgradeInput, upgradeClusterProxy framework.ClusterProxy) (*corev1.Namespace, context.CancelFunc) { bmoIronicNamespace := "baremetal-operator-system" initBMOKustomization := input.InitBMOKustomization @@ -356,14 +356,15 @@ var _ = Describe("Upgrade", Label("optional", "upgrade"), func() { var kubeconfigPath string upgradeClusterName := "bmo-e2e-upgrade" - if useExistingCluster { + if e2eConfig.GetVariable("UPGRADE_USE_EXISTING_CLUSTER") != "false" { kubeconfigPath = GetKubeconfigPath() } else { By("Creating a separate cluster for upgrade tests") upgradeClusterName = fmt.Sprintf("bmo-e2e-upgrade-%d", GinkgoParallelProcess()) upgradeClusterProvider := bootstrap.CreateKindBootstrapClusterAndLoadImages(ctx, bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{ - Name: upgradeClusterName, - Images: e2eConfig.Images, + Name: upgradeClusterName, + Images: e2eConfig.Images, + ExtraPortMappings: e2eConfig.KindExtraPortMappings, }) Expect(upgradeClusterProvider).ToNot(BeNil(), "Failed to create a cluster") kubeconfigPath = upgradeClusterProvider.GetKubeconfigPath() @@ -396,9 +397,11 @@ var _ = Describe("Upgrade", Label("optional", "upgrade"), func() { } }) DescribeTable("", + // Test function that runs for each table entry func(ctx context.Context, input *BMOIronicUpgradeInput) { namespace, cancelWatches = RunUpgradeTest(ctx, input, upgradeClusterProxy) }, + // Description function that generates test descriptions func(ctx context.Context, input *BMOIronicUpgradeInput) string { var upgradeFromKustomization string upgradeEntityName := input.UpgradeEntityName diff --git a/test/go.mod b/test/go.mod index 9530aa43d2..f24f3418a5 100644 --- a/test/go.mod +++ b/test/go.mod @@ -20,6 +20,7 @@ require ( sigs.k8s.io/cluster-api v1.7.9 sigs.k8s.io/cluster-api/test v1.7.9 sigs.k8s.io/controller-runtime v0.17.6 + sigs.k8s.io/kind v0.23.0 sigs.k8s.io/kustomize/api v0.17.3 sigs.k8s.io/kustomize/kyaml v0.17.2 ) @@ -144,7 +145,6 @@ require ( k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect sigs.k8s.io/gateway-api v0.7.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/kind v0.23.0 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/tools/bmh_test/vm2vbmc.sh b/tools/bmh_test/vm2vbmc.sh index bfbfbc5c26..c2be2ecf7a 100755 --- a/tools/bmh_test/vm2vbmc.sh +++ b/tools/bmh_test/vm2vbmc.sh @@ -4,8 +4,9 @@ set -eux NAME="${1:?}" VBMC_PORT="${2:?}" +VBMC_ADDRESS="${3:-"::"}" # Add the BareMetalHost VM to VBMC -docker exec vbmc vbmc add "${NAME}" --port "${VBMC_PORT}" --libvirt-uri "qemu:///system" +docker exec vbmc vbmc add "${NAME}" --port "${VBMC_PORT}" --address "${VBMC_ADDRESS}" --libvirt-uri "qemu:///system" docker exec vbmc vbmc start "${NAME}" docker exec vbmc vbmc list