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