@@ -29,25 +29,17 @@ var _ = Describe("Operator Install", func() {
29
29
ctx context.Context
30
30
pkgName string
31
31
operatorName string
32
+ catalogName string
32
33
operator * operatorv1alpha1.Operator
33
34
operatorCatalog * catalogd.Catalog
34
35
)
35
36
When ("An operator is installed from an operator catalog" , func () {
36
37
BeforeEach (func () {
37
38
ctx = context .Background ()
38
- pkgName = "prometheus"
39
- operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
40
- operator = & operatorv1alpha1.Operator {
41
- ObjectMeta : metav1.ObjectMeta {
42
- Name : operatorName ,
43
- },
44
- Spec : operatorv1alpha1.OperatorSpec {
45
- PackageName : pkgName ,
46
- },
47
- }
39
+ catalogName = fmt .Sprintf ("catalog-%s" , rand .String (8 ))
48
40
operatorCatalog = & catalogd.Catalog {
49
41
ObjectMeta : metav1.ObjectMeta {
50
- Name : testCatalogName ,
42
+ Name : catalogName ,
51
43
},
52
44
Spec : catalogd.CatalogSpec {
53
45
Source : catalogd.CatalogSource {
@@ -85,14 +77,14 @@ var _ = Describe("Operator Install", func() {
85
77
cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
86
78
g .Expect (cond ).ToNot (BeNil ())
87
79
g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
88
- g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
89
- g .Expect (cond .Message ).To (ContainSubstring ("resolved to" ))
90
- g .Expect (operator .Status .ResolvedBundleResource ).ToNot (BeEmpty ())
91
- }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
80
+ g .Expect (cond .Message ).To (ContainSubstring ("successfully unpacked the catalog image" ))
92
81
93
- By ("eventually installing the package successfully" )
94
- Eventually (func (g Gomega ) {
95
- err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
82
+ // For some reason the above condition check is returning true and the
83
+ // Operators end up being created before the packages exist. Adding this check
84
+ // to ensure that there are some packages that exist before actually returning from this
85
+ // check.
86
+ pkgList := & catalogd.PackageList {}
87
+ err = c .List (ctx , pkgList )
96
88
g .Expect (err ).ToNot (HaveOccurred ())
97
89
cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeInstalled )
98
90
g .Expect (cond ).ToNot (BeNil ())
@@ -159,6 +151,7 @@ var _ = Describe("Operator Install", func() {
159
151
g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
160
152
}).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
161
153
})
154
+
162
155
AfterEach (func () {
163
156
err := c .Delete (ctx , operator )
164
157
Expect (err ).ToNot (HaveOccurred ())
@@ -196,5 +189,118 @@ var _ = Describe("Operator Install", func() {
196
189
Expect (errors .IsNotFound (err )).To (BeTrue ())
197
190
}).WithTimeout (5 * time .Minute ).WithPolling (defaultPoll ).Should (Succeed ())
198
191
})
192
+
193
+ When ("the operator bundle format is registry+v1" , func () {
194
+ BeforeEach (func () {
195
+ pkgName = "prometheus"
196
+ operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
197
+ operator = & operatorv1alpha1.Operator {
198
+ ObjectMeta : metav1.ObjectMeta {
199
+ Name : operatorName ,
200
+ },
201
+ Spec : operatorv1alpha1.OperatorSpec {
202
+ PackageName : pkgName ,
203
+ },
204
+ }
205
+ })
206
+ It ("resolves the specified package with correct bundle path" , func () {
207
+ By ("creating the Operator resource" )
208
+ err := c .Create (ctx , operator )
209
+ Expect (err ).ToNot (HaveOccurred ())
210
+
211
+ By ("eventually reporting a successful resolution and bundle path" )
212
+ Eventually (func (g Gomega ) {
213
+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
214
+ g .Expect (err ).ToNot (HaveOccurred ())
215
+ g .Expect (len (operator .Status .Conditions )).To (Equal (2 ))
216
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
217
+ g .Expect (cond ).ToNot (BeNil ())
218
+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
219
+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
220
+ g .Expect (cond .Message ).To (ContainSubstring ("resolved to" ))
221
+ g .Expect (operator .Status .ResolvedBundleResource ).ToNot (BeEmpty ())
222
+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
223
+
224
+ By ("eventually installing the package successfully" )
225
+ Eventually (func (g Gomega ) {
226
+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
227
+ g .Expect (err ).ToNot (HaveOccurred ())
228
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeInstalled )
229
+ g .Expect (cond ).ToNot (BeNil ())
230
+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
231
+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
232
+ g .Expect (cond .Message ).To (ContainSubstring ("installed from" ))
233
+ g .Expect (operator .Status .InstalledBundleResource ).ToNot (BeEmpty ())
234
+ bd := rukpakv1alpha1.BundleDeployment {}
235
+ err = c .Get (ctx , types.NamespacedName {Name : operatorName }, & bd )
236
+ g .Expect (err ).ToNot (HaveOccurred ())
237
+ g .Expect (len (bd .Status .Conditions )).To (Equal (2 ))
238
+ g .Expect (bd .Status .Conditions [0 ].Reason ).To (Equal ("UnpackSuccessful" ))
239
+ g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
240
+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
241
+
242
+ })
243
+ AfterEach (func () {
244
+ err := c .Delete (ctx , operator )
245
+ Expect (err ).ToNot (HaveOccurred ())
246
+ })
247
+ })
248
+
249
+ When ("the operator bundle format is plain+v0" , func () {
250
+ BeforeEach (func () {
251
+ pkgName = "plain"
252
+ operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
253
+ operator = & operatorv1alpha1.Operator {
254
+ ObjectMeta : metav1.ObjectMeta {
255
+ Name : operatorName ,
256
+ },
257
+ Spec : operatorv1alpha1.OperatorSpec {
258
+ PackageName : pkgName ,
259
+ },
260
+ }
261
+ })
262
+ It ("resolves the specified package with correct bundle path" , func () {
263
+ By ("creating the Operator resource" )
264
+ err := c .Create (ctx , operator )
265
+ Expect (err ).ToNot (HaveOccurred ())
266
+
267
+ By ("eventually reporting a successful resolution and bundle path" )
268
+ Eventually (func (g Gomega ) {
269
+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
270
+ g .Expect (err ).ToNot (HaveOccurred ())
271
+ g .Expect (len (operator .Status .Conditions )).To (Equal (2 ))
272
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
273
+ g .Expect (cond ).ToNot (BeNil ())
274
+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
275
+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
276
+ g .Expect (cond .Message ).To (ContainSubstring ("resolved to" ))
277
+ g .Expect (operator .Status .ResolvedBundleResource ).ToNot (BeEmpty ())
278
+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
279
+
280
+ By ("eventually installing the package successfully" )
281
+ Eventually (func (g Gomega ) {
282
+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
283
+ g .Expect (err ).ToNot (HaveOccurred ())
284
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeInstalled )
285
+ g .Expect (cond ).ToNot (BeNil ())
286
+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
287
+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
288
+ g .Expect (cond .Message ).To (ContainSubstring ("installed from" ))
289
+ g .Expect (operator .Status .InstalledBundleResource ).ToNot (BeEmpty ())
290
+ bd := rukpakv1alpha1.BundleDeployment {}
291
+ err = c .Get (ctx , types.NamespacedName {Name : operatorName }, & bd )
292
+ g .Expect (err ).ToNot (HaveOccurred ())
293
+ g .Expect (len (bd .Status .Conditions )).To (Equal (2 ))
294
+ g .Expect (bd .Status .Conditions [0 ].Reason ).To (Equal ("UnpackSuccessful" ))
295
+ g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
296
+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
297
+
298
+ })
299
+ AfterEach (func () {
300
+ err := c .Delete (ctx , operator )
301
+ Expect (err ).ToNot (HaveOccurred ())
302
+ })
303
+ })
304
+
199
305
})
200
306
})
0 commit comments