Skip to content

Commit 9843132

Browse files
committed
Added San E2E test case.
1 parent 1e574bc commit 9843132

File tree

4 files changed

+172
-13
lines changed

4 files changed

+172
-13
lines changed

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices.Test/ScenarioTests/RecoveryServicesTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,12 @@ public void RecoveryServicesCommitRPTest()
200200
{
201201
this.RunPowerShellTest("Test-CommitRP -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
202202
}
203+
204+
[Fact]
205+
[Trait(Category.AcceptanceType, Category.CheckIn)]
206+
public void RecoveryServicesSanE2ETest()
207+
{
208+
this.RunPowerShellTest("Test-SanE2E -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
209+
}
203210
}
204211
}

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices.Test/ScenarioTests/RecoveryServicesTests.ps1

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,150 @@ function Test-DisableProtection
12061206
Assert-NotNull($job) "No VM found for Disable Protection"
12071207
}
12081208

1209+
<#
1210+
.SYNOPSIS
1211+
Recovery Services San E2E test
1212+
#>
1213+
function Test-SanE2E
1214+
{
1215+
param([string] $vaultSettingsFilePath)
1216+
1217+
# Import Azure Site Recovery Vault Settings
1218+
Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
1219+
1220+
$servers = Get-AzureSiteRecoveryServer
1221+
$primaryVmm = $servers[1]
1222+
$recoveryVmm = $servers[0]
1223+
$storagePri = Get-AzureSiteRecoveryStorage -Server $primaryVmm
1224+
$storageRec = Get-AzureSiteRecoveryStorage -Server $recoveryVmm
1225+
1226+
# Find primary array and pool.
1227+
foreach($storage in $storagePri)
1228+
{
1229+
# Find primary array
1230+
if ($storage.Name.Contains("HRMPROSVM01"))
1231+
{
1232+
$primaryArray = $storage
1233+
1234+
foreach($pool in $primaryArray.StoragePools)
1235+
{
1236+
# Find primary pool
1237+
if ($pool.Name.Contains("SanOneSDKPrimaryPool"))
1238+
{
1239+
$primaryStoragePool = $pool
1240+
break
1241+
}
1242+
}
1243+
}
1244+
}
1245+
1246+
# Find recovery array and pool.
1247+
foreach($storage in $storageRec)
1248+
{
1249+
# Find recovery array
1250+
if ($storage.Name.Contains("HRMDRSVM01"))
1251+
{
1252+
$recoveryArray = $storage
1253+
1254+
foreach($pool in $recoveryArray.StoragePools)
1255+
{
1256+
# Find recovery pool
1257+
if ($pool.Name.Contains("SanOneSDKRecoveryPool"))
1258+
{
1259+
$recoveryStoragePool = $pool
1260+
break
1261+
}
1262+
}
1263+
}
1264+
}
1265+
1266+
# Pair pools
1267+
$job = New-AzureSiteRecoveryStoragePoolMapping -PrimaryStorage $primaryArray -PrimaryStoragePoolId $primaryStoragePool.Id -RecoveryStorage $recoveryArray -RecoveryStoragePoolId $recoveryStoragePool.Id
1268+
Assert-NotNull($job);
1269+
1270+
$protectionContainers = Get-AzureSiteRecoveryProtectionContainer
1271+
Assert-True { $protectionContainers.Count -gt 0 }
1272+
Assert-NotNull($protectionContainers)
1273+
foreach($protectionContainer in $protectionContainers)
1274+
{
1275+
Assert-NotNull($protectionContainer.Name)
1276+
Assert-NotNull($protectionContainer.ID)
1277+
1278+
# Find primary cloud
1279+
if ($protectionContainer.Name.Contains("SanPrimaryCloud"))
1280+
{
1281+
$primaryContainer = $protectionContainer
1282+
}
1283+
1284+
# Find recovery cloud
1285+
if ($protectionContainer.Name.Contains("SanRecoverySanCloud"))
1286+
{
1287+
$recoveryContainer = $protectionContainer
1288+
}
1289+
}
1290+
1291+
# Create protection profile
1292+
$pp = New-AzureSiteRecoveryProtectionProfileObject -ReplicationProvider San -PrimaryContainerId $primaryContainer.ID -RecoveryContainerId $recoveryContainer.ID -PrimaryArrayId $primaryArray.ID -RecoveryArrayId $recoveryArray.ID
1293+
1294+
# Start cloud pairing
1295+
$job = Start-AzureSiteRecoveryProtectionProfileAssociationJob -ProtectionProfile $pp -PrimaryProtectionContainer $primaryContainer -RecoveryProtectionContainer $recoveryContainer
1296+
Assert-NotNull($job);
1297+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 600
1298+
1299+
# Get protection Entity (RG)
1300+
$pe = Get-AzureSiteRecoveryProtectionEntity -ProtectionContainer $primaryContainer
1301+
1302+
# Enable RG
1303+
$job = Set-AzureSiteRecoveryProtectionEntity -ProtectionEntity $pe -Protection Enable -RPO 0 -Replicationtype Async -RecoveryArrayId $recoveryArray.ID
1304+
Assert-NotNull($job);
1305+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 900
1306+
1307+
# Get protection Entity (RG) again after enable
1308+
$pe = Get-AzureSiteRecoveryProtectionEntity -ProtectionContainer $primaryContainer
1309+
1310+
# Test failover RG
1311+
$job = Start-AzureSiteRecoveryTestFailoverJob -ProtectionEntity $pe -WaitForCompletion -Direction PrimaryToRecovery
1312+
Assert-NotNull($job);
1313+
1314+
# Resume Job on manual action
1315+
$job = Resume-AzureSiteRecoveryJob -Id $job.ID
1316+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 900
1317+
1318+
# Planned failover RG
1319+
$job = Start-AzureSiteRecoveryPlannedFailoverJob -ProtectionEntity $pe -Direction PrimaryToRecovery
1320+
Assert-NotNull($job);
1321+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 900
1322+
1323+
# Reverse RG
1324+
$job = Update-AzureSiteRecoveryProtection -ProtectionEntity $pe -Direction RecoveryToPrimary
1325+
Assert-NotNull($job);
1326+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 600
1327+
1328+
# UnPlanned failover RG
1329+
$job = Start-AzureSiteRecoveryUnPlannedFailoverJob -ProtectionEntity $pe -Direction RecoveryToPrimary
1330+
Assert-NotNull($job);
1331+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 900
1332+
1333+
# Reverse RG
1334+
$job = Update-AzureSiteRecoveryProtection -ProtectionEntity $pe -Direction PrimaryToRecovery
1335+
Assert-NotNull($job);
1336+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 600
1337+
1338+
# Disable RG
1339+
$job = Set-AzureSiteRecoveryProtectionEntity -ProtectionEntity $pe -Protection Disable -DeleteReplicaLuns -RecoveryContainerId $recoveryContainer.ID
1340+
Assert-NotNull($job);
1341+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 900
1342+
1343+
# Start cloud unpairing
1344+
$job = Start-AzureSiteRecoveryProtectionProfileDissociationJob -ProtectionProfile $pp -PrimaryProtectionContainer $primaryContainer -RecoveryProtectionContainer $recoveryContainer
1345+
Assert-NotNull($job);
1346+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 600
1347+
1348+
# UnPair pools
1349+
$job = Remove-AzureSiteRecoveryStoragePoolMapping -PrimaryStorage $primaryArray -PrimaryStoragePoolId $primaryStoragePool.Id -RecoveryStorage $recoveryArray -RecoveryStoragePoolId $recoveryStoragePool.Id
1350+
Assert-NotNull($job);
1351+
}
1352+
12091353
<#
12101354
.SYNOPSIS
12111355
Recovery Services Enable Protection Tests
@@ -1249,3 +1393,18 @@ function WaitForJobCompletion
12491393

