Skip to content

Commit baa0abd

Browse files
committed
test: add pod with multiple volumes mount e2e test
doc: set `none` in PR template release note update test
1 parent 81c3cd6 commit baa0abd

File tree

5 files changed

+98
-3
lines changed

5 files changed

+98
-3
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ Fixes #
3737

3838
**Release note**:
3939
```
40-
40+
none
4141
```

pkg/blobfuse/controllerserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
8080
}
8181

8282
accountKind := string(storage.StorageV2)
83-
if strings.EqualFold(storageAccountType, "Premium_LRS") {
83+
if strings.HasPrefix(strings.ToLower(storageAccountType), "premium") {
8484
accountKind = string(storage.BlockBlobStorage)
8585
}
8686
account, accountKey, err := d.cloud.EnsureStorageAccount(accountName, storageAccountType, accountKind, resourceGroup, location, blobfuseAccountNamePrefix)

test/e2e/dynamic_provisioning_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,30 @@ var _ = ginkgo.Describe("[blobfuse-csi-e2e] Dynamic Provisioning", func() {
198198
}
199199
test.Run(cs, ns)
200200
})
201+
202+
ginkgo.It("should create a pod with multiple volumes", func() {
203+
volumes := []testsuites.VolumeDetails{}
204+
for i := 1; i <= 6; i++ {
205+
volume := testsuites.VolumeDetails{
206+
ClaimSize: "10Gi",
207+
VolumeMount: testsuites.VolumeMountDetails{
208+
NameGenerate: "test-volume-",
209+
MountPathGenerate: "/mnt/test-",
210+
},
211+
}
212+
volumes = append(volumes, volume)
213+
}
214+
215+
pods := []testsuites.PodDetails{
216+
{
217+
Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data",
218+
Volumes: volumes,
219+
},
220+
}
221+
test := testsuites.DynamicallyProvisionedPodWithMultiplePVsTest{
222+
CSIDriver: testDriver,
223+
Pods: pods,
224+
}
225+
test.Run(cs, ns)
226+
})
201227
})
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
"sigs.k8s.io/blobfuse-csi-driver/test/e2e/driver"
21+
22+
"github.com/onsi/ginkgo"
23+
v1 "k8s.io/api/core/v1"
24+
clientset "k8s.io/client-go/kubernetes"
25+
)
26+
27+
// DynamicallyProvisionedPodWithMultiplePVsTest will provision
28+
// one pod with multiple PVs
29+
// Waiting for the PV provisioner to create a new PV
30+
// Testing if the Pod(s) Cmd is run with a 0 exit code
31+
type DynamicallyProvisionedPodWithMultiplePVsTest struct {
32+
CSIDriver driver.DynamicPVTestDriver
33+
Pods []PodDetails
34+
}
35+
36+
func (t *DynamicallyProvisionedPodWithMultiplePVsTest) Run(client clientset.Interface, namespace *v1.Namespace) {
37+
for _, pod := range t.Pods {
38+
tpod, cleanup := pod.SetupWithDynamicMultipleVolumes(client, namespace, t.CSIDriver)
39+
// defer must be called here for resources not get removed before using them
40+
for i := range cleanup {
41+
defer cleanup[i]()
42+
}
43+
44+
ginkgo.By("deploying the pod")
45+
tpod.Create()
46+
defer tpod.Cleanup()
47+
ginkgo.By("checking that the pods command exits with no error")
48+
tpod.WaitForSuccess()
49+
}
50+
}

test/e2e/testsuites/specs.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ const (
6767
)
6868

6969
var (
70-
SnapshotAPIGroup = "snapshot.storage.k8s.io"
70+
SnapshotAPIGroup = "snapshot.storage.k8s.io"
71+
supportedStorageAccountTypes = []string{"Standard_LRS", "Premium_LRS", "Standard_GRS", "Standard_RAGRS"}
7172
)
7273

7374
type VolumeMountDetails struct {
@@ -100,6 +101,24 @@ func (pod *PodDetails) SetupWithDynamicVolumes(client clientset.Interface, names
100101
return tpod, cleanupFuncs
101102
}
102103

104+
// SetupWithDynamicMultipleVolumes each pod will be mounted with multiple volumes with different storage account types
105+
func (pod *PodDetails) SetupWithDynamicMultipleVolumes(client clientset.Interface, namespace *v1.Namespace, csiDriver driver.DynamicPVTestDriver) (*TestPod, []func()) {
106+
tpod := NewTestPod(client, namespace, pod.Cmd)
107+
cleanupFuncs := make([]func(), 0)
108+
accountTypeCount := len(supportedStorageAccountTypes)
109+
for n, v := range pod.Volumes {
110+
storageClassParameters := map[string]string{"skuName": supportedStorageAccountTypes[n%accountTypeCount]}
111+
tpvc, funcs := v.SetupDynamicPersistentVolumeClaim(client, namespace, csiDriver, storageClassParameters)
112+
cleanupFuncs = append(cleanupFuncs, funcs...)
113+
if v.VolumeMode == Block {
114+
tpod.SetupRawBlockVolume(tpvc.persistentVolumeClaim, fmt.Sprintf("%s%d", v.VolumeDevice.NameGenerate, n+1), v.VolumeDevice.DevicePath)
115+
} else {
116+
tpod.SetupVolume(tpvc.persistentVolumeClaim, fmt.Sprintf("%s%d", v.VolumeMount.NameGenerate, n+1), fmt.Sprintf("%s%d", v.VolumeMount.MountPathGenerate, n+1), v.VolumeMount.ReadOnly)
117+
}
118+
}
119+
return tpod, cleanupFuncs
120+
}
121+
103122
func (pod *PodDetails) SetupWithPreProvisionedVolumes(client clientset.Interface, namespace *v1.Namespace, csiDriver driver.PreProvisionedVolumeTestDriver) (*TestPod, []func()) {
104123
tpod := NewTestPod(client, namespace, pod.Cmd)
105124
cleanupFuncs := make([]func(), 0)

0 commit comments

Comments
 (0)