@@ -1206,6 +1206,150 @@ function Test-DisableProtection
1206
1206
Assert-NotNull ($job ) " No VM found for Disable Protection"
1207
1207
}
1208
1208
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
+
1209
1353
<#
1210
1354
. SYNOPSIS
1211
1355
Recovery Services Enable Protection Tests
@@ -1249,3 +1393,18 @@ function WaitForJobCompletion
1249
1393
1250
1394
Assert-True { $endStateDescription -ccontains $job.State } " Job did not reached desired state within $NumOfSecondsToWait seconds."
1251
1395
}
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
+ }
0 commit comments