Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NetAppFiles]Add 2021-10-01 changes #17767

Merged
merged 22 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/NetAppFiles/NetAppFiles.Test/NetAppFiles.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
</PropertyGroup>

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

<ItemGroup>
<ProjectReference Include="..\NetAppFiles\NetAppFiles.csproj" />
</ItemGroup>

</Project>
11 changes: 8 additions & 3 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/AccountTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ function Test-AccountActiveDirectory
Password = "sdkpass"
Domain = "sdkdomain"
Dns = "192.0.2.2"
SmbServerName = "PSSMBSName"
SmbServerName = "PSMBSName1"
}
$activeDirectory2 = @{
Username = "sdkuser1"
<#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="...")]#>
Password = "sdkpass1"
Password = "sdkpass2"
Domain = "sdkdomain"
Dns = "192.0.2.2"
SmbServerName = "PSSMBSName"
SmbServerName = "PSMBSName2"
}

try
Expand Down Expand Up @@ -109,6 +109,11 @@ function Test-AccountActiveDirectory
# Assert-AreEqual $activeDirectory2.Password $retrievedAcc.ActiveDirectories[0].Password
Assert-AreEqual $activeDirectory2.Username $retrievedAcc.ActiveDirectories[0].Username
Assert-AreEqual 1 $retrievedAcc.ActiveDirectories.Length

