Skip to content

adding a2a tests for enableReplication,AddDisk #10

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="25.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.10.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.2.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.SiteRecovery" Version="2.0.1-preview" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
########################## Site Recovery Tests #############################

##Default Value ##
$seed = "98"
$seed = "88"
function getVaultName{
return "A2APowershellTest" + $seed;
}
Expand Down Expand Up @@ -53,14 +53,12 @@ function getRecoveryFabric{

}

function getAzureVm{
param([string]$primaryLocation)

$VMLocalAdminUser = "adminUser"
$VMLocalAdminSecurePassword = "password"
$password=$VMLocalAdminSecurePassword|ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $password);
New-AzVM -Name MyVm -Credential $Credential -location getPrimaryLocation
function getAzureVmName{
return "a2aVM"+$seed
}

function getAzureDataDiskName{
return "a2aDataDisk"+$seed
}

function getPrimaryPolicy{
Expand Down Expand Up @@ -99,23 +97,90 @@ function getRecoveryNetworkMapping{
}

function getPrimaryNetworkId{
param([string] $location , [string] $resourceGroup)
}

function getRecoveryNetworkName{
return "A2ARecoveryNetwork"+ $seed;
}

function getCacheStorageAccountName{
return "cache"+ $seed;
}

function getRecoveryResourceGroupName{
return "recRG"+ $seed;
}

function createAzureVm{
param([string]$primaryLocation)

$VMLocalAdminUser = "adminUser"
$VMLocalAdminSecurePassword = "NewPassword@1"
$VMLocation = getPrimaryLocation
$VMName = getAzureVmName
$domain = "domain"+ $seed
$password=$VMLocalAdminSecurePassword|ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $password);
$vm = New-AzVM -Name $VMName -Credential $Credential -location $VMLocation -Image RHEL -DomainNameLabel $domain
return $vm.Id
}

function getRecoveryNetworkId{
function createRecoveryAzureVm{
param([string]$primaryLocation)

$VMLocalAdminUser = "adminUser"
$VMLocalAdminSecurePassword = "NewPassword@1"
$VMLocation = getRecoveryLocation
$VMName = getRecoveryResourceGroupName
$domain = "domain"+ $seed
$password=$VMLocalAdminSecurePassword|ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $password);
$vm = New-AzVM -Name $VMName -Credential $Credential -location $VMLocation -Image RHEL -DomainNameLabel $domain
return $vm.Id
}

function createRecoveryNetworkId{
param([string] $location , [string] $resourceGroup)

$primaryNetworkName = "recoveryNetwork"+ $location + $seed;
$NetworkName = getRecoveryNetworkName
$NetworkLocation = getRecoveryLocation
$ResourceGroupName = getRecoveryResourceGroupName
$frontendSubnet = New-AzVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$virtualNetwork = New-AzVirtualNetwork `
-ResourceGroupName $resourceGroup `
-Location $location `
-Name $primaryNetworkName `
-AddressPrefix 10.0.0.0/16
$virtualNetwork.id
-ResourceGroupName $ResourceGroupName `
-Location $NetworkLocation `
-Name $NetworkName `
-AddressPrefix 10.0.0.0/16 -Subnet $frontendSubnet
return $virtualNetwork.Id
}

function createCacheStorageAccount{
param([string] $location , [string] $resourceGroup)

$StorageAccountName = getCacheStorageAccountName
$cacheLocation = getPrimaryLocation
$storageRes = getAzureVmName
$storageAccount = New-AzStorageAccount `
-ResourceGroupName $storageRes `
-Location $cacheLocation `
-Name $StorageAccountName `
-Type 'Standard_LRS'
return $storageAccount.Id
}

function createRecoveryResourceGroup{
param([string] $location)

$ResourceGroupName = getRecoveryResourceGroupName
$ResourceLocation = getRecoveryLocation
$ResourceGroup = New-AzResourceGroup `
-Name $ResourceGroupName `
-Location $ResourceLocation -force
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
$ResourceGroup = Get-AzResourceGroup `
-Name $ResourceGroupName
return $ResourceGroup.ResourceId
}

##

Expand Down Expand Up @@ -198,3 +263,31 @@ Function WaitForIRCompletion
$IRjobs
WaitForJobCompletion -JobId $IRjobs[0].Name -JobQueryWaitTimeInSeconds $JobQueryWaitTimeInSeconds -Message $("Finalize IR in Progress...")
}

Function WaitForAddDisksIRCompletion
{
param(
[PSObject] $affectedObjectId,
[int] $JobQueryWaitTimeInSeconds = 10
)
$isProcessingLeft = $true
$IRjobs = $null

Write-Host $("Add-Disk IR in Progress...") -ForegroundColor Yellow
do
{
$IRjobs = Get-AzureRmRecoveryServicesAsrJob -TargetObjectId $affectedObjectId | Sort-Object StartTime -Descending | select -First 2 | Where-Object{$_.JobType -eq "AddDisksIrCompletion"}
$isProcessingLeft = ($IRjobs -eq $null -or $IRjobs.Count -ne 1)

if($isProcessingLeft)
{
Write-Host $("Adddisk IR in Progress...") -ForegroundColor Yellow
Write-Host $("Waiting for: " + $JobQueryWaitTimeInSeconds.ToString + " Seconds") -ForegroundColor Yellow
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait($JobQueryWaitTimeInSeconds * 1000)
}
}While($isProcessingLeft)

Write-Host $("Finalize Add disk IR jobs:") -ForegroundColor Green
$IRjobs
WaitForJobCompletion -JobId $IRjobs[0].Name -JobQueryWaitTimeInSeconds $JobQueryWaitTimeInSeconds -Message $("Finalize IR in Progress...")
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,32 @@ public void TestNewA2AManagedDiskReplicationConfig()
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-NewA2AManagedDiskReplicationConfiguration");
}

#if NETSTANDARD
[Fact(Skip = "Needs investigation, TestManagementClientHelper class wasn't initialized with the ResourceManagementClient client.")]
#else
[Fact]
#endif
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void A2ANewAsrFabric()
{
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-NewAsrFabric");
}

#if NETSTANDARD
[Fact(Skip = "Needs investigation, TestManagementClientHelper class wasn't initialized with the ResourceManagementClient client.")]
#else
[Fact]
#endif
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void A2ATestNewContainer()
{
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-NewContainer");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void A2ANewAsrReplicationProtectedItem()
{
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-NewReplicationProtectedItem");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void A2ANewAsrReplicationProtectedItemDisk()
{
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-AddReplicationProtectedItemDisk");
}
}
}
Loading