Skip to content

Commit 81c5891

Browse files
committed
UPSTREAM: <carry>: add ocp-87557
1 parent 4f50aa7 commit 81c5891

3 files changed

Lines changed: 151 additions & 0 deletions

File tree

openshift/tests-extension/.openshift-tests-extension/openshift_payload_olmv1.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,26 @@
13231323
"lifecycle": "blocking",
13241324
"environmentSelector": {}
13251325
},
1326+
{
1327+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected][Serial] OLMv1 ClusterExtension behavior after selected catalog removal should keep Installed=True and report Progressing=True/Succeeded when the selected catalog is removed",
1328+
"labels": {},
1329+
"resources": {
1330+
"isolation": {}
1331+
},
1332+
"source": "openshift:payload:olmv1",
1333+
"lifecycle": "blocking",
1334+
"environmentSelector": {}
1335+
},
1336+
{
1337+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected][Serial] OLMv1 ClusterExtension behavior after selected catalog removal should keep Installed=True when package source is removed by deleting the selected catalog",
1338+
"labels": {},
1339+
"resources": {
1340+
"isolation": {}
1341+
},
1342+
"source": "openshift:payload:olmv1",
1343+
"lifecycle": "blocking",
1344+
"environmentSelector": {}
1345+
},
13261346
{
13271347
"name": "[sig-olmv1][OCPFeatureGate:NewOLMConfigAPI][Skipped:Disconnected] OLMv1 DeploymentConfig support should apply environment variables from deploymentConfig to operator deployment containers",
13281348
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLMConfigAPI][Skipped:Disconnected] OLMv1 DeploymentConfig support should apply environment variables from deploymentConfig to operator deployment containers",

openshift/tests-extension/cmd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ func main() {
279279
// Removed marketplace catalog tests (marketplace catalog removed from default catalogs)
280280
"[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 openshift-redhat-marketplace Catalog should serve FBC via the /v1/api/all endpoint",
281281
"[sig-olmv1][OCPFeatureGate:NewOLMCatalogdAPIV1Metas][Skipped:Disconnected] OLMv1 openshift-redhat-marketplace Catalog should serve FBC via the /v1/api/metas endpoint",
282+
"[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected][Serial] OLMv1 ClusterExtension behavior after selected catalog removal should keep Installed=True and report Progressing=True/Retrying when the selected catalog is removed",
282283
)
283284

284285
// Initialize the environment before running any tests.

openshift/tests-extension/test/olmv1-catalog.go

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
//nolint:staticcheck // ST1001: dot-imports for readability
1010
. "github.com/onsi/gomega"
1111

12+
"github.com/openshift/origin/test/extended/util/image"
1213
batchv1 "k8s.io/api/batch/v1"
1314
corev1 "k8s.io/api/core/v1"
1415
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -20,6 +21,8 @@ import (
2021

2122
olmv1 "github.com/operator-framework/operator-controller/api/v1"
2223

24+
catalogdata "github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/bindata/catalog"
25+
operatordata "github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/bindata/operator"
2326
"github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/env"
2427
"github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/helpers"
2528
)
@@ -256,6 +259,133 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1
256259
})
257260
})
258261

