Skip to content

Commit b6a1b29

Browse files
authored
Merge pull request #6905 from AsrOneSdk/asr_managedDisk
Azure Site Recovery support for managed Managed disk and Service Api Version bumpup changes
2 parents 5ffc2e1 + 6e5d4ab commit b6a1b29

File tree

172 files changed

+142988
-76954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+142988
-76954
lines changed

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.SiteRecovery.Test/Commands.RecoveryServices.SiteRecovery.Test.csproj

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<Private>True</Private>
4040
</Reference>
4141
<Reference Include="Microsoft.Azure.Management.RecoveryServices.SiteRecovery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
42-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.SiteRecovery.1.0.3-preview\lib\net452\Microsoft.Azure.Management.RecoveryServices.SiteRecovery.dll</HintPath>
42+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.SiteRecovery.1.2.0-preview\lib\net452\Microsoft.Azure.Management.RecoveryServices.SiteRecovery.dll</HintPath>
4343
</Reference>
4444
</ItemGroup>
4545
<ItemGroup>
@@ -51,6 +51,8 @@
5151
<Compile Include="ScenarioTests\E2E\AsrE2ETests.cs" />
5252
<Compile Include="ScenarioTests\AsrTestsBase.cs" />
5353
<Compile Include="ScenarioTests\V2A\AsrV2ATests.cs" />
54+
<Compile Include="ScenarioTests\A2A\AsrA2ATests.cs" />
55+
<Compile Include="ScenarioTests\A2A\AsrA2ATestsBase.cs" />
5456
</ItemGroup>
5557
<ItemGroup>
5658
<None Include="packages.config">
@@ -167,6 +169,15 @@
167169
<None Include="SessionRecords\RecoveryServices.SiteRecovery.Test.AsrV2ATests\V2AUpdatePolicy.json">
168170
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
169171
</None>
172+
<None Include="ScenarioTests\A2A\AsrA2ATests.ps1">
173+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
174+
</None>
175+
<None Include="ScenarioTests\A2A\A2ATestsHelper.ps1">
176+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
177+
</None>
178+
<None Include="SessionRecords\RecoveryServices.SiteRecovery.Test.AsrA2ATests\*.json">
179+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
180+
</None>
170181
</ItemGroup>
171182
<ItemGroup>
172183
<ProjectReference Include="..\..\RecoveryServices\Commands.RecoveryServices\Commands.RecoveryServices.csproj">
@@ -181,9 +192,6 @@
181192
<ItemGroup>
182193
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
183194
</ItemGroup>
184-
<ItemGroup>
185-
<Folder Include="ScenarioTests\A2A\" />
186-
<Folder Include="SessionRecords\RecoveryServices.SiteRecovery.Test.AsrA2ATests\" />
187-
</ItemGroup>
195+
<ItemGroup />
188196
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
189197
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# encoding: utf-8
2+
# ----------------------------------------------------------------------------------
3+
#
4+
# Copyright Microsoft Corporation
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ----------------------------------------------------------------------------------
15+
16+
########################## Site Recovery Tests #############################
17+
18+
##Default Value ##
19+
$seed = "98"
20+
function getVaultName{
21+
return "A2APowershellTest" + $seed;
22+
}
23+
24+
function getVaultRg{
25+
return "A2APowershellTestRg" + $seed;
26+
}
27+
28+
29+
function getVaultRgLocation{
30+
return "eastus"
31+
}
32+
33+
function getVaultLocation{
34+
return "eastus"
35+
}
36+
37+
function getPrimaryLocation
38+
{
39+
return "westus"
40+
}
41+
42+
function getRecoveryLocation{
43+
return getVaultLocation
44+
}
45+
46+
function getPrimaryFabric{
47+
return "a2aPrimaryFabric"+$seed
48+
49+
}
50+
51+
function getRecoveryFabric{
52+
return "a2aRecoveryFabric"+$seed
53+
54+
}
55+
56+
function getAzureVm{
57+
param([string]$primaryLocation)
58+
59+
$VMLocalAdminUser = "adminUser"
60+
$VMLocalAdminSecurePassword = "password"
61+
$password=$VMLocalAdminSecurePassword|ConvertTo-SecureString -AsPlainText -Force
62+
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $password);
63+
New-AzureRmVM -Name MyVm -Credential $Credential -location getPrimaryLocation
64+
}
65+
66+
function getPrimaryPolicy{
67+
return "TestA2APolicy1" + $seed;
68+
}
69+
70+
function getRecoveryPolicy{
71+
return "TestA2APolicy1" + $seed;
72+
}
73+
74+
function getPrimaryContainer{
75+
return "A2APrimaryContainer"+ $seed;
76+
}
77+
78+
79+
function getRecoveryContainer{
80+
return "A2ARecoveryContainer"+ $seed;
81+
}
82+
83+
84+
function getPrimaryContainerMapping{
85+
return "A2APCM"+ $seed;
86+
}
87+
88+
89+
function getRecoveryContainerMapping{
90+
return "A2ARCM"+ $seed;
91+
}
92+
93+
function getPrimaryNetworkMapping{
94+
return "A2ANetworkMapping"+ $seed;
95+
}
96+
97+
function getRecoveryNetworkMapping{
98+
return "A2ARecoveryNetworkMapping"+ $seed;
99+
}
100+
101+
function getPrimaryNetworkId{
102+
param([string] $location , [string] $resourceGroup)
103+
104+
105+
}
106+
107+
function getRecoveryNetworkId{
108+
param([string] $location , [string] $resourceGroup)
109+
110+
$primaryNetworkName = "recoveryNetwork"+ $location + $seed;
111+
$virtualNetwork = New-AzureRmVirtualNetwork `
112+
-ResourceGroupName $resourceGroup `
113+
-Location $location `
114+
-Name $primaryNetworkName `
115+
-AddressPrefix 10.0.0.0/16
116+
$virtualNetwork.id
117+
}
118+
119+
120+
##
121+
122+
<#
123+
.SYNOPSIS
124+
Wait for job completion
125+
Usage:
126+
WaitForJobCompletion -JobId $Job.ID
127+
WaitForJobCompletion -JobId $Job.ID -NumOfSecondsToWait 10
128+
#>
129+
function WaitForJobCompletion
130+
{
131+
param(
132+
[string] $JobId,
133+
[int] $JobQueryWaitTimeInSeconds = 20,
134+
[string] $Message = "NA"
135+
)
136+
$isJobLeftForProcessing = $true;
137+
do
138+
{
139+
$Job = Get-AzureRmRecoveryServicesAsrJob -Name $JobId
140+
Write-Host $("Job Status:") -ForegroundColor Green
141+
$Job
142+
143+
$isJobLeftForProcessing = ($Job.State -eq 'InProgress' -or $Job.State -eq 'NotStarted')
144+
145+
if($isJobLeftForProcessing)
146+
{
147+
if($Message -ne "NA")
148+
{
149+
Write-Host $Message -ForegroundColor Yellow
150+
}
151+
else
152+
{
153+
Write-Host $($($Job.JobType) + " in Progress...") -ForegroundColor Yellow
154+
}
155+
Write-Host $("Waiting for: " + $JobQueryWaitTimeInSeconds.ToString + " Seconds") -ForegroundColor Yellow
156+
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait($JobQueryWaitTimeInSeconds * 1000)
157+
}else
158+
{
159+
if( !(($job.State -eq "Succeeded") -or ($job.State -eq "CompletedWithInformation")))
160+
{
161+
throw "Job " + $JobId + "failed."
162+
}
163+
}
164+
}While($isJobLeftForProcessing)
165+
}
166+
167+
<#
168+
.SYNOPSIS
169+
Wait for IR job completion
170+
Usage:
171+
WaitForJobCompletion -VM $VM
172+
WaitForJobCompletion -VM $VM -NumOfSecondsToWait 10
173+
#>
174+
Function WaitForIRCompletion
175+
{
176+
param(
177+
[PSObject] $affectedObjectId,
178+
[int] $JobQueryWaitTimeInSeconds = 10
179+
)
180+
$isProcessingLeft = $true
181+
$IRjobs = $null
182+
183+
Write-Host $("IR in Progress...") -ForegroundColor Yellow
184+
do
185+
{
186+
$IRjobs = Get-AzureRmRecoveryServicesAsrJob -TargetObjectId $affectedObjectId | Sort-Object StartTime -Descending | select -First 2 | Where-Object{$_.JobType -eq "SecondaryIrCompletion"}
187+
$isProcessingLeft = ($IRjobs -eq $null -or $IRjobs.Count -ne 1)
188+
189+
if($isProcessingLeft)
190+
{
191+
Write-Host $("IR in Progress...") -ForegroundColor Yellow
192+
Write-Host $("Waiting for: " + $JobQueryWaitTimeInSeconds.ToString + " Seconds") -ForegroundColor Yellow
193+
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait($JobQueryWaitTimeInSeconds * 1000)
194+
}
195+
}While($isProcessingLeft)
196+
197+
Write-Host $("Finalize IR jobs:") -ForegroundColor Green
198+
$IRjobs
199+
WaitForJobCompletion -JobId $IRjobs[0].Name -JobQueryWaitTimeInSeconds $JobQueryWaitTimeInSeconds -Message $("Finalize IR in Progress...")
200+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Xunit;
16+
using Xunit.Abstractions;
17+
using Microsoft.Azure.ServiceManagemenet.Common.Models;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
20+
21+
namespace RecoveryServices.SiteRecovery.Test
22+
{
23+
public class AsrA2ATests : AsrA2ATestsBase
24+
{
25+
public XunitTracingInterceptor _logger;
26+
27+
public AsrA2ATests(
28+
ITestOutputHelper output)
29+
{
30+
_logger = new XunitTracingInterceptor(output);
31+
XunitTracingInterceptor.AddToContext(_logger);
32+
33+
this.powershellHelperFile = System.IO.Path.Combine(
34+
System.AppDomain.CurrentDomain.BaseDirectory,
35+
"ScenarioTests\\A2A\\A2ATestsHelper.ps1");
36+
37+
this.powershellFile = System.IO.Path.Combine(
38+
System.AppDomain.CurrentDomain.BaseDirectory,
39+
"ScenarioTests\\A2A\\AsrA2ATests.ps1");
40+
this.initialize();
41+
}
42+
43+
[Fact]
44+
[Trait(Category.AcceptanceType, Category.CheckIn)]
45+
public void TestNewA2ADiskReplicationConfig()
46+
{
47+
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-NewA2ADiskReplicationConfiguration");
48+
}
49+
50+
[Fact]
51+
[Trait(Category.AcceptanceType, Category.CheckIn)]
52+
public void TestNewA2AManagedDiskReplicationConfig()
53+
{
54+
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-NewA2AManagedDiskReplicationConfiguration");
55+
}
56+
57+
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
59+
public void A2ANewAsrFabric()
60+
{
61+
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-NewAsrFabric");
62+
}
63+
64+
[Fact]
65+
[Trait(Category.AcceptanceType, Category.CheckIn)]
66+
public void A2ATestNewContainer()
67+
{
68+
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-NewContainer");
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)