12501394
Assert-True { $endStateDescription -ccontains $job.State } "Job did not reached desired state within $NumOfSecondsToWait seconds."
12511395
}
1396+
1397+
<#
1398+
.SYNOPSIS
1399+
Wait for job completion and validate the job
1400+
Usage:
1401+
WaitAndValidatetheJob -JobId $job.ID
1402+
WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 10
1403+
#>
1404+
function WaitAndValidatetheJob
1405+
{
1406+
param([string] $JobId, [Int] $NumOfSecondsToWait = 120)
1407+
WaitForJobCompletion -JobId $JobId -NumOfSecondsToWait $NumOfSecondsToWait
1408+
$job = Get-AzureSiteRecoveryJob -Id $job.ID
1409+
Assert-True { $job.State -eq "Succeeded" }
1410+
}

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Service/CreateAzureSiteRecoveryProtectionProfileObject.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ private void EnterpriseToEnterpriseSanProtectionProfileObject()
312312

313313
ASRProtectionProfile protectionProfile = new ASRProtectionProfile()
314314
{
315+
// In case of SAN we don't have a protection profile associated yet. So we are giving a dummy ID now.
315316
ID = this.PrimaryContainerId,
316317
ReplicationProvider = this.ReplicationProvider,
317318
HyperVReplicaAzureProviderSettingsObject = null,

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Service/SetAzureSiteRecoveryProtectionEntity.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,13 @@ public override void ExecuteCmdlet()
328328
sanInput.TargetCloudIdForLunDeletion = recoveryCloudId;
329329

330330
input.ReplicationProviderInput = DataContractUtils.Serialize<SanDisableProtectionInput>(sanInput);
331+
}
331332

332-
this.jobResponse =
333+
this.jobResponse =
333334
RecoveryServicesClient.DisableProtection(
334-
this.ProtectionContainerId,
335-
this.ProtectionEntity.FabricObjectId,
336-
input);
337-
}
338-
else
339-
{
340-
this.jobResponse =
341-
RecoveryServicesClient.DisableProtection(
342-
this.ProtectionContainerId,
343-
this.Id,
344-
input);
345-
}
335+
this.ProtectionContainerId,
336+
this.Id,
337+
input);
346338
}
347339

348340
this.WriteJob(this.jobResponse.Job);

0 commit comments

Comments
 (0)