Skip to content

Commit

Permalink
Added e2e tests for clones
Browse files Browse the repository at this point in the history
  • Loading branch information
tdawe committed Dec 9, 2024
1 parent e22ab62 commit 01cbecd
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 6 deletions.
78 changes: 72 additions & 6 deletions test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,40 @@ func (f *feature) createZoneSnapshotsAndRestore(location string) error {
return nil
}

func (f *feature) createZoneClonesAndRestore(location string) error {
log.Println("[createZoneClonesAndRestore] Creating clones and restores")
templateFile := "templates/" + location + "/clone.yaml"
updatedTemplateFile := "templates/" + location + "/clone-updated.yaml"

for i := 0; i < int(f.zoneReplicaCount); i++ {
time.Sleep(10 * time.Second)

cpCmd := "cp " + templateFile + " " + updatedTemplateFile
b, err := execLocalCommand(cpCmd)
if err != nil {
return fmt.Errorf("failed to copy template file: %v\nErrMessage:\n%s", err, string(b))
}

// Update iteration and apply...
err = replaceInFile("ITERATION", strconv.Itoa(i), updatedTemplateFile)
if err != nil {
return err
}

createClone := "kubectl apply -f " + updatedTemplateFile
_, err = execLocalCommand(createClone)
if err != nil {
return err
}
}

log.Println("[createZoneClonesAndRestore] Clones and restores created")

return nil
}

func (f *feature) deleteZoneSnapshotsAndRestore(location string) error {
log.Println("[createZoneSnapshotsAndRestore] Deleting restores and snapshots")
log.Println("[deleteZoneSnapshotsAndRestore] Deleting restores and snapshots")
templateFile := "templates/" + location + "/snapshot.yaml"
updatedTemplateFile := "templates/" + location + "/snapshot-updated.yaml"

Expand All @@ -394,14 +426,46 @@ func (f *feature) deleteZoneSnapshotsAndRestore(location string) error {
return err
}

createSnapshot := "kubectl delete -f " + updatedTemplateFile
_, err = execLocalCommand(createSnapshot)
deleteSnapshot := "kubectl delete -f " + updatedTemplateFile
_, err = execLocalCommand(deleteSnapshot)
if err != nil {
return err
}
}

log.Println("[deleteZoneSnapshotsAndRestore] Snapshots and restores deleted")

return nil
}

func (f *feature) deleteZoneClonesAndRestore(location string) error {
log.Println("[deleteZoneClonesAndRestore] Deleting restores and clones")
templateFile := "templates/" + location + "/clone.yaml"
updatedTemplateFile := "templates/" + location + "/clone-updated.yaml"

for i := 0; i < int(f.zoneReplicaCount); i++ {
time.Sleep(10 * time.Second)

cpCmd := "cp " + templateFile + " " + updatedTemplateFile
b, err := execLocalCommand(cpCmd)
if err != nil {
return fmt.Errorf("failed to copy template file: %v\nErrMessage:\n%s", err, string(b))
}

// Update iteration and apply...
err = replaceInFile("ITERATION", strconv.Itoa(i), updatedTemplateFile)
if err != nil {
return err
}

deleteClone := "kubectl delete -f " + updatedTemplateFile
_, err = execLocalCommand(deleteClone)
if err != nil {
return err
}
}

log.Println("[createZoneSnapshotsAndRestore] Snapshots and restores deleted")
log.Println("[deleteZoneClonesAndRestore] Clones and restores deleted")

return nil
}
Expand All @@ -426,7 +490,7 @@ func (f *feature) areAllRestoresRunning() error {

runningCount := 0
for _, pod := range pods {
if !strings.Contains(pod.ObjectMeta.Name, "snapshot-maz-restore") {
if !strings.Contains(pod.ObjectMeta.Name, "maz-restore") {
continue
}

Expand All @@ -446,7 +510,7 @@ func (f *feature) areAllRestoresRunning() error {
}

if !complete {
return fmt.Errorf("all restores not running, check pods status starting with snapshot-maz-restore and then try again")
return fmt.Errorf("all restores not running, check pods status containing maz-restore and then try again")
}

return nil
Expand Down Expand Up @@ -490,4 +554,6 @@ func InitializeScenario(s *godog.ScenarioContext) {
s.Step(`^create snapshots for zone volumes and restore in "([^"]*)"$`, f.createZoneSnapshotsAndRestore)
s.Step(`^delete snapshots for zone volumes and restore in "([^"]*)"$`, f.deleteZoneSnapshotsAndRestore)
s.Step(`^all zone restores are running$`, f.areAllRestoresRunning)
s.Step(`^create clones for zone volumes and restore in "([^"]*)"$`, f.createZoneClonesAndRestore)
s.Step(`^delete clones for zone volumes and restore in "([^"]*)"$`, f.deleteZoneClonesAndRestore)
}
15 changes: 15 additions & 0 deletions test/e2e/features/e2e.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,18 @@ Feature: VxFlex OS CSI interface
Examples:
| secret | namespace | location |
| "vxflexos-config" | "vxflexos" | "zone-wait" |

@zone
Scenario: Create zone volume and clones
Given a VxFlexOS service
And verify driver is configured and running correctly
And verify zone information from secret <secret> in namespace <namespace>
Then create zone volume and pod in <location>
And check the statefulset for zones
Then create clones for zone volumes and restore in <location>
And all zone restores are running
Then delete clones for zone volumes and restore in <location>
Then delete zone volume and pod in <location>
Examples:
| secret | namespace | location |
| "vxflexos-config" | "vxflexos" | "zone-wait" |
41 changes: 41 additions & 0 deletions test/e2e/templates/zone-wait/clone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: clone-maz-pvcITERATION
namespace: vxflexos-test
spec:
storageClassName: vxflexos-az-wait
dataSource:
name: multi-az-pvc-vxflextest-az-ITERATION
kind: PersistentVolumeClaim
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
---
apiVersion: v1
kind: Pod
metadata:
name: clone-maz-restore-podITERATION
namespace: vxflexos-test
spec:
containers:
- name: busybox
image: quay.io/quay/busybox:latest
command: ["/bin/sleep", "3600"]
volumeMounts:
- mountPath: "/data0"
name: multi-az-pvc
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "200m"
memory: "256Mi"
volumes:
- name: multi-az-pvc
persistentVolumeClaim:
claimName: clone-maz-pvcITERATION

0 comments on commit 01cbecd

Please sign in to comment.