# update (put) the account. The absence of an active directory should result in the removal of any currently associated. Also tags
$retrievedAcc = Set-AzNetAppFilesAccount -ResourceGroupName $resourceGroup -AccountName $accName1 -Location $resourceLocation
Assert-AreEqual $accName1 $retrievedAcc.Name

}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public BackupPolicyTests(Xunit.Abstractions.ITestOutputHelper output)

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestBackupPolicyCrud()
public void TestBackupPolicyCrud()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-BackupPolicyCrud");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ function Test-VolumeBackupStatus
$gibibyte = 1024 * 1024 * 1024
$usageThreshold = 100 * $gibibyte
#$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "eastus" -UseCanonical
$resourceLocation = "westus2"
$backupLocation = "eastus2euap"
$backupVNetLocation = "eastus2euap"
$resourceLocation = "eastus2"
$backupLocation = "eastus2"
$backupVNetLocation = "eastus2"
$label = "powershellBackupTest"
#$backupLocation = "eastus2euap"
#$backupVNetLocation = "eastus2euap"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ----------------------------------------------------------------------------------
//
// 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 ExportPolicyTests
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public ExportPolicyTests(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 TestExportPolicy()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ExportPolicy");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# ----------------------------------------------------------------------------------
#
# 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 ExportPolicy operations
#>
function Test-ExportPolicy
{
$currentSub = (Get-AzureRmContext).Subscription
$subsid = $currentSub.SubscriptionId

$resourceGroup = Get-ResourceGroupName
$accName = Get-ResourceName
$poolName = Get-ResourceName
$volName1 = Get-ResourceName
$gibibyte = 1024 * 1024 * 1024
$usageThreshold = 100 * $gibibyte
$doubleUsage = 2 * $usageThreshold
#$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "eastus" -UseCanonical
#$resourceLocation = "eastus2euap"
$resourceLocation = "eastus"

$subnetName = "default"
$poolSize = 4398046511104
$serviceLevel = "Premium"
$vnetName = $resourceGroup + "-vnet"

$subnetId = "/subscriptions/$subsId/resourceGroups/$resourceGroup/providers/Microsoft.Network/virtualNetworks/$vnetName/subnets/$subnetName"

# create the list of protocol types
$protocolTypes = New-Object string[] 1
$protocolTypes[0] = "NFSv3"

try
{
# create the resource group
New-AzResourceGroup -Name $resourceGroup -Location $resourceLocation -Tags @{Owner = 'b-aubald'}

# create virtual network
$virtualNetwork = New-AzVirtualNetwork -ResourceGroupName $resourceGroup -Location $resourceLocation -Name $vnetName -AddressPrefix 10.0.0.0/16
$delegation = New-AzDelegation -Name "netAppVolumes" -ServiceName "Microsoft.Netapp/volumes"
Add-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.1.0/24" -Delegation $delegation | Set-AzVirtualNetwork

# create account
$retrievedAcc = New-AzNetAppFilesAccount -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName

# create pool
$retrievedPool = New-AzNetAppFilesPool -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -PoolSize $poolSize -ServiceLevel $serviceLevel
#$exportPolicyRule = New-AzExportPolicyRuleObject -RuleIndex 1 -AllowedClients '0.0.0.0/0' -UnixReadOnly $false -UnixReadWrite $false -Cifs $false -Nfsv3 $true -Nfsv41 $false
$exportPolicyRule = New-AzExportPolicyRuleObject -RuleIndex 1 -AllowedClient '0.0.0.0/0' -UnixReadOnly -UnixReadWrite -Cifs -Nfsv3
$exportPolicyRules = $($exportPolicyRule)

$newExportPolicy = New-AzExportPolicyObject -Rule $exportPolicyRules

# create first volume and check
$newTagName = "tag1"
$newTagValue = "tagValue1"
$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 $newExportPolicy -ProtocolType $protocolTypes
Assert-AreEqual "$accName/$poolName/$volName1" $retrievedVolume.Name
Assert-AreEqual $serviceLevel $retrievedVolume.ServiceLevel
Assert-AreEqual True $retrievedVolume.Tags.ContainsKey($newTagName)
Assert-AreEqual "tagValue1" $retrievedVolume.Tags[$newTagName].ToString()
Assert-NotNull $retrievedVolume.ExportPolicy
Assert-AreEqual '0.0.0.0/0' $retrievedVolume.ExportPolicy.Rules[0].AllowedClients

Assert-AreEqual $retrievedVolume.ProtocolTypes[0] 'NFSv3'
Assert-NotNull $retrievedVolume.MountTargets
Assert-Null $retrievedVolume.VolumeType
Assert-Null $retrievedVolume.DataProtection

# use the NFSv4.1
$protocolTypesv4 = New-Object string[] 1
$protocolTypesv4[0] = "NFSv4.1"

#get and check a volume by name
$retrievedVolume = Get-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1
Assert-AreEqual "$accName/$poolName/$volName1" $retrievedVolume.Name
}
finally
{
# Cleanup
Clean-ResourceGroup $resourceGroup
}
}
37 changes: 37 additions & 0 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SubvolumeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ----------------------------------------------------------------------------------
//
// 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 SubvolumeTests
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
public SubvolumeTests(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 TestSubvolumeCrud()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SubvolumeCrud");
}


}
}
111 changes: 111 additions & 0 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SubvolumeTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# ----------------------------------------------------------------------------------
#
# 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 Volume CRUD operations
#>
function Test-SubvolumeCrud
{
$currentSub = (Get-AzureRmContext).Subscription
$subsid = $currentSub.SubscriptionId
$resourceGroup = Get-ResourceGroupName
$accName = Get-ResourceName
$poolName = Get-ResourceName
$volName1 = Get-ResourceName
$subvolName1 = Get-ResourceName
$subvolName2 = Get-ResourceName
$gibibyte = 1024 * 1024 * 1024
$usageThreshold = 100 * $gibibyte
$doubleUsage = 2 * $usageThreshold
$resourceLocation = "eastus"

$subnetName = "default"
$poolSize = 4398046511104
$serviceLevel = "Premium"
$vnetName = $resourceGroup + "-vnet"

$subnetId = "/subscriptions/$subsId/resourceGroups/$resourceGroup/providers/Microsoft.Network/virtualNetworks/$vnetName/subnets/$subnetName"

# create the list of protocol types
$protocolTypes = New-Object string[] 1
$protocolTypes[0] = "NFSv3"
$path = "/subvolumePath"
$updatePath = "/subvolumePath1"
$parentPath = "/parentPath"
$subvolumeSize = 5
try
{
# create the resource group
New-AzResourceGroup -Name $resourceGroup -Location $resourceLocation -Tags @{Owner = 'b-aubald'}
# create virtual network
$virtualNetwork = New-AzVirtualNetwork -ResourceGroupName $resourceGroup -Location $resourceLocation -Name $vnetName -AddressPrefix 10.0.0.0/16
$delegation = New-AzDelegation -Name "netAppVolumes" -ServiceName "Microsoft.Netapp/volumes"
Add-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.1.0/24" -Delegation $delegation | Set-AzVirtualNetwork

# create account
$retrievedAcc = New-AzNetAppFilesAccount -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName

# create pool
$retrievedPool = New-AzNetAppFilesPool -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -PoolSize $poolSize -ServiceLevel $serviceLevel
# create first volume and check
$newTagName = "tag1"
$newTagValue = "tagValue1"
$retrievedVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName1 -CreationToken $volName1 -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -Tag @{$newTagName = $newTagValue} -ProtocolType $protocolTypes -EnableSubvolume
Assert-AreEqual "$accName/$poolName/$volName1" $retrievedVolume.Name
Assert-AreEqual $serviceLevel $retrievedVolume.ServiceLevel
Assert-AreEqual True $retrievedVolume.Tags.ContainsKey($newTagName)
Assert-AreEqual "tagValue1" $retrievedVolume.Tags[$newTagName].ToString()
Assert-AreEqual '0.0.0.0/0' $retrievedVolume.ExportPolicy.Rules[0].AllowedClients
Assert-AreEqual $retrievedVolume.ProtocolTypes[0] 'NFSv3'

# create first subvolume and check
$retrievedSubvolume = New-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1 -Size $subvolumeSize -Path $path
Assert-AreEqual $path $retrievedSubvolume.Path

# get first subvolume and check
$getSubvolume = Get-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1
Assert-AreEqual $path $getSubvolume.Path

# get first subvolume metadata and check
$getSubvolumeMetadata = Get-AzNetAppFilesSubvolumeMetadata -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1
Assert-AreEqual $path $getSubvolumeMetadata.Path
Assert-NotNull $getSubvolumeMetadata.Permissions
Assert-NotNull $getSubvolumeMetadata.CreationTimeStamp

# Update subvolume and check
$updatedSubvolume = Update-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1 -Size 3 -Path $updatePath
Assert-AreEqual $updatePath $updatedSubvolume.Path

# create second subvolume and check
$retrievedSubvolume2 = New-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName2 -Size 5 -Path $path
Assert-AreEqual $path $retrievedSubvolume2.Path

# get list and check
$getSubvolumes = Get-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1
Assert-AreEqual 2 $getSubvolumes.Length

#Delete subvolume 1
$updatedSubvolume = Remove-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1

# get list and check again
$getSubvolumes = Get-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1
Assert-AreEqual 1 $getSubvolumes.Length
}
finally
{
# Cleanup
Clean-ResourceGroup $resourceGroup
}
}
37 changes: 37 additions & 0 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeGroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ----------------------------------------------------------------------------------
//
// 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 VolumeGroupTests
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
public VolumeGroupTests(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 TestVolumeGroupCrud()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-VolumeGroupCrud");
}


}
}
Loading