Skip to content

Commit

Permalink
[NetAppFiles]Apply 2021-08-01 Changes (#16855)
Browse files Browse the repository at this point in the history
* Apply 2021-10-01 Changes

* Add example output to md file

* Update ChangeLog.md

* Singular

* Administrators to singular

Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com>
  • Loading branch information
audunn and wyunchi-ms authored Jan 24, 2022
1 parent 559e606 commit 010f2d5
Show file tree
Hide file tree
Showing 51 changed files with 29,630 additions and 13,986 deletions.
2 changes: 1 addition & 1 deletion src/NetAppFiles/NetAppFiles.Test/NetAppFiles.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="1.14.0" />
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="1.15.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="21.0.0" />
</ItemGroup>

Expand Down
64 changes: 50 additions & 14 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ function Test-BackupCrud
$backupName2 = Get-ResourceName
$backupPolicyName1 = Get-ResourceName
$resourceLocation = Get-ProviderLocation "Microsoft.NetApp"
$backupLocation = "eastus2euap"
$backupVNetLocation = "eastus2euap"
$backupLocation = "eastus2"
$backupVNetLocation = "eastus2"
#$backupLocation = "southcentralusstage"
#$backupVNetLocation = "southcentralus"
#$backupLocation = "centralus"
Expand Down Expand Up @@ -59,6 +59,12 @@ function Test-BackupCrud
Cifs = $false
Nfsv3 = $true
Nfsv41 = $false
kerberos5ReadOnly = $false
kerberos5ReadWrite = $false
kerberos5iReadOnly = $false
kerberos5iReadWrite = $false
kerberos5pReadOnly = $false
kerberos5pReadWrite = $false
AllowedClients = '0.0.0.0/0'
}
$exportPolicy = @{
Expand All @@ -77,11 +83,16 @@ function Test-BackupCrud
do
{
$sourceVolume = Get-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1
Start-Sleep -Seconds 10.0
if ($env:AZURE_TEST_MODE -eq "Record")
{
Start-Sleep -Seconds 10.0
}
$i++
}
until ($sourceVolume.ProvisioningState -eq "Succeeded" -or $i -eq 3);
}
}



