Skip to content

Commit 5fdcfde

Browse files
Separate operator framework helpers
1 parent b34cd64 commit 5fdcfde

File tree

8 files changed

+229
-182
lines changed

8 files changed

+229
-182
lines changed

test/e2e/air_gapped_test.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
corev1 "k8s.io/api/core/v1"
2929
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha1"
31+
operatorframework "sigs.k8s.io/cluster-api-operator/test/framework"
3132
"sigs.k8s.io/cluster-api/test/framework"
3233
"sigs.k8s.io/controller-runtime/pkg/client"
3334
"sigs.k8s.io/yaml"
@@ -86,7 +87,7 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
8687
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
8788

8889
By("Waiting for core provider to be ready")
89-
WaitForConditional(ctx, ObjectConditionalInput{
90+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
9091
Reader: k8sclient,
9192
Object: coreProvider,
9293
Conditional: func() bool {
@@ -97,16 +98,16 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
9798
}
9899
return false
99100
},
100-
}, timeout)
101+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
101102

102103
By("Waiting for status.IntalledVersion to be set")
103-
WaitForConditional(ctx, ObjectConditionalInput{
104+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
104105
Reader: k8sclient,
105106
Object: coreProvider,
106107
Conditional: func() bool {
107108
return coreProvider.Status.InstalledVersion != nil && *coreProvider.Status.InstalledVersion == coreProvider.Spec.Version
108109
},
109-
}, timeout)
110+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
110111
})
111112

112113
It("should successfully downgrade a CoreProvider (latest -> v1.4.2)", func() {
@@ -126,7 +127,7 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
126127
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
127128

128129
By("Waiting for core provider to be ready")
129-
WaitForConditional(ctx, ObjectConditionalInput{
130+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
130131
Reader: k8sclient,
131132
Object: coreProvider,
132133
Conditional: func() bool {
@@ -137,10 +138,10 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
137138
}
138139
return false
139140
},
140-
}, timeout)
141+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
141142

142143
By("Waiting for status.IntalledVersion to be set")
143-
WaitForConditional(ctx, ObjectConditionalInput{
144+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
144145
Reader: k8sclient,
145146
Object: coreProvider,
146147
Conditional: func() bool {
@@ -149,7 +150,7 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
149150
}
150151
return false
151152
},
152-
}, timeout)
153+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
153154
})
154155

155156
It("should successfully upgrade a CoreProvider (v1.4.2 -> latest)", func() {
@@ -169,7 +170,7 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
169170
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
170171

171172
By("Waiting for core provider to be ready")
172-
WaitForConditional(ctx, ObjectConditionalInput{
173+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
173174
Reader: k8sclient,
174175
Object: coreProvider,
175176
Conditional: func() bool {
@@ -180,16 +181,16 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
180181
}
181182
return false
182183
},
183-
}, timeout)
184+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
184185

185186
By("Waiting for status.IntalledVersion to be set")
186-
WaitForConditional(ctx, ObjectConditionalInput{
187+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
187188
Reader: k8sclient,
188189
Object: coreProvider,
189190
Conditional: func() bool {
190191
return coreProvider.Status.InstalledVersion != nil && *coreProvider.Status.InstalledVersion == coreProvider.Spec.Version
191192
},
192-
}, timeout)
193+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
193194
})
194195

