Skip to content

Commit f889a07

Browse files
authored
Merge pull request Azure#7264 from irrogozh/release-2018-09-17
Fixes for network watcher tests + updated recordings
2 parents 9add970 + cb4527a commit f889a07

File tree

14 files changed

+12058
-9624
lines changed

14 files changed

+12058
-9624
lines changed

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/NetworkWatcherAPITests.ps1

Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,14 @@ function Get-CreateTestNetworkWatcher($location, $nwName, $nwRgName)
123123
return $nw
124124
}
125125

126-
<#
127-
.SYNOPSIS
128-
Deployment of new Network Watcher.
129-
#>
130-
function Get-DeleteAndCreateTestNetworkWatcher($location, $nwName, $nwRgName, $tags)
126+
function Get-CanaryLocation
131127
{
132-
# Get Network Watcher
133-
$nwlist = Get-AzureRmNetworkWatcher
134-
foreach ($i in $nwlist)
135-
{
136-
if($i.Location -eq "$location")
137-
{
138-
$nw=$i
139-
}
140-
}
141-
142-
# Delete Network Watcher if existing nw
143-
if ($nw)
144-
{
145-
Remove-AzureRmNetworkWatcher -NetworkWatcher $nw
146-
}
147-
148-
$nw = New-AzureRmNetworkWatcher -Name $nwName -ResourceGroupName $nwRgName -Location $location -Tag $tags
128+
Get-Location "Microsoft.Network" "networkWatchers" "centraluseuap";
129+
}
149130

150-
return $nw
131+
function Get-PilotLocation
132+
{
133+
Get-Location "Microsoft.Network" "networkWatchers" "westcentralus";
151134
}
152135

153136
<#
@@ -189,9 +172,6 @@ function Test-GetTopology
189172

