RamenDR / ramen

Apache License 2.0
70 stars 51 forks source link

e2e: run both rbd and cephfs pvc based subscription #1418

Closed par97 closed 3 weeks ago

ShyamsundarR commented 3 weeks ago

@par97 one change to this PR as suggested below (only compile tested).

The intention is that we do not need to teach/code the test for each workload, makes it easier to add more tests or test files, instead the deployment is passed the "env" it needs to run on and would know how to best kustomize itself to the env.

Otherwise the PR looks good.

diff --git a/e2e/exhaustive_suite_test.go b/e2e/exhaustive_suite_test.go
index 8ef5e52d..34d4cd06 100644
--- a/e2e/exhaustive_suite_test.go
+++ b/e2e/exhaustive_suite_test.go
@@ -40,16 +40,7 @@ func generateWorkloads([]workloads.Workload) {
                        Revision: GITREVISION,
                        AppName:  APPNAME,
                        Name:     fmt.Sprintf("Deployment-%d", i),
-                       Patch: `{
-                                               "patches": [{
-                                                       "target": {
-                                                               "kind": "PersistentVolumeClaim",
-                                                               "name": "busybox-pvc"
-                                                       },
-                                                       "patch": "- op: replace\n  path: /spec/storageClassName\n  value: ` + pvcs[i].StorageClassName +
-                               `\n- op: add\n  path: /spec/accessModes\n  value: [` + pvcs[i].AccessModes + `]"
-                                               }]
-                                       }`,
+                       PVCSpec:  pvcs[i],
                }
                Workloads = append(Workloads, deployment)
        }
diff --git a/e2e/workloads/deployment.go b/e2e/workloads/deployment.go
index 64278d2d..46339afc 100644
--- a/e2e/workloads/deployment.go
+++ b/e2e/workloads/deployment.go
@@ -3,13 +3,15 @@

 package workloads

+import "github.com/ramendr/ramen/e2e/util"
+
 type Deployment struct {
        // RepoURL  string
        Path     string
        Revision string
        AppName  string
        Name     string
-       Patch    string
+       PVCSpec  util.PVC
 }

 func (w Deployment) GetAppName() string {
@@ -33,7 +35,32 @@ func (w Deployment) GetRevision() string {
 }

 func (w Deployment) Kustomize() string {
-       return w.Patch
+       if w.PVCSpec.StorageClassName == "" && w.PVCSpec.AccessModes == "" {
+               return ""
+       }
+
+       scName := "rook-ceph-block"
+       if w.PVCSpec.StorageClassName != "" {
+               scName = w.PVCSpec.StorageClassName
+       }
+
+       accessMode := "ReadWriteOnce"
+       if w.PVCSpec.AccessModes != "" {
+               accessMode = w.PVCSpec.AccessModes
+       }
+
+       patch := `{
+               "patches": [{
+                       "target": {
+                               "kind": "PersistentVolumeClaim",
+                               "name": "busybox-pvc"
+                       },
+                       "patch": "- op: replace\n  path: /spec/storageClassName\n  value: ` + scName +
+               `\n- op: add\n  path: /spec/accessModes\n  value: [` + accessMode + `]"
+               }]
+       }`
+
+       return patch
 }

 func (w Deployment) GetResources() error {
ShyamsundarR commented 3 weeks ago

Ran this locally on a drenv setup and e2e worked fine. Unsure why e2e failed above, retrying once and potentially merging the PR for subsequent runs.