function SleepDuringRecord ($seconds = 30.0)
{
Expand All @@ -95,7 +106,7 @@ function Test-BackupCrud
try
{
# create the resource group
New-AzResourceGroup -Name $resourceGroup -Location $backupVNetLocation -Tags @{Owner = 'b-aubald'}
New-AzResourceGroup -Name $resourceGroup -Location $backupVNetLocation -Tags @{Owner = 'b-aubald';testTag1='psBackupTagValue1'}

# create virtual network
$virtualNetwork = New-AzVirtualNetwork -ResourceGroupName $resourceGroup -Location $backupVNetLocation -Name $vnetName -AddressPrefix 10.0.0.0/16
Expand All @@ -116,7 +127,7 @@ function Test-BackupCrud
$retrievedPool = New-AzNetAppFilesPool -ResourceGroupName $resourceGroup -Location $backupLocation -AccountName $accName1 -PoolName $poolName -PoolSize $poolSize -ServiceLevel $serviceLevel

# create volume and check
$retrievedVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $backupLocation -AccountName $accName1 -PoolName $poolName -VolumeName $volName1 -CreationToken $volName1 -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -Tag @{$newTagName = $newTagValue} -ExportPolicy $exportPolicy -ProtocolType $protocolTypes
$retrievedVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $backupLocation -AccountName $accName1 -PoolName $poolName -VolumeName $volName1 -CreationToken $volName1 -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -Tag @{$newTagName = $newTagValue} -ExportPolicy $exportPolicy -ProtocolType $protocolTypes
Assert-AreEqual "$accName1/$poolName/$volName1" $retrievedVolume.Name
Assert-AreEqual $serviceLevel $retrievedVolume.ServiceLevel
Assert-AreEqual True $retrievedVolume.Tags.ContainsKey($newTagName)
Expand Down Expand Up @@ -145,6 +156,7 @@ function Test-BackupCrud
# create and check Backup
$retrievedBackup = New-AzNetAppFilesBackup -ResourceGroupName $resourceGroup -Location $backupLocation -AccountName $accName1 -PoolName $poolName -VolumeName $volName1 -Name $backupName1 -Label $label
Assert-AreEqual "$accName1/$poolName/$volName1/$backupName1" $retrievedBackup.Name
WaitForBackupSucceeded $backupName1
# service side issue does not return label enable when fixed (ANF-8057)
#Assert-AreEqual $label $retrievedBackup.Label

Expand All @@ -166,7 +178,9 @@ function Test-BackupCrud

#create second Backup
$secondBackup = New-AzNetAppFilesBackup -ResourceGroupName $resourceGroup -Location $backupLocation -AccountName $accName1 -PoolName $poolName -VolumeName $volName1 -Name $backupName2 -Label $label2
Assert-AreEqual "$accName1/$poolName/$volName1/$backupName2" $secondBackup.Name
Assert-AreEqual "$accName1/$poolName/$volName1/$backupName2" $secondBackup.Name
WaitForBackupSucceeded $backupName2

# service side issue does not return label enable when fixed (ANF-8057)
# Assert-AreEqual $label $secondBackup.Label2

Expand All @@ -190,7 +204,8 @@ function Test-BackupCrud
Remove-AzNetAppFilesBackup -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1 -Name $backupName1 -WhatIf
$retrievedBackupsList = Get-AzNetAppFilesBackup -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1
Assert-AreEqual 2 $retrievedBackupsList.Length


SleepDuringRecord 200
#remove by name
Remove-AzNetAppFilesBackup -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1 -Name $backupName1
$retrievedBackupsList = Get-AzNetAppFilesBackup -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1
Expand Down Expand Up @@ -245,8 +260,8 @@ function Test-BackupPipelines
$usageThreshold = 100 * $gibibyte
$doubleUsage = 2 * $usageThreshold
$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "eastus" -UseCanonical
$backupLocation = "eastus2euap"
$backupVNetLocation = "eastus2euap"
$backupLocation = "eastus2"
$backupVNetLocation = "eastus2"
$subnetName = "default"
$poolSize = 4398046511104
$serviceLevel = "Premium"
Expand Down Expand Up @@ -304,7 +319,8 @@ function Test-BackupPipelines
#$retrieveSn = Get-AnfVolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName | New-AnfSnapshot -SnapshotName $snName1
$retrievedBackup = Get-AnfVolume -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1 | New-AnfBackup -BackupName $backupName1 -Label $label
Assert-AreEqual "$accName1/$poolName/$volName1/$backupName1" $retrievedBackup.Name
SleepDuringRecord 200

WaitForBackupSucceeded $backupName1
# $getRetrievedBackupPolicy = Get-AnfVolume -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -Name $volName1 | Get-AzNetAppFilesBackup -ResourceGroupName $resourceGroup -AccountName $accName1 -Name $backupName1

$updateRetrievedBackup = Get-AnfVolume -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -Name $volName1 | Update-AzNetAppFilesBackup -Name $backupName1 -Label $updateLabel
Expand All @@ -318,8 +334,8 @@ function Test-BackupPipelines

#create anoter backup
$retrievedBackup = Get-AnfVolume -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1 | New-AnfBackup -BackupName $backupName2 -Label $label
Assert-AreEqual "$accName1/$poolName/$volName1/$backupName2" $retrievedBackup.Name
SleepDuringRecord 200
Assert-AreEqual "$accName1/$poolName/$volName1/$backupName2" $retrievedBackup.Name
WaitForBackupSucceeded $backupName2

$retrievedBackups = Get-AnfBackup -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1
Assert-AreEqual 2 $retrievedBackups.Length
Expand All @@ -337,7 +353,7 @@ function Test-BackupPipelines
Remove-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1
$retrievedVolumes = Get-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName
Assert-AreEqual 0 $retrievedVolumes.Length

SleepDuringRecord 400
# delete the last backup by piping from AccountBackup get
Get-AnfBackup -ResourceGroupName $resourceGroup -AccountName $accName1 -AccountBackupName $backupName2 | Remove-AnfBackup
SleepDuringRecord 200
Expand Down Expand Up @@ -406,6 +422,12 @@ function Test-VolumeBackupStatus
Cifs = $false
Nfsv3 = $true
Nfsv41 = $false
kerberos5ReadOnly = $false
kerberos5ReadWrite = $false
kerberos5iReadOnly = $false
kerberos5iReadWrite = $false
kerberos5pReadOnly = $false
kerberos5pReadWrite = $false
AllowedClients = '0.0.0.0/0'
}

Expand Down Expand Up @@ -499,3 +521,17 @@ function Test-VolumeBackupStatus
Clean-ResourceGroup $resourceGroup
}
}
function WaitForBackupSucceeded ($backupName)
{
$i = 0
do
{
$sourceBackup = Get-AzNetAppFilesBackup -ResourceGroupName $resourceGroup -AccountName $accName1 -PoolName $poolName -VolumeName $volName1 -Name $backupName
if ($env:AZURE_TEST_MODE -eq "Record")
{
Start-Sleep -Seconds 10.0
}
$i++
}
until ($sourceBackup.ProvisioningState -eq "Succeeded" -or $i -eq 10);
}
36 changes: 36 additions & 0 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/QuotaLimitTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest
{
public class QuotaLimitTests
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public QuotaLimitTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestQuotaLimit()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-QuotaLimit");
}
}
}
40 changes: 40 additions & 0 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/QuotaLimitTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Test QuotaLimits
#>
function Test-QuotaLimit
{
$resourceLocation = Get-ProviderLocation "Microsoft.NetApp"
$quotaLimitName = "totalTiBsPerSubscription"
try
{
# get limits list
$retrievedLimits = Get-AzNetAppFilesQuotaLimit -Location $resourceLocation
Assert-NotNull $retrievedLimits
Assert-True {$retrievedLimits.Length -gt 0}

# get limit by name
$retrievedLimit = Get-AzNetAppFilesQuotaLimit -Location $resourceLocation -Name $quotaLimitName
Assert-NotNull $retrievedLimit
Assert-AreEqual "$resourceLocation/$quotaLimitName" $retrievedLimit.Name
}
finally
{
# Cleanup
Clean-ResourceGroup $resourceGroup
}
}
12 changes: 6 additions & 6 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SnapshotTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Test-SnapshotCrud
$resourceGroup = Get-ResourceGroupName
$accName = Get-ResourceName
$poolName = Get-ResourceName
$volName = Get-ResourceName
$volName = Get-ResourceName
$snName1 = Get-ResourceName
$snName2 = Get-ResourceName
$gibibyte = 1024 * 1024 * 1024
Expand Down Expand Up @@ -231,8 +231,9 @@ function Test-CreateVolumeFromSnapshot
Assert-AreEqual "$accName/$poolName/$volName/$snName1" $retrievedSnapshotById.Name

