Skip to content

Commit 4294379

Browse files
committed
e2e storage test: intree driver adds the support for nfs v3
1 parent 87fcae2 commit 4294379

File tree

2 files changed

+51
-25
lines changed

2 files changed

+51
-25
lines changed

test/e2e/storage/drivers/in_tree.go

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,20 @@ const (
6969
iSCSIIQNTemplate = "iqn.2003-01.io.k8s:e2e.%s"
7070
)
7171

72+
type NFSProtocalVersion string
73+
74+
const (
75+
NFSv3 NFSProtocalVersion = "3"
76+
NFSv4 NFSProtocalVersion = "4"
77+
)
78+
7279
// NFS
7380
type nfsDriver struct {
7481
externalProvisionerPod *v1.Pod
7582
externalPluginName string
7683

84+
// path that is exported by the NFS server.
85+
path string
7786
driverInfo storageframework.DriverInfo
7887
}
7988

@@ -90,28 +99,43 @@ var _ storageframework.PreprovisionedPVTestDriver = &nfsDriver{}
9099
var _ storageframework.DynamicPVTestDriver = &nfsDriver{}
91100

92101
// InitNFSDriver returns nfsDriver that implements TestDriver interface
93-
func InitNFSDriver() storageframework.TestDriver {
94-
return &nfsDriver{
95-
driverInfo: storageframework.DriverInfo{
96-
Name: "nfs",
97-
InTreePluginName: "kubernetes.io/nfs",
98-
MaxFileSize: storageframework.FileSizeLarge,
99-
SupportedSizeRange: e2evolume.SizeRange{
100-
Min: "1Gi",
101-
},
102-
SupportedFsType: sets.NewString(
103-
"", // Default fsType
104-
),
105-
SupportedMountOption: sets.NewString("relatime"),
106-
RequiredMountOption: sets.NewString("vers=4.0"),
107-
Capabilities: map[storageframework.Capability]bool{
108-
storageframework.CapPersistence: true,
109-
storageframework.CapExec: true,
110-
storageframework.CapRWX: true,
111-
storageframework.CapMultiPODs: true,
112-
storageframework.CapMultiplePVsSameID: true,
102+
func InitNFSDriver(version NFSProtocalVersion) func() storageframework.TestDriver {
103+
var driverName, path, mountOption string
104+
switch version {
105+
case NFSv3:
106+
driverName = "nfs3"
107+
path = "/exports"
108+
mountOption = "vers=3"
109+
case NFSv4:
110+
driverName = "nfs"
111+
path = "/"
112+
mountOption = "vers=4.0"
113+
}
114+
115+
return func() storageframework.TestDriver {
116+
return &nfsDriver{
117+
path: path,
118+
driverInfo: storageframework.DriverInfo{
119+
Name: driverName,
120+
InTreePluginName: "kubernetes.io/nfs",
121+
MaxFileSize: storageframework.FileSizeLarge,
122+
SupportedSizeRange: e2evolume.SizeRange{
123+
Min: "1Gi",
124+
},
125+
SupportedFsType: sets.NewString(
126+
"", // Default fsType
127+
),
128+
SupportedMountOption: sets.NewString("relatime"),
129+
RequiredMountOption: sets.NewString(mountOption),
130+
Capabilities: map[storageframework.Capability]bool{
131+
storageframework.CapPersistence: true,
132+
storageframework.CapExec: true,
133+
storageframework.CapRWX: true,
134+
storageframework.CapMultiPODs: true,
135+
storageframework.CapMultiplePVsSameID: true,
136+
},
113137
},
114-
},
138+
}
115139
}
116140
}
117141

@@ -130,7 +154,7 @@ func (n *nfsDriver) GetVolumeSource(readOnly bool, fsType string, e2evolume stor
130154
return &v1.VolumeSource{
131155
NFS: &v1.NFSVolumeSource{
132156
Server: nv.serverHost,
133-
Path: "/",
157+
Path: n.path,
134158
ReadOnly: readOnly,
135159
},
136160
}
@@ -144,15 +168,16 @@ func (n *nfsDriver) GetPersistentVolumeSource(readOnly bool, fsType string, e2ev
144168
return &v1.PersistentVolumeSource{
145169
NFS: &v1.NFSVolumeSource{
146170
Server: nv.serverHost,
147-
Path: "/",
171+
Path: n.path,
148172
ReadOnly: readOnly,
149173
},
150174
}, nil
151175
}
152176

153177
func (n *nfsDriver) GetDynamicProvisionStorageClass(ctx context.Context, config *storageframework.PerTestConfig, fsType string) *storagev1.StorageClass {
154178
provisioner := n.externalPluginName
155-
parameters := map[string]string{"mountOptions": "vers=4.0"}
179+
mountOptions := strings.Join(n.driverInfo.RequiredMountOption.List(), ",")
180+
parameters := map[string]string{"mountOptions": mountOptions}
156181
ns := config.Framework.Namespace.Name
157182

158183
return storageframework.GetStorageClass(provisioner, parameters, nil, ns)

test/e2e/storage/in_tree_volumes.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import (
2828

2929
// List of testDrivers to be executed in below loop
3030
var testDrivers = []func() storageframework.TestDriver{
31-
drivers.InitNFSDriver,
31+
drivers.InitNFSDriver(drivers.NFSv3),
32+
drivers.InitNFSDriver(drivers.NFSv4),
3233
drivers.InitISCSIDriver,
3334
drivers.InitHostPathDriver,
3435
drivers.InitHostPathSymlinkDriver,

0 commit comments

Comments
 (0)