@@ -1226,6 +1226,151 @@ function Test-DisableProtection
1226
1226
1227
1227
<#
1228
1228
. SYNOPSIS
1229
+ Recovery Services San E2E test
1230
+ #>
1231
+ function Test-SanE2E
1232
+ {
1233
+ param ([string ] $vaultSettingsFilePath )
1234
+
1235
+ # Import Azure Site Recovery Vault Settings
1236
+ Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
1237
+
1238
+ $servers = Get-AzureSiteRecoveryServer
1239
+ $primaryVmm = $servers [0 ]
1240
+ $recoveryVmm = $servers [1 ]
1241
+ $storagePri = Get-AzureSiteRecoveryStorage - Server $primaryVmm
1242
+ $storageRec = Get-AzureSiteRecoveryStorage - Server $recoveryVmm
1243
+
1244
+ # Find primary array and pool.
1245
+ foreach ($storage in $storagePri )
1246
+ {
1247
+ # Find primary array
1248
+ if ($storage.Name.Contains (" HRMPROSVM01" ))
1249
+ {
1250
+ $primaryArray = $storage
1251
+
1252
+ foreach ($pool in $primaryArray.StoragePools )
1253
+ {
1254
+ # Find primary pool
1255
+ if ($pool.Name.Contains (" SanOneSDKPrimaryPool" ))
1256
+ {
1257
+ $primaryStoragePool = $pool
1258
+ break
1259
+ }
1260
+ }
1261
+ }
1262
+ }
1263
+
1264
+ # Find recovery array and pool.
1265
+ foreach ($storage in $storageRec )
1266
+ {
1267
+ # Find recovery array
1268
+ if ($storage.Name.Contains (" HRMDRSVM01" ))
1269
+ {
1270
+ $recoveryArray = $storage
1271
+
1272
+ foreach ($pool in $recoveryArray.StoragePools )
1273
+ {
1274
+ # Find recovery pool
1275
+ if ($pool.Name.Contains (" SanOneSDKRecoveryPool" ))
1276
+ {
1277
+ $recoveryStoragePool = $pool
1278
+ break
1279
+ }
1280
+ }
1281
+ }
1282
+ }
1283
+
1284
+ # Pair pools
1285
+ $job = New-AzureSiteRecoveryStoragePoolMapping - PrimaryStorage $primaryArray - PrimaryStoragePoolId $primaryStoragePool.Id - RecoveryStorage $recoveryArray - RecoveryStoragePoolId $recoveryStoragePool.Id
1286
+ Assert-NotNull ($job );
1287
+
1288
+ $protectionContainers = Get-AzureSiteRecoveryProtectionContainer
1289
+ Assert-True { $protectionContainers.Count -gt 0 }
1290
+ Assert-NotNull ($protectionContainers )
1291
+ foreach ($protectionContainer in $protectionContainers )
1292
+ {
1293
+ Assert-NotNull ($protectionContainer.Name )
1294
+ Assert-NotNull ($protectionContainer.ID )
1295
+
1296
+ # Find primary cloud
1297
+ if ($protectionContainer.Name.Contains (" SanPrimaryCloud" ))
1298
+ {
1299
+ $primaryContainer = $protectionContainer
1300
+ }
1301
+
1302
+ # Find recovery cloud
1303
+ if ($protectionContainer.Name.Contains (" SanRecoveryCloud" ))
1304
+ {
1305
+ $recoveryContainer = $protectionContainer
1306
+ }
1307
+ }
1308
+
1309
+ # Create protection profile
1310
+ $pp = New-AzureSiteRecoveryProtectionProfileObject - ReplicationProvider San - PrimaryContainerId $primaryContainer.ID - RecoveryContainerId $recoveryContainer.ID - PrimaryArrayId $primaryArray.ID - RecoveryArrayId $recoveryArray.ID
1311
+
1312
+ # Start cloud pairing
1313
+ $job = Start-AzureSiteRecoveryProtectionProfileAssociationJob - ProtectionProfile $pp - PrimaryProtectionContainer $primaryContainer - RecoveryProtectionContainer $recoveryContainer
1314
+ Assert-NotNull ($job );
1315
+ WaitAndValidatetheJob - JobId $job.ID - NumOfSecondsToWait 600
1316
+
1317
+ # Get protection Entity (RG)
1318
+ $pe = Get-AzureSiteRecoveryProtectionEntity - ProtectionContainer $primaryContainer
1319
+
1320
+ # Enable RG
1321
+ $job = Set-AzureSiteRecoveryProtectionEntity - ProtectionEntity $pe - Protection Enable - RPO 0 - Replicationtype Async - RecoveryArrayId $recoveryArray.ID
1322
+ Assert-NotNull ($job );
1323
+ WaitAndValidatetheJob - JobId $job.ID - NumOfSecondsToWait 900
1324
+
1325
+ # Get protection Entity (RG) again after enable
1326
+ $pe = Get-AzureSiteRecoveryProtectionEntity - ProtectionContainer $primaryContainer
1327
+
1328
+ # Test failover RG
1329
+ $job = Start-AzureSiteRecoveryTestFailoverJob - ProtectionEntity $pe - WaitForCompletion - Direction PrimaryToRecovery
1330
+ Assert-NotNull ($job );
1331
+
1332
+ # Resume Job on manual action
1333
+ $job = Resume-AzureSiteRecoveryJob - Id $job.ID
1334
+ WaitAndValidatetheJob - JobId $job.ID - NumOfSecondsToWait 900
1335
+
1336
+ # Planned failover RG
1337
+ $job = Start-AzureSiteRecoveryPlannedFailoverJob - ProtectionEntity $pe - Direction PrimaryToRecovery
1338
+ Assert-NotNull ($job );
1339
+ WaitAndValidatetheJob - JobId $job.ID - NumOfSecondsToWait 900
1340
+
1341
+ # Reverse RG
1342
+ $job = Update-AzureSiteRecoveryProtection - ProtectionEntity $pe - Direction RecoveryToPrimary
1343
+ Assert-NotNull ($job );
1344
+ WaitAndValidatetheJob - JobId $job.ID - NumOfSecondsToWait 600
1345
+
1346
+ # UnPlanned failover RG
1347
+ $job = Start-AzureSiteRecoveryUnPlannedFailoverJob - ProtectionEntity $pe - Direction RecoveryToPrimary
1348
+ Assert-NotNull ($job );
1349
+ WaitAndValidatetheJob - JobId $job.ID - NumOfSecondsToWait 900
1350
+
1351
+ # Reverse RG
1352
+ $job = Update-AzureSiteRecoveryProtection - ProtectionEntity $pe - Direction PrimaryToRecovery
1353
+ Assert-NotNull ($job );
1354
+ WaitAndValidatetheJob - JobId $job.ID - NumOfSecondsToWait 600
1355
+
1356
+ # Disable RG
1357
+ $job = Set-AzureSiteRecoveryProtectionEntity - ProtectionEntity $pe - Protection Disable - DeleteReplicaLuns - RecoveryContainerId $recoveryContainer.ID
1358
+ Assert-NotNull ($job );
1359
+ WaitAndValidatetheJob - JobId $job.ID - NumOfSecondsToWait 900
1360
+
1361
+ # Start cloud unpairing
1362
+ $job = Start-AzureSiteRecoveryProtectionProfileDissociationJob - ProtectionProfile $pp - PrimaryProtectionContainer $primaryContainer - RecoveryProtectionContainer $recoveryContainer
1363
+ Assert-NotNull ($job );
1364
+ WaitAndValidatetheJob - JobId $job.ID - NumOfSecondsToWait 600
1365
+
1366
+ # UnPair pools
1367
+ $job = Remove-AzureSiteRecoveryStoragePoolMapping - PrimaryStorage $primaryArray - PrimaryStoragePoolId $primaryStoragePool.Id - RecoveryStorage $recoveryArray - RecoveryStoragePoolId $recoveryStoragePool.Id
1368
+ Assert-NotNull ($job );
1369
+ }
1370
+
1371
+ <#
1372
+ . SYNOPSIS
1373
+ Recovery Services Enable Protection Tests
1229
1374
Wait for CanFailover state
1230
1375
Usage:
1231
1376
WaitForCanFailover pcId peId
@@ -1270,3 +1415,18 @@ function WaitForJobCompletion
1270
1415
1271
1416
Assert-True { $endStateDescription -ccontains $job.State } " Job did not reached desired state within $NumOfSecondsToWait seconds."
1272
1417
}
1418
+
1419
+ <#
1420
+ . SYNOPSIS
1421
+ Wait for job completion and validate the job
1422
+ Usage:
1423
+ WaitAndValidatetheJob -JobId $job.ID
1424
+ WaitAndValidatetheJob -JobId $job.ID -NumOfSecondsToWait 10
1425
+ #>
1426
+ function WaitAndValidatetheJob
1427
+ {
1428
+ param ([string ] $JobId , [Int ] $NumOfSecondsToWait = 120 )
1429
+ WaitForJobCompletion - JobId $JobId - NumOfSecondsToWait $NumOfSecondsToWait
1430
+ $job = Get-AzureSiteRecoveryJob - Id $job.ID
1431
+ Assert-True { $job.State -eq " Succeeded" }
1432
+ }
0 commit comments