@@ -101,7 +101,75 @@ var _ = Describe("Operator Install", func() {
101
101
g .Expect (bd .Status .Conditions [0 ].Reason ).To (Equal ("UnpackSuccessful" ))
102
102
g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
103
103
}).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
104
+ })
105
+ AfterEach (func () {
106
+ err := c .Delete (ctx , operatorCatalog )
107
+ Expect (err ).ToNot (HaveOccurred ())
108
+ err = c .Delete (ctx , operator )
109
+ Expect (err ).ToNot (HaveOccurred ())
110
+ })
111
+ })
112
+ When ("resolving for an unavailable operator package" , func () {
113
+ BeforeEach (func () {
114
+ ctx = context .Background ()
115
+ pkgName = "argocd-operator"
116
+ operatorName = fmt .Sprintf ("operator-%s" , rand .String (8 ))
117
+ operator = & operatorv1alpha1.Operator {
118
+ ObjectMeta : metav1.ObjectMeta {
119
+ Name : operatorName ,
120
+ },
121
+ Spec : operatorv1alpha1.OperatorSpec {
122
+ PackageName : pkgName ,
123
+ },
124
+ }
125
+ operatorCatalog = & catalogd.CatalogSource {
126
+ ObjectMeta : metav1.ObjectMeta {
127
+ Name : "test-catalog" ,
128
+ },
129
+ Spec : catalogd.CatalogSourceSpec {
130
+ // (TODO): Set up a local image registry, and build and store a test catalog in it
131
+ // to use in the test suite
132
+ Image : "quay.io/operatorhubio/catalog:latest" ,
133
+ },
134
+ }
135
+ })
136
+
137
+ It ("resolves again when a new catalog is available" , func () {
138
+ By ("creating the Operator resource" )
139
+ err := c .Create (ctx , operator )
140
+ Expect (err ).ToNot (HaveOccurred ())
141
+
142
+ By ("failing to find Operator during resolution" )
143
+ Eventually (func (g Gomega ) {
144
+ err = c .Get (ctx , types.NamespacedName {Name : operator .Name }, operator )
145
+ g .Expect (err ).ToNot (HaveOccurred ())
146
+ g .Expect (len (operator .Status .Conditions )).To (Equal (2 ))
147
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorv1alpha1 .TypeResolved )
148
+ g .Expect (cond ).ToNot (BeNil ())
149
+ g .Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
150
+ g .Expect (cond .Reason ).To (Equal (operatorv1alpha1 .ReasonResolutionFailed ))
151
+ g .Expect (cond .Message ).To (Equal (fmt .Sprintf ("package '%s' not found" , pkgName )))
152
+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
104
153
154
+ By ("creating an Operator catalog with the desired package" )
155
+ err = c .Create (ctx , operatorCatalog )
156
+ Expect (err ).ToNot (HaveOccurred ())
157
+ Eventually (func (g Gomega ) {
158
+ err = c .Get (ctx , types.NamespacedName {Name : "test-catalog" }, operatorCatalog )
159
+ g .Expect (err ).ToNot (HaveOccurred ())
160
+ g .Expect (len (operatorCatalog .Status .Conditions )).To (Equal (1 ))
161
+ g .Expect (operatorCatalog .Status .Conditions [0 ].Message ).To (Equal ("catalog contents have been unpacked and are available on cluster" ))
162
+ }).WithTimeout (5 * time .Minute ).WithPolling (defaultPoll ).Should (Succeed ())
163
+
164
+ By ("eventually installing the package successfully" )
165
+ Eventually (func (g Gomega ) {
166
+ bd := rukpakv1alpha1.BundleDeployment {}
167
+ err = c .Get (ctx , types.NamespacedName {Name : operatorName }, & bd )
168
+ g .Expect (err ).ToNot (HaveOccurred ())
169
+ g .Expect (len (bd .Status .Conditions )).To (Equal (2 ))
170
+ g .Expect (bd .Status .Conditions [0 ].Reason ).To (Equal ("UnpackSuccessful" ))
171
+ g .Expect (bd .Status .Conditions [1 ].Reason ).To (Equal ("InstallationSucceeded" ))
172
+ }).WithTimeout (defaultTimeout ).WithPolling (defaultPoll ).Should (Succeed ())
105
173
})
106
174
AfterEach (func () {
107
175
err := c .Delete (ctx , operatorCatalog )
0 commit comments