From 365e07fe187884e18d350742bc6e38c555eb0dc2 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Wed, 11 Dec 2024 11:05:01 +0200 Subject: [PATCH] e2e: Fix supported check We checked if a deployer supports a workload by checking the hardcoded string "Deploy-cephfs". This wrong it 2 ways, assuming that we use the "Deploy" prefix, and assuming that the storage name is "cephfs". Fix by adding "unsupportedDeployers" lists to PVCSpec. The cephfs default configuration include the "disapp" as unsupported deployer. Move the supported check from the deployer to the workload, since the deployer has no state and it cannot tell if a workload is supported. To make it easier to filter deployers, names are now lower case. We anyway use lower case for test names. With this change, we can use any PVCSpec name, and we can keep multiple configurations running all of some the tests. Fixes: #1635 Signed-off-by: Nir Soffer --- e2e/config.yaml | 2 ++ e2e/deployers/applicationset.go | 6 +----- e2e/deployers/discoveredapp.go | 6 +----- e2e/deployers/subscription.go | 6 +----- e2e/test/context.go | 4 ++-- e2e/types/types.go | 4 +++- e2e/util/config.go | 7 ++++--- e2e/workloads/deployment.go | 6 ++++++ 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/e2e/config.yaml b/e2e/config.yaml index f44ed19c3..34b779f03 100644 --- a/e2e/config.yaml +++ b/e2e/config.yaml @@ -9,3 +9,5 @@ pvcspecs: - name: cephfs storageclassname: rook-cephfs accessmodes: ReadWriteMany + unsupportedDeployers: + - disapp diff --git a/e2e/deployers/applicationset.go b/e2e/deployers/applicationset.go index 835e226b8..f86fc0ea9 100644 --- a/e2e/deployers/applicationset.go +++ b/e2e/deployers/applicationset.go @@ -80,17 +80,13 @@ func (a ApplicationSet) Undeploy(ctx types.Context) error { } func (a ApplicationSet) GetName() string { - return "Appset" + return "appset" } func (a ApplicationSet) GetNamespace() string { return util.ArgocdNamespace } -func (a ApplicationSet) IsWorkloadSupported(w types.Workload) bool { - return true -} - func (a ApplicationSet) IsDiscovered() bool { return false } diff --git a/e2e/deployers/discoveredapp.go b/e2e/deployers/discoveredapp.go index 54973c315..bc3f8d41a 100644 --- a/e2e/deployers/discoveredapp.go +++ b/e2e/deployers/discoveredapp.go @@ -15,7 +15,7 @@ import ( type DiscoveredApp struct{} func (d DiscoveredApp) GetName() string { - return "Disapp" + return "disapp" } func (d DiscoveredApp) GetNamespace() string { @@ -114,10 +114,6 @@ func (d DiscoveredApp) Undeploy(ctx types.Context) error { return nil } -func (d DiscoveredApp) IsWorkloadSupported(w types.Workload) bool { - return w.GetName() != "Deploy-cephfs" -} - func (d DiscoveredApp) IsDiscovered() bool { return true } diff --git a/e2e/deployers/subscription.go b/e2e/deployers/subscription.go index f3e0003e1..d6bf4ae7f 100644 --- a/e2e/deployers/subscription.go +++ b/e2e/deployers/subscription.go @@ -15,7 +15,7 @@ const McsbName = ClusterSetName type Subscription struct{} func (s Subscription) GetName() string { - return "Subscr" + return "subscr" } func (s Subscription) GetNamespace() string { @@ -86,10 +86,6 @@ func (s Subscription) Undeploy(ctx types.Context) error { return util.DeleteNamespace(util.Ctx.Hub.Client, namespace, log) } -func (s Subscription) IsWorkloadSupported(w types.Workload) bool { - return true -} - func (s Subscription) IsDiscovered() bool { return false } diff --git a/e2e/test/context.go b/e2e/test/context.go index 31e112e5a..40b4d9863 100644 --- a/e2e/test/context.go +++ b/e2e/test/context.go @@ -59,8 +59,8 @@ func (c *Context) Logger() *zap.SugaredLogger { // Validated return an error if the combination of deployer and workload is not supported. // TODO: validate that the workload is compatible with the clusters. func (c *Context) Validate() error { - if !c.deployer.IsWorkloadSupported(c.workload) { - return fmt.Errorf("workload %q not supported by deployer %q", c.workload.GetName(), c.deployer.GetName()) + if !c.workload.SupportsDeployer(c.deployer) { + return fmt.Errorf("workload %q does not support deployer %q", c.workload.GetName(), c.deployer.GetName()) } return nil diff --git a/e2e/types/types.go b/e2e/types/types.go index ca38004b6..bfced6dc5 100644 --- a/e2e/types/types.go +++ b/e2e/types/types.go @@ -15,7 +15,6 @@ type Deployer interface { GetName() string // GetNamespace return the namespace for the ramen resources, or empty string if not using a special namespace. GetNamespace() string - IsWorkloadSupported(Workload) bool // Return true for OCM discovered application, false for OCM managed applications. IsDiscovered() bool } @@ -29,6 +28,9 @@ type Workload interface { GetPath() string GetRevision() string + // SupportsDeployer returns tue if this workload is compatible with deployer. + SupportsDeployer(Deployer) bool + // TODO: replace client with cluster. Health(ctx Context, client client.Client, namespace string) error } diff --git a/e2e/util/config.go b/e2e/util/config.go index 230a1e51f..6e03e8186 100644 --- a/e2e/util/config.go +++ b/e2e/util/config.go @@ -11,9 +11,10 @@ import ( ) type PVCSpec struct { - Name string - StorageClassName string - AccessModes string + Name string + StorageClassName string + AccessModes string + UnsupportedDeployers []string } type TestConfig struct { ChannelName string diff --git a/e2e/workloads/deployment.go b/e2e/workloads/deployment.go index b0cdd1740..6d6189b35 100644 --- a/e2e/workloads/deployment.go +++ b/e2e/workloads/deployment.go @@ -5,6 +5,8 @@ package workloads import ( "context" + "slices" + "strings" "github.com/ramendr/ramen/e2e/types" "github.com/ramendr/ramen/e2e/util" @@ -37,6 +39,10 @@ func (w Deployment) GetRevision() string { return w.Revision } +func (w Deployment) SupportsDeployer(d types.Deployer) bool { + return !slices.Contains(w.PVCSpec.UnsupportedDeployers, strings.ToLower(d.GetName())) +} + func (w Deployment) Kustomize() string { if w.PVCSpec.StorageClassName == "" && w.PVCSpec.AccessModes == "" { return ""