Skip to content
Open
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
8 changes: 6 additions & 2 deletions Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.22 AS builder
WORKDIR /go/src/github.com/openshift/cluster-capi-operator
COPY . .
RUN make build
RUN make build && \
gzip bin/cluster-capi-operator-ext

FROM registry.ci.openshift.org/ocp/4.22:base-rhel9
COPY --from=builder /go/src/github.com/openshift/cluster-capi-operator/bin/cluster-capi-operator .
COPY --from=builder /go/src/github.com/openshift/cluster-capi-operator/bin/machine-api-migration .
COPY --from=builder /go/src/github.com/openshift/cluster-capi-operator/manifests /manifests
COPY --from=builder /go/src/github.com/openshift/cluster-capi-operator/bin/cluster-capi-operator-ext.gz .

LABEL io.openshift.release.operator true
LABEL io.k8s.display-name="OpenShift Cluster CAPI Operator" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a separate docker file for the tests extension? I'm not sure we're shipping this as part of payload?

That being said, I'm not sure what existing patterns exist here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @theobarberbany no separate docker file needed, other similar implementations also modify their existing docker file to include the extension binary, it ships as part of the operator payload, openShift's test framework discovers it via the label and extracts it when needed.

  • machine-api-operator #1338
  • cloud-provider-aws #117
  • cluster-control-plane-machine-set-operator #372

io.openshift.release.operator=true \
io.openshift.tags="openshift,tests,e2e,e2e-extension"
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ifeq ($(HOME), /)
HOME = /tmp/kubebuilder-testing
endif

.PHONY: help all verify test build operator migration manifests-gen unit e2e run fmt vet lint vendor image push aws-cluster azure-cluster gcp-cluster powervs-cluster vsphere-cluster
.PHONY: help all verify test build operator migration manifests-gen tests-ext unit e2e run fmt vet lint vendor image push aws-cluster azure-cluster gcp-cluster powervs-cluster vsphere-cluster
.DEFAULT_GOAL := build

help: ## Display this help message
Expand All @@ -29,7 +29,7 @@ verify: fmt lint ## Run formatting and linting checks

test: verify unit ## Run verification and unit tests

build: operator migration manifests-gen ## Build all binaries
build: operator migration manifests-gen tests-ext ## Build all binaries

# Ensure bin directory exists for build outputs
bin/:
Expand All @@ -44,6 +44,9 @@ operator: | bin/ ## Build cluster-capi-operator binary
migration: | bin/ ## Build machine-api-migration binary
go build -o bin/machine-api-migration cmd/machine-api-migration/main.go

tests-ext: | bin/ ## Build tests extension binary
cd openshift-tests-extension && go build -o ../bin/cluster-capi-operator-ext ./cmd

.PHONY: localtestenv
localtestenv: .localtestenv

Expand All @@ -53,7 +56,7 @@ localtestenv: .localtestenv

TEST_DIRS ?= ./pkg/... ./manifests-gen/...
unit: .localtestenv ## Run unit tests
./hack/test.sh "$(TEST_DIRS)" 10m
./hack/test.sh "$(TEST_DIRS)" 20m

.PHONY: e2e
e2e: ## Run e2e tests against active kubeconfig
Expand Down
3 changes: 2 additions & 1 deletion e2e/aws_test.go → e2e/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
)