195196
It("should successfully delete a CoreProvider", func() {
@@ -207,21 +208,21 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
207208
Expect(k8sclient.Delete(ctx, coreProvider)).To(Succeed())
208209

209210
By("Waiting for the core provider deployment to be deleted")
210-
WaitForDelete(ctx, ObjectGetterInput{
211+
operatorframework.WaitForDelete(ctx, operatorframework.ObjectGetterInput{
211212
Reader: k8sclient,
212213
Object: &appsv1.Deployment{
213214
ObjectMeta: metav1.ObjectMeta{
214215
Name: coreProviderDeploymentName,
215216
Namespace: operatorNamespace,
216217
},
217218
},
218-
}, timeout)
219+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
219220

220221
By("Waiting for the core provider object to be deleted")
221-
WaitForDelete(ctx, ObjectGetterInput{
222+
operatorframework.WaitForDelete(ctx, operatorframework.ObjectGetterInput{
222223
Reader: k8sclient,
223224
Object: coreProvider,
224-
}, timeout)
225+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
225226
})
226227

227228
It("should successfully delete config maps with Core Provider manifests", func() {

test/e2e/compressed_manifests_test.go

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha1"
3131
"sigs.k8s.io/cluster-api/test/framework"
32+
33+
operatorframework "sigs.k8s.io/cluster-api-operator/test/framework"
3234
"sigs.k8s.io/controller-runtime/pkg/client"
3335
)
3436

@@ -65,7 +67,7 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
6567
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
6668

6769
By("Waiting for core provider to be ready")
68-
WaitForConditional(ctx, ObjectConditionalInput{
70+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
6971
Reader: k8sclient,
7072
Object: coreProvider,
7173
Conditional: func() bool {
@@ -76,16 +78,16 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
7678
}
7779
return false
7880
},
79-
}, timeout)
81+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
8082

8183
By("Waiting for status.IntalledVersion to be set")
82-
WaitForConditional(ctx, ObjectConditionalInput{
84+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
8385
Reader: k8sclient,
8486
Object: coreProvider,
8587
Conditional: func() bool {
8688
return coreProvider.Status.InstalledVersion != nil && *coreProvider.Status.InstalledVersion == coreProvider.Spec.Version
8789
},
88-
}, timeout)
90+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
8991
})
9092

9193
It("should successfully create and delete an InfrastructureProvider for OCI", func() {
@@ -105,7 +107,7 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
105107
Expect(k8sclient.Create(ctx, infraProvider)).To(Succeed())
106108

107109
By("Waiting for the infrastructure provider to be ready")
108-
WaitForConditional(ctx, ObjectConditionalInput{
110+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
109111
Reader: k8sclient,
110112
Object: infraProvider,
111113
Conditional: func() bool {
@@ -116,16 +118,16 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
116118
}
117119
return false
118120
},
119-
}, timeout)
121+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
120122

121123
By("Waiting for status.IntalledVersion to be set")
122-
WaitForConditional(ctx, ObjectConditionalInput{
124+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
123125
Reader: k8sclient,
124126
Object: infraProvider,
125127
Conditional: func() bool {
126128
return infraProvider.Status.InstalledVersion != nil && *infraProvider.Status.InstalledVersion == infraProvider.Spec.Version
127129
},
128-
}, timeout)
130+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
129131

130132
By("Ensure that the created config map has correct annotation")
131133
cmName := fmt.Sprintf("infrastructure-%s-%s", ociInfrastructureProviderName, ociInfrastructureProviderVersion)
@@ -148,26 +150,26 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
148150
By("Waiting for the infrastructure provider deployment to be created")
149151
Eventually(func() bool {
150152
return k8sclient.Get(ctx, client.ObjectKeyFromObject(deployment), deployment) == nil
151-
}, timeout)
153+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
152154

153155
Expect(k8sclient.Delete(ctx, infraProvider)).To(Succeed())
154156

155157
By("Waiting for the infrastructure provider deployment to be deleted")
156-
WaitForDelete(ctx, ObjectGetterInput{
158+
operatorframework.WaitForDelete(ctx, operatorframework.ObjectGetterInput{
157159
Reader: k8sclient,
158160
Object: deployment,
159-
}, timeout)
161+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
160162

161163
By("Waiting for the configmap to be deleted")
162-
WaitForDelete(ctx, ObjectGetterInput{
164+
operatorframework.WaitForDelete(ctx, operatorframework.ObjectGetterInput{
163165
Reader: k8sclient,
164166
Object: &corev1.ConfigMap{
165167
ObjectMeta: metav1.ObjectMeta{
166168
Namespace: operatorNamespace,
167169
Name: cmName,
168170
},
169171
},
170-
}, timeout)
172+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
171173
})
172174

173175
It("should successfully create and delete an InfrastructureProvider for OCI with custom name from a pre-created ConfigMap", func() {
@@ -201,7 +203,7 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
201203
Expect(k8sclient.Create(ctx, infraProvider)).To(Succeed())
202204

203205
By("Waiting for the infrastructure provider to be ready")
204-
WaitForConditional(ctx, ObjectConditionalInput{
206+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
205207
Reader: k8sclient,
206208
Object: infraProvider,
207209
Conditional: func() bool {
@@ -212,16 +214,16 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
212214
}
213215
return false
214216
},
215-
}, timeout)
217+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
216218

217219
By("Waiting for status.IntalledVersion to be set")
218-
WaitForConditional(ctx, ObjectConditionalInput{
220+
operatorframework.WaitForConditional(ctx, operatorframework.ObjectConditionalInput{
219221
Reader: k8sclient,
220222
Object: infraProvider,
221223
Conditional: func() bool {
222224
return infraProvider.Status.InstalledVersion != nil && *infraProvider.Status.InstalledVersion == infraProvider.Spec.Version
223225
},
224-
}, timeout)
226+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
225227

226228
By("Ensure that the created config map has correct annotation")
227229
cm := &corev1.ConfigMap{}
@@ -243,15 +245,15 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
243245
By("Waiting for the infrastructure provider deployment to be created")
244246
Eventually(func() bool {
245247
return k8sclient.Get(ctx, client.ObjectKeyFromObject(deployment), deployment) == nil
246-
}, timeout)
248+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
247249

248250
Expect(k8sclient.Delete(ctx, infraProvider)).To(Succeed())
249251

250252
By("Waiting for the infrastructure provider deployment to be deleted")
251-
WaitForDelete(ctx, ObjectGetterInput{
253+
operatorframework.WaitForDelete(ctx, operatorframework.ObjectGetterInput{
252254
Reader: k8sclient,
253255
Object: deployment,
254-
}, timeout)
256+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
255257
})
256258

257259
It("should successfully delete a CoreProvider", func() {
@@ -269,20 +271,20 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
269271
Expect(k8sclient.Delete(ctx, coreProvider)).To(Succeed())
270272

271273
By("Waiting for the core provider deployment to be deleted")
272-
WaitForDelete(ctx, ObjectGetterInput{
274+
operatorframework.WaitForDelete(ctx, operatorframework.ObjectGetterInput{
273275
Reader: k8sclient,
274276
Object: &appsv1.Deployment{
275277
ObjectMeta: metav1.ObjectMeta{
276278
Name: coreProviderDeploymentName,
277279
Namespace: operatorNamespace,
278280
},
279281
},
280-
}, timeout)
282+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
281283

282284
By("Waiting for the core provider object to be deleted")
283-
WaitForDelete(ctx, ObjectGetterInput{
285+
operatorframework.WaitForDelete(ctx, operatorframework.ObjectGetterInput{
284286
Reader: k8sclient,
285287
Object: coreProvider,
286-
}, timeout)
288+
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
287289
})
288290
})

test/e2e/e2e_suite_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import (
3838
"k8s.io/apimachinery/pkg/runtime"
3939
"k8s.io/klog/v2"
4040
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha1"
41+
42+
operatorframework "sigs.k8s.io/cluster-api-operator/test/framework"
4143
"sigs.k8s.io/cluster-api/test/framework"
4244
"sigs.k8s.io/cluster-api/test/framework/bootstrap"
4345
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
@@ -114,7 +116,7 @@ var (
114116
usePRArtifacts bool
115117

116118
// helmChart is the helm chart helper to be used for the e2e tests.
117-
helmChart *HelmChartHelper
119+
helmChart *operatorframework.HelmChart
118120
)
119121

120122
func init() {
@@ -172,7 +174,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
172174
}, scheme, useExistingCluster, "helm")
173175

174176
By("Initializing a helm chart helper")
175-
initHelmChartHelper()
177+
initHelmChart()
176178

177179
By("Initializing the helm cluster")
178180
initHelmCluster(helmClusterProxy, e2eConfig)
@@ -337,8 +339,8 @@ func ensureCertManager(clusterProxy framework.ClusterProxy, config *clusterctl.E
337339
}
338340
}
339341

340-
func initHelmChartHelper() {
341-
helmChart = &HelmChartHelper{
342+
func initHelmChart() {
343+
helmChart = &operatorframework.HelmChart{
342344
BinaryPath: helmBinaryPath,
343345
Path: chartPath,
344346
Name: "capi-operator",

0 commit comments

Comments
 (0)