Skip to content

Commit 77ba91e

Browse files
committed
create cmdlets
1 parent 4fbc0a9 commit 77ba91e

19 files changed

+9871
-1
lines changed

src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/A2ATestsHelper.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,26 @@ function getRecoveryNicName{
163163
return "A2ArecNICName"+ $seed;
164164
}
165165

166+
function getClusterPrimaryContainerName{
167+
return "asr-a2a-default-eastus2-container";
168+
}
169+
170+
function getClusterPrimaryFabricName{
171+
return "asr-a2a-default-eastus2-fabric";
172+
}
173+
174+
function getClusterRecoveryResourceGroupName{
175+
return "ClusterRG-Vijami-rec-1103115126";
176+
}
177+
178+
function getClusterVaultName{
179+
return "powershell-cluster-vault";
180+
}
181+
182+
function getClusterName{
183+
return "powershell-cluster";
184+
}
185+
166186
function Get-RandomSuffix(
167187
[int] $size = 8)
168188
{

src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,55 @@ public void A2ACRGReplication()
187187
$"Import-Module {_testModule.AsAbsoluteLocation()}",
188188
"Test-CRGReplication");
189189
}
190+
191+
[Fact]
192+
[Trait(Category.AcceptanceType, Category.CheckIn)]
193+
public void A2AClutserTestFailoverJob()
194+
{
195+
TestRunner.RunTestScript(
196+
$"Import-Module {_helperModule.AsAbsoluteLocation()}",
197+
$"Import-Module {_testModule.AsAbsoluteLocation()}",
198+
"Test-ClusterTestFailoverJob");
199+
}
200+
201+
[Fact]
202+
[Trait(Category.AcceptanceType, Category.CheckIn)]
203+
public void A2AClutserTestFailoverCleanupJob()
204+
{
205+
TestRunner.RunTestScript(
206+
$"Import-Module {_helperModule.AsAbsoluteLocation()}",
207+
$"Import-Module {_testModule.AsAbsoluteLocation()}",
208+
"Test-ClusterTestFailoverCleanupJob");
209+
}
210+
211+
[Fact]
212+
[Trait(Category.AcceptanceType, Category.CheckIn)]
213+
public void A2AClutserUnplannedFailoverJob()
214+
{
215+
TestRunner.RunTestScript(
216+
$"Import-Module {_helperModule.AsAbsoluteLocation()}",
217+
$"Import-Module {_testModule.AsAbsoluteLocation()}",
218+
"Test-ClusterUnplannedFailoverJob");
219+
}
220+
221+
[Fact]
222+
[Trait(Category.AcceptanceType, Category.CheckIn)]
223+
public void A2AApplyClusterRecoveryPoint()
224+
{
225+
TestRunner.RunTestScript(
226+
$"Import-Module {_helperModule.AsAbsoluteLocation()}",
227+
$"Import-Module {_testModule.AsAbsoluteLocation()}",
228+
"Test-ApplyClusterRecoveryPoint");
229+
}
230+
231+
[Fact]
232+
[Trait(Category.AcceptanceType, Category.CheckIn)]
233+
public void A2AClusterCommitFailoverJob()
234+
{
235+
TestRunner.RunTestScript(
236+
$"Import-Module {_helperModule.AsAbsoluteLocation()}",
237+
$"Import-Module {_testModule.AsAbsoluteLocation()}",
238+
"Test-ClusterCommitFailoverJob");
239+
}
190240
}
191241
}

src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,125 @@
1717

1818
##Default Value ##
1919

