Skip to content

Commit

Permalink
test: combining all NFS related tests for gcp to reduce execution time
Browse files Browse the repository at this point in the history
  • Loading branch information
abalaie committed Sep 23, 2024
1 parent a500332 commit 4fa5c7f
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 298 deletions.
168 changes: 163 additions & 5 deletions features/200-gcpnfsvolume.feature
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Feature: GcpNfsVolume feature
Feature: GcpNfsVolume/Backup/Restore feature

@gcp @allShoots @allEnvs
Scenario: GcpNfsVolume scenario
Given resource declaration:
| vol | GcpNfsVolume | "vol-"+rndStr(8) | namespace |
| pv | PersistentVolume | vol.status.id | |
| pvc | PersistentVolumeClaim | vol.metadata.name | namespace |
| pod | Pod | "test-vol" | namespace |
| vol | GcpNfsVolume | "vol-200-gcpnfsvolume" | namespace |
| pv | PersistentVolume | vol.status.id | |
| pvc | PersistentVolumeClaim | vol.metadata.name | namespace |
| pod | Pod | "test-vol-200-gcpnfsvolume" | namespace |
| backup | GcpNfsVolumeBackup | "backup-200-gcpnfsvolume" | namespace |
| restore | GcpNfsVolumeRestore | "restore-200-gcpnfsvolume" | namespace |
When resource vol is applied:
"""
apiVersion: cloud-resources.kyma-project.io/v1beta1
Expand Down Expand Up @@ -48,7 +50,163 @@ Feature: GcpNfsVolume feature
When resource pod is deleted
Then eventually resource pod does not exist

@gcp @allShoots @allEnvs
Scenario: GcpNfsVolumeBackup scenario
Given resource declaration:
| vol | GcpNfsVolume | "vol-200-gcpnfsvolume" | namespace |
| pv | PersistentVolume | vol.status.id | |
| pvc | PersistentVolumeClaim | vol.metadata.name | namespace |
| pod | Pod | "test-vol-200-gcpnfsvolume" | namespace |
| backup | GcpNfsVolumeBackup | "backup-200-gcpnfsvolume" | namespace |
| restore | GcpNfsVolumeRestore | "restore-200-gcpnfsvolume" | namespace |
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

@gcp @allShoots @allEnvs
Scenario: GcpNfsVolumeRestore scenario
Given resource declaration:
| vol | GcpNfsVolume | "vol-200-gcpnfsvolume" | namespace |
| pv | PersistentVolume | vol.status.id | |
| pvc | PersistentVolumeClaim | vol.metadata.name | namespace |
| pod | Pod | "test-vol-200-gcpnfsvolume" | namespace |
| backup | GcpNfsVolumeBackup | "backup-200-gcpnfsvolume" | namespace |
| restore | GcpNfsVolumeRestore | "restore-200-gcpnfsvolume" | namespace |
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 vol is deleted
Then eventually resource pvc does not exist
And eventually resource pv does not exist
And eventually resource vol does not exist

When resource vol 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("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:
- "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 vol is deleted
Then eventually resource vol does not exist

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


33 changes: 0 additions & 33 deletions features/200-gcpnfsvolumebackup.feature

This file was deleted.

115 changes: 0 additions & 115 deletions features/200-gcpnfsvolumerestore-newvolume.feature

This file was deleted.

Loading

0 comments on commit 4fa5c7f

Please sign in to comment.