Skip to content

Commit f75013f

Browse files
pmeidaclaude
andcommitted
OCPCLOUD-3507: Add OTE e2e tests for ClusterAPIMachineManagement feature gate
Add 10 non-disruptive health-check tests registered with the OTE binary that validate the Cluster API stack is correctly installed and operational when the ClusterAPIMachineManagement feature gate is enabled. Tests provide the Sippy signal required for feature gate promotion. Tests (all blocking, capio/parallel): - capi-operator deployment available in openshift-cluster-api-operator - cluster-api ClusterOperator reporting Available, not Degraded, not Progressing - capi-controllers deployment available in openshift-cluster-api - capi-installer deployment available in openshift-cluster-api-operator - capi-installer-images ConfigMap present in openshift-cluster-api-operator - Core CAPI CRDs (clusters, machines, machinesets) installed and established - Platform-specific infrastructure CRDs installed (derived from Cluster.Spec.InfrastructureRef) - Management Cluster object present with InfrastructureReady=True - Platform-specific infrastructure cluster object present (AWSCluster etc.) - Management cluster kubeconfig Secret present Platform-specific tests derive the infra Kind from the live Cluster object's InfrastructureRef rather than a hardcoded platform map, so no code changes are needed when new platforms are added. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 5656e20 commit f75013f

1 file changed

Lines changed: 201 additions & 0 deletions

