@@ -29,25 +29,17 @@ var _ = Describe("Operator Install", func() {
2929		ctx              context.Context 
3030		pkgName          string 
3131		operatorName     string 
32+ 		catalogName      string 
3233		operator         * operatorv1alpha1.Operator 
3334		operatorCatalog  * catalogd.Catalog 
3435	)
3536	When ("An operator is installed from an operator catalog" , func () {
3637		BeforeEach (func () {
3738			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 ))
4840			operatorCatalog  =  & catalogd.Catalog {
4941				ObjectMeta : metav1.ObjectMeta {
50- 					Name : testCatalogName ,
42+ 					Name : catalogName ,
5143				},
5244				Spec : catalogd.CatalogSpec {
5345					Source : catalogd.CatalogSource {
@@ -85,14 +77,14 @@ var _ = Describe("Operator Install", func() {
8577				cond  :=  apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
8678				g .Expect (cond ).ToNot (BeNil ())
8779				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" ))
9281
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 )
9688				g .Expect (err ).ToNot (HaveOccurred ())
9789				cond  :=  apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeInstalled )
9890				g .Expect (cond ).ToNot (BeNil ())
@@ -159,6 +151,7 @@ var _ = Describe("Operator Install", func() {
159151				g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
160152			}).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
161153		})
154+ 
162155		AfterEach (func () {
163156			err  :=  c .Delete (ctx , operator )
164157			Expect (err ).ToNot (HaveOccurred ())
@@ -196,5 +189,118 @@ var _ = Describe("Operator Install", func() {
196189				Expect (errors .IsNotFound (err )).To (BeTrue ())
197190			}).WithTimeout (5  *  time .Minute ).WithPolling (defaultPoll ).Should (Succeed ())
198191		})
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+ 
199305	})
200306})
0 commit comments