Skip to content

Commit eb0e8bd

Browse files
authored
Add BDD spec (#198)
* tests(quota): add namespace to the PVC delete calls Signed-off-by: Niladri Halder <[email protected]> * tests(bdd): add bdd specs for existing tests Signed-off-by: Niladri Halder <[email protected]> * tests(bdd): use Then directive to only check code behaviour Signed-off-by: Niladri Halder <[email protected]> --------- Signed-off-by: Niladri Halder <[email protected]>
1 parent 52d6cb5 commit eb0e8bd

File tree

6 files changed

+215
-4
lines changed

6 files changed

+215
-4
lines changed

tests/bdd/ext4_quota.feature

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Feature: Hostpath EXT4 Quota Local PV
2+
3+
Scenario: HostPath EXT4 Quota Local PV with Unsupported Filesystem
4+
Given a sparse file "disk.img"
5+
And a loop device is created on top of disk.img
6+
7+
When a StorageClass is created with the following attributes:
8+
| name | sc-hp-ext4 |
9+
| BasePath | /path/to/hostpath |
10+
| EXT4QuotaEnabled | "true" |
11+
| softLimit | "20%" |
12+
| hardLimit | "50%" |
13+
| provisionerName | openebs.io/local |
14+
| volumeBindingMode | WaitForFirstConsumer |
15+
| reclaimPolicy | Delete |
16+
And a minix filesystem is written into the loop device
17+
And the minix filesystem is mounted with project quota enabled
18+
And a PVC "pvc-hp-ext4" is created with the StorageClass "sc-hp-ext4"
19+
And a Pod is created with PVC "pvc-hp-ext4"
20+
Then the Pod should be in pending state
21+
And the PVC should be in pending state
22+
23+
When the Pod "busybox-hostpath" is deleted
24+
Then the Pod should be deleted successfully
25+
26+
When the PVC "pvc-hp-ext4" is deleted
27+
Then the PVC should be deleted successfully
28+
29+
Scenario: HostPath EXT4 Quota Local PV with EXT4 Filesystem
30+
Given a sparse file "disk.img"
31+
And a loop device is created on top of disk.img
32+
33+
When a StorageClass with valid EXT4 quota parameters is created
34+
Then it should create a StorageClass with the following attributes:
35+
| name | sc-hp-ext4 |
36+
| BasePath | /path/to/hostpath |
37+
| EXT4QuotaEnabled | "true" |
38+
| provisionerName | openebs.io/local |
39+
| volumeBindingMode | WaitForFirstConsumer |
40+
| reclaimPolicy | Delete |
41+
42+
When the loop device is formatted with EXT4 filesystem
43+
And the ext4 filesysten is mounted with project quota enabled
44+
And a PVC "pvc-hp-ext4" is created with the StorageClass "sc-hp-ext4"
45+
And a Pod is created with PVC "pvc-hp-ext4"
46+
Then the Pod should be up and running
47+
48+
When data is written more than the quota limit into the hostpath volume
49+
Then the container process should not be able to write more than the enforced limit
50+
51+
When the Pod consuming PVC "pvc-hp-ext4" is deleted
52+
Then the Pod should be deleted successfully
53+
54+
When the PVC "pvc-hp-ext4" is deleted
55+
Then the PVC should be deleted successfully
56+
And the Provisioner should delete the PV

tests/bdd/hostpath.feature

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Feature: TEST HOSTPATH LOCAL PV
2+
3+
Scenario: Creating and Deleting StorageClass, PVC, and Deployment with Busybox
4+
Given a hostpath provisioner is running
5+
When a StorageClass is created with the following attributes:
6+
| name | sc-hp |
7+
| BasePath | /path/to/hostpath |
8+
| provisionerName | openebs.io/local |
9+
| volumeBindingMode | WaitForFirstConsumer |
10+
| reclaimPolicy | Delete |
11+
And a PVC is created with the following attributes:
12+
| name | pvc-hp |
13+
| storageClass | sc-hp |
14+
| accessModes | ReadWriteOnce |
15+
| capacity | 2Gi |
16+
And a deployment with a busybox image is created with the following attributes:
17+
| name | busybox-hostpath |
18+
| image | busybox |
19+
| command | ["sleep", "3600"] |
20+
| volumeMounts | name: demo-vol1, mountPath: /mnt/store1 |
21+
| volumes | name: demo-vol1, pvcName: pvc-hp |
22+
Then the Pod should be in Running state
23+
And a bound PV should be created
24+
25+
When the deployment is deleted
26+
Then the deployment should not have any deployment or pod remaining
27+
28+
When the PVC is deleted
29+
Then the PVC should be deleted successfully
30+
Then the PV should be deleted
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Feature: Volume Provisioning/De-provisioning with NodeAffinityLabels CAS-config on StorageClass
2+
3+
Scenario: Volume provisioning/de-provisioning with custom NodeAffinityLabels CAS-config on StorageClass
4+
When a StorageClass is created with the following attributes:
5+
| name | sc-nod-aff-lab |
6+
| BasePath | /path/to/hostpath |
7+
| NodeAffinityLabels | "kubernetes.io/hostname", "kubernetes.io/os", "kubernetes.io/arch" |
8+
| provisionerName | openebs.io/local |
9+
| volumeBindingMode | WaitForFirstConsumer |
10+
| reclaimPolicy | Delete |
11+
And a PVC "pvc-nod-aff-lab" is created with StorageClass "sc-nod-aff-lab"
12+
And a deployment with a busybox image is created with PVC "pvc-nod-aff-lab"
13+
Then a Pod should be up and running
14+
And a bound PV should be created
15+
And the SC NodeAffinityLabels CAS-config should be set correctly on the PV
16+
17+
When the application Deployment is deleted
18+
Then The Pod should be deleted
19+
20+
When the PVC is deleted
21+
Then the PV should be deleted

tests/bdd/pvc_cas_config.feature

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Feature: Volume Provisioning/De-provisioning with Additive and Conflicting CAS-configs on PVC and SC
2+
3+
Scenario: Additive CAS-configs on PVC and SC
4+
When a StorageClass with is created with the following attributes:
5+
| name | sc-additive-cas-config |
6+
| BasePath | /path/to/hostpath |
7+
| provisionerName | openebs.io/local |
8+
| volumeBindingMode | WaitForFirstConsumer |
9+
| reclaimPolicy | Delete |
10+
And a PVC "pvc-additive-cas-config" is created with the following attributes:
11+
| name | pvc-additive-cas-config |
12+
| storageClass | sc-hp |
13+
| NodeAffinityLabels | "kubernetes.io/os", "kubernetes.io/arch" |
14+
| accessModes | ReadWriteOnce |
15+
| capacity | 2Gi |
16+
And a Deployment is created with PVC "pvc-additive-cas-config"
17+
Then the Pod should be up and running
18+
And a bound PV should be created
19+
And the PVC NodeAffinityLabels CAS-configs should be set correctly on the PV
20+
21+
When the application Deployment is deleted
22+
Then The Pod should be deleted
23+
24+
When the PVC is deleted
25+
Then the PV should be deleted
26+
27+
Scenario: Conflicting CAS-configs on PVC and SC
28+
When a StorageClass is created with the following attributes:
29+
| name | sc-conflicting-cas-config |
30+
| BasePath | /path/to/hostpath |
31+
| NodeAffinityLabels | "kubernetes.io/hostname" |
32+
| provisionerName | openebs.io/local |
33+
| volumeBindingMode | WaitForFirstConsumer |
34+
| reclaimPolicy | Delete |
35+
And a PVC "pvc-conflicting-cas-config" is created with the following attributes:
36+
| name | pvc-conflicting-cas-config |
37+
| storageClass | sc-hp |
38+
| NodeAffinityLabels | "kubernetes.io/os", "kubernetes.io/arch" |
39+
| accessModes | ReadWriteOnce |
40+
| capacity | 2Gi |
41+
And a Deployment is created with PVC "pvc-conflicting-cas-config"
42+
Then a Pod should be up and running
43+
And a bound PV should be created
44+
And the SC NodeAffinityLabels CAS-config should be set correctly on the PV
45+
46+
When the application Deployment deleted
47+
Then The Pod should be deleted
48+
49+
When the PVC is deleted
50+
Then the PV should be deleted

tests/bdd/xfs_quota.feature

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Feature: Hostpath XFS Quota Local PV
2+
3+
Scenario: HostPath XFS Quota Local PV with Unsupported Filesystem
4+
Given a sparse file "disk.img"
5+
And a loop device is created on top of disk.img
6+
7+
When a StorageClass is created with the following attributes:
8+
| name | sc-hp-xfs |
9+
| BasePath | /path/to/hostpath |
10+
| XFSQuotaEnabled | "true" |
11+
| softLimit | "20%" |
12+
| hardLimit | "50%" |
13+
| provisionerName | openebs.io/local |
14+
| volumeBindingMode | WaitForFirstConsumer |
15+
| reclaimPolicy | Delete |
16+
And a minix filesystem is written into the loop device
17+
And the minix filesystem is mounted with project quota enabled
18+
And a PVC "pvc-hp-xfs" is created with the StorageClass "sc-hp-xfs"
19+
And a Pod is created with PVC "pvc-hp-xfs"
20+
Then the Pod should be in pending state
21+
And the PVC should be in pending state
22+
23+
When the Pod "busybox-hostpath" is deleted
24+
Then the Pod should be deleted successfully
25+
26+
When the PVC "pvc-hp-xfs" is deleted
27+
Then the PVC should be deleted successfully
28+
29+
Scenario: HostPath XFS Quota Local PV with XFS Filesystem
30+
Given a sparse file "disk.img"
31+
And a loop device is created on top of disk.img
32+
33+
When a StorageClass is created with the following attributes:
34+
| name | sc-hp-xfs |
35+
| BasePath | /path/to/hostpath |
36+
| XFSQuotaEnabled | "true" |
37+
| provisionerName | openebs.io/local |
38+
| volumeBindingMode | WaitForFirstConsumer |
39+
| reclaimPolicy | Delete |
40+
And the loop device is formatted with XFS filesystem
41+
And the xfs filesysten is mounted with project quota enabled
42+
And a PVC "pvc-hp-xfs" is created with the StorageClass "sc-hp-xfs"
43+
And a Pod is created with PVC "pvc-hp-xfs"
44+
Then the Pod should be up and running
45+
46+
When data is written more than the quota limit into the hostpath volume
47+
Then the container process should not be able to write more than the enforced limit
48+
49+
When the Pod consuming PVC "pvc-hp-xfs" is deleted
50+
Then the Pod should be deleted successfully
51+
52+
When the PVC "pvc-hp-xfs" is deleted
53+
Then the PVC should be deleted successfully
54+
And the Provisioner should delete the PV

tests/hostpath_quota_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ var _ = Describe("TEST HOSTPATH XFS QUOTA LOCAL PV WITH UNSUPPORTED FILESYSTEM",
164164
)
165165

166166
By("deleting above PVC")
167-
err = ops.PVCClient.Delete(context.TODO(), pvcName, &metav1.DeleteOptions{})
167+
err = ops.PVCClient.WithNamespace(namespaceObj.Name).Delete(context.TODO(), pvcName, &metav1.DeleteOptions{})
168168
Expect(err).To(
169169
BeNil(),
170170
"while deleting pvc {%s} in namespace {%s}",
@@ -357,7 +357,7 @@ var _ = Describe("TEST HOSTPATH XFS QUOTA LOCAL PV WITH XFS FILESYSTEM", func()
357357
)
358358

359359
By("deleting above PVC")
360-
err = ops.PVCClient.Delete(context.TODO(), pvcName, &metav1.DeleteOptions{})
360+
err = ops.PVCClient.WithNamespace(namespaceObj.Name).Delete(context.TODO(), pvcName, &metav1.DeleteOptions{})
361361
Expect(err).To(
362362
BeNil(),
363363
"while deleting pvc {%s} in namespace {%s}",
@@ -543,7 +543,7 @@ var _ = Describe("TEST HOSTPATH EXT4 QUOTA LOCAL PV WITH UNSUPPORTED FILESYSTEM"
543543
)
544544

545545
By("deleting above PVC")
546-
err = ops.PVCClient.Delete(context.TODO(), pvcName, &metav1.DeleteOptions{})
546+
err = ops.PVCClient.WithNamespace(namespaceObj.Name).Delete(context.TODO(), pvcName, &metav1.DeleteOptions{})
547547
Expect(err).To(
548548
BeNil(),
549549
"while deleting pvc {%s} in namespace {%s}",
@@ -736,7 +736,7 @@ var _ = Describe("TEST HOSTPATH EXT4 QUOTA LOCAL PV WITH EXT4 FILESYSTEM", func(
736736
)
737737

738738
By("deleting above PVC")
739-
err = ops.PVCClient.Delete(context.TODO(), pvcName, &metav1.DeleteOptions{})
739+
err = ops.PVCClient.WithNamespace(namespaceObj.Name).Delete(context.TODO(), pvcName, &metav1.DeleteOptions{})
740740
Expect(err).To(
741741
BeNil(),
742742
"while deleting pvc {%s} in namespace {%s}",

0 commit comments

Comments
 (0)