File tree

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
// Copyright 2026 Red Hat, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package e2e
16+
17+
import (
18+
"fmt"
19+
20+
. "github.com/onsi/ginkgo/v2"
21+
. "github.com/onsi/gomega"
22+
23+
appsv1 "k8s.io/api/apps/v1"
24+
corev1 "k8s.io/api/core/v1"
25+
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
28+
"sigs.k8s.io/controller-runtime/pkg/client"
29+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
30+
31+
configv1 "github.com/openshift/api/config/v1"
32+
"github.com/openshift/api/features"
33+
"github.com/openshift/cluster-capi-operator/e2e/framework"
34+
"github.com/openshift/cluster-capi-operator/pkg/operatorstatus"
35+
"github.com/openshift/cluster-capi-operator/pkg/providerimages"
36+
"github.com/openshift/cluster-capi-operator/pkg/test"
37+
)
38+
39+
40+
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:ClusterAPIMachineManagement] Cluster API Machine Management", Ordered, func() {
41+
BeforeAll(func() {
42+
if !framework.IsFeatureGateEnabled(ctx, cl, features.FeatureGateClusterAPIMachineManagement) {
43+
Skip("Feature gate ClusterAPIMachineManagement is not enabled.")
44+
}
45+
})
46+
47+
Context("Operator & controller deployments", func() {
48+
It("should have the capi-operator deployment available", func() {
49+
deployment := &appsv1.Deployment{}
50+
Eventually(func(g Gomega) {
51+
g.Expect(cl.Get(ctx, client.ObjectKey{
52+
Name: "capi-operator",
53+
Namespace: framework.CAPIOperatorNamespace,
54+
}, deployment)).To(Succeed())
55+
g.Expect(deployment.Status.Conditions).To(ContainElement(SatisfyAll(
56+
HaveField("Type", Equal(appsv1.DeploymentAvailable)),
57+
HaveField("Status", Equal(corev1.ConditionTrue)),
58+
)))
59+
}).WithTimeout(framework.WaitMedium).WithPolling(framework.RetryMedium).Should(Succeed())
60+
})
61+
62+
It("should have the cluster-api ClusterOperator reporting healthy", func() {
63+
co := &configv1.ClusterOperator{}
64+
Eventually(func(g Gomega) {
65+
g.Expect(cl.Get(ctx, client.ObjectKey{Name: operatorstatus.ClusterOperatorName}, co)).To(Succeed())
66+
67+
By("Checking Available=True, Degraded=False, Progressing=False")
68+
g.Expect(co.Status.Conditions).To(SatisfyAll(
69+
test.HaveCondition(configv1.OperatorAvailable).WithStatus(configv1.ConditionTrue),
70+
test.HaveCondition(configv1.OperatorDegraded).WithStatus(configv1.ConditionFalse),
71+
test.HaveCondition(configv1.OperatorProgressing).WithStatus(configv1.ConditionFalse),
72+
))
73+
}).WithTimeout(framework.WaitMedium).WithPolling(framework.RetryMedium).Should(Succeed())
74+
})
75+
76+
It("should have the capi-controllers deployment available", func() {
77+
deployment := &appsv1.Deployment{}
78+
Eventually(func(g Gomega) {
79+
g.Expect(cl.Get(ctx, client.ObjectKey{
80+
Name: "capi-controllers",
81+
Namespace: framework.CAPINamespace,
82+
}, deployment)).To(Succeed())
83+
g.Expect(deployment.Status.Conditions).To(ContainElement(SatisfyAll(
84+
HaveField("Type", Equal(appsv1.DeploymentAvailable)),
85+
HaveField("Status", Equal(corev1.ConditionTrue)),
86+
)))
87+
}).WithTimeout(framework.WaitMedium).WithPolling(framework.RetryMedium).Should(Succeed())
88+
})
89+
90+
It("should have the capi-installer deployment available", func() {
91+
deployment := &appsv1.Deployment{}
92+
Eventually(func(g Gomega) {
93+
g.Expect(cl.Get(ctx, client.ObjectKey{
94+
Name: "capi-installer",
95+
Namespace: framework.CAPIOperatorNamespace,
96+
}, deployment)).To(Succeed())
97+
g.Expect(deployment.Status.Conditions).To(ContainElement(SatisfyAll(
98+
HaveField("Type", Equal(appsv1.DeploymentAvailable)),
99+
HaveField("Status", Equal(corev1.ConditionTrue)),
100+
)))
101+
}).WithTimeout(framework.WaitMedium).WithPolling(framework.RetryMedium).Should(Succeed())
102+
})
103+
104+
})
105+
106+
Context("Provider images & initialization", func() {
107+
It("should have the capi-installer-images ConfigMap present", func() {
108+
cm := &corev1.ConfigMap{}
109+
Expect(cl.Get(ctx, client.ObjectKey{
110+
Name: providerimages.ConfigMapName,
111+
Namespace: framework.CAPIOperatorNamespace,
112+
}, cm)).To(Succeed())
113+
Expect(cm.Data).NotTo(BeEmpty())
114+
})
115+
})
116+
117+
Context("CRD & API readiness", func() {
118+
It("should have core Cluster API CRDs installed and established", func() {
119+
for _, name := range []string{
120+
"clusters.cluster.x-k8s.io",
121+
"machines.cluster.x-k8s.io",
122+
"machinesets.cluster.x-k8s.io",
123+
} {
124+
crd := &apiextensionsv1.CustomResourceDefinition{}
125+
126+
By("Fetching CRD " + name)
127+
Expect(cl.Get(ctx, client.ObjectKey{Name: name}, crd)).To(Succeed())
128+
129+
By("Verifying CRD " + name + " is established")
130+
Expect(crd.Status.Conditions).To(ContainElement(SatisfyAll(
131+
HaveField("Type", Equal(apiextensionsv1.Established)),
132+
HaveField("Status", Equal(apiextensionsv1.ConditionTrue)),
133+
)))
134+
}
135+
})
136+
137+
It("should have platform-specific infrastructure CRDs installed", func() {
138+
cluster := &clusterv1.Cluster{}
139+
Expect(cl.Get(ctx, client.ObjectKey{Name: clusterName, Namespace: framework.CAPINamespace}, cluster)).To(Succeed())
140+
141+
mapping, err := cl.RESTMapper().RESTMapping(cluster.Spec.InfrastructureRef.GroupKind())
142+
Expect(err).NotTo(HaveOccurred())
143+
144+
crdName := mapping.Resource.Resource + "." + mapping.Resource.Group
145+
crd := &apiextensionsv1.CustomResourceDefinition{}
146+
147+
By("Fetching the infrastructure CRD " + crdName)
148+
Expect(cl.Get(ctx, client.ObjectKey{Name: crdName}, crd)).To(Succeed())
149+
150+
By("Verifying the infrastructure CRD is established")
151+
Expect(crd.Status.Conditions).To(ContainElement(SatisfyAll(
152+
HaveField("Type", Equal(apiextensionsv1.Established)),
153+
HaveField("Status", Equal(apiextensionsv1.ConditionTrue)),
154+
)))
155+
})
156+
})
157+
158+
Context("Management cluster resources", func() {
159+
It("should have the management Cluster object present and infrastructure ready", func() {
160+
cluster := &clusterv1.Cluster{}
161+
Eventually(func(g Gomega) {
162+
g.Expect(cl.Get(ctx, client.ObjectKey{
163+
Name: clusterName,
164+
Namespace: framework.CAPINamespace,
165+
}, cluster)).To(Succeed())
166+
167+
By("Checking InfrastructureReady=True")
168+
g.Expect(cluster.Status.Conditions).To(ContainElement(SatisfyAll(
169+
HaveField("Type", Equal(string(clusterv1.ClusterInfrastructureReadyCondition))),
170+
HaveField("Status", Equal(metav1.ConditionStatus("True"))),
171+
)))
172+
}).WithTimeout(framework.WaitLong).WithPolling(framework.RetryMedium).Should(Succeed())
173+
})
174+
175+
It("should have the platform-specific infrastructure cluster object present", func() {
176+
cluster := &clusterv1.Cluster{}
177+
Expect(cl.Get(ctx, client.ObjectKey{Name: clusterName, Namespace: framework.CAPINamespace}, cluster)).To(Succeed())
178+
179+
Eventually(func(g Gomega) {
180+
mapping, err := cl.RESTMapper().RESTMapping(cluster.Spec.InfrastructureRef.GroupKind())
181+
g.Expect(err).NotTo(HaveOccurred())
182+
183+
infraCluster := &unstructured.Unstructured{}
184+
infraCluster.SetGroupVersionKind(mapping.GroupVersionKind)
185+
g.Expect(cl.Get(ctx, client.ObjectKey{
186+
Name: cluster.Spec.InfrastructureRef.Name,
187+
Namespace: framework.CAPINamespace,
188+
}, infraCluster)).To(Succeed())
189+
}).WithTimeout(framework.WaitMedium).WithPolling(framework.RetryMedium).Should(Succeed())
190+
})
191+
192+
It("should have the management cluster kubeconfig Secret present", func() {
193+
secret := &corev1.Secret{}
194+
Expect(cl.Get(ctx, client.ObjectKey{
195+
Name: fmt.Sprintf("%s-kubeconfig", clusterName),
196+
Namespace: framework.CAPINamespace,
197+
}, secret)).To(Succeed())
198+
Expect(secret.Data).To(HaveKey("value"))
199+
})
200+
})
201+
})

0 commit comments

Comments
 (0)