Skip to content

Commit 756dd41

Browse files
authored
Merge pull request #58 from ZeroMagic/dynamically_provisioned_collocated_pod
test: add e2e test "dynamically_provisioned_collocated_pod"
2 parents 28a8f11 + b1bb165 commit 756dd41

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

test/e2e/dynamic_provisioning.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,41 @@ var _ = Describe("Dynamic Provisioning", func() {
9898
}
9999
test.Run(cs, ns)
100100
})
101+
102+
It("should create multiple PV objects, bind to PVCs and attach all to different pods on the same node", func() {
103+
pods := []testsuites.PodDetails{
104+
{
105+
Cmd: "while true; do echo $(date -u) >> /mnt/test-1/data; sleep 1; done",
106+
Volumes: []testsuites.VolumeDetails{
107+
{
108+
FSType: "ext3",
109+
ClaimSize: "10Gi",
110+
VolumeMount: testsuites.VolumeMountDetails{
111+
NameGenerate: "test-volume-",
112+
MountPathGenerate: "/mnt/test-",
113+
},
114+
},
115+
},
116+
},
117+
{
118+
Cmd: "while true; do echo $(date -u) >> /mnt/test-1/data; sleep 1; done",
119+
Volumes: []testsuites.VolumeDetails{
120+
{
121+
FSType: "ext4",
122+
ClaimSize: "10Gi",
123+
VolumeMount: testsuites.VolumeMountDetails{
124+
NameGenerate: "test-volume-",
125+
MountPathGenerate: "/mnt/test-",
126+
},
127+
},
128+
},
129+
},
130+
}
131+
test := testsuites.DynamicallyProvisionedCollocatedPodTest{
132+
CSIDriver: testDriver,
133+
Pods: pods,
134+
ColocatePods: true,
135+
}
136+
test.Run(cs, ns)
137+
})
101138
})
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
22+
"k8s.io/api/core/v1"
23+
clientset "k8s.io/client-go/kubernetes"
24+
25+
. "github.com/onsi/ginkgo"
26+
)
27+
28+
// DynamicallyProvisionedCollocatedPodTest will provision required StorageClass(es), PVC(s) and Pod(s)
29+
// Waiting for the PV provisioner to create a new PV
30+
// Testing if multiple Pod(s) can write simultaneously
31+
type DynamicallyProvisionedCollocatedPodTest struct {
32+
CSIDriver driver.DynamicPVTestDriver
33+
Pods []PodDetails
34+
ColocatePods bool
35+
}
36+
37+
func (t *DynamicallyProvisionedCollocatedPodTest) Run(client clientset.Interface, namespace *v1.Namespace) {
38+
nodeName := ""
39+
for _, pod := range t.Pods {
40+
tpod, cleanup := pod.SetupWithDynamicVolumes(client, namespace, t.CSIDriver)
41+
if t.ColocatePods && nodeName != "" {
42+
tpod.SetNodeSelector(map[string]string{"name": nodeName})
43+
}
44+
// defer must be called here for resources not get removed before using them
45+
for i := range cleanup {
46+
defer cleanup[i]()
47+
}
48+
49+
By("deploying the pod")
50+
tpod.Create()
51+
defer tpod.Cleanup()
52+
53+
By("checking that the pod is running")
54+
tpod.WaitForRunning()
55+
nodeName = tpod.pod.Spec.NodeName
56+
}
57+
58+
}

0 commit comments

Comments
 (0)