Skip to content

Commit 3fa8c50

Browse files
authored
Merge pull request Azure#7 from bganapa/infra-pr
add pester tests for InfrastructureInsights.admin
2 parents f00593a + 6e22ce1 commit 3fa8c50

15 files changed

+6758
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
2+
if (-Not (Test-Path -Path $loadEnvPath)) {
3+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
4+
}
5+
. ($loadEnvPath)
6+
$TestRecordingFile = Join-Path $PSScriptRoot 'Close-AzsAlert.Recording.json'
7+
$currentPath = $PSScriptRoot
8+
while(-not $mockingPath) {
9+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
10+
$currentPath = Split-Path -Path $currentPath -Parent
11+
}
12+
. ($mockingPath | Select-Object -First 1).FullName
13+
14+
15+
Describe "Alerts" -Tags @('Alert', 'InfrastructureInsightsAdmin') {
16+
17+
. $PSScriptRoot\Common.ps1
18+
19+
it "TestCloseAlert" -Skip:$('TestCloseAlert' -in $global:SkippedTests) {
20+
21+
$global:TestName = 'TestCloseAlert'
22+
23+
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $global:location
24+
25+
$Alerts | Should Not Be $null
26+
27+
foreach ($Alert in $Alerts) {
28+
29+
$Alert | Should not be $null
30+
$Alert.State | Should not be $null
31+
32+
if ($Alert.State -eq "Active") {
33+
34+
$Alert | Close-AzsAlert -Location $global:location -User "foobar"
35+
36+
return
37+
}
38+
}
39+
}
40+
}

src/Azs.InfrastructureInsights.Admin/test/Get-AzsAlert.Recording.json

Lines changed: 2322 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
2+
if (-Not (Test-Path -Path $loadEnvPath)) {
3+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
4+
}
5+
. ($loadEnvPath)
6+
$TestRecordingFile = Join-Path $PSScriptRoot 'Get-AzsAlert.Recording.json'
7+
$currentPath = $PSScriptRoot
8+
9+
while(-not $mockingPath) {
10+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
11+
$currentPath = Split-Path -Path $currentPath -Parent
12+
}
13+
. ($mockingPath | Select-Object -First 1).FullName
14+
15+
Describe "Alerts" -Tags @('Alert', 'InfrastructureInsightsAdmin') {
16+
17+
. $PSScriptRoot\Common.ps1
18+
19+
it "TestListAlerts" -Skip:$('TestListAlerts' -in $global:SkippedTests) {
20+
21+
$global:TestName = 'TestListAlerts'
22+
23+
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $global:Location
24+
25+
foreach ($Alert in $Alerts) {
26+
ValidateAlert -Alert $Alert
27+
}
28+
}
29+
30+
it "TestGetAlert" -Skip:$('TestGetAlert' -in $global:SkippedTests) {
31+
32+
$global:TestName = 'TestGetAlert'
33+
34+
$Regions = Get-AzsRegionHealth -ResourceGroupName $global:ResourceGroupName -Location $global:Location
35+
36+
foreach ($Region in $Regions) {
37+
38+
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $Region.Name
39+
40+
foreach ($Alert in $Alerts) {
41+
42+
$retrieved = Get-AzsAlert -Location $Region.Name -Name $Alert.AlertId
43+
AssertAlertsAreSame -Expected $Alert -Found $retrieved
44+
return
45+
}
46+
}
47+
}
48+
49+
it "TestGetAllAlerts" -Skip:$('TestGetAllAlerts' -in $global:SkippedTests) {
50+
51+
$global:TestName = 'TestGetAllAlerts'
52+
53+
$Regions = Get-AzsRegionHealth -ResourceGroupName $global:ResourceGroupName -Location $global:Location
54+
55+
foreach ($Region in $Regions) {
56+
57+
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $Region.Name
58+
59+
foreach ($Alert in $Alerts) {
60+
$retrieved = Get-AzsAlert -Location $Region.Name -Name $Alert.AlertId
61+
62+
AssertAlertsAreSame -Expected $Alert -Found $retrieved
63+
}
64+
}
65+
}
66+
67+
it "TestGetAllAlerts" -Skip:$('TestGetAllAlerts' -in $global:SkippedTests) {
68+
69+
$global:TestName = 'TestGetAllAlerts'
70+
71+
$Regions = Get-AzsRegionHealth -ResourceGroupName $global:ResourceGroupName -Location $global:Location
72+
73+
foreach ($Region in $Regions) {
74+
75+
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $Region.Name
76+
77+
foreach ($Alert in $Alerts) {
78+
$retrieved = $Alert | Get-AzsAlert
79+
AssertAlertsAreSame -Expected $Alert -Found $retrieved
80+
81+
}
82+
}
83+
}
84+
}

