From 2aaeefeeb89bf0d43af86e40314a43a871d163a4 Mon Sep 17 00:00:00 2001 From: Cristian Pop Date: Thu, 9 Feb 2017 13:54:56 +0200 Subject: [PATCH] Updated TestExtractDeviceAndPrefix and added TestExtractIface to reflect the changes brought by the #39202 fix. --- pkg/volume/iscsi/iscsi_util_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) mode change 100644 => 100755 pkg/volume/iscsi/iscsi_util_test.go diff --git a/pkg/volume/iscsi/iscsi_util_test.go b/pkg/volume/iscsi/iscsi_util_test.go old mode 100644 new mode 100755 index 2356df3c8d..94cae11a9c --- a/pkg/volume/iscsi/iscsi_util_test.go +++ b/pkg/volume/iscsi/iscsi_util_test.go @@ -57,10 +57,20 @@ func TestGetDevicePrefixRefCount(t *testing.T) { func TestExtractDeviceAndPrefix(t *testing.T) { 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" - device, prefix, err := extractDeviceAndPrefix("/var/lib/kubelet/plugins/kubernetes.io/iscsi/" + devicePath + lun) - if err != nil || device != (devicePath+lun) || prefix != devicePath { - t.Errorf("extractDeviceAndPrefix: expected %s and %s, got %v %s and %s", devicePath+lun, devicePath, err, device, prefix) + device, prefix, err := extractDeviceAndPrefix(mountPrefix + lun) + if err != nil || device != (devicePath+lun) || prefix != mountPrefix { + 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) } }