Skip to content

Commit 6807511

Browse files
committed
E2A Network Mapping test
1 parent 42c99be commit 6807511

File tree

3 files changed

+126
-1
lines changed

3 files changed

+126
-1
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@ public void RecoveryServicesNetworkMappingTest()
5454
this.RunPowerShellTest("Test-NetworkMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
5555
}
5656

57+
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
59+
public void RecoveryServicesNetworkUnMappingTest()
60+
{
61+
this.RunPowerShellTest("Test-NetworkUnMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
62+
}
63+
64+
[Fact]
65+
[Trait(Category.AcceptanceType, Category.CheckIn)]
66+
public void RecoveryServicesAzureNetworkMappingTest()
67+
{
68+
this.RunPowerShellTest("Test-AzureNetworkMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
69+
}
70+
71+
[Fact]
72+
[Trait(Category.AcceptanceType, Category.CheckIn)]
73+
public void RecoveryServicesAzureNetworkUnMappingTest()
74+
{
75+
this.RunPowerShellTest("Test-AzureNetworkUnMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
76+
}
77+
5778
[Fact]
5879
[Trait(Category.AcceptanceType, Category.CheckIn)]
5980
public void RecoveryServicesFailbackTest()

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

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,69 @@ function Test-NetworkMapping
253253
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
254254
}
255255

256+
<#
257+
.SYNOPSIS
258+
Recovery Services Azure Network mapping tests and validation
259+
#>
260+
function Test-AzureNetworkMapping
261+
{
262+
param([string] $vaultSettingsFilePath)
263+
264+
# Import Azure Site Recovery Vault Settings
265+
Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
266+
267+
# Enumerate Servers
268+
$servers = Get-AzureSiteRecoveryServer
269+
Assert-True { $servers.Count -gt 0 }
270+
Assert-NotNull($servers)
271+
foreach($server in $servers)
272+
{
273+
Assert-NotNull($server.Name)
274+
Assert-NotNull($server.ID)
275+
}
276+
277+
# Enumerate Networks
278+
$networks = Get-AzureSiteRecoveryNetwork -Server $servers[0]
279+
Assert-NotNull($networks)
280+
Assert-True { $networks.Count -gt 0 }
281+
foreach($network in $networks)
282+
{
283+
Assert-NotNull($network.Name)
284+
Assert-NotNull($network.ID)
285+
}
286+
287+
<#
288+
# Enumerate Azure VM Networks
289+
$azureVmNetworks = Get-AzureVNetSite
290+
Assert-NotNull($azureVmNetworks)
291+
Assert-True { $azureVmNetworks.Count -gt 0 }
292+
#>
293+
294+
# Enumerate AzureNetworkMappings
295+
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
296+
Assert-True { $networkMappings.Count -eq 0 }
297+
298+
# Create AzureNetworkMapping
299+
# $subscription = Get-AzureSubscription -Current
300+
301+
# TODO (sriramvu): There are few dependency issues on using Get-AzureVNetSite to get list of Azure VM Networks, will update the test.
302+
# Should setup NetworkManagementClient along with our two mgmt clients in RecoveryServicesTestsBase.cs
303+
# $job = New-AzureSiteRecoveryNetworkMapping -PrimaryNetwork $networks[0] -AzureSubscriptionId $subscription.SubscriptionId -AzureVMNetworkId $azureVmNetworks[0].Id
304+
$job = New-AzureSiteRecoveryNetworkMapping -PrimaryNetwork $networks[0] -AzureSubscriptionId 62633f66-ce59-4114-b65d-a50beb5bd8d8 -AzureVMNetworkId "1d0ecfad-ac09-4222-b46f-2ab74839fe7e"
305+
WaitForJobCompletion -JobId $job.ID
306+
307+
# Enumerate NetworkMappings
308+
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
309+
Assert-NotNull($networkMappings)
310+
Assert-True { $networkMappings.Count -eq 1 }
311+
Assert-NotNull($networkMappings[0].PrimaryServerId)
312+
Assert-NotNull($networkMappings[0].PrimaryNetworkId)
313+
Assert-NotNull($networkMappings[0].PrimaryNetworkName)
314+
Assert-NotNull($networkMappings[0].RecoveryServerId)
315+
Assert-NotNull($networkMappings[0].RecoveryNetworkId)
316+
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
317+
}
318+
256319
<#
257320
.SYNOPSIS
258321
Recovery Services Network unmapping tests and validation
@@ -285,7 +348,7 @@ function Test-NetworkUnMapping
285348
Assert-NotNull($networkMappings[0].RecoveryNetworkId)
286349
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
287350

288-
# Remove StorageMapping
351+
# Remove NetworkMapping
289352
$job = Remove-AzureSiteRecoveryNetworkMapping -NetworkMapping $networkMappings[0]
290353
WaitForJobCompletion -JobId $job.ID
291354

@@ -294,6 +357,47 @@ function Test-NetworkUnMapping
294357
Assert-True { $networkMappings.Count -eq 0 }
295358
}
296359

360+
<#
361+
.SYNOPSIS
362+
Recovery Services Azure Network unmapping tests and validation
363+
#>
364+
function Test-AzureNetworkUnMapping
365+
{
366+
param([string] $vaultSettingsFilePath)
367+
368+
# Import Azure Site Recovery Vault Settings
369+
Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
370+
371+
# Enumerate Servers
372+
$servers = Get-AzureSiteRecoveryServer
373+
Assert-True { $servers.Count -gt 0 }
374+
Assert-NotNull($servers)
375+
foreach($server in $servers)
376+
{
377+
Assert-NotNull($server.Name)
378+
Assert-NotNull($server.ID)
379+
}
380+
381+
# Enumerate Azure NetworkMappings
382+
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
383+
Assert-NotNull($networkMappings)
384+
Assert-True { $networkMappings.Count -eq 1 }
385+
Assert-NotNull($networkMappings[0].PrimaryServerId)
386+
Assert-NotNull($networkMappings[0].PrimaryNetworkId)
387+
Assert-NotNull($networkMappings[0].PrimaryNetworkName)
388+
Assert-NotNull($networkMappings[0].RecoveryServerId)
389+
Assert-NotNull($networkMappings[0].RecoveryNetworkId)
390+
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
391+
392+
# Remove Azure NetworkMapping
393+
$job = Remove-AzureSiteRecoveryNetworkMapping -NetworkMapping $networkMappings[0]
394+
WaitForJobCompletion -JobId $job.ID
395+
396+
# Enumerate Azure NetworkMappings
397+
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
398+
Assert-True { $networkMappings.Count -eq 0 }
399+
}
400+
297401
<#
298402
.SYNOPSIS
299403
Recovery Services Failback Tests

0 commit comments

Comments
 (0)