Skip to content

Azure Site Recovery support for managed Managed disk and Service Api Version bumpup changes #6905

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 26 commits into from
Sep 7, 2018
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 @@ -39,7 +39,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices.SiteRecovery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.SiteRecovery.1.0.3-preview\lib\net452\Microsoft.Azure.Management.RecoveryServices.SiteRecovery.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.SiteRecovery.1.2.0-preview\lib\net452\Microsoft.Azure.Management.RecoveryServices.SiteRecovery.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -51,6 +51,8 @@
<Compile Include="ScenarioTests\E2E\AsrE2ETests.cs" />
<Compile Include="ScenarioTests\AsrTestsBase.cs" />
<Compile Include="ScenarioTests\V2A\AsrV2ATests.cs" />
<Compile Include="ScenarioTests\A2A\AsrA2ATests.cs" />
<Compile Include="ScenarioTests\A2A\AsrA2ATestsBase.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
Expand Down Expand Up @@ -167,6 +169,15 @@
<None Include="SessionRecords\RecoveryServices.SiteRecovery.Test.AsrV2ATests\V2AUpdatePolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\A2A\AsrA2ATests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\A2A\A2ATestsHelper.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\RecoveryServices.SiteRecovery.Test.AsrA2ATests\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\RecoveryServices\Commands.RecoveryServices\Commands.RecoveryServices.csproj">
Expand All @@ -181,9 +192,6 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Folder Include="ScenarioTests\A2A\" />
<Folder Include="SessionRecords\RecoveryServices.SiteRecovery.Test.AsrA2ATests\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# encoding: utf-8
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

########################## Site Recovery Tests #############################

##Default Value ##
$seed = "98"
function getVaultName{
return "A2APowershellTest" + $seed;
}

function getVaultRg{
return "A2APowershellTestRg" + $seed;
}


function getVaultRgLocation{
return "eastus"
}

function getVaultLocation{
return "eastus"
}

function getPrimaryLocation
{
return "westus"
}

function getRecoveryLocation{
return getVaultLocation
}

function getPrimaryFabric{
return "a2aPrimaryFabric"+$seed

}

function getRecoveryFabric{
return "a2aRecoveryFabric"+$seed

}

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-AzureRmVM -Name MyVm -Credential $Credential -location getPrimaryLocation
}

function getPrimaryPolicy{
return "TestA2APolicy1" + $seed;
}

function getRecoveryPolicy{
return "TestA2APolicy1" + $seed;
}

function getPrimaryContainer{
return "A2APrimaryContainer"+ $seed;
}


function getRecoveryContainer{
return "A2ARecoveryContainer"+ $seed;
}


function getPrimaryContainerMapping{
return "A2APCM"+ $seed;
}


function getRecoveryContainerMapping{
return "A2ARCM"+ $seed;
}

function getPrimaryNetworkMapping{
return "A2ANetworkMapping"+ $seed;
}

function getRecoveryNetworkMapping{
return "A2ARecoveryNetworkMapping"+ $seed;
}

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


}

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

$primaryNetworkName = "recoveryNetwork"+ $location + $seed;
$virtualNetwork = New-AzureRmVirtualNetwork `
-ResourceGroupName $resourceGroup `
-Location $location `
-Name $primaryNetworkName `
-AddressPrefix 10.0.0.0/16
$virtualNetwork.id
}


##

<#
.SYNOPSIS
Wait for job completion
Usage:
WaitForJobCompletion -JobId $Job.ID
WaitForJobCompletion -JobId $Job.ID -NumOfSecondsToWait 10
#>
function WaitForJobCompletion
{
param(
[string] $JobId,
[int] $JobQueryWaitTimeInSeconds = 20,
[string] $Message = "NA"
)
$isJobLeftForProcessing = $true;
do
{
$Job = Get-AzureRmRecoveryServicesAsrJob -Name $JobId
Write-Host $("Job Status:") -ForegroundColor Green
$Job

$isJobLeftForProcessing = ($Job.State -eq 'InProgress' -or $Job.State -eq 'NotStarted')

if($isJobLeftForProcessing)
{
if($Message -ne "NA")
{
Write-Host $Message -ForegroundColor Yellow
}
else
{
Write-Host $($($Job.JobType) + " in Progress...") -ForegroundColor Yellow
}
Write-Host $("Waiting for: " + $JobQueryWaitTimeInSeconds.ToString + " Seconds") -ForegroundColor Yellow
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait($JobQueryWaitTimeInSeconds * 1000)
}else
{
if( !(($job.State -eq "Succeeded") -or ($job.State -eq "CompletedWithInformation")))
{
throw "Job " + $JobId + "failed."
}
}
}While($isJobLeftForProcessing)
}

<#
.SYNOPSIS
Wait for IR job completion
Usage:
WaitForJobCompletion -VM $VM
WaitForJobCompletion -VM $VM -NumOfSecondsToWait 10
#>
Function WaitForIRCompletion
{
param(
[PSObject] $affectedObjectId,
[int] $JobQueryWaitTimeInSeconds = 10
)
$isProcessingLeft = $true
$IRjobs = $null

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

if($isProcessingLeft)
{
Write-Host $("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 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
@@ -0,0 +1,71 @@
// ----------------------------------------------------------------------------------
//
// 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 Xunit;
using Xunit.Abstractions;
using Microsoft.Azure.ServiceManagemenet.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;


namespace RecoveryServices.SiteRecovery.Test
{
public class AsrA2ATests : AsrA2ATestsBase
{
public XunitTracingInterceptor _logger;

public AsrA2ATests(
ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);

this.powershellHelperFile = System.IO.Path.Combine(
System.AppDomain.CurrentDomain.BaseDirectory,
"ScenarioTests\\A2A\\A2ATestsHelper.ps1");

this.powershellFile = System.IO.Path.Combine(
System.AppDomain.CurrentDomain.BaseDirectory,
"ScenarioTests\\A2A\\AsrA2ATests.ps1");
this.initialize();
}

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

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

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

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