Skip to content

Commit

Permalink
Merge pull request #2203 from dtantsur/ironic-standalone-operator
Browse files Browse the repository at this point in the history
🌱 e2e: account for ironic-standalone-operator in pivoting tests
  • Loading branch information
metal3-io-bot authored Jan 13, 2025
2 parents bd0d602 + 538a546 commit 24e9e9f
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 11 deletions.
1 change: 1 addition & 0 deletions scripts/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/cert_rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions test/e2e/config/e2e_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
36 changes: 30 additions & 6 deletions test/e2e/pivoting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand All @@ -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",
Expand Down Expand Up @@ -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),
}
Expand Down
12 changes: 8 additions & 4 deletions test/e2e/upgrade_clusterctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down Expand Up @@ -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),
}
Expand Down
2 changes: 2 additions & 0 deletions test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down

0 comments on commit 24e9e9f

Please sign in to comment.