Merge pull request #52500 from wongma7/mount-e2e

Automatic merge from submit-queue (batch tested with PRs 52500, 52533). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>..

Add mount options e2e test

**What this PR does / why we need it**: A test for newly added StorageClass.mountOptions and PV.mountOptions: provision a pv using a class with its storageclass.mountoptions set, and the end result should be that the mount options can be seen from the mounter.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: Fixes #52138

**Special notes for your reviewer**: 

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-09-19 20:38:34 -07:00 committed by GitHub
commit 6b7dafe8b5

View File

@ -114,6 +114,7 @@ func testDynamicProvisioning(t storageClassTest, client clientset.Interface, cla
Expect(pv.Spec.AccessModes).To(Equal(expectedAccessModes))
Expect(pv.Spec.ClaimRef.Name).To(Equal(claim.ObjectMeta.Name))
Expect(pv.Spec.ClaimRef.Namespace).To(Equal(claim.ObjectMeta.Namespace))
Expect(pv.Spec.MountOptions).To(Equal(class.MountOptions))
// Run the checker
if t.pvCheck != nil {
@ -126,8 +127,15 @@ func testDynamicProvisioning(t storageClassTest, client clientset.Interface, cla
// - The second one runs grep 'hello world' on /mnt/test.
// If both succeed, Kubernetes actually allocated something that is
// persistent across pods.
By("checking the created volume is writable")
runInPodWithVolume(client, claim.Namespace, claim.Name, "echo 'hello world' > /mnt/test/data")
By("checking the created volume is writable and has the PV's mount options")
command := "echo 'hello world' > /mnt/test/data"
// We give the first pod the secondary responsibility of checking the volume has
// been mounted with the PV's mount options, if the PV was provisioned with any
for _, option := range pv.Spec.MountOptions {
// Get entry, get mount options at 6th word, replace brackets with commas
command += fmt.Sprintf(" && ( mount | grep 'on /mnt/test' | awk '{print $6}' | sed 's/^(/,/; s/)$/,/' | grep -q ,%s, )", option)
}
runInPodWithVolume(client, claim.Namespace, claim.Name, command)
By("checking the created volume is readable and retains data")
runInPodWithVolume(client, claim.Namespace, claim.Name, "grep 'hello world' /mnt/test/data")
@ -448,6 +456,29 @@ var _ = SIGDescribe("Dynamic Provisioning", func() {
framework.ExpectNoError(framework.WaitForPersistentVolumeDeleted(c, pv.Name, 1*time.Second, 30*time.Second))
})
It("should provision storage with mount options", func() {
framework.SkipUnlessProviderIs("gce", "gke")
test := storageClassTest{
"HDD PD on GCE/GKE",
[]string{"gce", "gke"},
"kubernetes.io/gce-pd",
map[string]string{
"type": "pd-standard",
},
"1Gi",
"1Gi",
func(volume *v1.PersistentVolume) error {
return checkGCEPD(volume, "pd-standard")
},
}
class := newStorageClass(test, ns, "mountoptions")
class.MountOptions = []string{"debug", "nouid32"}
claim := newClaim(test, ns, "mountoptions")
claim.Spec.StorageClassName = &class.Name
testDynamicProvisioning(test, c, claim, class)
})
// NOTE: Slow! The test will wait up to 5 minutes (framework.ClaimProvisionTimeout)
// when there is no regression.
It("should not provision a volume in an unmanaged GCE zone. [Slow]", func() {