diff --git a/hack/ci-e2e.sh b/hack/ci-e2e.sh index f125df3a93..1f14873108 100755 --- a/hack/ci-e2e.sh +++ b/hack/ci-e2e.sh @@ -24,6 +24,7 @@ case "${GINKGO_FOCUS:-}" in export DEPLOY_IRONIC="false" export DEPLOY_BMO="false" export DEPLOY_CERT_MANAGER="false" + export GINKGO_NODES=1 ;; *) export GINKGO_SKIP="${GINKGO_SKIP:-upgrade}" @@ -90,10 +91,6 @@ fi export E2E_BMCS_CONF_FILE="${REPO_ROOT}/test/e2e/config/bmcs-${BMO_E2E_EMULATOR}.yaml" "${REPO_ROOT}/hack/create_bmcs.sh" "${E2E_BMCS_CONF_FILE}" baremetal-e2e -# Set the number of ginkgo processes to the number of BMCs -n_vms=$(yq '. | length' "${E2E_BMCS_CONF_FILE}") -export GINKGO_NODES="${n_vms}" - # Image server variables CIRROS_VERSION="0.6.2" IMAGE_FILE="cirros-${CIRROS_VERSION}-x86_64-disk.img" @@ -113,7 +110,7 @@ docker run --name image-server-e2e -d \ ssh-keygen -t ed25519 -f "${IMAGE_DIR}/ssh_testkey" -q -N "" # Generate credentials -BMO_OVERLAYS=("${REPO_ROOT}/config/overlays/e2e" "${REPO_ROOT}/config/overlays/e2e-release-0.4" "${REPO_ROOT}/config/overlays/e2e-release-0.5") +BMO_OVERLAYS=("${REPO_ROOT}/config/overlays/e2e" "${REPO_ROOT}/config/overlays/e2e-release-0.3" "${REPO_ROOT}/config/overlays/e2e-release-0.4" "${REPO_ROOT}/config/overlays/e2e-release-0.5") IRONIC_OVERLAY="${REPO_ROOT}/ironic-deployment/overlays/e2e" IRONIC_USERNAME="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 12 | head -n 1)" @@ -142,6 +139,18 @@ envsubst < "${REPO_ROOT}/ironic-deployment/components/basic-auth/ironic-auth-con echo "IRONIC_HTPASSWD=$(htpasswd -n -b -B "${IRONIC_USERNAME}" "${IRONIC_PASSWORD}")" > \ "${IRONIC_OVERLAY}/ironic-htpasswd" +IRONIC_WITH_INSPECTOR_OVERLAY="${REPO_ROOT}/ironic-deployment/overlays/e2e-with-inspector" +envsubst < "${REPO_ROOT}/ironic-deployment/components/basic-auth/ironic-auth-config-tpl" > \ + "${IRONIC_WITH_INSPECTOR_OVERLAY}/ironic-auth-config" + +echo "IRONIC_HTPASSWD=$(htpasswd -n -b -B "${IRONIC_USERNAME}" "${IRONIC_PASSWORD}")" > \ + "${IRONIC_WITH_INSPECTOR_OVERLAY}/ironic-htpasswd" +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}" > \ + "${IRONIC_WITH_INSPECTOR_OVERLAY}/ironic-inspector-auth-config" +echo "INSPECTOR_HTPASSWD=$(htpasswd -n -b -B "${IRONIC_INSPECTOR_USERNAME}" \ + "${IRONIC_INSPECTOR_PASSWORD}")" > "${IRONIC_WITH_INSPECTOR_OVERLAY}/ironic-inspector-htpasswd" # We need to gather artifacts/logs before exiting also if there are errors set +e diff --git a/ironic-deployment/overlays/e2e-with-inspector/ironic-patch.yaml b/ironic-deployment/overlays/e2e-with-inspector/ironic-patch.yaml new file mode 100644 index 0000000000..6e378383e6 --- /dev/null +++ b/ironic-deployment/overlays/e2e-with-inspector/ironic-patch.yaml @@ -0,0 +1,10 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ironic +spec: + template: + spec: + containers: + - name: ironic-dnsmasq + $patch: delete diff --git a/ironic-deployment/overlays/e2e-with-inspector/ironic_bmo_configmap.env b/ironic-deployment/overlays/e2e-with-inspector/ironic_bmo_configmap.env new file mode 100644 index 0000000000..65624598de --- /dev/null +++ b/ironic-deployment/overlays/e2e-with-inspector/ironic_bmo_configmap.env @@ -0,0 +1,7 @@ +HTTP_PORT=6180 +PROVISIONING_IP=192.168.222.199 +CACHEURL=http://192.168.222.199/images +IRONIC_FAST_TRACK=true +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 new file mode 100644 index 0000000000..15989243ed --- /dev/null +++ b/ironic-deployment/overlays/e2e-with-inspector/kustomization.yaml @@ -0,0 +1,51 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: baremetal-operator-system +resources: +- ../../../config/namespace +- https://github.com/metal3-io/baremetal-operator/ironic-deployment/base?ref=release-0.5 + +components: +- https://github.com/metal3-io/baremetal-operator/ironic-deployment/components/basic-auth?ref=release-0.5 +- https://github.com/metal3-io/baremetal-operator/ironic-deployment/components/tls?ref=release-0.5 + +configMapGenerator: +- envs: + - ironic_bmo_configmap.env + name: ironic-bmo-configmap + behavior: create + +patches: + - path: ironic-patch.yaml + +# NOTE: These credentials are generated automatically in hack/ci-e2e.sh +secretGenerator: +- name: ironic-htpasswd + behavior: create + envs: + - ironic-htpasswd +- name: ironic-inspector-htpasswd + behavior: create + envs: + - ironic-inspector-htpasswd +- name: ironic-auth-config + files: + - auth-config=ironic-auth-config +- 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/test/e2e/config/fixture.yaml b/test/e2e/config/fixture.yaml index 9fb6517892..c176bbbaf6 100644 --- a/test/e2e/config/fixture.yaml +++ b/test/e2e/config/fixture.yaml @@ -23,7 +23,7 @@ variables: UPGRADE_DEPLOY_IRONIC: "false" UPGRADE_DEPLOY_BMO: "true" UPGRADE_DEPLOY_CERT_MANAGER: "true" - UPGRADE_BMO_KUSTOMIZATION_FROM: "../../config/overlays/fixture-release-0.5" + UPGRADE_BMO_KUSTOMIZATION_FROM: "../../config/overlays/fixture-release-0.3 ../../config/overlays/fixture-release-0.4 ../../config/overlays/fixture-release-0.5" IMAGE_URL: "http://192.168.222.1/cirros-0.6.2-x86_64-disk.img" IMAGE_CHECKSUM: "c8fc807773e5354afe61636071771906" diff --git a/test/e2e/config/ironic.yaml b/test/e2e/config/ironic.yaml index a04af65a14..8b0ed69369 100644 --- a/test/e2e/config/ironic.yaml +++ b/test/e2e/config/ironic.yaml @@ -22,12 +22,14 @@ variables: DEPLOY_CERT_MANAGER: "true" BMO_KUSTOMIZATION: "../../config/overlays/e2e" IRONIC_KUSTOMIZATION: "../../ironic-deployment/overlays/e2e" + # IRONIC_KUSTOMIZATION: "../../ironic-deployment/overlays/e2e-with-inspector" # These settings are for the separate cluster that are used for upgrade tests UPGRADE_DEPLOY_IRONIC: "true" UPGRADE_DEPLOY_BMO: "true" UPGRADE_DEPLOY_CERT_MANAGER: "true" - UPGRADE_BMO_KUSTOMIZATION_FROM: "../../config/overlays/e2e-release-0.5" + UPGRADE_BMO_KUSTOMIZATION_FROM: "../../config/overlays/e2e-release-0.3 ../../config/overlays/e2e-release-0.4 ../../config/overlays/e2e-release-0.5" + UPGRADE_BMO_IRONIC_KUSTOMIZATION: "../../ironic-deployment/overlays/e2e-with-inspector ../../ironic-deployment/overlays/e2e-with-inspector ../../ironic-deployment/overlays/e2e" IMAGE_URL: "http://192.168.222.1/cirros-0.6.2-x86_64-disk.img" IMAGE_CHECKSUM: "c8fc807773e5354afe61636071771906" diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index fd8d163e10..81bf7c0e40 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -54,6 +54,12 @@ var ( // the BMC instance to use in a parallel test. bmc BMC + + // the list of BMO Kustomization to upgrade from in BMO upgrade tests. + bmoFromKustomizations []string + + // the list of Ironic Kustomization to use in BMO upgrade tests. + bmoUpgradeIronicKustomizations []string ) func init() { @@ -72,13 +78,15 @@ func TestE2e(t *testing.T) { g.Expect(os.MkdirAll(artifactFolder, 0755)).To(Succeed(), "Invalid test suite argument. Can't create e2e.artifacts-folder %q", artifactFolder) RegisterFailHandler(Fail) + Expect(configPath).To(BeAnExistingFile(), "Invalid test suite argument. e2e.config should be an existing file.") + e2eConfig = LoadE2EConfig(configPath) + bmoFromKustomizations = strings.Split(e2eConfig.GetVariable("UPGRADE_BMO_KUSTOMIZATION_FROM"), " ") + bmoUpgradeIronicKustomizations = strings.Split(e2eConfig.GetVariable("UPGRADE_BMO_IRONIC_KUSTOMIZATION"), " ") RunSpecs(t, "E2e Suite") } var _ = SynchronizedBeforeSuite(func() []byte { var kubeconfigPath string - Expect(configPath).To(BeAnExistingFile(), "Invalid test suite argument. e2e.config should be an existing file.") - e2eConfig = LoadE2EConfig(configPath) if useExistingCluster { kubeconfigPath = os.Getenv("KUBECONFIG") diff --git a/test/e2e/upgrade_test.go b/test/e2e/upgrade_test.go index 204305a570..039520d792 100644 --- a/test/e2e/upgrade_test.go +++ b/test/e2e/upgrade_test.go @@ -8,6 +8,8 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "strings" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -182,6 +184,7 @@ var _ = Describe("BMO Upgrade", func() { ) BeforeEach(func() { var kubeconfigPath string + upgradeClusterName := "bmo-e2e-upgrade" if useExistingCluster { kubeconfigPath = os.Getenv("KUBECONFIG") @@ -190,19 +193,26 @@ var _ = Describe("BMO Upgrade", func() { } } else { By("Creating a separate cluster for upgrade tests") + upgradeClusterName = fmt.Sprintf("bmo-e2e-upgrade-%d", GinkgoParallelProcess()) upgradeClusterProvider = bootstrap.CreateKindBootstrapClusterAndLoadImages(ctx, bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{ - Name: "bmo-e2e-upgrade", + Name: upgradeClusterName, Images: e2eConfig.Images, }) Expect(upgradeClusterProvider).ToNot(BeNil(), "Failed to create a cluster") kubeconfigPath = upgradeClusterProvider.GetKubeconfigPath() + DeferCleanup(func() { + By(fmt.Sprintf("Disposing the kind cluster %s", upgradeClusterName)) + upgradeClusterProvider.Dispose(ctx) + }) } Expect(kubeconfigPath).To(BeAnExistingFile(), "Failed to get the kubeconfig file for the cluster") scheme := runtime.NewScheme() framework.TryAddDefaultSchemes(scheme) metal3api.AddToScheme(scheme) - upgradeClusterProxy = framework.NewClusterProxy("bmo-e2e-upgrade", kubeconfigPath, scheme) - + upgradeClusterProxy = framework.NewClusterProxy(upgradeClusterName, kubeconfigPath, scheme) + DeferCleanup(func() { + upgradeClusterProxy.Dispose(ctx) + }) if e2eConfig.GetVariable("UPGRADE_DEPLOY_CERT_MANAGER") != "false" { By("Installing cert-manager on the upgrade cluster") cmVersion := e2eConfig.GetVariable("CERT_MANAGER_VERSION") @@ -217,153 +227,150 @@ var _ = Describe("BMO Upgrade", func() { } }) - It("Should upgrade BMO to latest version", func() { - if e2eConfig.GetVariable("UPGRADE_DEPLOY_IRONIC") != "false" { - // Install Ironic - ironicKustomization := e2eConfig.GetVariable("IRONIC_KUSTOMIZATION") - By("Installing Ironic on the upgrade cluster") - err := BuildAndApplyKustomization(ctx, &BuildAndApplyKustomizationInput{ - Kustomization: ironicKustomization, - ClusterProxy: upgradeClusterProxy, - WaitForDeployment: true, - WatchDeploymentLogs: true, - DeploymentName: "ironic", - DeploymentNamespace: bmoIronicNamespace, - LogPath: filepath.Join(artifactFolder, "logs", fmt.Sprintf("%s-%s", bmoIronicNamespace, specName)), - WaitIntervals: e2eConfig.GetIntervals("default", "wait-deployment"), + for i := range bmoFromKustomizations { + bmoFromKustomization := bmoFromKustomizations[i] + ironicKustomization := bmoUpgradeIronicKustomizations[i] + bmoFromKustomizationName := strings.ReplaceAll(filepath.Base(bmoFromKustomization), ".", "-") + testCaseName := fmt.Sprintf("bmo-upgrade-from-%s", bmoFromKustomizationName) + testCaseArtifactFolder := filepath.Join(artifactFolder, testCaseName) + It(fmt.Sprintf("Should upgrade BMO from %s to latest version", bmoFromKustomization), func() { + if e2eConfig.GetVariable("UPGRADE_DEPLOY_IRONIC") != "false" { + // Install Ironic + By(fmt.Sprintf("Installing Ironic from kustomization %s on the upgrade cluster", ironicKustomization)) + err := BuildAndApplyKustomization(ctx, &BuildAndApplyKustomizationInput{ + Kustomization: ironicKustomization, + ClusterProxy: upgradeClusterProxy, + WaitForDeployment: true, + WatchDeploymentLogs: true, + DeploymentName: "ironic", + DeploymentNamespace: bmoIronicNamespace, + LogPath: filepath.Join(testCaseArtifactFolder, "logs", "ironic"), + WaitIntervals: e2eConfig.GetIntervals("default", "wait-deployment"), + }) + Expect(err).NotTo(HaveOccurred()) + + DeferCleanup(func() { + By("Removing Ironic on the upgrade cluster") + BuildAndRemoveKustomization(ctx, ironicKustomization, upgradeClusterProxy) + }) + } + if e2eConfig.GetVariable("UPGRADE_DEPLOY_BMO") != "false" { + By(fmt.Sprintf("Installing BMO from %s on the upgrade cluster", bmoFromKustomization)) + err := BuildAndApplyKustomization(ctx, &BuildAndApplyKustomizationInput{ + Kustomization: bmoFromKustomization, + ClusterProxy: upgradeClusterProxy, + WaitForDeployment: true, + WatchDeploymentLogs: true, + DeploymentName: "baremetal-operator-controller-manager", + DeploymentNamespace: bmoIronicNamespace, + LogPath: filepath.Join(testCaseArtifactFolder, "logs", fmt.Sprintf("bmo-from-%s", bmoFromKustomizationName)), + WaitIntervals: e2eConfig.GetIntervals("default", "wait-deployment"), + }) + Expect(err).NotTo(HaveOccurred()) + DeferCleanup(func() { + By(fmt.Sprintf("Removing BMO kustomization %s from the upgrade cluster", bmoFromKustomization)) + BuildAndRemoveKustomization(ctx, bmoFromKustomization, upgradeClusterProxy) + }) + } + + namespace, cancelWatches = framework.CreateNamespaceAndWatchEvents(ctx, framework.CreateNamespaceAndWatchEventsInput{ + Creator: upgradeClusterProxy.GetClient(), + ClientSet: upgradeClusterProxy.GetClientSet(), + Name: fmt.Sprintf("%s-%s", specName, util.RandomString(6)), + LogFolder: testCaseArtifactFolder, }) + + By("Creating a secret with BMH credentials") + bmcCredentialsData := map[string]string{ + "username": bmc.User, + "password": bmc.Password, + } + CreateSecret(ctx, upgradeClusterProxy.GetClient(), namespace.Name, secretName, bmcCredentialsData) + + By("Creating a BMH with inspection disabled and hardware details added") + bmh = metal3api.BareMetalHost{ + ObjectMeta: metav1.ObjectMeta{ + Name: specName, + Namespace: namespace.Name, + Annotations: map[string]string{ + metal3api.InspectAnnotationPrefix: "disabled", + // hardwareDetails of release0.4 is compatible to release0.3 and release0.5 as well + // This can be changed to the new hardwareDetails once we no longer test release0.4 + metal3api.HardwareDetailsAnnotation: hardwareDetailsRelease04, + }, + }, + Spec: metal3api.BareMetalHostSpec{ + Online: true, + BMC: metal3api.BMCDetails{ + Address: bmc.Address, + CredentialsName: secretName, + }, + BootMode: metal3api.Legacy, + BootMACAddress: bmc.BootMacAddress, + }, + } + err := upgradeClusterProxy.GetClient().Create(ctx, &bmh) Expect(err).NotTo(HaveOccurred()) - DeferCleanup(func() { - By("Removing Ironic on the upgrade cluster") - BuildAndRemoveKustomization(ctx, ironicKustomization, upgradeClusterProxy) - }) - } - if e2eConfig.GetVariable("UPGRADE_DEPLOY_BMO") != "false" { - bmoFromKustomization := e2eConfig.GetVariable("UPGRADE_BMO_KUSTOMIZATION_FROM") - bmoFromKustomizationName := filepath.Base(bmoFromKustomization) - By(fmt.Sprintf("Installing BMO from %s on the upgrade cluster", bmoFromKustomization)) - err := BuildAndApplyKustomization(ctx, &BuildAndApplyKustomizationInput{ - Kustomization: bmoFromKustomization, + By("Waiting for the BMH to become available") + WaitForBmhInProvisioningState(ctx, WaitForBmhInProvisioningStateInput{ + Client: upgradeClusterProxy.GetClient(), + Bmh: bmh, + State: metal3api.StateAvailable, + }, e2eConfig.GetIntervals(specName, "wait-available")...) + + By("Upgrading BMO deployment") + clientSet := upgradeClusterProxy.GetClientSet() + bmoDeployName := "baremetal-operator-controller-manager" + deploy, err := clientSet.AppsV1().Deployments(bmoIronicNamespace).Get(ctx, bmoDeployName, metav1.GetOptions{}) + Expect(err).NotTo(HaveOccurred()) + bmoKustomization := e2eConfig.GetVariable("BMO_KUSTOMIZATION") + err = BuildAndApplyKustomization(ctx, &BuildAndApplyKustomizationInput{ + Kustomization: bmoKustomization, ClusterProxy: upgradeClusterProxy, - WaitForDeployment: true, + WaitForDeployment: false, WatchDeploymentLogs: true, DeploymentName: "baremetal-operator-controller-manager", DeploymentNamespace: bmoIronicNamespace, - LogPath: filepath.Join(artifactFolder, "logs", fmt.Sprintf("%s-%s", bmoIronicNamespace, specName), fmt.Sprintf("bmo-%s", bmoFromKustomizationName)), + LogPath: filepath.Join(testCaseArtifactFolder, "logs", "bmo-upgrade-main"), WaitIntervals: e2eConfig.GetIntervals("default", "wait-deployment"), }) Expect(err).NotTo(HaveOccurred()) DeferCleanup(func() { - By(fmt.Sprintf("Removing BMO from %s on the upgrade cluster", bmoFromKustomization)) - BuildAndRemoveKustomization(ctx, bmoFromKustomization, upgradeClusterProxy) + By(fmt.Sprintf("Removing BMO kustomization %s from the upgrade cluster", bmoKustomization)) + BuildAndRemoveKustomization(ctx, bmoKustomization, upgradeClusterProxy) }) - } - - namespace, cancelWatches = framework.CreateNamespaceAndWatchEvents(ctx, framework.CreateNamespaceAndWatchEventsInput{ - Creator: upgradeClusterProxy.GetClient(), - ClientSet: upgradeClusterProxy.GetClientSet(), - Name: fmt.Sprintf("%s-%s", specName, util.RandomString(6)), - LogFolder: artifactFolder, - }) - By("Creating a secret with BMH credentials") - bmcCredentialsData := map[string]string{ - "username": bmc.User, - "password": bmc.Password, - } - CreateSecret(ctx, upgradeClusterProxy.GetClient(), namespace.Name, secretName, bmcCredentialsData) - By("Creating a BMH with inspection disabled and hardware details added") - bmh = metal3api.BareMetalHost{ - ObjectMeta: metav1.ObjectMeta{ - Name: specName, - Namespace: namespace.Name, - Annotations: map[string]string{ - metal3api.InspectAnnotationPrefix: "disabled", - // hardwareDetails of release0.4 is compatible to release0.3 and release0.5 as well - // This can be changed to the new hardwareDetails once we no longer test release0.4 - metal3api.HardwareDetailsAnnotation: hardwareDetailsRelease04, - }, - }, - Spec: metal3api.BareMetalHostSpec{ - Online: true, - BMC: metal3api.BMCDetails{ - Address: bmc.Address, - CredentialsName: secretName, - }, - BootMode: metal3api.Legacy, - BootMACAddress: bmc.BootMacAddress, + By("Waiting for BMO update to rollout") + Eventually(func() bool { + return DeploymentRolledOut(ctx, upgradeClusterProxy, bmoDeployName, bmoIronicNamespace, deploy.Status.ObservedGeneration+1) }, - } - err := upgradeClusterProxy.GetClient().Create(ctx, &bmh) - Expect(err).NotTo(HaveOccurred()) + e2eConfig.GetIntervals("default", "wait-deployment")..., + ).Should(BeTrue()) - By("Waiting for the BMH to become available") - WaitForBmhInProvisioningState(ctx, WaitForBmhInProvisioningStateInput{ - Client: upgradeClusterProxy.GetClient(), - Bmh: bmh, - State: metal3api.StateAvailable, - }, e2eConfig.GetIntervals(specName, "wait-available")...) + By("Patching the BMH to test provisioning") + helper, err := patch.NewHelper(&bmh, upgradeClusterProxy.GetClient()) + Expect(err).NotTo(HaveOccurred()) + bmh.Spec.Image = &metal3api.Image{ + URL: e2eConfig.GetVariable("IMAGE_URL"), + Checksum: e2eConfig.GetVariable("IMAGE_CHECKSUM"), + } + bmh.Spec.RootDeviceHints = &metal3api.RootDeviceHints{ + DeviceName: "/dev/vda", + } + Expect(helper.Patch(ctx, &bmh)).To(Succeed()) - By("Upgrading BMO deployment") - clientSet := upgradeClusterProxy.GetClientSet() - bmoDeployName := "baremetal-operator-controller-manager" - deploy, err := clientSet.AppsV1().Deployments(bmoIronicNamespace).Get(ctx, bmoDeployName, metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred()) - bmoKustomization := e2eConfig.GetVariable("BMO_KUSTOMIZATION") - bmoKustomizationName := filepath.Base(bmoKustomization) - err = BuildAndApplyKustomization(ctx, &BuildAndApplyKustomizationInput{ - Kustomization: bmoKustomization, - ClusterProxy: upgradeClusterProxy, - WaitForDeployment: false, - WatchDeploymentLogs: true, - DeploymentName: "baremetal-operator-controller-manager", - DeploymentNamespace: bmoIronicNamespace, - LogPath: filepath.Join(artifactFolder, "logs", fmt.Sprintf("%s-%s", bmoIronicNamespace, specName), fmt.Sprintf("bmo-%s", bmoKustomizationName)), - WaitIntervals: e2eConfig.GetIntervals("default", "wait-deployment"), - }) - DeferCleanup(func() { - By("Removing BMO main e2e deployment") - BuildAndRemoveKustomization(ctx, bmoKustomization, upgradeClusterProxy) + By("Waiting for the BMH to become provisioned") + WaitForBmhInProvisioningState(ctx, WaitForBmhInProvisioningStateInput{ + Client: upgradeClusterProxy.GetClient(), + Bmh: bmh, + State: metal3api.StateProvisioned, + }, e2eConfig.GetIntervals(specName, "wait-provisioned")...) }) - Expect(err).NotTo(HaveOccurred()) - By("Waiting for BMO update to rollout") - Eventually(func() bool { - return DeploymentRolledOut(ctx, upgradeClusterProxy, bmoDeployName, bmoIronicNamespace, deploy.Status.ObservedGeneration+1) - }, - e2eConfig.GetIntervals("default", "wait-deployment")..., - ).Should(BeTrue()) - - By("Patching the BMH to test provisioning") - helper, err := patch.NewHelper(&bmh, upgradeClusterProxy.GetClient()) - Expect(err).NotTo(HaveOccurred()) - bmh.Spec.Image = &metal3api.Image{ - URL: e2eConfig.GetVariable("IMAGE_URL"), - Checksum: e2eConfig.GetVariable("IMAGE_CHECKSUM"), - } - bmh.Spec.RootDeviceHints = &metal3api.RootDeviceHints{ - DeviceName: "/dev/vda", - } - Expect(helper.Patch(ctx, &bmh)).To(Succeed()) - - By("Waiting for the BMH to become provisioned") - WaitForBmhInProvisioningState(ctx, WaitForBmhInProvisioningStateInput{ - Client: upgradeClusterProxy.GetClient(), - Bmh: bmh, - State: metal3api.StateProvisioned, - }, e2eConfig.GetIntervals(specName, "wait-provisioned")...) - }) + } AfterEach(func() { cleanup(ctx, upgradeClusterProxy, namespace, cancelWatches, e2eConfig.GetIntervals("default", "wait-namespace-deleted")...) - if !skipCleanup { - if upgradeClusterProxy != nil { - upgradeClusterProxy.Dispose(ctx) - } - if upgradeClusterProvider != nil { - upgradeClusterProvider.Dispose(ctx) - } - } }) })