@@ -58,7 +58,6 @@ func newTestGCNVDriver(mockAPI gcnvapi.GCNV) *NASStorageDriver {
5858 AuthProviderX509CertURL : gcnvapi .AuthProviderX509CertURL ,
5959 ClientX509CertURL : gcnvapi .ClientX509CertURL ,
6060 },
61- NFSMountOptions : "nfsvers=3" ,
6261 VolumeCreateTimeout : "10" ,
6362 }
6463
@@ -873,7 +872,7 @@ func TestPopulateConfigurationDefaults_NoneSet(t *testing.T) {
873872 assert .Equal (t , drivers .DefaultVolumeSize , driver .Config .Size , "size mismatch" )
874873 assert .Equal (t , gcnvapi .ServiceLevelStandard , driver .Config .ServiceLevel , "service level mismatch" )
875874 assert .Equal (t , defaultStorageClass , driver .Config .StorageClass , "storage class mismatch" )
876- assert .Equal (t , defaultNfsMountOptions , driver .Config .NFSMountOptions , "NFS mount options mismatch" )
875+ assert .Equal (t , "" , driver .Config .NFSMountOptions , "NFS mount options mismatch" )
877876 assert .Equal (t , "" , driver .Config .SnapshotDir , "snapshot dir mismatch" )
878877 assert .Equal (t , defaultSnapshotReserve , driver .Config .SnapshotReserve , "snapshot reserve mismatch" )
879878 assert .Equal (t , defaultUnixPermissions , driver .Config .UnixPermissions , "unix permissions mismatch" )
@@ -1161,7 +1160,7 @@ func getStructsForCreateNFSVolume(ctx context.Context, driver *NASStorageDriver,
11611160 AllowedClients : "0.0.0.0/0" ,
11621161 SMB : false ,
11631162 Nfsv3 : true ,
1164- Nfsv4 : false ,
1163+ Nfsv4 : true ,
11651164 RuleIndex : 1 ,
11661165 AccessType : gcnvapi .AccessTypeReadWrite ,
11671166 },
@@ -1197,12 +1196,12 @@ func getStructsForCreateNFSVolume(ctx context.Context, driver *NASStorageDriver,
11971196 ServiceLevel : gcnvapi .ServiceLevelPremium ,
11981197 SizeBytes : gcnvapi .VolumeSizeI64 ,
11991198 ExportPolicy : exportPolicy ,
1200- ProtocolTypes : []string {gcnvapi .ProtocolTypeNFSv3 },
1199+ ProtocolTypes : []string {gcnvapi .ProtocolTypeNFSv3 , gcnvapi . ProtocolTypeNFSv41 },
12011200 MountTargets : nil ,
12021201 UnixPermissions : "0755" ,
12031202 Labels : nil ,
12041203 SnapshotReserve : 0 ,
1205- SnapshotDirectory : false ,
1204+ SnapshotDirectory : true ,
12061205 SecurityStyle : "Unix" ,
12071206 }
12081207
@@ -1212,7 +1211,7 @@ func getStructsForCreateNFSVolume(ctx context.Context, driver *NASStorageDriver,
12121211 CapacityPool : "CP1" ,
12131212 SizeBytes : gcnvapi .VolumeSizeI64 ,
12141213 ExportPolicy : exportPolicy ,
1215- ProtocolTypes : []string {gcnvapi .ProtocolTypeNFSv3 },
1214+ ProtocolTypes : []string {gcnvapi .ProtocolTypeNFSv3 , gcnvapi . ProtocolTypeNFSv41 },
12161215 UnixPermissions : "0755" ,
12171216 Labels : map [string ]string {
12181217 "backend_uuid" : gcnvapi .BackendUUID ,
@@ -1222,7 +1221,7 @@ func getStructsForCreateNFSVolume(ctx context.Context, driver *NASStorageDriver,
12221221 "version" : driver .fixGCPLabelValue (driver .telemetry .TridentVersion ),
12231222 },
12241223 SnapshotReserve : nil ,
1225- SnapshotDirectory : false ,
1224+ SnapshotDirectory : true ,
12261225 SecurityStyle : "Unix" ,
12271226 }
12281227
@@ -1311,7 +1310,7 @@ func TestCreate_NFSVolume(t *testing.T) {
13111310 assert .Equal (t , volume .FullName , volConfig .InternalID , "internal ID not set on volConfig" )
13121311 assert .Equal (t , strconv .FormatInt (createRequest .SizeBytes , 10 ), volConfig .Size , "request size mismatch" )
13131312 assert .Equal (t , gcnvapi .ServiceLevelPremium , volConfig .ServiceLevel )
1314- assert .Equal (t , "false " , volConfig .SnapshotDir )
1313+ assert .Equal (t , "true " , volConfig .SnapshotDir )
13151314 assert .Equal (t , "0777" , volConfig .UnixPermissions )
13161315}
13171316
@@ -1355,7 +1354,7 @@ func TestCreate_NFSVolume_MultipleCapacityPools_FirstSucceeds(t *testing.T) {
13551354 assert .Equal (t , volume .FullName , volConfig .InternalID , "internal ID not set on volConfig" )
13561355 assert .Equal (t , strconv .FormatInt (createRequest .SizeBytes , 10 ), volConfig .Size , "request size mismatch" )
13571356 assert .Equal (t , gcnvapi .ServiceLevelPremium , volConfig .ServiceLevel )
1358- assert .Equal (t , "false " , volConfig .SnapshotDir )
1357+ assert .Equal (t , "true " , volConfig .SnapshotDir )
13591358 assert .Equal (t , "0777" , volConfig .UnixPermissions )
13601359}
13611360
@@ -1407,7 +1406,7 @@ func TestCreate_NFSVolume_MultipleCapacityPools_SecondSucceeds(t *testing.T) {
14071406 assert .Equal (t , volume .FullName , volConfig .InternalID , "internal ID not set on volConfig" )
14081407 assert .Equal (t , strconv .FormatInt (createRequest .SizeBytes , 10 ), volConfig .Size , "request size mismatch" )
14091408 assert .Equal (t , gcnvapi .ServiceLevelPremium , volConfig .ServiceLevel )
1410- assert .Equal (t , "false " , volConfig .SnapshotDir )
1409+ assert .Equal (t , "true " , volConfig .SnapshotDir )
14111410 assert .Equal (t , "0777" , volConfig .UnixPermissions )
14121411}
14131412
@@ -1955,7 +1954,7 @@ func TestGCNVCreate_InvalidSnapshotReserve(t *testing.T) {
19551954 assert .Equal (t , createRequest .ProtocolTypes , volume .ProtocolTypes , "protocol type mismatch" )
19561955 assert .Equal (t , volume .FullName , volConfig .InternalID , "internal ID not set on volConfig" )
19571956 assert .Equal (t , gcnvapi .ServiceLevelPremium , volConfig .ServiceLevel )
1958- assert .Equal (t , "false " , volConfig .SnapshotDir )
1957+ assert .Equal (t , "true " , volConfig .SnapshotDir )
19591958 assert .Equal (t , "0777" , volConfig .UnixPermissions )
19601959}
19611960
@@ -1977,6 +1976,9 @@ func TestCreate_MountOptions(t *testing.T) {
19771976 volConfig , capacityPool , volume , createRequest := getStructsForCreateNFSVolume (ctx , driver , storagePool )
19781977 volConfig .MountOptions = "nfsvers=3"
19791978 createRequest .UnixPermissions = "0777"
1979+ createRequest .ProtocolTypes = []string {gcnvapi .ProtocolTypeNFSv3 }
1980+ createRequest .ExportPolicy .Rules [0 ].Nfsv4 = false
1981+ createRequest .SnapshotDirectory = false
19801982
19811983 mockAPI .EXPECT ().RefreshGCNVResources (ctx ).Return (nil ).Times (1 )
19821984 mockAPI .EXPECT ().VolumeExists (ctx , volConfig ).Return (false , nil , nil ).Times (1 )
@@ -2014,7 +2016,6 @@ func TestCreate_MountOptions_NFSv4(t *testing.T) {
20142016
20152017 volConfig , capacityPool , volume , createRequest := getStructsForCreateNFSVolume (ctx , driver , storagePool )
20162018
2017- volConfig .SnapshotDir = "false"
20182019 volConfig .MountOptions = "nfsvers=4"
20192020 volume .ProtocolTypes = []string {gcnvapi .ProtocolTypeNFSv41 }
20202021 createRequest .ProtocolTypes = []string {gcnvapi .ProtocolTypeNFSv41 }
@@ -2061,9 +2062,6 @@ func TestCreate_MountOptions_BothEnabled(t *testing.T) {
20612062
20622063 volConfig , capacityPool , volume , createRequest := getStructsForCreateNFSVolume (ctx , driver , storagePool )
20632064
2064- volConfig .SnapshotDir = "false"
2065- volConfig .MountOptions = " "
2066-
20672065 createRequest .UnixPermissions = "0777"
20682066 createRequest .ProtocolTypes = []string {gcnvapi .ProtocolTypeNFSv3 , gcnvapi .ProtocolTypeNFSv41 }
20692067 createRequest .ExportPolicy .Rules [0 ].Nfsv4 = true
@@ -2114,13 +2112,12 @@ func TestCreate_InvalidMountOptions(t *testing.T) {
21142112 assert .Equal (t , "" , volConfig .InternalID , "internal ID set on volConfig" )
21152113}
21162114
2117- func TestCreate_NFSVolume_DefaultMountOptions (t * testing.T ) {
2115+ func TestCreate_NFSVolume_VolConfigMountOptionsNFSv3 (t * testing.T ) {
21182116 mockAPI , driver := newMockGCNVDriver (t )
21192117
21202118 driver .Config .BackendName = "gcnv"
21212119 driver .Config .ServiceLevel = gcnvapi .ServiceLevelPremium
21222120 driver .Config .NASType = "nfs"
2123- driver .Config .NFSMountOptions = ""
21242121
21252122 err := driver .populateConfigurationDefaults (ctx , & driver .Config )
21262123 assert .NoError (t , err , "error occurred" )
@@ -2131,7 +2128,13 @@ func TestCreate_NFSVolume_DefaultMountOptions(t *testing.T) {
21312128 storagePool := driver .pools ["gcnv_pool" ]
21322129
21332130 volConfig , capacityPool , volume , createRequest := getStructsForCreateNFSVolume (ctx , driver , storagePool )
2131+ volConfig .MountOptions = "nfsvers=3"
2132+ volConfig .SnapshotDir = "false"
2133+
21342134 createRequest .UnixPermissions = "0777"
2135+ createRequest .ProtocolTypes = []string {gcnvapi .ProtocolTypeNFSv3 }
2136+ createRequest .ExportPolicy .Rules [0 ].Nfsv4 = false
2137+ createRequest .SnapshotDirectory = false
21352138
21362139 mockAPI .EXPECT ().RefreshGCNVResources (ctx ).Return (nil ).Times (1 )
21372140 mockAPI .EXPECT ().VolumeExists (ctx , volConfig ).Return (false , nil , nil ).Times (1 )
@@ -2147,8 +2150,6 @@ func TestCreate_NFSVolume_DefaultMountOptions(t *testing.T) {
21472150 result := driver .Create (ctx , volConfig , storagePool , nil )
21482151
21492152 assert .NoError (t , result , "create failed" )
2150- assert .Equal (t , createRequest .SizeBytes , DefaultVolumeSize , "request size mismatch" )
2151- assert .Equal (t , volConfig .Size , defaultVolumeSizeStr , "config size mismatch" )
21522153 assert .Equal (t , volume .FullName , volConfig .InternalID , "internal ID not set on volConfig" )
21532154}
21542155
@@ -2169,7 +2170,6 @@ func TestCreate_NFSVolume_VolConfigMountOptions(t *testing.T) {
21692170
21702171 volConfig , capacityPool , volume , createRequest := getStructsForCreateNFSVolume (ctx , driver , storagePool )
21712172 volConfig .MountOptions = "nfsvers=4.1"
2172- volConfig .SnapshotDir = "false"
21732173
21742174 createRequest .UnixPermissions = "0777"
21752175 createRequest .ProtocolTypes = []string {gcnvapi .ProtocolTypeNFSv41 }
@@ -2308,7 +2308,7 @@ func TestCreate_NFSVolumeWithPoolLabels(t *testing.T) {
23082308 assert .Equal (t , volume .FullName , volConfig .InternalID , "internal ID not set on volConfig" )
23092309 assert .Equal (t , strconv .FormatInt (createRequest .SizeBytes , 10 ), volConfig .Size , "request size mismatch" )
23102310 assert .Equal (t , gcnvapi .ServiceLevelPremium , volConfig .ServiceLevel )
2311- assert .Equal (t , "false " , volConfig .SnapshotDir )
2311+ assert .Equal (t , "true " , volConfig .SnapshotDir )
23122312 assert .Equal (t , "0777" , volConfig .UnixPermissions )
23132313}
23142314
@@ -5108,13 +5108,13 @@ func TestPublish_NFSVolume(t *testing.T) {
51085108 driver .initializeTelemetry (ctx , gcnvapi .BackendUUID )
51095109
51105110 volConfig , volume , publishInfo := getStructsForPublishNFSVolume (ctx , driver )
5111+ volConfig .MountOptions = "nfsvers=3"
51115112 publishInfo .NfsPath = volConfig .AccessInfo .NfsPath
51125113
51135114 mockAPI .EXPECT ().RefreshGCNVResources (ctx ).Return (nil ).Times (1 )
51145115 mockAPI .EXPECT ().Volume (ctx , volConfig ).Return (volume , nil ).Times (1 )
51155116
51165117 result := driver .Publish (ctx , volConfig , publishInfo )
5117-
51185118 assert .Nil (t , result , "not nil" )
51195119 assert .Equal (t , "/trident-testvol1" , publishInfo .NfsPath , "NFS path mismatch" )
51205120 assert .Equal (t , "1.1.1.1" , publishInfo .NfsServerIP , "NFS server IP mismatch" )
@@ -5132,6 +5132,7 @@ func TestPublish_ROClone_NFSVolume(t *testing.T) {
51325132 driver .initializeTelemetry (ctx , gcnvapi .BackendUUID )
51335133
51345134 volConfig , volume , publishInfo := getStructsForPublishNFSVolume (ctx , driver )
5135+ volConfig .MountOptions = "nfsvers=3"
51355136 publishInfo .NfsPath = "/trident-testvol1/.snapshot/" + gcnvapi .SnapshotUUID
51365137 volConfig .CloneSourceVolumeInternal = volConfig .Name
51375138 volConfig .ReadOnlyClone = true
0 commit comments