20+
<#
21+
.SYNOPSIS
22+
Test Cluster Test Failover Job.
23+
#>
24+
function Test-ClusterTestFailoverJob {
25+
$primaryContainerName = getClusterPrimaryContainerName
26+
$primaryFabricName = getClusterPrimaryFabricName
27+
$recoveryResourceGroupName = getClusterRecoveryResourceGroupName
28+
$vaultName = getClusterVaultName
29+
$clusterName = getClusterName
30+
$Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName
31+
Set-ASRVaultContext -Vault $Vault
32+
$primaryFabric = get-asrFabric -Name $primaryFabricName
33+
$protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric
34+
$protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName
35+
36+
$tfoJob = Start-AzRecoveryServicesAsrClusterTestFailoverJob -ReplicationProtectionCluster $protectionCluster -Direction PrimaryToRecovery -AzureVMNetworkId "/subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/ClusterRG-Vijami-1103115126-asr/providers/Microsoft.Network/virtualNetworks/adVNET-asr" -LatestProcessedRecoveryPoint
37+
38+
WaitForJobCompletion -JobId $tfoJob.Name
39+
#Get recovery vm and verify
40+
$recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1-test"
41+
Assert-NotNull($recvm.Id);
42+
}
43+
44+
<#
45+
.SYNOPSIS
46+
Test Cluster Unplanned Failover Job.
47+
#>
48+
function Test-ClusterUnplannedFailoverJob {
49+
$primaryContainerName = getClusterPrimaryContainerName
50+
$primaryFabricName = getClusterPrimaryFabricName
51+
$recoveryResourceGroupName = getClusterRecoveryResourceGroupName
52+
$vaultName = getClusterVaultName
53+
$clusterName = getClusterName
54+
$Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName
55+
Set-ASRVaultContext -Vault $Vault
56+
$primaryFabric = get-asrFabric -Name $primaryFabricName
57+
$protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric
58+
$protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName
59+
60+
$ufoJob = Start-AzRecoveryServicesAsrClusterUnplannedFailoverJob -ReplicationProtectionCluster $protectionCluster -Direction PrimaryToRecovery -LatestProcessedRecoveryPoint
61+
62+
WaitForJobCompletion -JobId $ufoJob.Name
63+
#Get recovery vm and verify
64+
$recvm = get-azVm -ResourceGroupName $$recoveryResourceGroupName -Name "sdgql1"
65+
Assert-NotNull($recvm.Id);
66+
}
67+
68+
<#
69+
.SYNOPSIS
70+
Test Cluster Test Failover Cleanup Job.
71+
#>
72+
function Test-ClusterTestFailoverCleanupJob {
73+
$primaryContainerName = getClusterPrimaryContainerName
74+
$primaryFabricName = getClusterPrimaryFabricName
75+
$recoveryResourceGroupName = getClusterRecoveryResourceGroupName
76+
$vaultName = getClusterVaultName
77+
$clusterName = getClusterName
78+
$Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName
79+
Set-ASRVaultContext -Vault $Vault
80+
$primaryFabric = get-asrFabric -Name $primaryFabricName
81+
$protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric
82+
$protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName
83+
84+
$tfoCleanupJob = Start-AzRecoveryServicesAsrClusterTestFailoverCleanupJob -ReplicationProtectionCluster $protectionCluster
85+
86+
WaitForJobCompletion -JobId $tfoCleanupJob.Name
87+
#Get recovery vm will give exception
88+
Assert-ThrowsContains { get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1-test"} "The Resource 'Microsoft.Compute/virtualMachines/sdgql1-test' under resource group 'ClusterRG-Vijami-1103115126-asr' was not found."
89+
}
90+
91+
<#
92+
.SYNOPSIS
93+
Test Cluster Apply Cluster Recovery Point.
94+
#>
95+
function Test-ApplyClusterRecoveryPoint {
96+
$primaryContainerName = getClusterPrimaryContainerName
97+
$primaryFabricName = getClusterPrimaryFabricName
98+
$recoveryResourceGroupName = getClusterRecoveryResourceGroupName
99+
$vaultName = getClusterVaultName
100+
$clusterName = getClusterName
101+
$Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName
102+
Set-ASRVaultContext -Vault $Vault
103+
$primaryFabric = get-asrFabric -Name $primaryFabricName
104+
$protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric
105+
$protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName
106+
107+
$changePitJob = Start-AzRecoveryServicesAsrApplyClusterRecoveryPoint -ReplicationProtectionCluster $protectionCluster -LatestProcessedRecoveryPoint
108+
109+
WaitForJobCompletion -JobId $changePitJob.Name
110+
#Get recovery vm and verify
111+
$recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1"
112+
Assert-NotNull($recvm.Id);
113+
}
114+
115+
<#
116+
.SYNOPSIS
117+
Test Cluster Commit Failover Job.
118+
#>
119+
function Test-ClusterCommitFailoverJob {
120+
$primaryContainerName = getClusterPrimaryContainerName
121+
$primaryFabricName = getClusterPrimaryFabricName
122+
$recoveryResourceGroupName = getClusterRecoveryResourceGroupName
123+
$vaultName = getClusterVaultName
124+
$clusterName = getClusterName
125+
$Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName
126+
Set-ASRVaultContext -Vault $Vault
127+
$primaryFabric = get-asrFabric -Name $primaryFabricName
128+
$protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric
129+
$protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName
130+
131+
$CommitFailoverJob = Start-AzRecoveryServicesAsrClusterCommitFailoverJob -ReplicationProtectionCluster $protectionCluster
132+
133+
WaitForJobCompletion -JobId $CommitFailoverJob.Name
134+
#Get recovery vm and verify
135+
$recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1"
136+
Assert-NotNull($recvm.Id);
137+
}
138+
20139
<#
21140
.SYNOPSIS
22141
NewA2ADiskReplicationConfiguration creation test.

0 commit comments

Comments
 (0)