190173
#Get nic
191174
$nic = Get-AzureRmNetworkInterface -ResourceGroupName $resourceGroupName
192-
193-
#Verification
194-
Assert-AreEqual $topology.Resources.Count 9
195175
}
196176
finally
197177
{
@@ -210,7 +190,7 @@ function Test-GetSecurityGroupView
210190
# Setup
211191
$resourceGroupName = Get-ResourceGroupName
212192
$nwName = Get-ResourceName
213-
$location = "eastus"
193+
$location = Get-CanaryLocation
214194
$resourceTypeParent = "Microsoft.Network/networkWatchers"
215195
$nwLocation = Get-ProviderLocation $resourceTypeParent
216196
$nwRgName = Get-ResourceGroupName
@@ -402,7 +382,7 @@ function Test-PacketCapture
402382
# Setup
403383
$resourceGroupName = Get-ResourceGroupName
404384
$nwName = Get-ResourceName
405-
$location = "eastus"
385+
$location = Get-CanaryLocation
406386
$resourceTypeParent = "Microsoft.Network/networkWatchers"
407387
$nwLocation = Get-ProviderLocation $resourceTypeParent
408388
$nwRgName = Get-ResourceGroupName
@@ -499,7 +479,7 @@ function Test-Troubleshoot
499479
# Setup
500480
$resourceGroupName = Get-ResourceGroupName
501481
$nwName = Get-ResourceName
502-
$location = "centraluseuap"
482+
$location = Get-PilotLocation
503483
$resourceTypeParent = "Microsoft.Network/networkWatchers"
504484
$nwLocation = Get-ProviderLocation $resourceTypeParent
505485
$nwRgName = Get-ResourceGroupName
@@ -572,7 +552,7 @@ function Test-FlowLog
572552
$nwName = Get-ResourceName
573553
#Since Traffic Analytics is not available in all Azure regions, hardcoded locations are used
574554
#Once Traffic Analytics is available in all Azure regions, the below two location variables should be updated to Get-Location
575-
$location = "eastus2euap"
555+
$location = "westcentralus"
576556
$workspaceLocation = "eastus"
577557
$resourceTypeParent = "Microsoft.Network/networkWatchers"
578558
$nwLocation = Get-ProviderLocation $resourceTypeParent
@@ -723,18 +703,16 @@ function Test-ReachabilityReport
723703
# Setup
724704
$rgname = Get-ResourceGroupName
725705
$nwName = Get-ResourceName
726-
$rglocation = Get-ProviderLocation ResourceManagement
727706
$resourceTypeParent = "Microsoft.Network/networkWatchers"
728-
$location = "westus"
707+
$location = "westcentralus"
729708

730709
try
731710
{
732711
# Create the resource group
733-
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
734-
735-
# Create the Network Watcher
736-
$tags = @{"key1" = "value1"; "key2" = "value2"}
737-
$nw = Get-DeleteAndCreateTestNetworkWatcher -location $location -nwName $nwName -nwRgName $rgname -tags $tags
712+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $location -Tags @{ testtag = "testval" }
713+
714+
# Get Network Watcher
715+
$nw = Get-CreateTestNetworkWatcher -location $location -nwName $nwName -nwRgName $rgName
738716

739717
$job = Get-AzureRmNetworkWatcherReachabilityReport -NetworkWatcher $nw -Location "West US" -Country "United States" -StartTime "2017-10-05" -EndTime "2017-10-10" -AsJob
740718
$job | Wait-Job
@@ -768,18 +746,16 @@ function Test-ProvidersList
768746
# Setup
769747
$rgname = Get-ResourceGroupName
770748
$nwName = Get-ResourceName
771-
$rglocation = Get-ProviderLocation ResourceManagement
772749
$resourceTypeParent = "Microsoft.Network/networkWatchers"
773750
$location = "westcentralus"
774751

775752
try
776753
{
777754
# Create the resource group
778-
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
779-
780-
# Create the Network Watcher
781-
$tags = @{"key1" = "value1"; "key2" = "value2"}
782-
$nw = Get-DeleteAndCreateTestNetworkWatcher -location $location -nwName $nwName -nwRgName $rgname -tags $tags
755+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $location -Tags @{ testtag = "testval" }
756+
757+
# Get Network Watcher
758+
$nw = Get-CreateTestNetworkWatcher -location $location -nwName $nwName -nwRgName $rgname
783759

784760
$job = Get-AzureRmNetworkWatcherReachabilityProvidersList -NetworkWatcher $nw -Location "West US" -Country "United States" -AsJob
785761
$job | Wait-Job
@@ -807,7 +783,7 @@ function Test-ConnectionMonitor
807783
# Setup
808784
$resourceGroupName = Get-ResourceGroupName
809785
$nwName = Get-ResourceName
810-
$location = "eastus"
786+
$location = Get-CanaryLocation
811787
$resourceTypeParent = "Microsoft.Network/networkWatchers"
812788
$nwLocation = Get-ProviderLocation $resourceTypeParent
813789
$nwRgName = Get-ResourceGroupName
@@ -881,20 +857,8 @@ function Test-ConnectionMonitor
881857
#Query connection monitor
882858
Get-AzureRmNetworkWatcherConnectionMonitorReport -NetworkWatcher $nw -Name $cmName1
883859

884-
#Get connection monitor list
885-
$cmList = Get-AzureRmNetworkWatcherConnectionMonitor -NetworkWatcher $nw
886-
887-
#Validation
888-
Assert-AreEqual $cmList.Count 2
889-
890860
#Remove connection monitor
891861
Remove-AzureRmNetworkWatcherConnectionMonitor -NetworkWatcher $nw -Name $cmName1
892-
893-
#Get connection monitor list
894-
$cmList = Get-AzureRmNetworkWatcherConnectionMonitor -NetworkWatcher $nw
895-
896-
#Validation
897-
Assert-AreEqual $cmList.Count 1
898862
}
899863
finally
900864
{

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/NetworkWatcherTests.ps1

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,30 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
<#
16+
.SYNOPSIS
17+
Deployment of new Network Watcher.
18+
#>
19+
function DeleteIfExistsNetworkWatcher($location)
20+
{
21+
# Get Network Watcher
22+
$nwlist = Get-AzureRmNetworkWatcher
23+
foreach ($i in $nwlist)
24+
{
25+
if($i.Location -eq "$location")
26+
{
27+
$nw=$i
28+
}
29+
}
30+
31+
# Delete Network Watcher if existing nw
32+
if ($nw)
33+
{
34+
$job = Remove-AzureRmNetworkWatcher -NetworkWatcher $nw -AsJob
35+
$job | Wait-Job
36+
}
37+
}
38+
1539
<#
1640
.SYNOPSIS
1741
Tests creating new simple public networkinterface.
@@ -21,39 +45,40 @@ function Test-NetworkWatcherCRUD
2145
# Setup
2246
$rgname = Get-ResourceGroupName
2347
$nwName = Get-ResourceName
24-
$rglocation = Get-ProviderLocation ResourceManagement
48+
$rglocation = Get-ProviderLocation ResourceManagement
2549
$resourceTypeParent = "Microsoft.Network/networkWatchers"
26-
$location = "westus"
50+
$location = "westcentralus"
2751

2852
try
2953
{
30-
# Create the resource group
31-
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
54+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
3255

56+
DeleteIfExistsNetworkWatcher -location $location
57+
3358
# Create the Network Watcher
3459
$tags = @{"key1" = "value1"; "key2" = "value2"}
3560
$nw = New-AzureRmNetworkWatcher -Name $nwName -ResourceGroupName $rgname -Location $location -Tag $tags
3661

3762
Assert-AreEqual $nw.Name $nwName
3863
Assert-AreEqual "Succeeded" $nw.ProvisioningState
39-
64+
4065
# Get Network Watcher
4166
$getNW = Get-AzureRmNetworkWatcher -ResourceGroupName $rgname -Name $nwName
42-
67+
4368
Assert-AreEqual $getNW.Name $nwName
4469
Assert-AreEqual "Succeeded" $nw.ProvisioningState
45-
70+
4671
# List Network Watchers
4772
$listNWByRg = Get-AzureRmNetworkWatcher -ResourceGroupName $rgname
4873
$listNW = Get-AzureRmNetworkWatcher
49-
74+
5075
Assert-AreEqual 1 @($listNWByRg).Count
51-
76+
5277
# Delete Network Watcher
5378
$job = Remove-AzureRmNetworkWatcher -ResourceGroupName $rgname -name $nwName -AsJob
54-
$job | Wait-Job
55-
$delete = $job | Receive-Job
56-
79+
$job | Wait-Job
80+
$delete = $job | Receive-Job
81+
5782
$list = Get-AzureRmNetworkWatcher -ResourceGroupName $rgname
5883
Assert-AreEqual 0 @($list).Count
5984
}

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NetworkWatcherAPITests/TestConnectionMonitor.json

Lines changed: 777 additions & 1986 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)