var _ = Describe("Cluster API AWS MachineSet", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][Feature:ClusterAPI][platform:aws][Disruptive] Cluster API AWS MachineSet", Ordered, Label("Conformance"), Label("Serial"), func() {
var (
awsMachineTemplate *awsv1.AWSMachineTemplate
machineSet *clusterv1.MachineSet
Expand All @@ -22,6 +22,7 @@ var _ = Describe("Cluster API AWS MachineSet", Ordered, func() {
)

BeforeAll(func() {
InitCommonVariables()
if platform != configv1.AWSPlatformType {
Skip("Skipping AWS E2E tests")
}
Expand Down
5 changes: 3 additions & 2 deletions e2e/azure_test.go → e2e/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ const (
capzManagerBootstrapCredentials = "capz-manager-bootstrap-credentials"
)

var _ = Describe("Cluster API Azure MachineSet", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][Feature:ClusterAPI][platform:azure][Disruptive] Cluster API Azure MachineSet", Ordered, Label("Conformance"), Label("Serial"), func() {
var azureMachineTemplate *azurev1.AzureMachineTemplate
var machineSet *clusterv1.MachineSet
var mapiMachineSpec *mapiv1beta1.AzureMachineProviderSpec

BeforeAll(func() {
InitCommonVariables()
if platform != configv1.AzurePlatformType {
Skip("Skipping Azure E2E tests")
}
Expand Down Expand Up @@ -114,7 +115,7 @@ func createAzureMachineTemplate(ctx context.Context, cl client.Client, mapiProvi
if mi := mapiProviderSpec.ManagedIdentity; mi != "" {
providerID := mi
if !strings.HasPrefix(mi, "/subscriptions/") {
providerID = fmt.Sprintf("azure:///subscriptions/%s/resourcegroups/%s/providers/Microsoft.ManagedIdentity/userAssignedIdentities/%s", subscriptionID, mapiProviderSpec.ResourceGroup, mi)
providerID = fmt.Sprintf("azure:///subscriptions/%s/resourcegroups/%s/providers/Microsoft.ManagedIdentity/userAssignedIdentities/%s", string(subscriptionID), mapiProviderSpec.ResourceGroup, mi)
}
userAssignedIdentities = []azurev1.UserAssignedIdentity{{ProviderID: providerID}}
identity = azurev1.VMIdentityUserAssigned
Expand Down
3 changes: 2 additions & 1 deletion e2e/baremetal_test.go → e2e/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ const (
baremetalMachineTemplateName = "baremetal-machine-template"
)

var _ = Describe("Cluster API Baremetal MachineSet", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][Feature:ClusterAPI][platform:baremetal][Disruptive] Cluster API Baremetal MachineSet", Ordered, Label("Conformance"), Label("Serial"), func() {
var baremetalMachineTemplate *metal3v1.Metal3MachineTemplate
var machineSet *clusterv1.MachineSet
var mapiMachineSpec *bmv1alpha1.BareMetalMachineProviderSpec

BeforeAll(func() {
InitCommonVariables()
if platform != configv1.BareMetalPlatformType {
Skip("Skipping Baremetal E2E tests")
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/framework/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

// CreateCluster creates a cluster with the given name and returns the cluster object.
// CreateCoreCluster creates a cluster with the given name and returns the cluster object.
func CreateCoreCluster(ctx context.Context, cl client.Client, clusterName, infraClusterKind string) *clusterv1.Cluster {
By("Creating core cluster")

Expand Down
5 changes: 3 additions & 2 deletions e2e/gcp_test.go → e2e/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ const (
gcpMachineTemplateName = "gcp-machine-template"
)

var _ = Describe("Cluster API GCP MachineSet", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][Feature:ClusterAPI][platform:gcp][Disruptive] Cluster API GCP MachineSet", Ordered, Label("Conformance"), Label("Serial"), func() {
var gcpMachineTemplate *gcpv1.GCPMachineTemplate
var machineSet *clusterv1.MachineSet
var mapiMachineSpec *mapiv1beta1.GCPMachineProviderSpec

BeforeAll(func() {
InitCommonVariables()
if platform != configv1.GCPPlatformType {
Skip("Skipping GCP E2E tests")
}
Expand Down Expand Up @@ -91,9 +92,9 @@ func createGCPMachineTemplate(ctx context.Context, cl client.Client, mapiProvide
Expect(len(mapiProviderSpec.NetworkInterfaces)).To(BeNumerically(">", 0))
Expect(mapiProviderSpec.NetworkInterfaces[0].Subnetwork).ToNot(BeEmpty())
Expect(mapiProviderSpec.ServiceAccounts).ToNot(BeNil())
Expect(len(mapiProviderSpec.ServiceAccounts)).To(BeNumerically(">", 0))
Expect(mapiProviderSpec.ServiceAccounts[0].Email).ToNot(BeEmpty())
Expect(mapiProviderSpec.ServiceAccounts[0].Scopes).ToNot(BeNil())
Expect(len(mapiProviderSpec.ServiceAccounts)).To(BeNumerically(">", 0))
Expect(mapiProviderSpec.Tags).ToNot(BeNil())
Expect(len(mapiProviderSpec.Tags)).To(BeNumerically(">", 0))

Expand Down
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d
sigs.k8s.io/cluster-api v1.11.3
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.0
sigs.k8s.io/cluster-api-provider-azure v0.0.0-20251202084521-c2e0e38d1e0e
sigs.k8s.io/cluster-api-provider-azure v1.20.2
sigs.k8s.io/cluster-api-provider-gcp v1.11.0-beta.0
sigs.k8s.io/cluster-api-provider-ibmcloud v0.12.0
sigs.k8s.io/cluster-api-provider-openstack v0.13.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
)

var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Machine Migration CAPI Authoritative Tests", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration][platform:aws][Disruptive] Machine Migration CAPI Authoritative Tests", Ordered, Label("Conformance"), Label("Serial"), func() {
BeforeAll(func() {
InitCommonVariables()
if platform != configv1.AWSPlatformType {
Skip(fmt.Sprintf("Skipping tests on %s, this is only supported on AWS", platform))
}
Expand Down Expand Up @@ -63,13 +64,14 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
Context("with spec.authoritativeAPI: ClusterAPI and no existing CAPI Machine with same name", func() {
BeforeAll(func() {
newMapiMachine = createMAPIMachineWithAuthority(ctx, cl, mapiMachineAuthCAPIName, mapiv1beta1.MachineAuthorityClusterAPI)
newCapiMachine = capiframework.GetMachine(cl, newMapiMachine.Name, capiframework.CAPINamespace)

DeferCleanup(func() {
By("Cleaning up machine resources")
cleanupMachineResources(
ctx,
cl,
[]*clusterv1.Machine{},
[]*clusterv1.Machine{newCapiMachine},
[]*mapiv1beta1.Machine{newMapiMachine},
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
)

var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Machine Migration MAPI Authoritative Tests", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration][platform:aws][Disruptive] Machine Migration MAPI Authoritative Tests", Ordered, Label("Conformance"), Label("Serial"), func() {
BeforeAll(func() {
InitCommonVariables()
if platform != configv1.AWSPlatformType {
Skip(fmt.Sprintf("Skipping tests on %s, this is only supported on AWS", platform))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
)

var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] MachineSet Migration CAPI Authoritative Tests", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration][platform:aws][Disruptive] MachineSet Migration CAPI Authoritative Tests", Ordered, Label("Conformance"), Label("Serial"), func() {
BeforeAll(func() {
InitCommonVariables()
if platform != configv1.AWSPlatformType {
Skip(fmt.Sprintf("Skipping tests on %s, this is only supported on AWS", platform))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest/komega"
)

var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] MachineSet Migration MAPI Authoritative Tests", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration][platform:aws][Disruptive] MachineSet Migration MAPI Authoritative Tests", Ordered, Label("Conformance"), Label("Serial"), func() {
var k komega.Komega

BeforeAll(func() {
InitCommonVariables()
if platform != configv1.AWSPlatformType {
Skip(fmt.Sprintf("Skipping tests on %s, this is only supported on AWS", platform))
}
Expand Down Expand Up @@ -73,7 +74,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
cleanupMachineSetTestResources(
ctx,
cl,
[]*clusterv1.MachineSet{},
[]*clusterv1.MachineSet{capiMachineSet},
[]*awsv1.AWSMachineTemplate{awsMachineTemplate},
[]*mapiv1beta1.MachineSet{mapiMachineSet},
)
Expand Down Expand Up @@ -320,7 +321,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
By("Verifying new InfraTemplate has the updated InstanceType")
var err error
newAWSMachineTemplate, err = capiframework.GetAWSMachineTemplateByPrefix(cl, mapiMSAuthMAPIName, capiframework.CAPINamespace)
Expect(err).ToNot(HaveOccurred(), "Failed to get new awsMachineTemplate %s", newAWSMachineTemplate)
Expect(err).ToNot(HaveOccurred(), "Failed to get new awsMachineTemplate %s", newAWSMachineTemplate)
Expect(newAWSMachineTemplate.Spec.Template.Spec.InstanceType).To(Equal(newInstanceType))

By("Verifying the old InfraTemplate is deleted")
Expand All @@ -343,7 +344,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
verifyMachinesetReplicas(capiMachineSet, 0)
})

It("should be rejected when when updating providerSpec of MAPI MachineSet", func() {
It("should be rejected when updating providerSpec of MAPI MachineSet", func() {
By("Getting the current MAPI MachineSet providerSpec InstanceType")
originalSpec := getAWSProviderSpecFromMachineSet(mapiMachineSet)

Expand Down
6 changes: 3 additions & 3 deletions e2e/powervs_test.go → e2e/powervs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package e2e

import (
"context"
"fmt"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -25,12 +24,13 @@ const (
powerVSMachineTemplateVersion = "infrastructure.cluster.x-k8s.io/v1beta2"
)

var _ = Describe("Cluster API IBMPowerVS MachineSet", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][Feature:ClusterAPI][platform:powervs][Disruptive] Cluster API IBMPowerVS MachineSet", Ordered, Label("Conformance"), Label("Serial"), func() {
var powerVSMachineTemplate *ibmpowervsv1.IBMPowerVSMachineTemplate
var machineSet *clusterv1.MachineSet
var mapiMachineSpec *mapiv1.PowerVSMachineProviderConfig

BeforeAll(func() {
InitCommonVariables()
if platform != configv1.PowerVSPlatformType {
Skip("Skipping PowerVS E2E tests")
}
Expand Down Expand Up @@ -91,6 +91,7 @@ func createIBMPowerVSMachineTemplate(ctx context.Context, cl client.Client, mapi
Expect(mapiProviderSpec.Image).ToNot(BeNil())
Expect(mapiProviderSpec.SystemType).ToNot(BeEmpty())
Expect(mapiProviderSpec.ProcessorType).ToNot(BeEmpty())
Expect(mapiProviderSpec.Network.Type).ToNot(BeEmpty())

ibmPowerVSMachineSpec := ibmpowervsv1.IBMPowerVSMachineSpec{
ServiceInstance: getServiceInstance(mapiProviderSpec.ServiceInstance),
Expand Down Expand Up @@ -118,7 +119,6 @@ func createIBMPowerVSMachineTemplate(ctx context.Context, cl client.Client, mapi
}

if err := cl.Create(ctx, ibmPowerVSMachineTemplate); err != nil && !apierrors.IsAlreadyExists(err) {
fmt.Println(err)
Expect(err).ToNot(HaveOccurred())
}

Expand Down
5 changes: 3 additions & 2 deletions e2e/vsphere_test.go → e2e/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ const (
vSphereCredentialsName = "vsphere-creds"
)

var _ = Describe("Cluster API vSphere MachineSet", Ordered, func() {
var _ = Describe("[sig-cluster-lifecycle][Feature:ClusterAPI][platform:vsphere][Disruptive] Cluster API vSphere MachineSet", Ordered, Label("Conformance"), Label("Serial"), func() {
var vSphereMachineTemplate *vspherev1.VSphereMachineTemplate
var machineSet *clusterv1.MachineSet
var mapiMachineSpec *mapiv1beta1.VSphereMachineProviderSpec

BeforeAll(func() {
InitCommonVariables()
if platform != configv1.VSpherePlatformType {
Skip("Skipping vSphere E2E tests")
}
Expand Down Expand Up @@ -226,7 +227,7 @@ func createVSphereMachineTemplate(cl client.Client, mapiProviderSpec *mapiv1beta
}

if err := cl.Create(ctx, vSphereMachineTemplate); err != nil && !apierrors.IsAlreadyExists(err) {
Expect(err).ToNot(HaveOccurred(), "should not error creating the VSphere Cluster object")
Expect(err).ToNot(HaveOccurred(), "should not error creating the VSphereMachineTemplate object")
}

return vSphereMachineTemplate
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require (
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d
sigs.k8s.io/cluster-api v1.11.3
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.0
sigs.k8s.io/cluster-api-provider-azure v0.0.0-20251202084521-c2e0e38d1e0e
sigs.k8s.io/cluster-api-provider-azure v1.20.2
sigs.k8s.io/cluster-api-provider-gcp v1.11.0-beta.0
sigs.k8s.io/cluster-api-provider-ibmcloud v0.12.0
sigs.k8s.io/cluster-api-provider-openstack v0.13.1
Expand Down
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use (
./e2e
./hack/tools
./manifests-gen
./openshift-tests-extension
)

replace (
Expand Down
Loading