@@ -24,9 +24,11 @@ function Test-VolumeCrud
2424 $resourceGroup = Get-ResourceGroupName
2525 $accName = Get-ResourceName
2626 $poolName = Get-ResourceName
27+ $poolName2 = Get-ResourceName
2728 $volName1 = Get-ResourceName
2829 $volName2 = Get-ResourceName
2930 $volName3 = Get-ResourceName
31+ $volName4 = Get-ResourceName
3032 $gibibyte = 1024 * 1024 * 1024
3133 $usageThreshold = 100 * $gibibyte
3234 $doubleUsage = 2 * $usageThreshold
@@ -56,13 +58,32 @@ function Test-VolumeCrud
5658 Nfsv4 = ' false'
5759 AllowedClients = ' 1.2.3.0/24'
5860 }
59-
61+ $rule3 = @ {
62+ RuleIndex = 2
63+ UnixReadOnly = ' false'
64+ UnixReadWrite = ' true'
65+ Cifs = ' false'
66+ Nfsv3 = ' true'
67+ Nfsv4 = ' false'
68+ AllowedClients = ' 2.3.4.0/24'
69+ }
6070
6171 $exportPolicy = @ {
6272 Rules = (
6373 $rule1 , $rule2
6474 )
6575 }
76+
77+ $exportPolicyMod = @ {
78+ Rules = (
79+ $rule3
80+ )
81+ }
82+
83+ # create the list of protocol types
84+ $protocolTypes = New-Object string[] 2
85+ $protocolTypes [0 ] = " NFSv3"
86+ $protocolTypes [1 ] = " NFSv4"
6687
6788 try
6889 {
@@ -83,19 +104,24 @@ function Test-VolumeCrud
83104 # create first volume and check
84105 $newTagName = " tag1"
85106 $newTagValue = " tagValue1"
86- $retrievedVolume = New-AzNetAppFilesVolume - ResourceGroupName $resourceGroup - Location $resourceLocation - AccountName $accName - PoolName $poolName - VolumeName $volName1 - CreationToken $volName1 - UsageThreshold $usageThreshold - ServiceLevel $serviceLevel - SubnetId $subnetId - Tag @ {$newTagName = $newTagValue } - ExportPolicy $exportPolicy
107+ $retrievedVolume = New-AzNetAppFilesVolume - ResourceGroupName $resourceGroup - Location $resourceLocation - AccountName $accName - PoolName $poolName - VolumeName $volName1 - CreationToken $volName1 - UsageThreshold $usageThreshold - ServiceLevel $serviceLevel - SubnetId $subnetId - Tag @ {$newTagName = $newTagValue } - ExportPolicy $exportPolicy - ProtocolTypes $protocolTypes
87108 Assert-AreEqual " $accName /$poolName /$volName1 " $retrievedVolume.Name
88109 Assert-AreEqual $serviceLevel $retrievedVolume.ServiceLevel
89110 Assert-AreEqual True $retrievedVolume.Tags.ContainsKey ($newTagName )
90111 Assert-AreEqual " tagValue1" $retrievedVolume.Tags [$newTagName ].ToString()
91112 Assert-NotNull $retrievedVolume.ExportPolicy
92113 Assert-AreEqual $retrievedVolume.ExportPolicy.Rules [0 ].AllowedClients ' 0.0.0.0/0'
93114 Assert-AreEqual $retrievedVolume.ExportPolicy.Rules [1 ].AllowedClients ' 1.2.3.0/24'
115+ Assert-AreEqual $retrievedVolume.ProtocolTypes [0 ] ' NFSv3'
116+ Assert-AreEqual $retrievedVolume.ProtocolTypes [1 ] ' NFSv4'
117+ Assert-NotNull $retrievedVolume.MountTargets
94118
95119 # create second volume and check using the confirm flag
96120 $retrievedVolume = New-AzNetAppFilesVolume - ResourceGroupName $resourceGroup - Location $resourceLocation - AccountName $accName - PoolName $poolName - VolumeName $volName2 - CreationToken $volName2 - UsageThreshold $usageThreshold - ServiceLevel $serviceLevel - SubnetId $subnetId - Confirm:$false
97121 Assert-AreEqual " $accName /$poolName /$volName2 " $retrievedVolume.Name
98122 Assert-AreEqual $serviceLevel $retrievedVolume.ServiceLevel
123+ # default protocol type for new volume
124+ Assert-AreEqual $retrievedVolume.ProtocolTypes [0 ] ' NFSv3'
99125
100126 # create and check a third volume using the WhatIf - it should not be created
101127 $retrievedVolume = New-AzNetAppFilesVolume - ResourceGroupName $resourceGroup - Location $resourceLocation - AccountName $accName - PoolName $poolName - VolumeName $volName3 - CreationToken $volName2 - UsageThreshold $usageThreshold - ServiceLevel $serviceLevel - SubnetId $subnetId - WhatIf
@@ -156,6 +182,31 @@ function Test-VolumeCrud
156182 Remove-AzNetAppFilesVolume - ResourceGroupName $resourceGroup - AccountName $accName - PoolName $poolName - VolumeName $volName2
157183 $retrievedVolume = Get-AzNetAppFilesVolume - ResourceGroupName $resourceGroup - AccountName $accName - PoolName $poolName
158184 Assert-AreEqual 0 $retrievedVolume.Length
185+
186+ # test export policy update with non-default volume (and "Standard" Pool)
187+ # create pool
188+ $retrievedPool = New-AzNetAppFilesPool - ResourceGroupName $resourceGroup - Location $resourceLocation - AccountName $accName - PoolName $poolName2 - PoolSize $poolSize - ServiceLevel " Standard"
189+
190+ # create the volume and check
191+ $newTagName = " tag1"
192+ $newTagValue = " tagValue1"
193+ $retrievedVolume = New-AzNetAppFilesVolume - ResourceGroupName $resourceGroup - Location $resourceLocation - AccountName $accName - PoolName $poolName2 - VolumeName $volName4 - CreationToken $volName4 - UsageThreshold $doubleUsage - ServiceLevel " Standard" - SubnetId $subnetId - Tag @ {$newTagName = $newTagValue } - ExportPolicy $exportPolicy - ProtocolTypes $protocolTypes
194+ Assert-AreEqual " $accName /$poolName2 /$volName4 " $retrievedVolume.Name
195+ Assert-AreEqual " Standard" $retrievedVolume.ServiceLevel
196+ Assert-AreEqual True $retrievedVolume.Tags.ContainsKey ($newTagName )
197+ Assert-AreEqual " tagValue1" $retrievedVolume.Tags [$newTagName ].ToString()
198+ Assert-NotNull $retrievedVolume.ExportPolicy
199+ Assert-AreEqual ' 0.0.0.0/0' $retrievedVolume.ExportPolicy.Rules [0 ].AllowedClients
200+ Assert-AreEqual ' 1.2.3.0/24' $retrievedVolume.ExportPolicy.Rules [1 ].AllowedClients
201+
202+ # update (patch) export policy and check no change to rest of volume
203+ $retrievedVolume = Update-AzNetAppFilesVolume - ResourceGroupName $resourceGroup - Location $resourceLocation - AccountName $accName - PoolName $poolName2 - VolumeName $volName4 - ExportPolicy $exportPolicyMod
204+ Assert-AreEqual ' 2.3.4.0/24' $retrievedVolume.ExportPolicy.Rules [0 ].AllowedClients
205+ # unchanged, not part of the patch
206+ Assert-AreEqual " Standard" $retrievedVolume.ServiceLevel
207+ Assert-AreEqual $doubleUsage $retrievedVolume.usageThreshold
208+ Assert-AreEqual True $retrievedVolume.Tags.ContainsKey ($newTagName )
209+ Assert-AreEqual " tagValue1" $retrievedVolume.Tags [$newTagName ].ToString()
159210 }
160211 finally
161212 {
0 commit comments