# Create volume from snapshot
$restoredVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName -CreationToken $volName -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -SnapshotId $retrievedSnapshot.SnapshotId
Assert-AreEqual $retrievedVolume.Name $restoredVolume.Name
$restoredNewVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName2 -CreationToken $volName2 -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -SnapshotId $retrievedSnapshot.SnapshotId
Assert-NotNull $restoredNewVolume
Assert-AreEqual "$accName/$poolName/$volName2" $restoredNewVolume.Name
}
finally
{
Expand Down Expand Up @@ -305,9 +306,8 @@ function Test-RestoreVolumeFromSnapshot
$retrievedSnapshotById = Get-AzNetAppFilesSnapshot -ResourceId $retrievedSnapshot.Id
Assert-AreEqual "$accName/$poolName/$volName/$snName1" $retrievedSnapshotById.Name

# revert the volume from snapshot
Restore-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName -SnapshotId $retrievedSnapshot.SnapshotId

# Restore the volume from snapshot
$restoredVolume = Restore-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName -SnapshotId $retrievedSnapshot.SnapshotId
}
finally
{
Expand Down
21 changes: 15 additions & 6 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,18 @@ function Test-VolumeReplication
$doubleUsage = 2 * $usageThreshold
$srcResourceGroupLocation = "westus2"
$destResourceGroupLocation = "eastus"
#$srcResourceLocation = "westus2stage"

#$srcResourceGroupLocation = "eastus2euap"
#$destResourceGroupLocation = "southcentralus"
$srcResourceLocation = "westus2"
$destResourceLocation = "eastus"
#for when using stage regions (southcentralusstage then vnet is created in southcentralus)
$destVnetLocation = "eastus"

#$srcResourceLocation = "eastus2euap"
#$destResourceLocation = "southcentralusstage"
#$destVnetLocation = "southcentralus"

$subnetName = "default"
$poolSize = 4398046511104
$serviceLevel = "Premium"
Expand Down Expand Up @@ -311,7 +320,7 @@ function Test-VolumeReplication
Start-Sleep -Seconds 10.0
$i++
}
until ($replicationStatus.MirrorState -eq $targetState -or $i -eq 20);
until ($replicationStatus.MirrorState -eq $targetState -or $i -eq 40);

