Skip to content

ANF-243 update to R5 RP 2019-07-01 API #28

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

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
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.1.0" />
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.17.0-preview" />
</ItemGroup>

Expand Down
10 changes: 10 additions & 0 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/AccountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,31 @@ public AccountTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAccountCrud()
{
GetSessionsDirectoryPath();
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AccountCrud");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAccountActiveDirectory()
{
GetSessionsDirectoryPath();
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AccountActiveDirectory");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAccountPipelines()
{
GetSessionsDirectoryPath();
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AccountPipelines");
}

private static void GetSessionsDirectoryPath()
{
string connectionString = "SubscriptionId=8f38cfec-0ecd-413a-892e-2494f77a3b56;ServicePrincipal=c6c4faba-2b22-44d9-80a4-71ff5b71f811;ServicePrincipalSecret={QR[+@avhE+3qiyY1Xf;AADTenant=72f988bf-86f1-41af-91ab-2d7cd011db47;Environment=Prod;HttpRecorderMode=Record;";
System.Environment.SetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION", connectionString, System.EnvironmentVariableTarget.Process);
System.Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Record", System.EnvironmentVariableTarget.Process);
}
}
}
26 changes: 13 additions & 13 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/AccountTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ function Test-AccountActiveDirectory
Username = "sdkuser1"
<#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="...")]#>
Password = "sdkpass1"
Domain = "sdkdomain1"
Dns = "127.0.0.2"
SmbServerName = "PSSMBSNam1"
Domain = "sdkdomain"
Dns = "127.0.0.1"
SmbServerName = "PSSMBSName"
}


try
{
Expand Down Expand Up @@ -79,7 +78,7 @@ function Test-AccountActiveDirectory
Assert-AreEqual $activeDirectory1.Username $retrievedAcc.ActiveDirectories[0].Username

# patch an Active Directory with no active directory. Should be no change
# create and check account 1
# except for the tag update
$newTagName = "tag1"
$newTagValue = "tagValue2"
$retrievedAcc = Update-AzNetAppFilesAccount -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName1 -Tag @{$newTagName = $newTagValue}
Expand All @@ -89,20 +88,21 @@ function Test-AccountActiveDirectory
Assert-AreEqual 1 $retrievedAcc.ActiveDirectories.Length
Assert-AreEqual "tagValue2" $retrievedAcc.Tags[$newTagName].ToString()

# 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
Assert-Null $retrievedAcc.Tags
Assert-Null $retrievedAcc.ActiveDirectories

# patch an Active Directory. Should be updated to contain only the new one
$activedirectories = @( $activeDirectory2 )
$retrievedAcc = Update-AzNetAppFilesAccount -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName1 -ActiveDirectory $activedirectories
Assert-AreEqual $accName1 $retrievedAcc.Name
Assert-AreEqual $activeDirectory2.SmbServerName $retrievedAcc.ActiveDirectories[0].SmbServerName
# correction to (wildcard values in) returned password expected in RP
# add this check back in at that time since username/password are the two fields of concern
# Assert-AreEqual $activeDirectory2.Password $retrievedAcc.ActiveDirectories[0].Password
Assert-AreEqual $activeDirectory2.Username $retrievedAcc.ActiveDirectories[0].Username
Assert-AreEqual 1 $retrievedAcc.ActiveDirectories.Length
Assert-AreEqual "tagValue2" $retrievedAcc.Tags[$newTagName].ToString()

# 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
Assert-Null $retrievedAcc.Tags
Assert-Null $retrievedAcc.ActiveDirectories
}
finally
{
Expand Down
6 changes: 3 additions & 3 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ function Get-ProviderLocation($provider)

if ($location -eq $null)
{
return "eastus2"
return "westcentralus"
} else
{
return $location.Locations[0]
}
}

return "eastus2"
return "westcentralus"
}

return "eastus2"
return "westcentralus"
}

<#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function Test-SnapshotCrud
# create two snapshots and check
$retrieveSn = New-AzNetAppFilesSnapshot -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName -SnapshotName $snName1 -FileSystemId $retrievedVolume.FileSystemId
Assert-AreEqual "$accName/$poolName/$volName/$snName1" $retrieveSn.Name
# check created date has been populated
Assert-NotNull $retrieveSn.Created

# one without using the filesystem id
$retrieveSn = New-AzNetAppFilesSnapshot -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName -SnapshotName $snName2
Expand Down
77 changes: 47 additions & 30 deletions src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,48 +42,61 @@ function Test-VolumeCrud

