forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#7 from bganapa/infra-pr
add pester tests for InfrastructureInsights.admin
- Loading branch information
Showing
15 changed files
with
6,758 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/Azs.InfrastructureInsights.Admin/test/Close-AzsAlert.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' | ||
if (-Not (Test-Path -Path $loadEnvPath)) { | ||
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' | ||
} | ||
. ($loadEnvPath) | ||
$TestRecordingFile = Join-Path $PSScriptRoot 'Close-AzsAlert.Recording.json' | ||
$currentPath = $PSScriptRoot | ||
while(-not $mockingPath) { | ||
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File | ||
$currentPath = Split-Path -Path $currentPath -Parent | ||
} | ||
. ($mockingPath | Select-Object -First 1).FullName | ||
|
||
|
||
Describe "Alerts" -Tags @('Alert', 'InfrastructureInsightsAdmin') { | ||
|
||
. $PSScriptRoot\Common.ps1 | ||
|
||
it "TestCloseAlert" -Skip:$('TestCloseAlert' -in $global:SkippedTests) { | ||
|
||
$global:TestName = 'TestCloseAlert' | ||
|
||
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $global:location | ||
|
||
$Alerts | Should Not Be $null | ||
|
||
foreach ($Alert in $Alerts) { | ||
|
||
$Alert | Should not be $null | ||
$Alert.State | Should not be $null | ||
|
||
if ($Alert.State -eq "Active") { | ||
|
||
$Alert | Close-AzsAlert -Location $global:location -User "foobar" | ||
|
||
return | ||
} | ||
} | ||
} | ||
} |
2,322 changes: 2,322 additions & 0 deletions
2,322
src/Azs.InfrastructureInsights.Admin/test/Get-AzsAlert.Recording.json
Large diffs are not rendered by default.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
src/Azs.InfrastructureInsights.Admin/test/Get-AzsAlert.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' | ||
if (-Not (Test-Path -Path $loadEnvPath)) { | ||
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' | ||
} | ||
. ($loadEnvPath) | ||
$TestRecordingFile = Join-Path $PSScriptRoot 'Get-AzsAlert.Recording.json' | ||
$currentPath = $PSScriptRoot | ||
|
||
while(-not $mockingPath) { | ||
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File | ||
$currentPath = Split-Path -Path $currentPath -Parent | ||
} | ||
. ($mockingPath | Select-Object -First 1).FullName | ||
|
||
Describe "Alerts" -Tags @('Alert', 'InfrastructureInsightsAdmin') { | ||
|
||
. $PSScriptRoot\Common.ps1 | ||
|
||
it "TestListAlerts" -Skip:$('TestListAlerts' -in $global:SkippedTests) { | ||
|
||
$global:TestName = 'TestListAlerts' | ||
|
||
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $global:Location | ||
|
||
foreach ($Alert in $Alerts) { | ||
ValidateAlert -Alert $Alert | ||
} | ||
} | ||
|
||
it "TestGetAlert" -Skip:$('TestGetAlert' -in $global:SkippedTests) { | ||
|
||
$global:TestName = 'TestGetAlert' | ||
|
||
$Regions = Get-AzsRegionHealth -ResourceGroupName $global:ResourceGroupName -Location $global:Location | ||
|
||
foreach ($Region in $Regions) { | ||
|
||
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $Region.Name | ||
|
||
foreach ($Alert in $Alerts) { | ||
|
||
$retrieved = Get-AzsAlert -Location $Region.Name -Name $Alert.AlertId | ||
AssertAlertsAreSame -Expected $Alert -Found $retrieved | ||
return | ||
} | ||
} | ||
} | ||
|
||
it "TestGetAllAlerts" -Skip:$('TestGetAllAlerts' -in $global:SkippedTests) { | ||
|
||
$global:TestName = 'TestGetAllAlerts' | ||
|
||
$Regions = Get-AzsRegionHealth -ResourceGroupName $global:ResourceGroupName -Location $global:Location | ||
|
||
foreach ($Region in $Regions) { | ||
|
||
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $Region.Name | ||
|
||
foreach ($Alert in $Alerts) { | ||
$retrieved = Get-AzsAlert -Location $Region.Name -Name $Alert.AlertId | ||
|
||
AssertAlertsAreSame -Expected $Alert -Found $retrieved | ||
} | ||
} | ||
} | ||
|
||
it "TestGetAllAlerts" -Skip:$('TestGetAllAlerts' -in $global:SkippedTests) { | ||
|
||
$global:TestName = 'TestGetAllAlerts' | ||
|
||
$Regions = Get-AzsRegionHealth -ResourceGroupName $global:ResourceGroupName -Location $global:Location | ||
|
||
foreach ($Region in $Regions) { | ||
|
||
$Alerts = Get-AzsAlert -ResourceGroupName $global:ResourceGroupName -Location $Region.Name | ||
|
||
foreach ($Alert in $Alerts) { | ||
$retrieved = $Alert | Get-AzsAlert | ||
AssertAlertsAreSame -Expected $Alert -Found $retrieved | ||
|
||
} | ||
} | ||
} | ||
} |
682 changes: 682 additions & 0 deletions
682
src/Azs.InfrastructureInsights.Admin/test/Get-AzsRPHealth.Recording.json
Large diffs are not rendered by default.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
src/Azs.InfrastructureInsights.Admin/test/Get-AzsRPHealth.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' | ||
if (-Not (Test-Path -Path $loadEnvPath)) { | ||
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' | ||
} | ||
. ($loadEnvPath) | ||
$TestRecordingFile = Join-Path $PSScriptRoot 'Get-AzsRPHealth.Recording.json' | ||
$currentPath = $PSScriptRoot | ||
while(-not $mockingPath) { | ||
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File | ||
$currentPath = Split-Path -Path $currentPath -Parent | ||
} | ||
. ($mockingPath | Select-Object -First 1).FullName | ||
|
||
Describe "AzsServiceHealths" -Tags @('AzsServiceHealth', 'InfrastructureInsightsAdmin') { | ||
|
||
. $PSScriptRoot\Common.ps1 | ||
|
||
it "TestListServiceHealths" -Skip:$('TestListServiceHealths' -in $global:SkippedTests) { | ||
$global:TestName = 'TestListServiceHealths' | ||
|
||
|
||
$RegionHealths = Get-AzsRegionHealth -Location $global:Location -ResourceGroupName $global:ResourceGroupName | ||
foreach ($RegionHealth in $RegionHealths) { | ||
$ServiceHealths = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name | ||
foreach ($serviceHealth in $ServiceHealths) { | ||
ValidateAzsServiceHealth -ServiceHealth $serviceHealth | ||
} | ||
} | ||
} | ||
|
||
it "TestGetServiceHealth" -Skip:$('TestGetServiceHealth' -in $global:SkippedTests) { | ||
$global:TestName = 'TestGetServiceHealth' | ||
|
||
$RegionHealths = Get-AzsRegionHealth -Location $global:Location -ResourceGroupName $global:ResourceGroupName | ||
foreach ($RegionHealth in $RegionHealths) { | ||
$ServiceHealths = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name | ||
foreach ($serviceHealth in $ServiceHealths) { | ||
$retrieved = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name -ServiceHealth $serviceHealth.RegistrationId | ||
AssertAzsServiceHealthsAreSame -Expected $serviceHealth -Found $retrieved | ||
break | ||
} | ||
break | ||
} | ||
} | ||
|
||
it "TestGetAllServiceHealths" -Skip:$('TestGetAllServiceHealths' -in $global:SkippedTests) { | ||
$global:TestName = 'TestGetAllServiceHealths' | ||
|
||
$RegionHealths = Get-AzsRegionHealth -Location $global:Location -ResourceGroupName $global:ResourceGroupName | ||
foreach ($RegionHealth in $RegionHealths) { | ||
$ServiceHealths = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name | ||
foreach ($serviceHealth in $ServiceHealths) { | ||
$retrieved = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name -ServiceHealth $serviceHealth.RegistrationId | ||
AssertAzsServiceHealthsAreSame -Expected $serviceHealth -Found $retrieved | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
it "TestGetAllServiceHealths" -Skip:$('TestGetAllServiceHealths' -in $global:SkippedTests) { | ||
$global:TestName = 'TestGetAllServiceHealths' | ||
|
||
$RegionHealths = Get-AzsRegionHealth -Location $global:Location -ResourceGroupName $global:ResourceGroupName | ||
foreach ($RegionHealth in $RegionHealths) { | ||
$ServiceHealths = Get-AzsRPHealth -ResourceGroupName $global:ResourceGroupName -Location $RegionHealth.Name | ||
foreach ($serviceHealth in $ServiceHealths) { | ||
$retrieved = $serviceHealth | Get-AzsRPHealth | ||
AssertAzsServiceHealthsAreSame -Expected $serviceHealth -Found $retrieved | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.