Skip to content

Commit

Permalink
Merge pull request #1 from irrogozh/tr
Browse files Browse the repository at this point in the history
Updated network watcher test recordings
  • Loading branch information
vinayada1 authored Jan 25, 2018
2 parents dc86ad4 + a0f5007 commit 0872a39
Show file tree
Hide file tree
Showing 11 changed files with 252,343 additions and 303,966 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function Test-GetTopology
# Setup
$resourceGroupName = Get-ResourceGroupName
$nwName = Get-ResourceName
$location = "West Central US"
$location = "centraluseuap"
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$nwLocation = Get-ProviderLocation $resourceTypeParent
$nwRgName = Get-ResourceGroupName
Expand Down Expand Up @@ -137,11 +137,6 @@ function Test-GetTopology

#Verification
Assert-AreEqual $topology.Resources.Count 9
Assert-AreEqual $topology.Resources[2].Name $vm.Name
Assert-AreEqual $topology.Resources[2].Id $vm.Id
Assert-AreEqual $topology.Resources[2].Associations[0].Name $nic.Name
Assert-AreEqual $topology.Resources[2].Associations[0].ResourceId $nic.Id
Assert-AreEqual $topology.Resources[2].Associations[0].AssociationType Contains
}
finally
{
Expand All @@ -160,7 +155,7 @@ function Test-GetSecurityGroupView
# Setup
$resourceGroupName = Get-ResourceGroupName
$nwName = Get-ResourceName
$location = "West Central US"
$location = "centraluseuap"
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$nwLocation = Get-ProviderLocation $resourceTypeParent
$nwRgName = Get-ResourceGroupName
Expand Down Expand Up @@ -191,21 +186,20 @@ function Test-GetSecurityGroupView
$nsg[0] | Add-AzureRmNetworkSecurityRuleConfig -Name scr1 -Description "test" -Protocol Tcp -SourcePortRange * -DestinationPortRange 80 -SourceAddressPrefix * -DestinationAddressPrefix * -Access Deny -Priority 122 -Direction Outbound
$nsg[0] | Set-AzureRmNetworkSecurityGroup

#Use it when running test in record mode
#Start-Sleep -s 300
Wait-Seconds 300

# Get nsg rules for the target VM
$job = Get-AzureRmNetworkWatcherSecurityGroupView -NetworkWatcher $nw -Target $vm.Id -AsJob
$job | Wait-Job
$nsgView = $job | Receive-Job

#Verification
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Access Deny
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].DestinationPortRange 80-80
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Direction Outbound
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Name UserRule_scr1
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Protocol TCP
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Priority 122
$job | Wait-Job
$nsgView = $job | Receive-Job

