Skip to content

Commit 98a0274

Browse files
authored
Merge pull request #59 from ZeroMagic/dynamically_provisioned_delete_pod
test: add e2e test "dynamically_provisioned_delete_pod_test"
2 parents 756dd41 + 83c8b7f commit 98a0274

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

test/e2e/dynamic_provisioning.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,31 @@ var _ = Describe("Dynamic Provisioning", func() {
7474
test.Run(cs, ns)
7575
})
7676

77+
It("should create a deployment object, write and read to it, delete the pod and write and read to it again", func() {
78+
pod := testsuites.PodDetails{
79+
Cmd: "echo 'hello world' >> /mnt/test-1/data && while true; do sleep 1; done",
80+
Volumes: []testsuites.VolumeDetails{
81+
{
82+
FSType: "ext3",
83+
ClaimSize: "10Gi",
84+
VolumeMount: testsuites.VolumeMountDetails{
85+
NameGenerate: "test-volume-",
86+
MountPathGenerate: "/mnt/test-",
87+
},
88+
},
89+
},
90+
}
91+
test := testsuites.DynamicallyProvisionedDeletePodTest{
92+
CSIDriver: testDriver,
93+
Pod: pod,
94+
PodCheck: &testsuites.PodExecCheck{
95+
Cmd: []string{"cat", "/mnt/test-1/data"},
96+
ExpectedString: "hello world\nhello world\n", // pod will be restarted so expect to see 2 instances of string
97+
},
98+
}
99+
test.Run(cs, ns)
100+
})
101+
77102
// Track issue https://github.com/kubernetes/kubernetes/issues/70505
78103
It("should create a volume on demand and mount it as readOnly in a pod", func() {
79104
pods := []testsuites.PodDetails{
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package testsuites
18+
19+
import (
20+
"github.com/csi-driver/blobfuse-csi-driver/test/e2e/driver"
21+
. "github.com/onsi/ginkgo"
22+
"k8s.io/api/core/v1"
23+
clientset "k8s.io/client-go/kubernetes"
24+
)
25+
26+
// DynamicallyProvisionedDeletePodTest will provision required StorageClass and Deployment
27+
// Testing if the Pod can write and read to mounted volumes
28+
// Deleting a pod, and again testing if the Pod can write and read to mounted volumes
29+
type DynamicallyProvisionedDeletePodTest struct {
30+
CSIDriver driver.DynamicPVTestDriver
31+
Pod PodDetails
32+
PodCheck *PodExecCheck
33+
}
34+
35+
type PodExecCheck struct {
36+
Cmd []string
37+
ExpectedString string
38+
}
39+
40+
func (t *DynamicallyProvisionedDeletePodTest) Run(client clientset.Interface, namespace *v1.Namespace) {
41+
tDeployment, cleanup := t.Pod.SetupDeployment(client, namespace, t.CSIDriver)
42+
// defer must be called here for resources not get removed before using them
43+
for i := range cleanup {
44+
defer cleanup[i]()
45+
}
46+
47+
By("deploying the deployment")
48+
tDeployment.Create()
49+
50+
By("checking that the pod is running")
51+
tDeployment.WaitForPodReady()
52+
53+
By("deleting the pod for deployment")
54+
tDeployment.DeletePodAndWait()
55+
56+
By("checking again that the pod is running")
57+
tDeployment.WaitForPodReady()
58+
59+
if t.PodCheck != nil {
60+
By("checking pod exec")
61+
tDeployment.Exec(t.PodCheck.Cmd, t.PodCheck.ExpectedString)
62+
}
63+
}

0 commit comments

Comments
 (0)