-
Notifications
You must be signed in to change notification settings - Fork 92
OADP-7235: OLMv1 lifecycle tests + OLMv0→OLMv1 migration target #2160
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
weshayutin
wants to merge
23
commits into
openshift:oadp-dev
Choose a base branch
from
weshayutin:olmv1tests
base: oadp-dev
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.
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2b88073
dnm: test olmv1 deployment
weshayutin 76f9c16
fix unit tests
weshayutin ac16803
update lint
weshayutin 565e178
Enhance OLMv1 migration support: update service account naming, add m…
kaovilai 8285756
Add OLMv0 remnant cleanup and CatalogSource migration to OLMv1 tests
kaovilai 5234080
Add olm.managed=true cleanup to Makefile migration target
kaovilai f9cfb45
Add CI compatibility, version verification, and docs for OLMv1 migrat…
kaovilai 9de0e76
Add generated OLMv1 manifest to .gitignore
kaovilai d30d922
Address review feedback: fix manifest schema, scope cleanup, add mirr…
kaovilai da78e23
fix: replace xargs -r with portable POSIX alternative in Makefile
kaovilai c8ccff9
fix: handle List errors in Eventually closures to prevent nil deref
kaovilai 87a3e6e
fix: log List errors in OLMv0 remnant cleanup instead of discarding
kaovilai 4cab1a0
fix: set createdCatalog flag when existing ClusterCatalog matches image
kaovilai 929711e
fix: wait for CRD deletion to complete before proceeding
kaovilai 8d1fb17
fix: delete existing ClusterExtension before Create for rerun safety
kaovilai 3cc3733
fix: pin catalog selector in migration path when catalog is auto-dete…
kaovilai 698fcc2
fix: log when ClusterCatalog has no conditions yet during wait
kaovilai 8cd05a8
fix: default OLMv1 test targets to ttl.sh with auto-build
kaovilai 05d8104
fix: default OLMV1_VERSION to VERSION (99.0.0)
kaovilai 04564d0
fix: echo OLMv1 test configuration before running
kaovilai ba5487d
fix: skip OLMv1 tests when cluster lacks prerequisites
kaovilai 16fb09e
fix: check NewOLMOwnSingleNamespace feature gate before running tests
kaovilai c62bcbd
fix: support CustomNoUpgrade as alternative to TechPreviewNoUpgrade
kaovilai 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| tmp/ |
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 |
|---|---|---|
| @@ -0,0 +1,264 @@ | ||
| package olmv1_test | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "log" | ||
| "time" | ||
|
|
||
| "github.com/onsi/ginkgo/v2" | ||
| "github.com/onsi/gomega" | ||
| corev1 "k8s.io/api/core/v1" | ||
| apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| const ( | ||
| clusterExtensionName = "oadp-operator" | ||
|
|
||
| oadpCRDName = "dataprotectionapplications.oadp.openshift.io" | ||
| veleroCRDName = "backups.velero.io" | ||
| restoreCRDName = "restores.velero.io" | ||
|
kaovilai marked this conversation as resolved.
|
||
|
|
||
| managerLabelSelector = "control-plane=controller-manager" | ||
| ) | ||
|
|
||
| var _ = ginkgo.Describe("OADP OLMv1 lifecycle", ginkgo.Ordered, ginkgo.Label("olmv1"), func() { | ||
| ctx := context.Background() | ||
|
|
||
| ginkgo.BeforeAll(func() { | ||
| ginkgo.By("Cleaning up orphaned OADP/Velero CRDs from previous installs") | ||
| cleanupOrphanedCRDs(ctx) | ||
|
|
||
| ginkgo.By("Setting up namespace, ServiceAccount, and RBAC") | ||
| ensureNamespace(ctx, namespace) | ||
| ensureServiceAccount(ctx, serviceAccountName, namespace) | ||
| ensureClusterAdminBinding(ctx, serviceAccountName, namespace) | ||
|
|
||
| if catalogImage != "" { | ||
| ginkgo.By(fmt.Sprintf("Creating ClusterCatalog %s from image %s", catalogName, catalogImage)) | ||
| ensureClusterCatalog(ctx, catalogName, catalogImage) | ||
| waitForClusterCatalogServing(ctx, catalogName) | ||
| } | ||
| }) | ||
|
|
||
| ginkgo.AfterAll(func() { | ||
| ginkgo.By("Cleaning up OLMv1 test resources") | ||
| err := deleteClusterExtension(ctx, clusterExtensionName) | ||
| if err != nil { | ||
| log.Printf("Warning: failed to delete ClusterExtension: %v", err) | ||
| } | ||
|
|
||
| gomega.Eventually(func() bool { | ||
| _, err := getClusterExtension(ctx, clusterExtensionName) | ||
| return apierrors.IsNotFound(err) | ||
| }, 3*time.Minute, 5*time.Second).Should(gomega.BeTrue(), "ClusterExtension should be deleted") | ||
|
|
||
| if createdCatalog { | ||
| ginkgo.By(fmt.Sprintf("Deleting ClusterCatalog %s", catalogName)) | ||
| deleteClusterCatalog(ctx, catalogName) | ||
| } | ||
|
|
||
| cleanupClusterRoleBinding(ctx, serviceAccountName) | ||
| }) | ||
|
|
||
| ginkgo.It("should install OADP operator via ClusterExtension", func() { | ||
| ginkgo.By("Creating the ClusterExtension") | ||
| ce := buildClusterExtension(clusterExtensionName, packageName, namespace, serviceAccountName) | ||
| _, err := dynamicClient.Resource(clusterExtensionGVR).Create(ctx, ce, metav1.CreateOptions{}) | ||
|
kaovilai marked this conversation as resolved.
|
||
| gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
| log.Printf("Created ClusterExtension %s (package=%s, namespace=%s)", clusterExtensionName, packageName, namespace) | ||
|
|
||
| ginkgo.By("Waiting for ClusterExtension to be installed") | ||
| terminalReasons := map[string]bool{ | ||
| "InvalidConfiguration": true, | ||
| "Failed": true, | ||
| } | ||
| gomega.Eventually(func(g gomega.Gomega) { | ||
| obj, err := getClusterExtension(ctx, clusterExtensionName) | ||
| g.Expect(err).NotTo(gomega.HaveOccurred(), "ClusterExtension should exist") | ||
|
|
||
| logAllConditions(obj) | ||
|
|
||
| progCond, progFound := getCondition(obj, "Progressing") | ||
| if progFound { | ||
| reason, _ := progCond["reason"].(string) | ||
| message, _ := progCond["message"].(string) | ||
| g.Expect(terminalReasons[reason]).NotTo(gomega.BeTrue(), | ||
| "ClusterExtension has terminal error on Progressing: reason=%s message=%s", reason, message) | ||
| } | ||
|
|
||
| instCond, instFound := getCondition(obj, "Installed") | ||
| g.Expect(instFound).To(gomega.BeTrue(), "Installed condition should be present") | ||
| status, _ := instCond["status"].(string) | ||
| g.Expect(status).To(gomega.Equal("True"), "Installed condition should be True") | ||
| }, 10*time.Minute, 10*time.Second).Should(gomega.Succeed()) | ||
|
|
||
| ginkgo.By("Checking installed bundle info") | ||
| obj, err := getClusterExtension(ctx, clusterExtensionName) | ||
| gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
| bundleName, bundleVersion, found := getInstalledBundle(obj) | ||
| gomega.Expect(found).To(gomega.BeTrue(), "installed bundle should be present in status") | ||
| log.Printf("Installed bundle: name=%s version=%s", bundleName, bundleVersion) | ||
| }) | ||
|
|
||
| ginkgo.It("should have the OADP controller-manager pod running", func() { | ||
| ginkgo.By("Waiting for controller-manager pod to be Running") | ||
| gomega.Eventually(func() (bool, error) { | ||
| pods, err := kubeClient.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{ | ||
| LabelSelector: managerLabelSelector, | ||
| }) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
| for _, pod := range pods.Items { | ||
| if pod.Status.Phase == corev1.PodRunning { | ||
| log.Printf("Controller-manager pod %s is Running", pod.Name) | ||
| return true, nil | ||
| } | ||
| log.Printf("Controller-manager pod %s phase: %s", pod.Name, pod.Status.Phase) | ||
| } | ||
| return false, nil | ||
| }, 5*time.Minute, 10*time.Second).Should(gomega.BeTrue(), "controller-manager pod should be Running") | ||
|
weshayutin marked this conversation as resolved.
|
||
| }) | ||
|
|
||
| ginkgo.It("should have OADP CRDs installed", func() { | ||
| expectedCRDs := []string{ | ||
|
kaovilai marked this conversation as resolved.
|
||
| oadpCRDName, | ||
| veleroCRDName, | ||
| restoreCRDName, | ||
| "schedules.velero.io", | ||
| "backupstoragelocations.velero.io", | ||
| "volumesnapshotlocations.velero.io", | ||
| } | ||
|
|
||
| for _, crdName := range expectedCRDs { | ||
| ginkgo.By(fmt.Sprintf("Checking CRD %s exists", crdName)) | ||
| exists, err := crdExists(ctx, crdName) | ||
| gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
| gomega.Expect(exists).To(gomega.BeTrue(), fmt.Sprintf("CRD %s should exist", crdName)) | ||
| log.Printf("CRD %s exists", crdName) | ||
| } | ||
| }) | ||
|
|
||
| ginkgo.It("should not report deprecation warnings", func() { | ||
| obj, err := getClusterExtension(ctx, clusterExtensionName) | ||
| gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
|
|
||
| for _, condType := range []string{"Deprecated", "PackageDeprecated", "ChannelDeprecated", "BundleDeprecated"} { | ||
| cond, found := getCondition(obj, condType) | ||
| if found { | ||
| status, _ := cond["status"].(string) | ||
| gomega.Expect(status).To(gomega.Equal("False"), | ||
| fmt.Sprintf("%s condition should be False, got %s", condType, status)) | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| ginkgo.When("upgrading the operator", func() { | ||
| ginkgo.BeforeAll(func() { | ||
| if upgradeVersion == "" { | ||
| ginkgo.Skip("No --upgrade-version specified, skipping upgrade tests") | ||
| } | ||
| }) | ||
|
|
||
| ginkgo.It("should upgrade the ClusterExtension to the target version", func() { | ||
| ginkgo.By(fmt.Sprintf("Patching ClusterExtension version to %s", upgradeVersion)) | ||
| obj, err := getClusterExtension(ctx, clusterExtensionName) | ||
| gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
|
|
||
| previousBundleName, previousVersion, _ := getInstalledBundle(obj) | ||
| log.Printf("Current installed bundle: name=%s version=%s", previousBundleName, previousVersion) | ||
|
|
||
| catalogSpec, _, _ := unstructuredNestedMap(obj.Object, "spec", "source", "catalog") | ||
| gomega.Expect(catalogSpec).NotTo(gomega.BeNil()) | ||
| catalogSpec["version"] = upgradeVersion | ||
| catalogSpec["upgradeConstraintPolicy"] = "SelfCertified" | ||
| err = unstructuredSetNestedMap(obj.Object, catalogSpec, "spec", "source", "catalog") | ||
| gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
|
|
||
| _, err = dynamicClient.Resource(clusterExtensionGVR).Update(ctx, obj, metav1.UpdateOptions{}) | ||
| gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| log.Printf("Patched ClusterExtension version to %s", upgradeVersion) | ||
|
|
||
| ginkgo.By("Waiting for upgrade to complete") | ||
| gomega.Eventually(func() string { | ||
| updated, err := getClusterExtension(ctx, clusterExtensionName) | ||
| if err != nil { | ||
| return "" | ||
| } | ||
|
|
||
| cond, found := getCondition(updated, "Installed") | ||
| if !found { | ||
| return "" | ||
| } | ||
| status, _ := cond["status"].(string) | ||
| if status != "True" { | ||
| reason, _ := cond["reason"].(string) | ||
| message, _ := cond["message"].(string) | ||
| log.Printf("Installed condition: status=%s reason=%s message=%s", status, reason, message) | ||
| return "" | ||
| } | ||
|
|
||
| _, bundleVer, found := getInstalledBundle(updated) | ||
| if !found { | ||
| return "" | ||
| } | ||
| log.Printf("Installed bundle version: %s", bundleVer) | ||
| return bundleVer | ||
| }, 10*time.Minute, 10*time.Second).ShouldNot(gomega.Equal(previousVersion), | ||
| "Installed bundle version should change after upgrade") | ||
|
|
||
| ginkgo.By("Verifying controller-manager pod is running after upgrade") | ||
| gomega.Eventually(func() (bool, error) { | ||
| pods, err := kubeClient.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{ | ||
| LabelSelector: managerLabelSelector, | ||
| }) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
| for _, pod := range pods.Items { | ||
| if pod.Status.Phase == corev1.PodRunning { | ||
| return true, nil | ||
| } | ||
| } | ||
| return false, nil | ||
| }, 5*time.Minute, 10*time.Second).Should(gomega.BeTrue()) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| func unstructuredNestedMap(obj map[string]interface{}, fields ...string) (map[string]interface{}, bool, error) { | ||
| var current interface{} = obj | ||
| for _, field := range fields { | ||
| m, ok := current.(map[string]interface{}) | ||
| if !ok { | ||
| return nil, false, fmt.Errorf("expected map at field %s", field) | ||
| } | ||
| current, ok = m[field] | ||
| if !ok { | ||
| return nil, false, nil | ||
| } | ||
| } | ||
| result, ok := current.(map[string]interface{}) | ||
| if !ok { | ||
| return nil, false, fmt.Errorf("final value is not a map") | ||
| } | ||
| return result, true, nil | ||
| } | ||
|
|
||
| func unstructuredSetNestedMap(obj map[string]interface{}, value map[string]interface{}, fields ...string) error { | ||
| if len(fields) == 0 { | ||
| return fmt.Errorf("no fields specified") | ||
| } | ||
| current := obj | ||
| for _, field := range fields[:len(fields)-1] { | ||
| next, ok := current[field].(map[string]interface{}) | ||
| if !ok { | ||
| return fmt.Errorf("expected map at field %s", field) | ||
| } | ||
| current = next | ||
| } | ||
| current[fields[len(fields)-1]] = value | ||
| return nil | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.