$replicationStatus = Get-AnfReplicationStatus -ResourceGroupName $destResourceGroup -AccountName $destAccName -PoolName $destPoolName -VolumeName $destVolName
Assert-AreEqual $targetState $replicationStatus.MirrorState
Expand Down Expand Up @@ -344,7 +353,7 @@ function Test-VolumeReplication
Add-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.2.0/24" -Delegation $delegation | Set-AzVirtualNetwork

# create virtual network destination
$virtualNetwork = New-AzVirtualNetwork -ResourceGroupName $destResourceGroup -Location $destResourceLocation -Name $destVnetName -AddressPrefix 10.0.0.0/16
$virtualNetwork = New-AzVirtualNetwork -ResourceGroupName $destResourceGroup -Location $destVnetLocation -Name $destVnetName -AddressPrefix 10.0.0.0/16
$delegation = New-AzDelegation -Name "netAppVolumes" -ServiceName "Microsoft.Netapp/volumes"
Add-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.3.0/24" -Delegation $delegation | Set-AzVirtualNetwork

Expand Down Expand Up @@ -436,7 +445,7 @@ function Test-SetVolumePool
$gibibyte = 1024 * 1024 * 1024
$usageThreshold = 100 * $gibibyte
#$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "eastus" -UseCanonical
$resourceLocation = "westus2"
$resourceLocation = "eastus"
$subnetName = "default"
$poolSize = 4398046511104
$serviceLevel = "Premium"
Expand Down Expand Up @@ -543,7 +552,7 @@ function Update-AzNetAppFilesVolumeSnapshotPolicy
$gibibyte = 1024 * 1024 * 1024
$usageThreshold = 100 * $gibibyte
#$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "eastus" -UseCanonical
$resourceLocation = "westus2"
$resourceLocation = "eastus"
$subnetName = "default"
$poolSize = 4398046511104
$serviceLevel = "Premium"
Expand Down Expand Up @@ -658,7 +667,7 @@ function Test-VolumePipelines
$doubleUsage = 2 * $usageThreshold
#$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "eastus" -UseCanonical
#$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "westcentralus" -UseCanonical
$resourceLocation = "westus2"
$resourceLocation = "eastus"
$subnetName = "default"
$poolSize = 4398046511104
$serviceLevel = "Premium"
Expand Down
Loading

0 comments on commit 010f2d5

Please sign in to comment.