mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Add unit tests for CSI mount options
This commit is contained in:
parent
65d3beb820
commit
85b224856d
@ -164,6 +164,7 @@ func MounterSetUpTests(t *testing.T, podInfoEnabled bool) {
|
|||||||
|
|
||||||
pv := makeTestPV("test-pv", 10, test.driver, testVol)
|
pv := makeTestPV("test-pv", 10, test.driver, testVol)
|
||||||
pv.Spec.CSI.VolumeAttributes = test.attributes
|
pv.Spec.CSI.VolumeAttributes = test.attributes
|
||||||
|
pv.Spec.MountOptions = []string{"foo=bar", "baz=qux"}
|
||||||
pvName := pv.GetName()
|
pvName := pv.GetName()
|
||||||
|
|
||||||
mounter, err := plug.NewMounter(
|
mounter, err := plug.NewMounter(
|
||||||
@ -240,6 +241,9 @@ func MounterSetUpTests(t *testing.T, podInfoEnabled bool) {
|
|||||||
if vol.Path != csiMounter.GetPath() {
|
if vol.Path != csiMounter.GetPath() {
|
||||||
t.Errorf("csi server expected path %s, got %s", csiMounter.GetPath(), vol.Path)
|
t.Errorf("csi server expected path %s, got %s", csiMounter.GetPath(), vol.Path)
|
||||||
}
|
}
|
||||||
|
if !reflect.DeepEqual(vol.MountFlags, pv.Spec.MountOptions) {
|
||||||
|
t.Errorf("csi server expected mount options %v, got %v", pv.Spec.MountOptions, vol.MountFlags)
|
||||||
|
}
|
||||||
if podInfoEnabled {
|
if podInfoEnabled {
|
||||||
if !reflect.DeepEqual(vol.Attributes, test.expectedAttributes) {
|
if !reflect.DeepEqual(vol.Attributes, test.expectedAttributes) {
|
||||||
t.Errorf("csi server expected attributes %+v, got %+v", test.expectedAttributes, vol.Attributes)
|
t.Errorf("csi server expected attributes %+v, got %+v", test.expectedAttributes, vol.Attributes)
|
||||||
|
@ -59,6 +59,7 @@ func (f *IdentityClient) Probe(ctx context.Context, in *csipb.ProbeRequest, opts
|
|||||||
type CSIVolume struct {
|
type CSIVolume struct {
|
||||||
Attributes map[string]string
|
Attributes map[string]string
|
||||||
Path string
|
Path string
|
||||||
|
MountFlags []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeClient returns CSI node client
|
// NodeClient returns CSI node client
|
||||||
@ -126,6 +127,7 @@ func (f *NodeClient) NodePublishVolume(ctx context.Context, req *csipb.NodePubli
|
|||||||
f.nodePublishedVolumes[req.GetVolumeId()] = CSIVolume{
|
f.nodePublishedVolumes[req.GetVolumeId()] = CSIVolume{
|
||||||
Path: req.GetTargetPath(),
|
Path: req.GetTargetPath(),
|
||||||
Attributes: req.GetVolumeAttributes(),
|
Attributes: req.GetVolumeAttributes(),
|
||||||
|
MountFlags: req.GetVolumeCapability().GetMount().MountFlags,
|
||||||
}
|
}
|
||||||
return &csipb.NodePublishVolumeResponse{}, nil
|
return &csipb.NodePublishVolumeResponse{}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user