From 52835883fd2817c4f67ac97cc7e9097b9722b9a1 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 | 2 +- e2e/deployers/discoveredapps.go | 2 +- e2e/deployers/subscription.go | 2 +- 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(+), 9 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 228dcf6f3..cc7e2e289 100644 --- a/e2e/deployers/applicationset.go +++ b/e2e/deployers/applicationset.go @@ -82,7 +82,7 @@ func (a ApplicationSet) Undeploy(ctx types.Context) error { } func (a ApplicationSet) GetName() string { - return "Appset" + return "appset" } func (a ApplicationSet) GetNamespace() string { diff --git a/e2e/deployers/discoveredapps.go b/e2e/deployers/discoveredapps.go index 24e77c708..e0860ca3b 100644 --- a/e2e/deployers/discoveredapps.go +++ b/e2e/deployers/discoveredapps.go @@ -15,7 +15,7 @@ import ( type DiscoveredApps struct{} func (d DiscoveredApps) GetName() string { - return "Disapp" + return "disapp" } func (d DiscoveredApps) GetNamespace() string { diff --git a/e2e/deployers/subscription.go b/e2e/deployers/subscription.go index aa64eb3a2..994039ad7 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 { diff --git a/e2e/test/context.go b/e2e/test/context.go index 8bfdafac0..62bcaa9bc 100644 --- a/e2e/test/context.go +++ b/e2e/test/context.go @@ -66,8 +66,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 e2675f398..dd6dffe1f 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 } type Workload interface { @@ -27,6 +26,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 ""