Skip to content

Commit

Permalink
Merge pull request #13 from AsrOneSdk/sriramvu-dev
Browse files Browse the repository at this point in the history
E2A Network Mapping & UnMapping tests
  • Loading branch information
sriramvu committed Jan 21, 2015
2 parents fc1559d + 6d361ab commit 5c96efc
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ public void RecoveryServicesNetworkMappingTest()
this.RunPowerShellTest("Test-NetworkMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RecoveryServicesNetworkUnMappingTest()
{
this.RunPowerShellTest("Test-NetworkUnMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RecoveryServicesAzureNetworkMappingTest()
{
this.RunPowerShellTest("Test-AzureNetworkMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RecoveryServicesAzureNetworkUnMappingTest()
{
this.RunPowerShellTest("Test-AzureNetworkUnMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RecoveryServicesFailbackTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,70 @@ function Test-NetworkMapping
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
}

<#
.SYNOPSIS
Recovery Services Azure Network mapping tests and validation
#>
function Test-AzureNetworkMapping
{
param([string] $vaultSettingsFilePath)

# Import Azure Site Recovery Vault Settings
Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath

# Enumerate Servers
$servers = Get-AzureSiteRecoveryServer
Assert-True { $servers.Count -gt 0 }
Assert-NotNull($servers)
foreach($server in $servers)
{
Assert-NotNull($server.Name)
Assert-NotNull($server.ID)
}

# Enumerate Networks
$networks = Get-AzureSiteRecoveryNetwork -Server $servers[0]
Assert-NotNull($networks)
Assert-True { $networks.Count -gt 0 }
foreach($network in $networks)
{
Assert-NotNull($network.Name)
Assert-NotNull($network.ID)
}

<#
# Enumerate Azure VM Networks
$azureVmNetworks = Get-AzureVNetSite
Assert-NotNull($azureVmNetworks)
Assert-True { $azureVmNetworks.Count -gt 0 }
#>

# Enumerate AzureNetworkMappings
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
Assert-True { $networkMappings.Count -eq 0 }

# Create AzureNetworkMapping
# $subscription = Get-AzureSubscription -Current

# TODO (sriramvu): There are few dependency issues on using Get-AzureVNetSite to get list of Azure VM Networks, will update the test.
# Should setup NetworkManagementClient along with our two mgmt clients in RecoveryServicesTestsBase.cs
# $job = New-AzureSiteRecoveryNetworkMapping -PrimaryNetwork $networks[0] -AzureSubscriptionId $subscription.SubscriptionId -AzureVMNetworkId $azureVmNetworks[0].Id
# $job = New-AzureSiteRecoveryNetworkMapping -PrimaryNetwork $networks[0] -AzureSubscriptionId 62633f66-ce59-4114-b65d-a50beb5bd8d8 -AzureVMNetworkId "1d0ecfad-ac09-4222-b46f-2ab74839fe7e" # OneBox details
$job = New-AzureSiteRecoveryNetworkMapping -PrimaryNetwork $networks[0] -AzureSubscriptionId a5aa5997-33e5-46cc-8ab8-8bd89b76b7ba -AzureVMNetworkId ecb3a462-664f-4f57-873e-d09b5925e1a1 # POD details
WaitForJobCompletion -JobId $job.ID

# Enumerate NetworkMappings
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
Assert-NotNull($networkMappings)
Assert-True { $networkMappings.Count -eq 1 }
Assert-NotNull($networkMappings[0].PrimaryServerId)
Assert-NotNull($networkMappings[0].PrimaryNetworkId)
Assert-NotNull($networkMappings[0].PrimaryNetworkName)
Assert-NotNull($networkMappings[0].RecoveryServerId)
Assert-NotNull($networkMappings[0].RecoveryNetworkId)
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
}

<#
.SYNOPSIS
Recovery Services Network unmapping tests and validation
Expand Down Expand Up @@ -285,7 +349,7 @@ function Test-NetworkUnMapping
Assert-NotNull($networkMappings[0].RecoveryNetworkId)
Assert-NotNull($networkMappings[0].RecoveryNetworkName)

# Remove StorageMapping
# Remove NetworkMapping
$job = Remove-AzureSiteRecoveryNetworkMapping -NetworkMapping $networkMappings[0]
WaitForJobCompletion -JobId $job.ID

Expand All @@ -294,6 +358,47 @@ function Test-NetworkUnMapping
Assert-True { $networkMappings.Count -eq 0 }
}

<#
.SYNOPSIS
Recovery Services Azure Network unmapping tests and validation
#>
function Test-AzureNetworkUnMapping
{
param([string] $vaultSettingsFilePath)

# Import Azure Site Recovery Vault Settings
Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath

# Enumerate Servers
$servers = Get-AzureSiteRecoveryServer
Assert-True { $servers.Count -gt 0 }
Assert-NotNull($servers)
foreach($server in $servers)
{
Assert-NotNull($server.Name)
Assert-NotNull($server.ID)
}

# Enumerate Azure NetworkMappings
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
Assert-NotNull($networkMappings)
Assert-True { $networkMappings.Count -eq 1 }
Assert-NotNull($networkMappings[0].PrimaryServerId)
Assert-NotNull($networkMappings[0].PrimaryNetworkId)
Assert-NotNull($networkMappings[0].PrimaryNetworkName)
Assert-NotNull($networkMappings[0].RecoveryServerId)
Assert-NotNull($networkMappings[0].RecoveryNetworkId)
Assert-NotNull($networkMappings[0].RecoveryNetworkName)

# Remove Azure NetworkMapping
$job = Remove-AzureSiteRecoveryNetworkMapping -NetworkMapping $networkMappings[0]
WaitForJobCompletion -JobId $job.ID

# Enumerate Azure NetworkMappings
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
Assert-True { $networkMappings.Count -eq 0 }
}

<#
.SYNOPSIS
Recovery Services Failback Tests
Expand Down
Binary file not shown.

0 comments on commit 5c96efc

Please sign in to comment.