Skip to content

Commit

Permalink
e2e: Fix supported check
Browse files Browse the repository at this point in the history
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: RamenDR#1635
Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Dec 11, 2024
1 parent 59d41ea commit 365e07f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 21 deletions.
2 changes: 2 additions & 0 deletions e2e/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ pvcspecs:
- name: cephfs
storageclassname: rook-cephfs
accessmodes: ReadWriteMany
unsupportedDeployers:
- disapp
6 changes: 1 addition & 5 deletions e2e/deployers/applicationset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 1 addition & 5 deletions e2e/deployers/discoveredapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
type DiscoveredApp struct{}

func (d DiscoveredApp) GetName() string {
return "Disapp"
return "disapp"
}

func (d DiscoveredApp) GetNamespace() string {
Expand Down Expand Up @@ -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
}
6 changes: 1 addition & 5 deletions e2e/deployers/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const McsbName = ClusterSetName
type Subscription struct{}

func (s Subscription) GetName() string {
return "Subscr"
return "subscr"
}

func (s Subscription) GetNamespace() string {
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions e2e/test/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion e2e/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
7 changes: 4 additions & 3 deletions e2e/util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions e2e/workloads/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package workloads

import (
"context"
"slices"
"strings"

"github.com/ramendr/ramen/e2e/types"
"github.com/ramendr/ramen/e2e/util"
Expand Down Expand Up @@ -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 ""
Expand Down

0 comments on commit 365e07f

Please sign in to comment.