262+
var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected][Serial] OLMv1 ClusterExtension behavior after selected catalog removal", func() {
263+
var (
264+
k8sClient client.Client
265+
namespace string
266+
catalog string
267+
ceName string
268+
packageRef string
269+
)
270+
271+
BeforeEach(func(ctx SpecContext) {
272+
helpers.RequireOLMv1CapabilityOnOpenshift()
273+
helpers.RequireImageRegistry(ctx)
274+
k8sClient = env.Get().K8sClient
275+
276+
replacements := map[string]string{
277+
"{{ TEST-BUNDLE }}": "", // auto-filled
278+
"{{ NAMESPACE }}": "", // auto-filled
279+
"{{ TEST-CONTROLLER }}": image.ShellImage(),
280+
}
281+
unique, nsName, ccName, opName := helpers.NewCatalogAndClusterBundles(ctx, replacements,
282+
catalogdata.AssetNames, catalogdata.Asset,
283+
operatordata.AssetNames, operatordata.Asset,
284+
)
285+
_ = unique
286+
namespace = nsName
287+
catalog = ccName
288+
packageRef = opName
289+
290+
By("waiting for the catalog to be serving")
291+
Eventually(func(g Gomega) {
292+
cc := &olmv1.ClusterCatalog{}
293+
err := k8sClient.Get(ctx, client.ObjectKey{Name: catalog}, cc)
294+
g.Expect(err).NotTo(HaveOccurred(), "failed to get ClusterCatalog")
295+
296+
serving := meta.FindStatusCondition(cc.Status.Conditions, "Serving")
297+
g.Expect(serving).NotTo(BeNil(), "expected Serving condition")
298+
g.Expect(serving.Status).To(Equal(metav1.ConditionTrue), "expected Serving=True")
299+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
300+
301+
By(fmt.Sprintf("creating ClusterExtension for package %q from catalog %q", packageRef, catalog))
302+
var cleanupCE func()
303+
ceName, cleanupCE = helpers.CreateClusterExtension(packageRef, "", namespace, "", helpers.WithCatalogNameSelector(catalog))
304+
DeferCleanup(cleanupCE)
305+
})
306+
307+
AfterEach(func(ctx SpecContext) {
308+
if CurrentSpecReport().Failed() {
309+
By("dumping for debugging")
310+
helpers.DescribeAllClusterCatalogs(ctx)
311+
helpers.DescribeAllClusterExtensions(ctx, namespace)
312+
}
313+
})
314+
315+
It("should keep Installed=True and report Progressing=True/Succeeded when the selected catalog is removed", func(ctx SpecContext) {
316+
By("waiting for the ClusterExtension to install")
317+
helpers.ExpectClusterExtensionToBeInstalled(ctx, ceName)
318+
319+
By("verifying Installed=True before deleting the catalog")
320+
Eventually(func(g Gomega) {
321+
ce := &olmv1.ClusterExtension{}
322+
err := k8sClient.Get(ctx, client.ObjectKey{Name: ceName}, ce)
323+
g.Expect(err).NotTo(HaveOccurred())
324+
325+
installed := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeInstalled)
326+
g.Expect(installed).NotTo(BeNil(), "Installed condition not found")
327+
g.Expect(installed.Status).To(Equal(metav1.ConditionTrue), "expected Installed=True before catalog deletion")
328+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
329+
330+
By(fmt.Sprintf("deleting ClusterCatalog %q", catalog))
331+
cc := &olmv1.ClusterCatalog{ObjectMeta: metav1.ObjectMeta{Name: catalog}}
332+
Expect(k8sClient.Delete(ctx, cc)).To(Succeed(), "failed to delete ClusterCatalog")
333+
334+
By("waiting for the ClusterCatalog to be deleted")
335+
Eventually(func() bool {
336+
err := k8sClient.Get(ctx, client.ObjectKey{Name: catalog}, &olmv1.ClusterCatalog{})
337+
return apierrors.IsNotFound(err)
338+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(BeTrue())
339+
340+
By("waiting for ClusterExtension conditions to reflect fallback to the installed bundle")
341+
Eventually(func(g Gomega) {
342+
ce := &olmv1.ClusterExtension{}
343+
err := k8sClient.Get(ctx, client.ObjectKey{Name: ceName}, ce)
344+
g.Expect(err).NotTo(HaveOccurred())
345+
346+
progressing := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeProgressing)
347+
g.Expect(progressing).NotTo(BeNil(), "Progressing condition not found")
348+
g.Expect(progressing.Status).To(Equal(metav1.ConditionTrue), "expected Progressing=True after catalog deletion")
349+
g.Expect(progressing.Reason).To(Equal("Succeeded"), "expected Progressing reason=Succeeded after fallback to the installed bundle")
350+
351+
installed := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeInstalled)
352+
g.Expect(installed).NotTo(BeNil(), "Installed condition not found")
353+
g.Expect(installed.Status).To(Equal(metav1.ConditionTrue), "expected Installed=True after catalog deletion")
354+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
355+
})
356+
357+
It("should keep Installed=True when package source is removed by deleting the selected catalog", func(ctx SpecContext) {
358+
By("waiting for the ClusterExtension to install")
359+
helpers.ExpectClusterExtensionToBeInstalled(ctx, ceName)
360+
361+
By("simulating package removal by deleting the selected catalog")
362+
cc := &olmv1.ClusterCatalog{ObjectMeta: metav1.ObjectMeta{Name: catalog}}
363+
Expect(k8sClient.Delete(ctx, cc)).To(Succeed(), "failed to delete ClusterCatalog")
364+
365+
By("waiting for the ClusterCatalog to be deleted")
366+
Eventually(func() bool {
367+
err := k8sClient.Get(ctx, client.ObjectKey{Name: catalog}, &olmv1.ClusterCatalog{})
368+
return apierrors.IsNotFound(err)
369+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(BeTrue())
370+
371+
By("verifying ClusterExtension conditions after package source removal")
372+
Eventually(func(g Gomega) {
373+
ce := &olmv1.ClusterExtension{}
374+
err := k8sClient.Get(ctx, client.ObjectKey{Name: ceName}, ce)
375+
g.Expect(err).NotTo(HaveOccurred())
376+
377+
progressing := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeProgressing)
378+
g.Expect(progressing).NotTo(BeNil(), "Progressing condition not found")
379+
g.Expect(progressing.Status).To(Equal(metav1.ConditionTrue), "expected Progressing=True after source removal")
380+
g.Expect(progressing.Reason).To(Equal("Succeeded"), "expected Progressing reason=Succeeded after fallback to the installed bundle")
381+
382+
installed := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeInstalled)
383+
g.Expect(installed).NotTo(BeNil(), "Installed condition not found")
384+
g.Expect(installed.Status).To(Equal(metav1.ConditionTrue), "expected Installed=True after source removal")
385+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
386+
})
387+
})
388+
259389
func buildCurlJob(prefix, namespace, url, serviceAccountName string) *batchv1.Job {
260390
backoff := int32(1)
261391
// This means the k8s garbage collector will automatically delete the job 5 minutes

0 commit comments

Comments
 (0)