@@ -27,7 +27,6 @@ const (
2727var _ = Describe ("Operator Install" , func () {
2828 var (
2929 ctx context.Context
30- pkgName string
3130 operatorName string
3231 operator * operatorv1alpha1.Operator
3332 operatorCatalog * catalogd.Catalog
@@ -55,18 +54,18 @@ var _ = Describe("Operator Install", func() {
5554 g .Expect (err ).ToNot (HaveOccurred ())
5655 g .Expect (pList .Items ).To (HaveLen (2 ))
5756 }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
57+
58+ operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
59+ operator = & operatorv1alpha1.Operator {
60+ ObjectMeta : metav1.ObjectMeta {
61+ Name : operatorName ,
62+ },
63+ }
5864 })
5965 When ("the operator bundle format is registry+v1" , func () {
6066 BeforeEach (func () {
61- pkgName = "prometheus"
62- operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
63- operator = & operatorv1alpha1.Operator {
64- ObjectMeta : metav1.ObjectMeta {
65- Name : operatorName ,
66- },
67- Spec : operatorv1alpha1.OperatorSpec {
68- PackageName : pkgName ,
69- },
67+ operator .Spec = operatorv1alpha1.OperatorSpec {
68+ PackageName : "prometheus" ,
7069 }
7170 })
7271 It ("resolves the specified package with correct bundle path" , func () {
@@ -105,71 +104,12 @@ var _ = Describe("Operator Install", func() {
105104 g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
106105 }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
107106 })
108- It ("resolves again when a new catalog is available" , func () {
109- // Delete the catalog first
110- err := c .Delete (ctx , operatorCatalog )
111- Expect (err ).ToNot (HaveOccurred ())
112-
113- Eventually (func (g Gomega ) {
114- // target package should not be present on cluster
115- err := c .Get (ctx , types.NamespacedName {Name : pkgName }, & catalogd.Package {})
116- g .Expect (errors .IsNotFound (err )).To (BeTrue ())
117- }).WithTimeout (5 * time .Minute ).WithPolling (defaultPoll ).Should (Succeed ())
118-
119- By ("creating the Operator resource" )
120- err = c .Create (ctx , operator )
121- Expect (err ).ToNot (HaveOccurred ())
122-
123- By ("failing to find Operator during resolution" )
124- Eventually (func (g Gomega ) {
125- err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
126- g .Expect (err ).ToNot (HaveOccurred ())
127- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
128- g .Expect (cond ).ToNot (BeNil ())
129- g .Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
130- g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonResolutionFailed ))
131- g .Expect (cond .Message ).To (Equal (fmt .Sprintf ("package '%s' not found" , pkgName )))
132- }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
133-
134- By ("creating an Operator catalog with the desired package" )
135- operatorCatalog , err = createTestCatalog (ctx , testCatalogName , testCatalogRef )
136- Expect (err ).ToNot (HaveOccurred ())
137- Eventually (func (g Gomega ) {
138- err = c .Get (ctx , types.NamespacedName {Name : operatorCatalog .Name }, operatorCatalog )
139- g .Expect (err ).ToNot (HaveOccurred ())
140- cond := apimeta .FindStatusCondition (operatorCatalog .Status .Conditions , catalogd .TypeUnpacked )
141- g .Expect (cond ).ToNot (BeNil ())
142- g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
143- g .Expect (cond .Reason ).To (Equal (catalogd .ReasonUnpackSuccessful ))
144- }).WithTimeout (5 * time .Minute ).WithPolling (defaultPoll ).Should (Succeed ())
145-
146- By ("eventually resolving the package successfully" )
147- Eventually (func (g Gomega ) {
148- err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
149- g .Expect (err ).ToNot (HaveOccurred ())
150- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
151- g .Expect (cond ).ToNot (BeNil ())
152- g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
153- g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
154- }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
155- })
156- AfterEach (func () {
157- err := c .Delete (ctx , operator )
158- Expect (err ).ToNot (HaveOccurred ())
159- })
160107 })
161108
162109 When ("the operator bundle format is plain+v0" , func () {
163110 BeforeEach (func () {
164- pkgName = "plain"
165- operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
166- operator = & operatorv1alpha1.Operator {
167- ObjectMeta : metav1.ObjectMeta {
168- Name : operatorName ,
169- },
170- Spec : operatorv1alpha1.OperatorSpec {
171- PackageName : pkgName ,
172- },
111+ operator .Spec = operatorv1alpha1.OperatorSpec {
112+ PackageName : "plain" ,
173113 }
174114 })
175115 It ("resolves the specified package with correct bundle path" , func () {
@@ -208,62 +148,70 @@ var _ = Describe("Operator Install", func() {
208148 g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
209149 }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
210150 })
211- It ("resolves again when a new catalog is available" , func () {
212- // Delete the catalog first
213- err := c .Delete (ctx , operatorCatalog )
214- Expect (err ).ToNot (HaveOccurred ())
151+ })
215152
216- Eventually ( func (g Gomega ) {
217- // target package should not be present on cluster
218- err := c . Get ( ctx , types. NamespacedName { Name : pkgName }, & catalogd. Package {})
219- g . Expect ( errors . IsNotFound ( err )). To ( BeTrue ())
220- }). WithTimeout ( 5 * time . Minute ). WithPolling ( defaultPoll ). Should ( Succeed ())
153+ It ( "resolves again when a new catalog is available" , func () {
154+ pkgName := "prometheus"
155+ operator . Spec = operatorv1alpha1. OperatorSpec {
156+ PackageName : pkgName ,
157+ }
221158
222- By ( "creating the Operator resource" )
223- err = c .Create (ctx , operator )
224- Expect (err ).ToNot (HaveOccurred ())
159+ // Delete the catalog first
160+ err : = c .Delete (ctx , operatorCatalog )
161+ Expect (err ).ToNot (HaveOccurred ())
225162
226- By ("failing to find Operator during resolution" )
227- Eventually (func (g Gomega ) {
228- err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
229- g .Expect (err ).ToNot (HaveOccurred ())
230- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
231- g .Expect (cond ).ToNot (BeNil ())
232- g .Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
233- g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonResolutionFailed ))
234- g .Expect (cond .Message ).To (Equal (fmt .Sprintf ("package '%s' not found" , pkgName )))
235- }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
163+ Eventually (func (g Gomega ) {
164+ // target package should not be present on cluster
165+ err := c .Get (ctx , types.NamespacedName {Name : pkgName }, & catalogd.Package {})
166+ g .Expect (errors .IsNotFound (err )).To (BeTrue ())
167+ }).WithTimeout (5 * time .Minute ).WithPolling (defaultPoll ).Should (Succeed ())
236168
237- By ("creating an Operator catalog with the desired package" )
238- operatorCatalog , err = createTestCatalog (ctx , testCatalogName , testCatalogRef )
239- Expect (err ).ToNot (HaveOccurred ())
240- Eventually (func (g Gomega ) {
241- err = c .Get (ctx , types.NamespacedName {Name : operatorCatalog .Name }, operatorCatalog )
242- g .Expect (err ).ToNot (HaveOccurred ())
243- cond := apimeta .FindStatusCondition (operatorCatalog .Status .Conditions , catalogd .TypeUnpacked )
244- g .Expect (cond ).ToNot (BeNil ())
245- g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
246- g .Expect (cond .Reason ).To (Equal (catalogd .ReasonUnpackSuccessful ))
247- }).WithTimeout (5 * time .Minute ).WithPolling (defaultPoll ).Should (Succeed ())
169+ By ("creating the Operator resource" )
170+ err = c .Create (ctx , operator )
171+ Expect (err ).ToNot (HaveOccurred ())
248172
249- By ("eventually resolving the package successfully" )
250- Eventually (func (g Gomega ) {
251- err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
252- g .Expect (err ).ToNot (HaveOccurred ())
253- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
254- g .Expect (cond ).ToNot (BeNil ())
255- g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
256- g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
257- }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
258- })
259- AfterEach (func () {
260- err := c .Delete (ctx , operator )
261- Expect (err ).ToNot (HaveOccurred ())
262- })
173+ By ("failing to find Operator during resolution" )
174+ Eventually (func (g Gomega ) {
175+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
176+ g .Expect (err ).ToNot (HaveOccurred ())
177+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
178+ g .Expect (cond ).ToNot (BeNil ())
179+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
180+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonResolutionFailed ))
181+ g .Expect (cond .Message ).To (Equal (fmt .Sprintf ("package '%s' not found" , pkgName )))
182+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
183+
184+ By ("creating an Operator catalog with the desired package" )
185+ operatorCatalog , err = createTestCatalog (ctx , testCatalogName , testCatalogRef )
186+ Expect (err ).ToNot (HaveOccurred ())
187+ Eventually (func (g Gomega ) {
188+ err = c .Get (ctx , types.NamespacedName {Name : operatorCatalog .Name }, operatorCatalog )
189+ g .Expect (err ).ToNot (HaveOccurred ())
190+ cond := apimeta .FindStatusCondition (operatorCatalog .Status .Conditions , catalogd .TypeUnpacked )
191+ g .Expect (cond ).ToNot (BeNil ())
192+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
193+ g .Expect (cond .Reason ).To (Equal (catalogd .ReasonUnpackSuccessful ))
194+ }).WithTimeout (5 * time .Minute ).WithPolling (defaultPoll ).Should (Succeed ())
195+
196+ By ("eventually resolving the package successfully" )
197+ Eventually (func (g Gomega ) {
198+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
199+ g .Expect (err ).ToNot (HaveOccurred ())
200+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
201+ g .Expect (cond ).ToNot (BeNil ())
202+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
203+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonSuccess ))
204+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
263205 })
264206
265207 AfterEach (func () {
266- err := c .Delete (ctx , operatorCatalog )
208+ err := c .Delete (ctx , operator )
209+ Eventually (func (g Gomega ) {
210+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, & operatorv1alpha1.Operator {})
211+ Expect (errors .IsNotFound (err )).To (BeTrue ())
212+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
213+
214+ err = c .Delete (ctx , operatorCatalog )
267215 Expect (err ).ToNot (HaveOccurred ())
268216 Eventually (func (g Gomega ) {
269217 err = c .Get (ctx , types.NamespacedName {Name : operatorCatalog .Name }, & catalogd.Catalog {})
0 commit comments