src/Azs.InfrastructureInsights.Admin/test/Get-AzsRPHealth.Recording.json

Lines changed: 682 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
2+
if (-Not (Test-Path -Path $loadEnvPath)) {
3+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
4+
}
5+
. ($loadEnvPath)
6+
$TestRecordingFile = Join-Path $PSScriptRoot 'Get-AzsRPHealth.Recording.json'
7+
$currentPath = $PSScriptRoot
8+
while(-not $mockingPath) {
9+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
10+
$currentPath = Split-Path -Path $currentPath -Parent
11+
}
12+
. ($mockingPath | Select-Object -First 1).FullName
13+
14+
Describe "AzsServiceHealths" -Tags @('AzsServiceHealth', 'InfrastructureInsightsAdmin') {
15+
16+
. $PSScriptRoot\Common.ps1
17+
18+
it "TestListServiceHealths" -Skip:$('TestListServiceHealths' -in $global:SkippedTests) {
19+
$global:TestName = 'TestListServiceHealths'
20+
21+
22+
$RegionHealths = Get-AzsRegionHealth -Location $global:Location -ResourceGroupName $global:ResourceGroupName
23+
foreach ($RegionHealth in $RegionHealths) {
24+
$ServiceHealths = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name
25+
foreach ($serviceHealth in $ServiceHealths) {
26+
ValidateAzsServiceHealth -ServiceHealth $serviceHealth
27+
}
28+
}
29+
}
30+
31+
it "TestGetServiceHealth" -Skip:$('TestGetServiceHealth' -in $global:SkippedTests) {
32+
$global:TestName = 'TestGetServiceHealth'
33+
34+
$RegionHealths = Get-AzsRegionHealth -Location $global:Location -ResourceGroupName $global:ResourceGroupName
35+
foreach ($RegionHealth in $RegionHealths) {
36+
$ServiceHealths = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name
37+
foreach ($serviceHealth in $ServiceHealths) {
38+
$retrieved = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name -ServiceHealth $serviceHealth.RegistrationId
39+
AssertAzsServiceHealthsAreSame -Expected $serviceHealth -Found $retrieved
40+
break
41+
}
42+
break
43+
}
44+
}
45+
46+
it "TestGetAllServiceHealths" -Skip:$('TestGetAllServiceHealths' -in $global:SkippedTests) {
47+
$global:TestName = 'TestGetAllServiceHealths'
48+
49+
$RegionHealths = Get-AzsRegionHealth -Location $global:Location -ResourceGroupName $global:ResourceGroupName
50+
foreach ($RegionHealth in $RegionHealths) {
51+
$ServiceHealths = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name
52+
foreach ($serviceHealth in $ServiceHealths) {
53+
$retrieved = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name -ServiceHealth $serviceHealth.RegistrationId
54+
AssertAzsServiceHealthsAreSame -Expected $serviceHealth -Found $retrieved
55+
}
56+
}
57+
}
58+
59+
60+
61+
it "TestGetAllServiceHealths" -Skip:$('TestGetAllServiceHealths' -in $global:SkippedTests) {
62+
$global:TestName = 'TestGetAllServiceHealths'
63+
64+
$RegionHealths = Get-AzsRegionHealth -Location $global:Location -ResourceGroupName $global:ResourceGroupName
65+
foreach ($RegionHealth in $RegionHealths) {
66+
$ServiceHealths = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name
67+
foreach ($serviceHealth in $ServiceHealths) {
68+
$retrieved = $serviceHealth | Get-AzsRPHealth
69+
AssertAzsServiceHealthsAreSame -Expected $serviceHealth -Found $retrieved
70+
}
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)