$rule1 = @{
RuleIndex = 1
UnixReadOnly = 'false'
UnixReadWrite = 'true'
Cifs = 'false'
Nfsv3 = 'true'
Nfsv4 = 'false'
UnixReadOnly = $false
UnixReadWrite = $true
Cifs = $false
Nfsv3 = $true
Nfsv41 = $false
AllowedClients = '0.0.0.0/0'
}
$rule2 = @{
RuleIndex = 2
UnixReadOnly = 'false'
UnixReadWrite = 'true'
Cifs = 'false'
Nfsv3 = 'true'
Nfsv4 = 'false'
UnixReadOnly = $false
UnixReadWrite = $true
Cifs = $false
Nfsv3 = $false
Nfsv41 = $true
AllowedClients = '1.2.3.0/24'
}
$rule3 = @{
RuleIndex = 2
UnixReadOnly = 'false'
UnixReadWrite = 'true'
Cifs = 'false'
Nfsv3 = 'true'
Nfsv4 = 'false'
UnixReadOnly = $false
UnixReadWrite = $true
Cifs = $false
Nfsv3 = $true
Nfsv41 = $false
AllowedClients = '2.3.4.0/24'
}

$rule5 = @{
RuleIndex = 1
UnixReadOnly = $false
UnixReadWrite = $true
Cifs = $false
Nfsv3 = $false
Nfsv41 = $true
AllowedClients = '1.2.3.0/24'
}
$exportPolicy = @{
Rules = (
$rule1, $rule2
)
}

$exportPolicyv4 = @{
Rules = (
$rule5
)
}

$exportPolicyMod = @{
Rules = (
$rule3
)
}

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

try
{
Expand Down Expand Up @@ -112,16 +125,18 @@ function Test-VolumeCrud
Assert-NotNull $retrievedVolume.ExportPolicy
Assert-AreEqual $retrievedVolume.ExportPolicy.Rules[0].AllowedClients '0.0.0.0/0'
Assert-AreEqual $retrievedVolume.ExportPolicy.Rules[1].AllowedClients '1.2.3.0/24'
Assert-AreEqual $retrievedVolume.ProtocolTypes[0] $protocolTypes[0]
Assert-AreEqual $retrievedVolume.ProtocolTypes[1] $protocolTypes[1]
Assert-AreEqual $retrievedVolume.ProtocolTypes[0] 'NFSv3'
Assert-NotNull $retrievedVolume.MountTargets

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

# create second volume and check using the confirm flag
$retrievedVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName2 -CreationToken $volName2 -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -Confirm:$false
$retrievedVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName2 -CreationToken $volName2 -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -ExportPolicy $exportPolicyv4 -ProtocolType $protocolTypesv4 -Confirm:$false
Assert-AreEqual "$accName/$poolName/$volName2" $retrievedVolume.Name
Assert-AreEqual $serviceLevel $retrievedVolume.ServiceLevel
# default protocol type for new volume
Assert-AreEqual $retrievedVolume.ProtocolTypes[0] 'NFSv3'
Assert-AreEqual $retrievedVolume.ProtocolTypes[0] 'NFSv4.1'

# create and check a third volume using the WhatIf - it should not be created
$retrievedVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName3 -CreationToken $volName2 -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -WhatIf
Expand Down Expand Up @@ -153,11 +168,11 @@ function Test-VolumeCrud

$rule4 = @{
RuleIndex = 3
UnixReadOnly = 'false'
UnixReadWrite = 'true'
Cifs = 'false'
Nfsv3 = 'true'
Nfsv4 = 'false'
UnixReadOnly = $false
UnixReadWrite = $true
Cifs = $false
Nfsv3 = $true
Nfsv41 = $false
AllowedClients = '1.2.3.0/24'
}

Expand Down Expand Up @@ -190,14 +205,16 @@ function Test-VolumeCrud
# create the volume and check
$newTagName = "tag1"
$newTagValue = "tagValue1"
$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 -ProtocolType $protocolTypes
$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
Assert-AreEqual "$accName/$poolName2/$volName4" $retrievedVolume.Name
Assert-AreEqual "Standard" $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 '1.2.3.0/24' $retrievedVolume.ExportPolicy.Rules[1].AllowedClients
# default protocol type for new volume
Assert-AreEqual $retrievedVolume.ProtocolTypes[0] 'NFSv3'

# update (patch) export policy and check no change to rest of volume
$retrievedVolume = Update-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName2 -VolumeName $volName4 -ExportPolicy $exportPolicyMod
Expand Down Expand Up @@ -298,4 +315,4 @@ function Test-VolumePipelines
# Cleanup
Clean-ResourceGroup $resourceGroup
}
}
}
Loading