@@ -2020,9 +2020,15 @@ func TestOntapSanEconomyVolumeImport_UnsupportedNameLength(t *testing.T) {
20202020
20212021func TestOntapSanEconomyVolumeImport_ManagedNoRename (t * testing.T ) {
20222022 mockAPI , d := newMockOntapSanEcoDriver (t )
2023-
2024- d .flexvolNamePrefix = "test_lun_pool_"
20252023 d .Config .SVM = "test_svm"
2024+ var storagePrefix string
2025+ if d .Config .StoragePrefix != nil {
2026+ storagePrefix = * d .Config .StoragePrefix
2027+ } else {
2028+ storagePrefix = ""
2029+ }
2030+ d .flexvolNamePrefix = fmt .Sprintf ("trident_lun_pool_%s_" , storagePrefix )
2031+ d .Config .DriverContext = tridentconfig .ContextCSI
20262032
20272033 tests := []struct {
20282034 name string // Name of the test case
@@ -2042,12 +2048,12 @@ func TestOntapSanEconomyVolumeImport_ManagedNoRename(t *testing.T) {
20422048 FileSystem : "xfs" ,
20432049 ImportNoRename : true ,
20442050 },
2045- volToImport : "original_vol /original_lun" ,
2051+ volToImport : d . FlexvolNamePrefix () + "12345 /original_lun" ,
20462052 mocks : func (mockAPI * mockapi.MockOntapAPI ) {
20472053 mockAPI .EXPECT ().VolumeInfo (gomock .Any (), gomock .Any ()).
2048- Return (& api.Volume {Name : "original_vol " , AccessType : "rw" }, nil )
2054+ Return (& api.Volume {Name : d . FlexvolNamePrefix () + "12345 " , AccessType : "rw" }, nil )
20492055 mockAPI .EXPECT ().LunGetByName (gomock .Any (), gomock .Any ()).
2050- Return (& api.Lun {Name : "/vol/original_vol /original_lun" , State : "online" , Size : "1073741824" }, nil )
2056+ Return (& api.Lun {Name : "/vol/" + d . FlexvolNamePrefix () + "12345 /original_lun" , State : "online" , Size : "1073741824" }, nil )
20512057 mockAPI .EXPECT ().LunListIgroupsMapped (gomock .Any (), gomock .Any ()).Return (nil , nil )
20522058 },
20532059 wantErr : assert .NoError ,
@@ -2056,7 +2062,7 @@ func TestOntapSanEconomyVolumeImport_ManagedNoRename(t *testing.T) {
20562062 // With ImportNoRename, InternalName should be set to original LUN name
20572063 assert .Equal (t , "original_lun" , volConfig .InternalName , "InternalName should be original LUN name" )
20582064 // InternalID should be set properly
2059- expectedID := "/svm/test_svm/flexvol/original_vol /lun/original_lun"
2065+ expectedID := "/svm/test_svm/flexvol/" + d . FlexvolNamePrefix () + "12345 /lun/original_lun"
20602066 assert .Equal (t , expectedID , volConfig .InternalID , "InternalID should be set correctly" )
20612067 },
20622068 },
@@ -2069,12 +2075,12 @@ func TestOntapSanEconomyVolumeImport_ManagedNoRename(t *testing.T) {
20692075 FileSystem : "xfs" ,
20702076 ImportNoRename : true ,
20712077 },
2072- volToImport : "original_vol /original_lun" ,
2078+ volToImport : d . FlexvolNamePrefix () + "67890 /original_lun" ,
20732079 mocks : func (mockAPI * mockapi.MockOntapAPI ) {
20742080 mockAPI .EXPECT ().VolumeInfo (gomock .Any (), gomock .Any ()).
2075- Return (& api.Volume {Name : "original_vol " , AccessType : "rw" }, nil )
2081+ Return (& api.Volume {Name : d . FlexvolNamePrefix () + "67890 " , AccessType : "rw" }, nil )
20762082 mockAPI .EXPECT ().LunGetByName (gomock .Any (), gomock .Any ()).
2077- Return (& api.Lun {Name : "/vol/original_vol /original_lun" , State : "online" , Size : "1073741824" }, nil )
2083+ Return (& api.Lun {Name : "/vol/" + d . FlexvolNamePrefix () + "67890 /original_lun" , State : "online" , Size : "1073741824" }, nil )
20782084 mockAPI .EXPECT ().LunListIgroupsMapped (gomock .Any (), gomock .Any ()).
20792085 Return (nil , errors .New ("igroup list failed" ))
20802086 },
@@ -2083,7 +2089,7 @@ func TestOntapSanEconomyVolumeImport_ManagedNoRename(t *testing.T) {
20832089 validate : func (t * testing.T , volConfig * storage.VolumeConfig ) {
20842090 // Validate InternalName and InternalID are still set even on failure
20852091 assert .Equal (t , "original_lun" , volConfig .InternalName , "InternalName should be original LUN name" )
2086- expectedID := "/svm/test_svm/flexvol/original_vol /lun/original_lun"
2092+ expectedID := "/svm/test_svm/flexvol/" + d . FlexvolNamePrefix () + "67890 /lun/original_lun"
20872093 assert .Equal (t , expectedID , volConfig .InternalID , "InternalID should be set correctly" )
20882094 },
20892095 },
@@ -2102,15 +2108,11 @@ func TestOntapSanEconomyVolumeImport_ManagedNoRename(t *testing.T) {
21022108 Return (& api.Volume {Name : "non_conforming_vol" , AccessType : "rw" }, nil )
21032109 mockAPI .EXPECT ().LunGetByName (gomock .Any (), gomock .Any ()).
21042110 Return (& api.Lun {Name : "/vol/non_conforming_vol/my_lun" , State : "online" , Size : "1073741824" }, nil )
2105- mockAPI .EXPECT ().LunListIgroupsMapped (gomock .Any (), gomock .Any ()).Return (nil , nil )
21062111 },
2107- wantErr : assert .NoError ,
2108- testOut : "Import succeeded " ,
2112+ wantErr : assert .Error ,
2113+ testOut : "Import should fail with non-conforming Flexvol name " ,
21092114 validate : func (t * testing.T , volConfig * storage.VolumeConfig ) {
2110- // With ImportNoRename, no rename should happen regardless of naming convention
2111- assert .Equal (t , "my_lun" , volConfig .InternalName , "InternalName should be original LUN name" )
2112- expectedID := "/svm/test_svm/flexvol/non_conforming_vol/lun/my_lun"
2113- assert .Equal (t , expectedID , volConfig .InternalID , "InternalID should use original Flexvol and LUN names" )
2115+ // Validation removed as import should fail before this point
21142116 },
21152117 },
21162118 }
0 commit comments