@@ -20,34 +20,29 @@ import (
2020
2121const (
2222 olmv1GroupName = "olm.operatorframework.io"
23- typeIncompatibelOperatorsUpgradeable = "InstalledOLMOperatorsUpgradeable"
23+ typeIncompatibleOperatorsUpgradeable = "InstalledOLMOperatorsUpgradeable"
2424)
2525
26- var _ = g .Describe ("[sig-olmv1] OLMv1 CRDs" , func () {
26+ var _ = g .Describe ("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 CRDs" , func () {
2727 defer g .GinkgoRecover ()
2828 oc := exutil .NewCLIWithoutNamespace ("default" )
2929
3030 g .It ("should be installed" , func (ctx g.SpecContext ) {
31- g .Skip ("Test is temporarily disabled while we make anticipated, breaking changes." )
32- // Check for tech preview, if this is not tech preview, bail
33- if ! exutil .IsTechPreviewNoUpgrade (ctx , oc .AdminConfigClient ()) {
34- g .Skip ("Test only runs in tech-preview" )
35- }
31+ checkFeatureCapability (ctx , oc )
3632
37- // supports multiple versions during transision
3833 providedAPIs := []struct {
3934 group string
4035 version []string
4136 plural string
4237 }{
4338 {
4439 group : olmv1GroupName ,
45- version : []string {"v1alpha1" , " v1" },
40+ version : []string {"v1" },
4641 plural : "clusterextensions" ,
4742 },
4843 {
4944 group : olmv1GroupName ,
50- version : []string {"v1alpha1" , " v1" },
45+ version : []string {"v1" },
5146 plural : "clustercatalogs" ,
5247 },
5348 }
@@ -70,16 +65,12 @@ var _ = g.Describe("[sig-olmv1] OLMv1 CRDs", func() {
7065 })
7166})
7267
73- var _ = g .Describe ("[sig-olmv1] OLMv1 Catalogs" , func () {
68+ var _ = g .Describe ("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 Catalogs" , func () {
7469 defer g .GinkgoRecover ()
7570 oc := exutil .NewCLIWithoutNamespace ("default" )
7671
7772 g .It ("should be installed" , func (ctx g.SpecContext ) {
78- g .Skip ("Test is temporarily disabled while we make anticipated, breaking changes." )
79- // Check for tech preview, if this is not tech preview, bail
80- if ! exutil .IsTechPreviewNoUpgrade (ctx , oc .AdminConfigClient ()) {
81- g .Skip ("Test only runs in tech-preview" )
82- }
73+ checkFeatureCapability (ctx , oc )
8374
8475 providedCatalogs := []string {
8576 "openshift-certified-operators" ,
@@ -102,7 +93,46 @@ var _ = g.Describe("[sig-olmv1] OLMv1 Catalogs", func() {
10293 })
10394})
10495
105- var _ = g .Describe ("[sig-olmv1][Serial] OLMv1 operator installation" , func () {
96+ var _ = g .Describe ("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 New Catalog Install" , func () {
97+ defer g .GinkgoRecover ()
98+
99+ var (
100+ baseDir = exutil .FixturePath ("testdata" , "olmv1" )
101+ catFile = filepath .Join (baseDir , "install-catalog.yaml" )
102+ catName = "bad-catalog"
103+ )
104+
105+ oc := exutil .NewCLIWithoutNamespace ("default" )
106+
107+ g .BeforeEach (func () {
108+ exutil .PreTestDump ()
109+ })
110+
111+ g .AfterEach (func () {
112+ if g .CurrentSpecReport ().Failed () {
113+ exutil .DumpPodLogsStartingWith ("" , oc )
114+ }
115+ oc .AsAdmin ().WithoutNamespace ().Run ("delete" ).Args ("-f" , catFile ).Execute ()
116+ os .Remove (catFile )
117+ })
118+
119+ g .It ("should fail to install if it has an invalid reference" , func (ctx g.SpecContext ) {
120+ checkFeatureCapability (ctx , oc )
121+
122+ g .By ("applying the necessary resources" )
123+ err := oc .AsAdmin ().WithoutNamespace ().Run ("apply" ).Args ("-f" , catFile ).Execute ()
124+ o .Expect (err ).NotTo (o .HaveOccurred ())
125+
126+ g .By (fmt .Sprintf ("checking that %q is not serving" , catName ))
127+ err = wait .PollUntilContextTimeout (ctx , time .Second , 5 * time .Minute , true ,
128+ func (ctx context.Context ) (bool , error ) {
129+ return waitForCatalogFailure (oc , catName )
130+ })
131+ o .Expect (err ).NotTo (o .HaveOccurred ())
132+ })
133+ })
134+
135+ var _ = g .Describe ("[sig-olmv1][OCPFeatureGate:NewOLM][Serial] OLMv1 operator installation" , func () {
106136 defer g .GinkgoRecover ()
107137
108138 var (
@@ -125,93 +155,95 @@ var _ = g.Describe("[sig-olmv1][Serial] OLMv1 operator installation", func() {
125155 })
126156
127157 g .It ("should install a cluster extension" , func (ctx g.SpecContext ) {
128- g .Skip ("Test is temporarily disabled while we make anticipated, breaking changes." )
158+ checkFeatureCapability (ctx , oc )
159+
129160 const (
130161 packageName = "quay-operator"
131162 version = "3.13.0"
132163 )
133- // Check for tech preview, if this is not tech preview, bail
134- if ! exutil .IsTechPreviewNoUpgrade (ctx , oc .AdminConfigClient ()) {
135- g .Skip ("Test only runs in tech-preview" )
136- }
137164
138- ns := oc .Namespace ()
139- g .By (fmt .Sprintf ("Updating the namespace to: %q" , ns ))
140- newCeFile = ceFile + "." + ns
141- b , err := os .ReadFile (ceFile )
142- o .Expect (err ).NotTo (o .HaveOccurred ())
143- s := updateCe (b , ns , packageName , version )
144- err = os .WriteFile (newCeFile , []byte (s ), 0666 )
145- o .Expect (err ).NotTo (o .HaveOccurred ())
146-
147- g .By ("applying the necessary resources" )
148- err = oc .AsAdmin ().WithoutNamespace ().Run ("apply" ).Args ("-f" , newCeFile ).Execute ()
149- o .Expect (err ).NotTo (o .HaveOccurred ())
165+ newCeFile = applyClusterExtension (oc , packageName , version , ceFile )
150166
151167 g .By ("waiting for the ClusterExtention to be installed" )
152- err = wait .PollUntilContextTimeout (ctx , time .Second , 5 * time .Minute , true ,
168+ err : = wait .PollUntilContextTimeout (ctx , time .Second , 5 * time .Minute , true ,
153169 func (ctx context.Context ) (bool , error ) {
154- return WaitForClusterExtensionReady (oc , "install-test-ce" )
170+ return waitForClusterExtensionReady (oc , "install-test-ce" )
155171 })
156172 o .Expect (err ).NotTo (o .HaveOccurred ())
157173
158174 g .By ("ensuring the cluster is upgradeable when no olm.maxopenshiftversion is specified" )
159175 err = wait .PollUntilContextTimeout (ctx , time .Second , 5 * time .Minute , true ,
160176 func (ctx context.Context ) (bool , error ) {
161- return WaitForCondition (oc , true )
177+ return waitForUpgradableCondition (oc , true )
178+ })
179+ o .Expect (err ).NotTo (o .HaveOccurred ())
180+ })
181+
182+ g .It ("should fail to install a non-existing cluster extension" , func (ctx g.SpecContext ) {
183+ checkFeatureCapability (ctx , oc )
184+
185+ const (
186+ packageName = "does-not-exist"
187+ version = "99.99.99"
188+ )
189+
190+ newCeFile = applyClusterExtension (oc , packageName , version , ceFile )
191+
192+ g .By ("waiting for the ClusterExtention to report failure" )
193+ err := wait .PollUntilContextTimeout (ctx , time .Second , 5 * time .Minute , true ,
194+ func (ctx context.Context ) (bool , error ) {
195+ return waitForClusterExtensionFailure (oc , "install-test-ce" )
162196 })
163197 o .Expect (err ).NotTo (o .HaveOccurred ())
164198 })
165199
166200 g .It ("should block cluster upgrades if an incompatible operator is installed" , func (ctx g.SpecContext ) {
167- g .Skip ("Test is temporarily disabled while we make anticipated, breaking changes." )
201+ g .Skip ("This test is broken: need to verify OCP max version behavior" )
202+ checkFeatureCapability (ctx , oc )
203+
168204 const (
169205 packageName = "elasticsearch-operator"
170206 version = "5.8.13"
171207 )
172- // Check for tech preview, if this is not tech preview, bail
173- if ! exutil .IsTechPreviewNoUpgrade (ctx , oc .AdminConfigClient ()) {
174- g .Skip ("Test only runs in tech-preview" )
175- }
176208
177- ns := oc .Namespace ()
178- g .By (fmt .Sprintf ("Updating the namespace to: %q" , ns ))
179- newCeFile = ceFile + "." + ns
180- b , err := os .ReadFile (ceFile )
181- o .Expect (err ).NotTo (o .HaveOccurred ())
182- s := updateCe (b , ns , packageName , version )
183- err = os .WriteFile (newCeFile , []byte (s ), 0666 )
184- o .Expect (err ).NotTo (o .HaveOccurred ())
185-
186- g .By ("applying the necessary resources" )
187- err = oc .AsAdmin ().WithoutNamespace ().Run ("apply" ).Args ("-f" , newCeFile ).Execute ()
188- o .Expect (err ).NotTo (o .HaveOccurred ())
209+ newCeFile = applyClusterExtension (oc , packageName , version , ceFile )
189210
190211 g .By ("waiting for the ClusterExtention to be installed" )
191- err = wait .PollUntilContextTimeout (ctx , time .Second , 5 * time .Minute , true ,
212+ err : = wait .PollUntilContextTimeout (ctx , time .Second , 5 * time .Minute , true ,
192213 func (ctx context.Context ) (bool , error ) {
193- return WaitForClusterExtensionReady (oc , "install-test-ce" )
214+ return waitForClusterExtensionReady (oc , "install-test-ce" )
194215 })
195216 o .Expect (err ).NotTo (o .HaveOccurred ())
196217
197- g .By ("ensuring the cluster is upgradeable when no olm.maxopenshiftversion is specified" )
218+ g .By ("ensuring the cluster is not upgradeable when olm.maxopenshiftversion is specified" )
198219 err = wait .PollUntilContextTimeout (ctx , time .Second , 5 * time .Minute , true ,
199220 func (ctx context.Context ) (bool , error ) {
200- return WaitForCondition (oc , false )
221+ return waitForUpgradableCondition (oc , false )
201222 })
202223 o .Expect (err ).NotTo (o .HaveOccurred ())
203224 })
204225})
205226
206- func updateCe (b []byte , args ... string ) string {
227+ func applyClusterExtension (oc * exutil.CLI , packageName , version , ceFile string ) string {
228+ ns := oc .Namespace ()
229+ g .By (fmt .Sprintf ("updating the namespace to: %q" , ns ))
230+ newCeFile := ceFile + "." + ns
231+ b , err := os .ReadFile (ceFile )
232+ o .Expect (err ).NotTo (o .HaveOccurred ())
207233 s := string (b )
208- s = strings .ReplaceAll (s , "{REPLACE}" , args [0 ])
209- s = strings .ReplaceAll (s , "{PACKAGENAME}" , args [1 ])
210- s = strings .ReplaceAll (s , "{VERSION}" , args [2 ])
211- return s
234+ s = strings .ReplaceAll (s , "{NAMESPACE}" , ns )
235+ s = strings .ReplaceAll (s , "{PACKAGENAME}" , packageName )
236+ s = strings .ReplaceAll (s , "{VERSION}" , version )
237+ err = os .WriteFile (newCeFile , []byte (s ), 0666 )
238+ o .Expect (err ).NotTo (o .HaveOccurred ())
239+
240+ g .By ("applying the necessary resources" )
241+ err = oc .AsAdmin ().WithoutNamespace ().Run ("apply" ).Args ("-f" , newCeFile ).Execute ()
242+ o .Expect (err ).NotTo (o .HaveOccurred ())
243+ return newCeFile
212244}
213245
214- func WaitForClusterExtensionReady (oc * exutil.CLI , ceName string ) (done bool , err error ) {
246+ func waitForClusterExtensionReady (oc * exutil.CLI , ceName string ) (done bool , err error ) {
215247 var conditions []metav1.Condition
216248 output , err := oc .AsAdmin ().WithoutNamespace ().Run ("get" ).Args ("clusterextensions.olm.operatorframework.io" , ceName , "-o=jsonpath={.status.conditions}" ).Output ()
217249 if err != nil {
@@ -225,7 +257,7 @@ func WaitForClusterExtensionReady(oc *exutil.CLI, ceName string) (done bool, err
225257 if err != nil {
226258 return false , fmt .Errorf ("error in json.Unmarshal(%v): %v" , output , err )
227259 }
228- if ! meta .IsStatusConditionPresentAndEqual (conditions , "Progressing" , metav1 .ConditionFalse ) {
260+ if ! meta .IsStatusConditionPresentAndEqual (conditions , "Progressing" , metav1 .ConditionTrue ) {
229261 return false , nil
230262 }
231263 if ! meta .IsStatusConditionPresentAndEqual (conditions , "Installed" , metav1 .ConditionTrue ) {
@@ -234,9 +266,9 @@ func WaitForClusterExtensionReady(oc *exutil.CLI, ceName string) (done bool, err
234266 return true , nil
235267}
236268
237- func WaitForCondition (oc * exutil.CLI , status bool ) (done bool , err error ) {
269+ func waitForClusterExtensionFailure (oc * exutil.CLI , ceName string ) (done bool , err error ) {
238270 var conditions []metav1.Condition
239- output , err := oc .AsAdmin ().WithoutNamespace ().Run ("get" ).Args ("clusterextensions.olm.operatorframework.io" , "install-test-ce" , "-o=jsonpath={.status.conditions}" ).Output ()
271+ output , err := oc .AsAdmin ().WithoutNamespace ().Run ("get" ).Args ("clusterextensions.olm.operatorframework.io" , ceName , "-o=jsonpath={.status.conditions}" ).Output ()
240272 if err != nil {
241273 return false , err
242274 }
@@ -248,8 +280,79 @@ func WaitForCondition(oc *exutil.CLI, status bool) (done bool, err error) {
248280 if err != nil {
249281 return false , fmt .Errorf ("error in json.Unmarshal(%v): %v" , output , err )
250282 }
251- if ! meta .IsStatusConditionPresentAndEqual (conditions , "Installed" , metav1 .ConditionTrue ) {
283+ if ! meta .IsStatusConditionPresentAndEqual (conditions , "Progressing" , metav1 .ConditionTrue ) {
284+ return false , nil
285+ }
286+ c := meta .FindStatusCondition (conditions , "Progressing" )
287+ if c == nil {
288+ return false , fmt .Errorf ("Progressing condtion should not be nil" )
289+ }
290+ if ! strings .HasPrefix (c .Message , "no bundles found" ) {
291+ return false , nil
292+ }
293+ if ! meta .IsStatusConditionPresentAndEqual (conditions , "Installed" , metav1 .ConditionFalse ) {
294+ return false , nil
295+ }
296+ return true , nil
297+ }
298+
299+ func waitForUpgradableCondition (oc * exutil.CLI , status bool ) (bool , error ) {
300+ var conditions []metav1.Condition
301+ output , err := oc .AsAdmin ().WithoutNamespace ().Run ("get" ).Args ("olms.operator.openshift.io" , "cluster" , "-o=jsonpath={.status.conditions}" ).Output ()
302+ if err != nil {
303+ return false , err
304+ }
305+ // no data yet, so try again
306+ if output == "" {
307+ return false , nil
308+ }
309+ err = json .Unmarshal ([]byte (output ), & conditions )
310+ if err != nil {
311+ return false , fmt .Errorf ("error in json.Unmarshal(%v): %v" , output , err )
312+ }
313+ if status {
314+ return meta .IsStatusConditionTrue (conditions , typeIncompatibleOperatorsUpgradeable ), nil
315+ }
316+ return meta .IsStatusConditionFalse (conditions , typeIncompatibleOperatorsUpgradeable ), nil
317+ }
318+
319+ func waitForCatalogFailure (oc * exutil.CLI , name string ) (bool , error ) {
320+ output , err := oc .AsAdmin ().WithoutNamespace ().Run ("get" ).Args ("clustercatalogs.olm.operatorframework.io" , name , "-o=jsonpath={.status.conditions}" ).Output ()
321+ if err != nil {
322+ return false , err
323+ }
324+ // no data yet, so try again
325+ if output == "" {
326+ return false , nil
327+ }
328+ var conditions []metav1.Condition
329+ err = json .Unmarshal ([]byte (output ), & conditions )
330+ if err != nil {
331+ return false , fmt .Errorf ("error in json.Unmarshal(%v): %v" , output , err )
332+ }
333+ if ! meta .IsStatusConditionPresentAndEqual (conditions , "Progressing" , metav1 .ConditionTrue ) {
334+ return false , nil
335+ }
336+ c := meta .FindStatusCondition (conditions , "Progressing" )
337+ if c == nil {
338+ return false , fmt .Errorf ("Progressing condtion should not be nil" )
339+ }
340+ if c .Reason != "Retrying" {
341+ return false , nil
342+ }
343+ if ! strings .Contains (c .Message , "error creating image source" ) {
252344 return false , nil
253345 }
254346 return true , nil
255347}
348+
349+ func checkFeatureCapability (ctx context.Context , oc * exutil.CLI ) {
350+ // Hardcoded until openshift/api is updated:
351+ // import ( configv1 "github.com/openshift/api/config/v1" )
352+ // configv1.ClusterVersionCapabilityOperatorLifecycleManagerV1
353+ cap , err := exutil .IsCapabilityEnabled (oc , "OperatorLifecycleManagerV1" )
354+ o .Expect (err ).NotTo (o .HaveOccurred ())
355+ if ! cap {
356+ g .Skip ("Test only runs with OperatorLifecycleManagerV1 capability" )
357+ }
358+ }
0 commit comments