Skip to content
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

e2e: Support any storage class name #1714

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions e2e/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ channelname: "ramen-gitops"
channelnamespace: "ramen-samples"
giturl: "https://github.com/RamenDR/ocm-ramen-samples.git"
pvcspecs:
- storageclassname: rook-cephfs
accessmodes: ReadWriteMany
- storageclassname: rook-ceph-block
- name: rbd
storageclassname: rook-ceph-block
accessmodes: ReadWriteOnce
- name: cephfs
storageclassname: rook-cephfs
accessmodes: ReadWriteMany
unsupportedDeployers:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer limiting the config file to user preferences. Whether a storageClass is not supported by a deployer is a function of the code not config.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in combination with my other comment, the helper function can decide in code if a pvcspec name is incompatible with a workload,deployer config.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code does not have any way to tell if something is supported or not. This is pure configuration.

When this is set in the configuration, I can create multiple configurations. For If I work on rbd related stuff, I can run the test only with rbd, without using cryptic -run arguments. This is much more powerful that doing this in code.

- 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
}
18 changes: 1 addition & 17 deletions e2e/exhaustive_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package e2e_test

import (
"fmt"
"strings"
"testing"

"github.com/ramendr/ramen/e2e/deployers"
Expand Down Expand Up @@ -33,30 +32,15 @@ var (
Deployers = []types.Deployer{subscription, appset, discoveredApps}
)

func generateSuffix(storageClassName string) string {
suffix := storageClassName

if strings.ToLower(storageClassName) == "rook-ceph-block" {
suffix = "rbd"
}

if strings.ToLower(storageClassName) == "rook-cephfs" {
suffix = "cephfs"
}

return suffix
}

func generateWorkloads([]types.Workload) {
pvcSpecs := util.GetPVCSpecs()
for _, pvcSpec := range pvcSpecs {
// add storageclass name to deployment name
suffix := generateSuffix(pvcSpec.StorageClassName)
deployment := &workloads.Deployment{
Path: GITPATH,
Revision: GITREVISION,
AppName: APPNAME,
Name: fmt.Sprintf("Deploy-%s", suffix),
Name: fmt.Sprintf("Deploy-%s", pvcSpec.Name),
PVCSpec: pvcSpec,
}
Workloads = append(Workloads, deployment)
Expand Down
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
6 changes: 4 additions & 2 deletions e2e/util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
)

type PVCSpec struct {
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
Loading