Skip to content

Commit

Permalink
test: add GcpNfsVolume backup/restore features (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
abalaie authored Sep 20, 2024
1 parent e996822 commit a500332
Show file tree
Hide file tree
Showing 3 changed files with 293 additions and 0 deletions.
33 changes: 33 additions & 0 deletions features/200-gcpnfsvolumebackup.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Feature: GcpNfsVolumeBackup feature

@gcp @allShoots @allEnvs
Scenario: GcpNfsVolumeBackup scenario
Given resource declaration:
| vol | GcpNfsVolume | "vol-"+rndStr(8) | namespace |
| backup | GcpNfsVolumeBackup | "backup-"+rndStr(8) | namespace |
When resource vol is applied:
"""
apiVersion: cloud-resources.kyma-project.io/v1beta1
kind: GcpNfsVolume
spec:
capacityGb: 1024
"""
Then eventually value load("vol").status.state equals "Ready" with timeout2X

When resource backup is applied:
"""
apiVersion: cloud-resources.kyma-project.io/v1beta1
kind: GcpNfsVolumeBackup
spec:
source:
volume:
name: <(vol.metadata.name)>
"""
Then eventually value load("backup").status.state equals "Ready" with timeout2X

When resource backup is deleted
Then eventually resource backup does not exist

When resource vol is deleted
Then eventually resource vol does not exist

115 changes: 115 additions & 0 deletions features/200-gcpnfsvolumerestore-newvolume.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
Feature: GcpNfsVolumeRestore-NewVolume feature

@gcp @allShoots @allEnvs
Scenario: GcpNfsVolumeRestore-NewVolume scenario
Given resource declaration:
| vol | GcpNfsVolume | "vol-"+rndStr(8) | namespace |
| backup | GcpNfsVolumeBackup | "backup-"+rndStr(8) | namespace |
| vol2 | GcpNfsVolume | "vol-"+rndStr(8) | namespace |
| pod | Pod | "test-vol" | namespace |
| pod2 | Pod | "test-vol2" | namespace |

When resource vol is applied:
"""
apiVersion: cloud-resources.kyma-project.io/v1beta1
kind: GcpNfsVolume
spec:
capacityGb: 1024
"""
Then eventually value load("vol").status.state equals "Ready" with timeout2X

When resource pod is applied:
"""
apiVersion: v1
kind: Pod
spec:
volumes:
- name: data
persistentVolumeClaim:
claimName: <(vol.metadata.name)>
containers:
- name: cloud1
image: ubuntu
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: "/mnt/data1"
name: data
command:
- "/bin/bash"
- "-c"
- "--"
args:
- "echo 'test line' > /mnt/data1/test.txt & cat /mnt/data1/test.txt"
restartPolicy: Never
"""
Then eventually value load("pod").status.phase equals "Succeeded"
And value logs("pod").search(/test line/) > -1 equals true


When resource backup is applied:
"""
apiVersion: cloud-resources.kyma-project.io/v1beta1
kind: GcpNfsVolumeBackup
spec:
source:
volume:
name: <(vol.metadata.name)>
"""
Then eventually value load("backup").status.state equals "Ready" with timeout2X

When resource vol2 is applied:
"""
apiVersion: cloud-resources.kyma-project.io/v1beta1
kind: GcpNfsVolume
spec:
capacityGb: 1024
sourceBackup:
name: <(backup.metadata.name)>
namespace: <(backup.metadata.namespace)>
"""
Then eventually value load("vol2").status.state equals "Ready" with timeout2X

When resource pod2 is applied:
"""
apiVersion: v1
kind: Pod
spec:
volumes:
- name: data
persistentVolumeClaim:
claimName: <(vol.metadata.name)>
containers:
- name: cloud1
image: ubuntu
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: "/mnt/data1"
name: data
command:
- "/bin/bash"
- "-c"
- "--"
args:
- "cat /mnt/data1/test.txt"
restartPolicy: Never
"""
Then eventually value load("pod2").status.phase equals "Succeeded"
And value logs("pod2").search(/test line/) > -1 equals true

When resource pod is deleted
Then eventually resource pod does not exist

When resource pod2 is deleted
Then eventually resource pod2 does not exist

When resource vol2 is deleted
Then eventually resource vol2 does not exist

When resource backup is deleted
Then eventually resource backup does not exist

When resource vol is deleted
Then eventually resource vol does not exist



145 changes: 145 additions & 0 deletions features/200-gcpnfsvolumerestore.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
Feature: GcpNfsVolumeRestore feature

@gcp @allShoots @allEnvs
Scenario: GcpNfsVolumeRestore scenario
Given resource declaration:
| vol | GcpNfsVolume | "vol-"+rndStr(8) | namespace |
| backup | GcpNfsVolumeBackup | "backup-"+rndStr(8) | namespace |
| restore | GcpNfsVolumeRestore | "restore-"+rndStr(8) | namespace |
| pod | Pod | "test-vol" | namespace |

When resource vol is applied:
"""
apiVersion: cloud-resources.kyma-project.io/v1beta1
kind: GcpNfsVolume
spec:
capacityGb: 1024
"""
Then eventually value load("vol").status.state equals "Ready" with timeout2X

When resource pod is applied:
"""
apiVersion: v1
kind: Pod
spec:
volumes:
- name: data
persistentVolumeClaim:
claimName: <(vol.metadata.name)>
containers:
- name: cloud1
image: ubuntu
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: "/mnt/data1"
name: data
command:
- "/bin/bash"
- "-c"
- "--"
args:
- "echo 'test line' > /mnt/data1/test.txt & cat /mnt/data1/test.txt"
restartPolicy: Never
"""
Then eventually value load("pod").status.phase equals "Succeeded"
And value logs("pod").search(/test line/) > -1 equals true

When resource backup is applied:
"""
apiVersion: cloud-resources.kyma-project.io/v1beta1
kind: GcpNfsVolumeBackup
spec:
source:
volume:
name: <(vol.metadata.name)>
"""
Then eventually value load("backup").status.state equals "Ready" with timeout2X

When resource pod is deleted
Then eventually resource pod does not exist

When resource pod is applied:
"""
apiVersion: v1
kind: Pod
spec:
volumes:
- name: data
persistentVolumeClaim:
claimName: <(vol.metadata.name)>
containers:
- name: cloud1
image: ubuntu
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: "/mnt/data1"
name: data
command:
- "/bin/bash"
- "-c"
- "--"
args:
- "rm /mnt/data1/test.txt & echo 'test.txt was deleted'"
restartPolicy: Never
"""
Then eventually value load("pod").status.phase equals "Succeeded"
And value logs("pod").search(/test.txt was deleted/) > -1 equals true

When resource pod is deleted
Then eventually resource pod does not exist

When resource restore is applied:
"""
apiVersion: cloud-resources.kyma-project.io/v1beta1
kind: GcpNfsVolumeRestore
spec:
source:
backup:
name: <(backup.metadata.name)>
namespace: <(backup.metadata.namespace)>
destination:
volume:
name: <(vol.metadata.name)>
"""
Then eventually value load("restore").status.state equals "Done" with timeout2X

When resource pod is applied:
"""
apiVersion: v1
kind: Pod
spec:
volumes:
- name: data
persistentVolumeClaim:
claimName: <(vol.metadata.name)>
containers:
- name: cloud1
image: ubuntu
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: "/mnt/data1"
name: data
command:
- "/bin/bash"
- "-c"
- "--"
args:
- "cat /mnt/data1/test.txt"
restartPolicy: Never
"""
Then eventually value load("pod").status.phase equals "Succeeded"
And value logs("pod").search(/test line/) > -1 equals true

When resource pod is deleted
Then eventually resource pod does not exist

When resource restore is deleted
Then eventually resource restore does not exist

When resource backup is deleted
Then eventually resource backup does not exist

When resource vol is deleted
Then eventually resource vol does not exist


0 comments on commit a500332

Please sign in to comment.