-
Notifications
You must be signed in to change notification settings - Fork 46
OPRUN-4426: add ocp-87557 #635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bandrade
wants to merge
1
commit into
openshift:main
Choose a base branch
from
bandrade:OCP-87557
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+156
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |
| //nolint:staticcheck // ST1001: dot-imports for readability | ||
| . "github.com/onsi/gomega" | ||
|
|
||
| "github.com/openshift/origin/test/extended/util/image" | ||
| batchv1 "k8s.io/api/batch/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
|
|
@@ -20,6 +21,8 @@ import ( | |
|
|
||
| olmv1 "github.com/operator-framework/operator-controller/api/v1" | ||
|
|
||
| catalogdata "github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/bindata/catalog" | ||
| operatordata "github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/bindata/operator" | ||
| "github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/env" | ||
| "github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/helpers" | ||
| ) | ||
|
|
@@ -256,6 +259,133 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 | |
| }) | ||
| }) | ||
|
|
||
| var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected][Serial] OLMv1 ClusterExtension behavior after selected catalog removal", func() { | ||
| var ( | ||
| k8sClient client.Client | ||
| namespace string | ||
| catalog string | ||
| ceName string | ||
| packageRef string | ||
| ) | ||
|
|
||
| BeforeEach(func(ctx SpecContext) { | ||
| helpers.RequireOLMv1CapabilityOnOpenshift() | ||
| helpers.RequireImageRegistry(ctx) | ||
| k8sClient = env.Get().K8sClient | ||
|
|
||
| replacements := map[string]string{ | ||
| "{{ TEST-BUNDLE }}": "", // auto-filled | ||
| "{{ NAMESPACE }}": "", // auto-filled | ||
| "{{ TEST-CONTROLLER }}": image.ShellImage(), | ||
| } | ||
| unique, nsName, ccName, opName := helpers.NewCatalogAndClusterBundles(ctx, replacements, | ||
| catalogdata.AssetNames, catalogdata.Asset, | ||
| operatordata.AssetNames, operatordata.Asset, | ||
| ) | ||
| _ = unique | ||
| namespace = nsName | ||
| catalog = ccName | ||
| packageRef = opName | ||
|
|
||
| By("waiting for the catalog to be serving") | ||
| Eventually(func(g Gomega) { | ||
| cc := &olmv1.ClusterCatalog{} | ||
| err := k8sClient.Get(ctx, client.ObjectKey{Name: catalog}, cc) | ||
| g.Expect(err).NotTo(HaveOccurred(), "failed to get ClusterCatalog") | ||
|
|
||
| serving := meta.FindStatusCondition(cc.Status.Conditions, "Serving") | ||
| g.Expect(serving).NotTo(BeNil(), "expected Serving condition") | ||
| g.Expect(serving.Status).To(Equal(metav1.ConditionTrue), "expected Serving=True") | ||
| }).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed()) | ||
|
|
||
| By(fmt.Sprintf("creating ClusterExtension for package %q from catalog %q", packageRef, catalog)) | ||
| var cleanupCE func() | ||
| ceName, cleanupCE = helpers.CreateClusterExtension(packageRef, "", namespace, "", helpers.WithCatalogNameSelector(catalog)) | ||
| DeferCleanup(cleanupCE) | ||
| }) | ||
|
|
||
| AfterEach(func(ctx SpecContext) { | ||
| if CurrentSpecReport().Failed() { | ||
| By("dumping for debugging") | ||
| helpers.DescribeAllClusterCatalogs(ctx) | ||
| helpers.DescribeAllClusterExtensions(ctx, namespace) | ||
| } | ||
| }) | ||
|
|
||
| It("should keep Installed=True and report Progressing=True/Succeeded when the selected catalog is removed", func(ctx SpecContext) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both |
||
| By("waiting for the ClusterExtension to install") | ||
| helpers.ExpectClusterExtensionToBeInstalled(ctx, ceName) | ||
|
|
||
| By("verifying Installed=True before deleting the catalog") | ||
| Eventually(func(g Gomega) { | ||
| ce := &olmv1.ClusterExtension{} | ||
| err := k8sClient.Get(ctx, client.ObjectKey{Name: ceName}, ce) | ||
| g.Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| installed := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeInstalled) | ||
| g.Expect(installed).NotTo(BeNil(), "Installed condition not found") | ||
| g.Expect(installed.Status).To(Equal(metav1.ConditionTrue), "expected Installed=True before catalog deletion") | ||
| }).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed()) | ||
|
|
||
| By(fmt.Sprintf("deleting ClusterCatalog %q", catalog)) | ||
| cc := &olmv1.ClusterCatalog{ObjectMeta: metav1.ObjectMeta{Name: catalog}} | ||
| Expect(k8sClient.Delete(ctx, cc)).To(Succeed(), "failed to delete ClusterCatalog") | ||
|
|
||
| By("waiting for the ClusterCatalog to be deleted") | ||
| Eventually(func() bool { | ||
| err := k8sClient.Get(ctx, client.ObjectKey{Name: catalog}, &olmv1.ClusterCatalog{}) | ||
| return apierrors.IsNotFound(err) | ||
| }).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(BeTrue()) | ||
|
|
||
| By("waiting for ClusterExtension conditions to reflect fallback to the installed bundle") | ||
| Eventually(func(g Gomega) { | ||
| ce := &olmv1.ClusterExtension{} | ||
| err := k8sClient.Get(ctx, client.ObjectKey{Name: ceName}, ce) | ||
| g.Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| progressing := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeProgressing) | ||
| g.Expect(progressing).NotTo(BeNil(), "Progressing condition not found") | ||
| g.Expect(progressing.Status).To(Equal(metav1.ConditionTrue), "expected Progressing=True after catalog deletion") | ||
| g.Expect(progressing.Reason).To(Equal("Succeeded"), "expected Progressing reason=Succeeded after fallback to the installed bundle") | ||
|
|
||
| installed := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeInstalled) | ||
| g.Expect(installed).NotTo(BeNil(), "Installed condition not found") | ||
| g.Expect(installed.Status).To(Equal(metav1.ConditionTrue), "expected Installed=True after catalog deletion") | ||
| }).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed()) | ||
| }) | ||
|
|
||
| It("should keep Installed=True when package source is removed by deleting the selected catalog", func(ctx SpecContext) { | ||
| By("waiting for the ClusterExtension to install") | ||
| helpers.ExpectClusterExtensionToBeInstalled(ctx, ceName) | ||
|
|
||
| By("simulating package removal by deleting the selected catalog") | ||
| cc := &olmv1.ClusterCatalog{ObjectMeta: metav1.ObjectMeta{Name: catalog}} | ||
| Expect(k8sClient.Delete(ctx, cc)).To(Succeed(), "failed to delete ClusterCatalog") | ||
|
|
||
| By("waiting for the ClusterCatalog to be deleted") | ||
| Eventually(func() bool { | ||
| err := k8sClient.Get(ctx, client.ObjectKey{Name: catalog}, &olmv1.ClusterCatalog{}) | ||
| return apierrors.IsNotFound(err) | ||
| }).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(BeTrue()) | ||
|
|
||
| By("verifying ClusterExtension conditions after package source removal") | ||
| Eventually(func(g Gomega) { | ||
| ce := &olmv1.ClusterExtension{} | ||
| err := k8sClient.Get(ctx, client.ObjectKey{Name: ceName}, ce) | ||
| g.Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| progressing := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeProgressing) | ||
| g.Expect(progressing).NotTo(BeNil(), "Progressing condition not found") | ||
| g.Expect(progressing.Status).To(Equal(metav1.ConditionTrue), "expected Progressing=True after source removal") | ||
| g.Expect(progressing.Reason).To(Equal("Succeeded"), "expected Progressing reason=Succeeded after fallback to the installed bundle") | ||
|
|
||
| installed := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeInstalled) | ||
| g.Expect(installed).NotTo(BeNil(), "Installed condition not found") | ||
| g.Expect(installed.Status).To(Equal(metav1.ConditionTrue), "expected Installed=True after source removal") | ||
| }).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed()) | ||
| }) | ||
| }) | ||
bandrade marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| func buildCurlJob(prefix, namespace, url, serviceAccountName string) *batchv1.Job { | ||
| backoff := int32(1) | ||
| // This means the k8s garbage collector will automatically delete the job 5 minutes | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing if truly unused.