diff --git a/scripts/ci-e2e.sh b/scripts/ci-e2e.sh index 27bf756a8..211ffa0e3 100755 --- a/scripts/ci-e2e.sh +++ b/scripts/ci-e2e.sh @@ -43,6 +43,7 @@ export NUM_NODES=${NUM_NODES:-"4"} export KUBERNETES_VERSION=${KUBERNETES_VERSION} export IMAGE_OS=${IMAGE_OS} export FORCE_REPO_UPDATE="false" +export USE_IRSO="${USE_IRSO:-false}" EOF # if running a scalability test skip apply bmhs in dev-env and run fakeIPA if [[ ${GINKGO_FOCUS:-} == "clusterctl-upgrade" ]]; then diff --git a/test/e2e/cert_rotation.go b/test/e2e/cert_rotation.go index dda47ea83..049641957 100644 --- a/test/e2e/cert_rotation.go +++ b/test/e2e/cert_rotation.go @@ -29,7 +29,7 @@ func certRotation(ctx context.Context, inputGetter func() CertRotationInput) { input := inputGetter() clientSet := input.ManagementCluster.GetClientSet() clusterClient := input.ManagementCluster.GetClient() - mariadbEnabled := input.E2EConfig.GetVariable(ironicMariadb) == "true" + mariadbEnabled := GetBoolVariable(input.E2EConfig, ironicMariadb) By("Check if Ironic pod is running") ironicNamespace := input.E2EConfig.GetVariable("NAMEPREFIX") + "-system" ironicDeploymentName := input.E2EConfig.GetVariable("NAMEPREFIX") + ironicSuffix diff --git a/test/e2e/common.go b/test/e2e/common.go index 68d794777..fa036fe20 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -126,6 +126,19 @@ func getSha256Hash(filename string) ([]byte, error) { return hash.Sum(nil), nil } +var falseValues = []string{"", "false", "no"} + +// GetBoolVariable returns a variable from environment variables or from the e2e config file as boolean. +func GetBoolVariable(e2eConfig *clusterctl.E2EConfig, varName string) bool { + value := e2eConfig.GetVariable(varName) + for _, falseVal := range falseValues { + if strings.EqualFold(value, falseVal) { + return false + } + } + return true +} + // TODO change this function to handle multiple workload(target) clusters. func DumpSpecResourcesAndCleanup(ctx context.Context, specName string, bootstrapClusterProxy framework.ClusterProxy, targetClusterProxy framework.ClusterProxy, artifactFolder string, namespace string, intervalsGetter func(spec, key string) []interface{}, clusterName, clusterctlLogFolder string, skipCleanup bool) { Expect(os.RemoveAll(clusterctlLogFolder)).Should(Succeed()) diff --git a/test/e2e/config/e2e_conf.yaml b/test/e2e/config/e2e_conf.yaml index edf4b74d5..7b63b75f0 100644 --- a/test/e2e/config/e2e_conf.yaml +++ b/test/e2e/config/e2e_conf.yaml @@ -259,6 +259,7 @@ variables: IRONIC_BASIC_AUTH: "true" IRONIC_KEEPALIVED: "true" IRONIC_USE_MARIADB: "false" + USE_IRSO: "false" RESTART_CONTAINER_CERTIFICATE_UPDATED: "true" CONTAINER_REGISTRY: "${CONTAINER_REGISTRY:-quay.io}" DOCKER_HUB_PROXY: "${DOCKER_HUB_PROXY:-docker.io}" diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index b78c303aa..5a2af4bbf 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -14,6 +14,7 @@ import ( bmov1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1" infrav1 "github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1" ipamv1 "github.com/metal3-io/ip-address-manager/api/v1alpha1" + irsov1alpha1 "github.com/metal3-io/ironic-standalone-operator/api/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "gopkg.in/yaml.v3" @@ -165,6 +166,7 @@ func initScheme() *runtime.Scheme { Expect(bmov1alpha1.AddToScheme(sc)).To(Succeed()) Expect(infrav1.AddToScheme(sc)).To(Succeed()) Expect(ipamv1.AddToScheme(sc)).To(Succeed()) + Expect(irsov1alpha1.AddToScheme(sc)).To(Succeed()) return sc } diff --git a/test/e2e/pivoting.go b/test/e2e/pivoting.go index 38425b349..c79246469 100644 --- a/test/e2e/pivoting.go +++ b/test/e2e/pivoting.go @@ -12,6 +12,7 @@ import ( containerTypes "github.com/docker/docker/api/types/container" docker "github.com/docker/docker/client" bmov1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1" + irsov1alpha1 "github.com/metal3-io/ironic-standalone-operator/api/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -109,14 +110,16 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) { Expect(er).ToNot(HaveOccurred(), "Cannot fetch target cluster kubeconfig") By("Remove Ironic containers from the source cluster") - isIronicDeployment := true + ironicDeploymentType := IronicDeploymentTypeBMO if ephemeralCluster == Kind { - isIronicDeployment = false + ironicDeploymentType = IronicDeploymentTypeLocal + } else if GetBoolVariable(input.E2EConfig, "USE_IRSO") { + ironicDeploymentType = IronicDeploymentTypeIrSO } removeIronic(ctx, func() RemoveIronicInput { return RemoveIronicInput{ ManagementCluster: input.BootstrapClusterProxy, - IsDeployment: isIronicDeployment, + DeploymentType: ironicDeploymentType, Namespace: input.E2EConfig.GetVariable(ironicNamespace), NamePrefix: input.E2EConfig.GetVariable(NamePrefix), } @@ -151,6 +154,7 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) { labelHDCRDs(ctx, input.BootstrapClusterProxy) By("Install Ironic in the target cluster") + // TODO(dtantsur): support ironic-standalone-operator installIronicBMO(ctx, func() installIronicBMOInput { return installIronicBMOInput{ ManagementCluster: input.TargetCluster, @@ -340,16 +344,24 @@ func installIronicBMO(ctx context.Context, inputGetter func() installIronicBMOIn } } +type IronicDeploymentType string + +const ( + IronicDeploymentTypeLocal IronicDeploymentType = "local" + IronicDeploymentTypeBMO IronicDeploymentType = "deploy.sh" + IronicDeploymentTypeIrSO IronicDeploymentType = "irso" +) + type RemoveIronicInput struct { ManagementCluster framework.ClusterProxy - IsDeployment bool + DeploymentType IronicDeploymentType Namespace string NamePrefix string } func removeIronic(ctx context.Context, inputGetter func() RemoveIronicInput) { input := inputGetter() - if input.IsDeployment { + if input.DeploymentType == IronicDeploymentTypeBMO { deploymentName := input.NamePrefix + ironicSuffix RemoveDeployment(ctx, func() RemoveDeploymentInput { return RemoveDeploymentInput{ @@ -358,6 +370,16 @@ func removeIronic(ctx context.Context, inputGetter func() RemoveIronicInput) { Name: deploymentName, } }) + } else if input.DeploymentType == IronicDeploymentTypeIrSO { + // NOTE(dtantsur): metal3-dev-env hardcodes the name "ironic". + ironicObj := &irsov1alpha1.Ironic{ + ObjectMeta: metav1.ObjectMeta{ + Name: "ironic", + Namespace: input.Namespace, + }, + } + err := input.ManagementCluster.GetClient().Delete(ctx, ironicObj) + Expect(err).ToNot(HaveOccurred(), "Failed to delete Ironic") } else { ironicContainerList := []string{ "ironic", @@ -445,10 +467,12 @@ func rePivoting(ctx context.Context, inputGetter func() RePivotingInput) { os.Unsetenv("KUBECONFIG_WORKLOAD") By("Remove Ironic deployment from target cluster") + ironicDeploymentType := IronicDeploymentTypeBMO + // TODO(dtantsur): support USE_IRSO in the target cluster removeIronic(ctx, func() RemoveIronicInput { return RemoveIronicInput{ ManagementCluster: input.TargetCluster, - IsDeployment: true, + DeploymentType: ironicDeploymentType, Namespace: input.E2EConfig.GetVariable(ironicNamespace), NamePrefix: input.E2EConfig.GetVariable(NamePrefix), } diff --git a/test/e2e/upgrade_clusterctl_test.go b/test/e2e/upgrade_clusterctl_test.go index d7d7596b2..b8fedf125 100644 --- a/test/e2e/upgrade_clusterctl_test.go +++ b/test/e2e/upgrade_clusterctl_test.go @@ -219,14 +219,16 @@ func preInitFunc(clusterProxy framework.ClusterProxy, bmoRelease string, ironicR // Remove ironic By("Remove Ironic containers from the source cluster") ephemeralCluster := os.Getenv("EPHEMERAL_CLUSTER") - isIronicDeployment := true + ironicDeploymentType := IronicDeploymentTypeBMO if ephemeralCluster == Kind { - isIronicDeployment = false + ironicDeploymentType = IronicDeploymentTypeLocal + } else if GetBoolVariable(e2eConfig, "USE_IRSO") { + ironicDeploymentType = IronicDeploymentTypeIrSO } removeIronic(ctx, func() RemoveIronicInput { return RemoveIronicInput{ ManagementCluster: bootstrapClusterProxy, - IsDeployment: isIronicDeployment, + DeploymentType: ironicDeploymentType, Namespace: e2eConfig.GetVariable(ironicNamespace), NamePrefix: e2eConfig.GetVariable(NamePrefix), } @@ -377,10 +379,12 @@ func preCleanupManagementCluster(clusterProxy framework.ClusterProxy, ironicRele Expect(err).NotTo(HaveOccurred()) } } + ironicDeploymentType := IronicDeploymentTypeBMO + // TODO(dtantsur): support USE_IRSO in the target cluster removeIronic(ctx, func() RemoveIronicInput { return RemoveIronicInput{ ManagementCluster: clusterProxy, - IsDeployment: true, + DeploymentType: ironicDeploymentType, Namespace: e2eConfig.GetVariable(ironicNamespace), NamePrefix: e2eConfig.GetVariable(NamePrefix), } diff --git a/test/go.mod b/test/go.mod index 0d9916088..b35c656ee 100644 --- a/test/go.mod +++ b/test/go.mod @@ -9,6 +9,7 @@ require ( github.com/metal3-io/baremetal-operator/apis v0.9.0 github.com/metal3-io/cluster-api-provider-metal3/api v0.0.0 github.com/metal3-io/ip-address-manager/api v1.9.2 + github.com/metal3-io/ironic-standalone-operator v0.0.0-20241223110838-7a780c05847c github.com/onsi/ginkgo/v2 v2.22.2 github.com/onsi/gomega v1.36.2 github.com/pkg/errors v0.9.1 @@ -138,6 +139,7 @@ require ( go.opentelemetry.io/otel/trace v1.28.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/multierr v1.11.0 // indirect + go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/net v0.34.0 // indirect golang.org/x/oauth2 v0.24.0 // indirect diff --git a/test/go.sum b/test/go.sum index 3ac0e531d..6ecf14b47 100644 --- a/test/go.sum +++ b/test/go.sum @@ -178,6 +178,8 @@ github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.9.0 h1:4xilUV03Z2OP github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.9.0/go.mod h1:f1a/eqi7MA+mf1xFshToVfn02jcPDMw3aYQinLTlMVQ= github.com/metal3-io/ip-address-manager/api v1.9.2 h1:8pFVk2jhs3zpijIbr9nKaqKPPvg323Z2QKLBNRrKL2Y= github.com/metal3-io/ip-address-manager/api v1.9.2/go.mod h1:l4tGHeMiR3VfwAxOKw1O7f+3y9waB1tDQ0AVbRp9zoc= +github.com/metal3-io/ironic-standalone-operator v0.0.0-20241223110838-7a780c05847c h1:FUHVXXaaQA1PXlBI01u3WvFWm3Qqt662LUe80Ptrfqk= +github.com/metal3-io/ironic-standalone-operator v0.0.0-20241223110838-7a780c05847c/go.mod h1:+m9iKBZTR43Qtz+JGevTeDh73p9+ISjjfEr3DM+IzDA= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -310,6 +312,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= +go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=