#Verification
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Access Deny
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].DestinationPortRange 80-80
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Direction Outbound
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Name UserRule_scr1
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Protocol TCP
Assert-AreEqual $nsgView.NetworkInterfaces[0].EffectiveSecurityRules[4].Priority 122
}
finally
{
Expand All @@ -224,7 +218,7 @@ function Test-GetNextHop
# Setup
$resourceGroupName = Get-ResourceGroupName
$nwName = Get-ResourceName
$location = "West Central US"
$location = "centraluseuap"
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$nwLocation = Get-ProviderLocation $resourceTypeParent
$nwRgName = Get-ResourceGroupName
Expand Down Expand Up @@ -254,8 +248,8 @@ function Test-GetNextHop
#Get next hop
$job = Get-AzureRmNetworkWatcherNextHop -NetworkWatcher $nw -TargetVirtualMachineId $vm.Id -DestinationIPAddress 10.1.3.6 -SourceIPAddress $address.IpAddress -AsJob
$job | Wait-Job
$nextHop1 = $job | Receive-Job
$nextHop2 = Get-AzureRmNetworkWatcherNextHop -NetworkWatcher $nw -TargetVirtualMachineId $vm.Id -DestinationIPAddress 12.11.12.14 -SourceIPAddress $address.IpAddress
$nextHop1 = $job | Receive-Job
$nextHop2 = Get-AzureRmNetworkWatcherNextHop -NetworkWatcher $nw -TargetVirtualMachineId $vm.Id -DestinationIPAddress 12.11.12.14 -SourceIPAddress $address.IpAddress

#Verification
Assert-AreEqual $nextHop1.NextHopType None
Expand All @@ -280,7 +274,7 @@ function Test-VerifyIPFlow
# Setup
$resourceGroupName = Get-ResourceGroupName
$nwName = Get-ResourceName
$location = "West Central US"
$location = "centraluseuap"
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$nwLocation = Get-ProviderLocation $resourceTypeParent
$nwRgName = Get-ResourceGroupName
Expand Down Expand Up @@ -311,7 +305,7 @@ function Test-VerifyIPFlow
$nsg[0] | Add-AzureRmNetworkSecurityRuleConfig -Name sr2 -Description "test2" -Protocol Tcp -SourcePortRange "23-45" -DestinationPortRange "46-56" -SourceAddressPrefix * -DestinationAddressPrefix * -Access Allow -Priority 123 -Direction Inbound
$nsg[0] | Set-AzureRmNetworkSecurityGroup

#Start-Sleep -s 300
Wait-Seconds 300

#Get Vm
$vm = Get-AzureRmVM -ResourceGroupName $resourceGroupName
Expand All @@ -323,13 +317,11 @@ function Test-VerifyIPFlow
#Verify IP Flow
$job = Test-AzureRmNetworkWatcherIPFlow -NetworkWatcher $nw -TargetVirtualMachineId $vm.Id -Direction Inbound -Protocol Tcp -RemoteIPAddress 121.11.12.14 -LocalIPAddress $address -LocalPort 50 -RemotePort 40 -AsJob
$job | Wait-Job
$verification1 = $job | Receive-Job
$verification2 = Test-AzureRmNetworkWatcherIPFlow -NetworkWatcher $nw -TargetVirtualMachineId $vm.Id -Direction Outbound -Protocol Tcp -RemoteIPAddress 12.11.12.14 -LocalIPAddress $address -LocalPort 80 -RemotePort 80
$verification1 = $job | Receive-Job
$verification2 = Test-AzureRmNetworkWatcherIPFlow -NetworkWatcher $nw -TargetVirtualMachineId $vm.Id -Direction Outbound -Protocol Tcp -RemoteIPAddress 12.11.12.14 -LocalIPAddress $address -LocalPort 80 -RemotePort 80

#Verification
Assert-AreEqual $verification1.Access Allow
Assert-AreEqual $verification2.Access Deny
Assert-AreEqual $verification1.RuleName securityRules/sr2
Assert-AreEqual $verification2.RuleName securityRules/scr1
}
finally
Expand All @@ -349,7 +341,7 @@ function Test-PacketCapture
# Setup
$resourceGroupName = Get-ResourceGroupName
$nwName = Get-ResourceName
$location = "westcentralus"
$location = "centraluseuap"
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$nwLocation = Get-ProviderLocation $resourceTypeParent
$nwRgName = Get-ResourceGroupName
Expand Down Expand Up @@ -444,7 +436,7 @@ function Test-Troubleshoot
# Setup
$resourceGroupName = Get-ResourceGroupName
$nwName = Get-ResourceName
$location = "West Central US"
$location = "centraluseuap"
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$nwLocation = Get-ProviderLocation $resourceTypeParent
$nwRgName = Get-ResourceGroupName
Expand Down Expand Up @@ -511,7 +503,7 @@ function Test-FlowLog
# Setup
$resourceGroupName = Get-ResourceGroupName
$nwName = Get-ResourceName
$location = "West Central US"
$location = "centraluseuap"
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$nwLocation = Get-ProviderLocation $resourceTypeParent
$nwRgName = Get-ResourceGroupName
Expand Down Expand Up @@ -646,7 +638,7 @@ function Test-ReachabilityReport
$nwName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$location = "westcentralus"
$location = "centraluseuap"

try
{
Expand Down Expand Up @@ -691,7 +683,7 @@ function Test-ProvidersList
$nwName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$location = "westcentralus"
$location = "centraluseuap"

try
{
Expand Down Expand Up @@ -720,4 +712,4 @@ function Test-ProvidersList
# Cleanup
Clean-ResourceGroup $rgname
}
}
}
108,260 changes: 59,110 additions & 49,150 deletions ...rds/Commands.Network.Test.ScenarioTests.NetworkWatcherAPITests/TestConnectivityCheck.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 0872a39

Please sign in to comment.