mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Updated TestExtractDeviceAndPrefix and added TestExtractIface to reflect the changes brought by the #39202 fix.
This commit is contained in:
parent
b0d285c706
commit
2aaeefeeb8
16
pkg/volume/iscsi/iscsi_util_test.go
Normal file → Executable file
16
pkg/volume/iscsi/iscsi_util_test.go
Normal file → Executable file
@ -57,10 +57,20 @@ func TestGetDevicePrefixRefCount(t *testing.T) {
|
|||||||
|
|
||||||
func TestExtractDeviceAndPrefix(t *testing.T) {
|
func TestExtractDeviceAndPrefix(t *testing.T) {
|
||||||
devicePath := "127.0.0.1:3260-iqn.2014-12.com.example:test.tgt00"
|
devicePath := "127.0.0.1:3260-iqn.2014-12.com.example:test.tgt00"
|
||||||
|
mountPrefix := "/var/lib/kubelet/plugins/kubernetes.io/iscsi/default/" + devicePath
|
||||||
lun := "-lun-0"
|
lun := "-lun-0"
|
||||||
device, prefix, err := extractDeviceAndPrefix("/var/lib/kubelet/plugins/kubernetes.io/iscsi/" + devicePath + lun)
|
device, prefix, err := extractDeviceAndPrefix(mountPrefix + lun)
|
||||||
if err != nil || device != (devicePath+lun) || prefix != devicePath {
|
if err != nil || device != (devicePath+lun) || prefix != mountPrefix {
|
||||||
t.Errorf("extractDeviceAndPrefix: expected %s and %s, got %v %s and %s", devicePath+lun, devicePath, err, device, prefix)
|
t.Errorf("extractDeviceAndPrefix: expected %s and %s, got %v %s and %s", devicePath+lun, mountPrefix, err, device, prefix)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestExtractIface(t *testing.T) {
|
||||||
|
ifaceName := "default"
|
||||||
|
devicePath := "127.0.0.1:3260-iqn.2014-12.com.example:test.tgt00-lun-0"
|
||||||
|
iface, err := extractIface("/var/lib/kubelet/plugins/kubernetes.io/iscsi/" + ifaceName + "/" + devicePath)
|
||||||
|
if err != nil || iface != ifaceName {
|
||||||
|
t.Errorf("extractIface: expected %s, got %v %s", ifaceName, err, iface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user