From 6b282d26f4bd5e6ecc7d92ff7f43e784b39e4be1 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Fri, 25 May 2018 07:21:17 +0200 Subject: [PATCH 1/8] fixing typos --- README.md | 2 +- src/Generate Module Manifest.ps1 | 2 +- src/PoShMon.psd1 | Bin 14930 -> 14934 bytes 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14372b8..231d97d 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Of course there are loads of monitoring systems and tools out there, both paid a ## Release Notes 1.1.0 * Added ability to create ad-hoc html report -* For Drive Space Test, Add Volume Name to Output +* For Drive Space test, added Volume Name to output * Added html formatting to Exception emails 1.0.0 diff --git a/src/Generate Module Manifest.ps1 b/src/Generate Module Manifest.ps1 index 4b904a0..0240e6c 100644 --- a/src/Generate Module Manifest.ps1 +++ b/src/Generate Module Manifest.ps1 @@ -21,7 +21,7 @@ For more information, documentation etc. visit https://github.com/HiltonGiesenow $releaseNotes = " 1.1.0 * Added ability to create ad-hoc html report -* For Drive Space Test, Add Volume Name to Output +* For Drive Space test, added Volume Name to output * Added html formatting to Exception emails 1.0.0 diff --git a/src/PoShMon.psd1 b/src/PoShMon.psd1 index e80440a50fbec009b43367b88acd140acd054900..f11c06981c8c55cf52046d727e2c143b3639fa8e 100644 GIT binary patch delta 45 zcmcaqa;;>-2}aY6Cl{&-moTI<6f=}C=rAZSBr>D`Vd~^cb>+zg1|pj`s4o%%0C-;x A=l}o! delta 39 vcmcasa;ap(2}YBRCl{*mhcKiv6f=}C=rAZSI5MP6u2olN^xwQteX9@vBvB0O From 3cbbb42f038edfc3f17a5e2b67d0e74db1f41079 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Sun, 3 Jun 2018 10:20:19 +0200 Subject: [PATCH 2/8] fixing an issues with running web tests on local machine --- .../PoShMon.Monitoring.Web/Test-WebSites.ps1 | 6 +- .../Test-WebSite.Tests.ps1 | 58 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/Functions/PoShMon.Monitoring.Web/Test-WebSites.ps1 b/src/Functions/PoShMon.Monitoring.Web/Test-WebSites.ps1 index dcb268f..a008bf8 100644 --- a/src/Functions/PoShMon.Monitoring.Web/Test-WebSites.ps1 +++ b/src/Functions/PoShMon.Monitoring.Web/Test-WebSites.ps1 @@ -14,7 +14,9 @@ Function Test-WebSites $mainOutput = Get-InitialOutputWithTimer -SectionHeader "Web Test - $siteUrl" -OutputHeaders ([ordered]@{ 'ServerName' = 'Server'; 'StatusCode' = 'Status Code'; 'Outcome' = 'Outcome' }) - For ($i = -1; $i -lt $PoShMonConfiguration.General.ServerNames.Count; $i++) { + $allServersExceptLocal = $PoShMonConfiguration.General.ServerNames | Where-Object { $_ -ne $env:COMPUTERNAME } + + For ($i = -1; $i -lt $allServersExceptLocal.Count; $i++) { $serverName = '(Direct)' $highlight = @() @@ -26,7 +28,7 @@ Function Test-WebSites $webRequest = Invoke-WebRequest $siteUrl -UseDefaultCredentials -UseBasicParsing } else { - $serverName = $PoShMonConfiguration.General.ServerNames[$i] + $serverName = $allServersExceptLocal[$i] if ($serverName -ne $env:COMPUTERNAME) { diff --git a/src/Tests/CI/Unit/PoShMon.Monitoring.Web/Test-WebSite.Tests.ps1 b/src/Tests/CI/Unit/PoShMon.Monitoring.Web/Test-WebSite.Tests.ps1 index 4b4d3ce..8d327b9 100644 --- a/src/Tests/CI/Unit/PoShMon.Monitoring.Web/Test-WebSite.Tests.ps1 +++ b/src/Tests/CI/Unit/PoShMon.Monitoring.Web/Test-WebSite.Tests.ps1 @@ -231,6 +231,64 @@ Describe "Test-Website-NewScope" { Assert-MockCalled -CommandName Invoke-WebRequest -Times 1 -Exactly Assert-MockCalled -CommandName Invoke-RemoteWebRequest -Times 2 -Exactly + } + } +} +Describe "Test-Website-NewScope2" { + InModuleScope PoShMon { + + class WebRequestMock { + [int]$StatusCode + [string]$StatusDescription + [string]$Content + + WebRequestMock ([int]$NewStatusCode, [String]$NewStatusDescription, [String]$NewContent) { + $this.StatusCode = $NewStatusCode; + $this.StatusDescription = $NewStatusDescription; + $this.Content = $NewContent; + } + } + + class RemoteWebRequestMock { + [int]$StatusCode + [string]$StatusDescription + [string]$Content + [string]$ServerName + + RemoteWebRequestMock ([int]$NewStatusCode, [String]$NewStatusDescription, [String]$NewContent, [String]$NewServerName) { + $this.StatusCode = $NewStatusCode; + $this.StatusDescription = $NewStatusDescription; + $this.Content = $NewContent; + $this.ServerName = $NewServerName; + } + } + + Mock -CommandName Invoke-WebRequest -MockWith { + return [WebRequestMock]::new(200, "OK", "Some Text") + } + Mock -CommandName Invoke-RemoteWebRequest -ModuleName PoShMon -MockWith { + return [RemoteWebRequestMock]::new(200, "OK", "Some Text", $serverName) + } + + It "Should test Direct on local server and stop if no other servers" { + + $poShMonConfiguration = New-PoShMonConfiguration { + General ` + -ServerNames $env:COMPUTERNAME + WebSite ` + -WebsiteDetails @{ + "http://my.website.com" = "Some Text" + } + } + + $actual = Test-WebSites $poShMonConfiguration + + $actual.NoIssuesFound | Should Be $true + $actual.OutputValues.Count | Should Be 1 + $actual.OutputValues[0].ServerName | Should Be '(Direct)' + + Assert-MockCalled -CommandName Invoke-WebRequest -Times 1 -Exactly + Assert-MockCalled -CommandName Invoke-RemoteWebRequest -Times 0 -Exactly } } } \ No newline at end of file From c82eafa86fd40399aa996aad1501aa650622a496 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Wed, 27 Jun 2018 08:23:00 +0200 Subject: [PATCH 3/8] Failure verification test --- .../Test-WebSite.Tests.ps1 | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/src/Tests/CI/Unit/PoShMon.Monitoring.Web/Test-WebSite.Tests.ps1 b/src/Tests/CI/Unit/PoShMon.Monitoring.Web/Test-WebSite.Tests.ps1 index 8d327b9..7f497d6 100644 --- a/src/Tests/CI/Unit/PoShMon.Monitoring.Web/Test-WebSite.Tests.ps1 +++ b/src/Tests/CI/Unit/PoShMon.Monitoring.Web/Test-WebSite.Tests.ps1 @@ -290,5 +290,64 @@ Describe "Test-Website-NewScope2" { Assert-MockCalled -CommandName Invoke-WebRequest -Times 1 -Exactly Assert-MockCalled -CommandName Invoke-RemoteWebRequest -Times 0 -Exactly } - } + } +} + Describe "Test-Website-NewScope3" { + InModuleScope PoShMon { + + class WebRequestMock { + [int]$StatusCode + [string]$StatusDescription + [string]$Content + + WebRequestMock ([int]$NewStatusCode, [String]$NewStatusDescription, [String]$NewContent) { + $this.StatusCode = $NewStatusCode; + $this.StatusDescription = $NewStatusDescription; + $this.Content = $NewContent; + } + } + + class RemoteWebRequestMock { + [int]$StatusCode + [string]$StatusDescription + [string]$Content + [string]$ServerName + + RemoteWebRequestMock ([int]$NewStatusCode, [String]$NewStatusDescription, [String]$NewContent, [String]$NewServerName) { + $this.StatusCode = $NewStatusCode; + $this.StatusDescription = $NewStatusDescription; + $this.Content = $NewContent; + $this.ServerName = $NewServerName; + } + } + + Mock -CommandName Invoke-WebRequest -MockWith { + return [WebRequestMock]::new(200, "OK", "Some Text") + } + Mock -CommandName Invoke-RemoteWebRequest -ModuleName PoShMon -MockWith { + return [RemoteWebRequestMock]::new(200, "OK", "Some Text", $serverName) + } + + It "Should test Direct on local server correctly for just one more server" { + + $poShMonConfiguration = New-PoShMonConfiguration { + General ` + -ServerNames $env:COMPUTERNAME,'Server2' + WebSite ` + -WebsiteDetails @{ + "http://my.website.com" = "Some Text" + } + } + + $actual = Test-WebSites $poShMonConfiguration + + $actual.NoIssuesFound | Should Be $true + $actual.OutputValues.Count | Should Be 2 + $actual.OutputValues[0].ServerName | Should Be '(Direct)' + $actual.OutputValues[1].ServerName | Should Be 'Server2' + + Assert-MockCalled -CommandName Invoke-WebRequest -Times 1 -Exactly + Assert-MockCalled -CommandName Invoke-RemoteWebRequest -ParameterFilter { $ServerName -eq 'Server2' } -Times 1 -Exactly + } + } } \ No newline at end of file From 2c9c715bfdab88591f1d783aac39f633bcbbcb08 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Wed, 27 Jun 2018 08:31:07 +0200 Subject: [PATCH 4/8] Fixing #200 --- src/Functions/PoShMon.Monitoring.Web/Test-WebSites.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Functions/PoShMon.Monitoring.Web/Test-WebSites.ps1 b/src/Functions/PoShMon.Monitoring.Web/Test-WebSites.ps1 index a008bf8..a5ca658 100644 --- a/src/Functions/PoShMon.Monitoring.Web/Test-WebSites.ps1 +++ b/src/Functions/PoShMon.Monitoring.Web/Test-WebSites.ps1 @@ -16,6 +16,8 @@ Function Test-WebSites $allServersExceptLocal = $PoShMonConfiguration.General.ServerNames | Where-Object { $_ -ne $env:COMPUTERNAME } + if ($allServersExceptLocal -ne $null -and $allServersExceptLocal.GetType().Name -eq "String") { $allServersExceptLocal = ,$allServersExceptLocal } #convert to proper array + For ($i = -1; $i -lt $allServersExceptLocal.Count; $i++) { $serverName = '(Direct)' From bb9b5d45aef65a587334c797d35f308bbd7e5bee Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Mon, 16 Jul 2018 08:17:04 +0200 Subject: [PATCH 5/8] Renaming PoShMon Html Report Function --- ...te-ReportToFile.ps1 => Write-PoShMonHtmlReport.ps1} | 4 ++-- .../PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) rename src/Functions/PoShMon.Logging.File/{Write-ReportToFile.ps1 => Write-PoShMonHtmlReport.ps1} (90%) diff --git a/src/Functions/PoShMon.Logging.File/Write-ReportToFile.ps1 b/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 similarity index 90% rename from src/Functions/PoShMon.Logging.File/Write-ReportToFile.ps1 rename to src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 index 2d46f2a..bee61a4 100644 --- a/src/Functions/PoShMon.Logging.File/Write-ReportToFile.ps1 +++ b/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 @@ -1,4 +1,4 @@ -Function Write-ReportToFile { +Function Write-PoShMonHtmlReport { [CmdletBinding()] Param( [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] @@ -15,7 +15,7 @@ Function Write-ReportToFile { $PoShMonConfiguration = $Global:PoShMonConfiguration } - if ($TotalElapsedTime.Ticks -eq 0) + if ($TotalElapsedTime -eq $null -or $TotalElapsedTime.Ticks -eq 0) { Write-Verbose "No TotalElapsedTime supplied, using Global one created previously" $TotalElapsedTime = $Global:TotalElapsedPoShMonTime diff --git a/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 b/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 index c6dc029..db43ede 100644 --- a/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 +++ b/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 @@ -2,7 +2,7 @@ $rootPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) -ChildPa Remove-Module PoShMon -ErrorAction SilentlyContinue Import-Module (Join-Path $rootPath -ChildPath "PoShMon.psd1") -Describe "Write-ReportToFile" { +Describe "Write-PoShMonHtmlReport" { InModuleScope PoShMon { @@ -19,7 +19,7 @@ Describe "Write-ReportToFile" { $PoShMonConfigurationGlobal = New-PoShMonConfiguration { General -EnvironmentName "Global Test" } $testMonitoringOutput = @() - $testMonitoringOutput | Write-ReportToFile -OutputFilePath "C:\Temp\PoShMonReport.html" + $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" Assert-MockCalled -CommandName New-HtmlBody -ParameterFilter { $PoShMonConfiguration.General.EnvironmentName -eq "Global Test" } Assert-MockCalled -CommandName Out-File @@ -31,7 +31,7 @@ Describe "Write-ReportToFile" { $Global:TotalElapsedPoShMonTime = New-TimeSpan -Minutes 1 -Seconds 2 $testMonitoringOutput = @() - $testMonitoringOutput | Write-ReportToFile -OutputFilePath "C:\Temp\PoShMonReport.html" + $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" Assert-MockCalled -CommandName New-HtmlBody -ParameterFilter { $TotalElapsedTime.TotalMilliseconds -eq 62000 } Assert-MockCalled -CommandName Out-File @@ -43,7 +43,7 @@ Describe "Write-ReportToFile" { $PoShMonConfigurationGlobal = New-PoShMonConfiguration { General -EnvironmentName "Global Test" } $testMonitoringOutput = @() - $testMonitoringOutput | Write-ReportToFile -OutputFilePath "C:\Temp\PoShMonReport.html" -PoShMonConfiguration $PoShMonConfigurationTest + $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" -PoShMonConfiguration $PoShMonConfigurationTest Assert-MockCalled -CommandName New-HtmlBody -ParameterFilter { $PoShMonConfiguration.General.EnvironmentName -eq "Instance Test" } Assert-MockCalled -CommandName Out-File @@ -56,7 +56,7 @@ Describe "Write-ReportToFile" { $TestTimeSpan = New-TimeSpan -Minutes 2 -Seconds 3 $testMonitoringOutput = @() - $testMonitoringOutput | Write-ReportToFile -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan + $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan Assert-MockCalled -CommandName New-HtmlBody -ParameterFilter { $TotalElapsedTime.TotalMilliseconds -eq 123000 } Assert-MockCalled -CommandName Out-File From 121714658f9ec378ab2a0b434d610009c071ef09 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Mon, 16 Jul 2018 08:35:16 +0200 Subject: [PATCH 6/8] Changing OverwriteFile to Switch --- .../Write-PoShMonHtmlReport.ps1 | 2 +- .../Write-ReportToFile.Tests.ps1 | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 b/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 index bee61a4..f0cad92 100644 --- a/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 +++ b/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 @@ -6,7 +6,7 @@ Function Write-PoShMonHtmlReport { [hashtable]$PoShMonConfiguration = $null, [TimeSpan]$TotalElapsedTime = (New-TimeSpan), [string]$OutputFilePath, - [boolean]$OverwriteFileIfExists = $false + [switch]$OverwriteFileIfExists = $false ) if ($PoShMonConfiguration -eq $null) diff --git a/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 b/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 index db43ede..4812dc8 100644 --- a/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 +++ b/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 @@ -11,6 +11,7 @@ Describe "Write-PoShMonHtmlReport" { } Mock -CommandName Out-File -Verifiable -MockWith { + Write-Host $NoClobber return; } @@ -61,5 +62,30 @@ Describe "Write-PoShMonHtmlReport" { Assert-MockCalled -CommandName New-HtmlBody -ParameterFilter { $TotalElapsedTime.TotalMilliseconds -eq 123000 } Assert-MockCalled -CommandName Out-File } + + It "Passes in NoClobber correctly" { + + $PoShMonConfigurationGlobal = New-PoShMonConfiguration { General -EnvironmentName "Global Test" } + $Global:TotalElapsedPoShMonTime = New-TimeSpan -Minutes 1 -Seconds 2 + $TestTimeSpan = New-TimeSpan -Minutes 2 -Seconds 3 + + $testMonitoringOutput = @() + $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan + + Assert-MockCalled -CommandName Out-File -ParameterFilter { $NoClobber -eq $true } + + } + + It "Passes in NoClobber correctly for FALSE" { + + $PoShMonConfigurationGlobal = New-PoShMonConfiguration { General -EnvironmentName "Global Test" } + $Global:TotalElapsedPoShMonTime = New-TimeSpan -Minutes 1 -Seconds 2 + $TestTimeSpan = New-TimeSpan -Minutes 2 -Seconds 3 + + $testMonitoringOutput = @() + $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan -OverwriteFileIfExists:$true + + Assert-MockCalled -CommandName Out-File -ParameterFilter { $NoClobber -eq $false } + } } } From f2ee26587587c1ff715a1993821b26d3c34eb417 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Mon, 16 Jul 2018 08:52:16 +0200 Subject: [PATCH 7/8] Changing Report To Remove Pipeline --- .vscode/launch.json | 8 ++ .../Write-PoShMonHtmlReport.ps1 | 1 - .../Write-ReportToFile.Tests.ps1 | 73 +++++++++++++++++-- 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0ec64fd..6d7a543 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,6 +1,14 @@ { "version": "0.4.0", "configurations": [ + { + "type": "PowerShell", + "request": "launch", + "name": "PowerShell Launch Current File", + "script": "${file}", + "args": [], + "cwd": "${file}" + }, { "name": "PowerShell", "type": "PowerShell", diff --git a/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 b/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 index f0cad92..3f3912b 100644 --- a/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 +++ b/src/Functions/PoShMon.Logging.File/Write-PoShMonHtmlReport.ps1 @@ -1,7 +1,6 @@ Function Write-PoShMonHtmlReport { [CmdletBinding()] Param( - [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [System.Collections.ArrayList]$PoShMonOutputValues, [hashtable]$PoShMonConfiguration = $null, [TimeSpan]$TotalElapsedTime = (New-TimeSpan), diff --git a/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 b/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 index 4812dc8..c8d45e7 100644 --- a/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 +++ b/src/Tests/CI/Unit/PoShMon.Logging.File/Write-ReportToFile.Tests.ps1 @@ -11,7 +11,6 @@ Describe "Write-PoShMonHtmlReport" { } Mock -CommandName Out-File -Verifiable -MockWith { - Write-Host $NoClobber return; } @@ -20,7 +19,7 @@ Describe "Write-PoShMonHtmlReport" { $PoShMonConfigurationGlobal = New-PoShMonConfiguration { General -EnvironmentName "Global Test" } $testMonitoringOutput = @() - $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" + Write-PoShMonHtmlReport -PoShMonOutputValues $testMonitoringOutput -OutputFilePath "C:\Temp\PoShMonReport.html" Assert-MockCalled -CommandName New-HtmlBody -ParameterFilter { $PoShMonConfiguration.General.EnvironmentName -eq "Global Test" } Assert-MockCalled -CommandName Out-File @@ -32,7 +31,7 @@ Describe "Write-PoShMonHtmlReport" { $Global:TotalElapsedPoShMonTime = New-TimeSpan -Minutes 1 -Seconds 2 $testMonitoringOutput = @() - $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" + Write-PoShMonHtmlReport -PoShMonOutputValues $testMonitoringOutput -OutputFilePath "C:\Temp\PoShMonReport.html" Assert-MockCalled -CommandName New-HtmlBody -ParameterFilter { $TotalElapsedTime.TotalMilliseconds -eq 62000 } Assert-MockCalled -CommandName Out-File @@ -44,7 +43,7 @@ Describe "Write-PoShMonHtmlReport" { $PoShMonConfigurationGlobal = New-PoShMonConfiguration { General -EnvironmentName "Global Test" } $testMonitoringOutput = @() - $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" -PoShMonConfiguration $PoShMonConfigurationTest + Write-PoShMonHtmlReport -PoShMonOutputValues $testMonitoringOutput -OutputFilePath "C:\Temp\PoShMonReport.html" -PoShMonConfiguration $PoShMonConfigurationTest Assert-MockCalled -CommandName New-HtmlBody -ParameterFilter { $PoShMonConfiguration.General.EnvironmentName -eq "Instance Test" } Assert-MockCalled -CommandName Out-File @@ -57,7 +56,7 @@ Describe "Write-PoShMonHtmlReport" { $TestTimeSpan = New-TimeSpan -Minutes 2 -Seconds 3 $testMonitoringOutput = @() - $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan + Write-PoShMonHtmlReport -PoShMonOutputValues $testMonitoringOutput -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan Assert-MockCalled -CommandName New-HtmlBody -ParameterFilter { $TotalElapsedTime.TotalMilliseconds -eq 123000 } Assert-MockCalled -CommandName Out-File @@ -70,7 +69,7 @@ Describe "Write-PoShMonHtmlReport" { $TestTimeSpan = New-TimeSpan -Minutes 2 -Seconds 3 $testMonitoringOutput = @() - $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan + Write-PoShMonHtmlReport -PoShMonOutputValues $testMonitoringOutput -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan Assert-MockCalled -CommandName Out-File -ParameterFilter { $NoClobber -eq $true } @@ -83,7 +82,67 @@ Describe "Write-PoShMonHtmlReport" { $TestTimeSpan = New-TimeSpan -Minutes 2 -Seconds 3 $testMonitoringOutput = @() - $testMonitoringOutput | Write-PoShMonHtmlReport -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan -OverwriteFileIfExists:$true + Write-PoShMonHtmlReport -PoShMonOutputValues $testMonitoringOutput -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan -OverwriteFileIfExists:$true + + Assert-MockCalled -CommandName Out-File -ParameterFilter { $NoClobber -eq $false } + } + + It "Writes All Output in One Go" { + + $PoShMonConfigurationGlobal = New-PoShMonConfiguration { General -EnvironmentName "Global Test" } + $Global:TotalElapsedPoShMonTime = New-TimeSpan -Minutes 1 -Seconds 2 + $TestTimeSpan = New-TimeSpan -Minutes 2 -Seconds 3 + + $testMonitoringOutput = @( + @{ + "SectionHeader" = "Grouped Test" + "OutputHeaders" = @{ 'EventID' = 'Event ID'; 'Message' ='Message' } + "NoIssuesFound" = $true + "ElapsedTime" = (Get-Date).Subtract((Get-Date).AddMinutes(-1)) + "OutputValues" = @( + @{ + "GroupName" = "Server 1" + "GroupOutputValues" = @( + @{ + "EventID" = 123 + "Message" = "Message 1" + }, + @{ + "EventID" = 456 + "Message" = "Message 2" + } + ) + }, + @{ + "GroupName" = "Server 2" + "GroupOutputValues" = @( + @{ + "EventID" = 789 + "Message" = "Message 3" + } + ) + } + ) + } + @{ + "SectionHeader" = "Ungrouped Test" + "OutputHeaders" = @{ 'ComponentName' = 'Component'; 'State' = 'State' } + "NoIssuesFound" = $false + "ElapsedTime" = (Get-Date).Subtract((Get-Date).AddMinutes(-1)) + "OutputValues" = @( + @{ + "ComponentName" = 123 + "State" = "State 1" + }, + @{ + "ComponentName" = 456 + "State" = "State 2" + } + ) + } + ) + + Write-PoShMonHtmlReport -PoShMonOutputValues $testMonitoringOutput -OutputFilePath "C:\Temp\PoShMonReport.html" -TotalElapsedTime $TestTimeSpan -OverwriteFileIfExists:$true Assert-MockCalled -CommandName Out-File -ParameterFilter { $NoClobber -eq $false } } From 23035b85bed72aa6b98b9b557f5c7866234f8532 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Mon, 16 Jul 2018 16:06:47 +0200 Subject: [PATCH 8/8] 1.1.1 release --- README.md | 5 +++++ src/Generate Module Manifest.ps1 | 10 ++++++---- src/PoShMon.psd1 | Bin 14934 -> 15010 bytes 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 231d97d..7435e89 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,11 @@ Of course there are loads of monitoring systems and tools out there, both paid a --- ## Release Notes +1.1.1 +* Various bug fixes in Web tests +* Renamed html ad hoc report function +* Various bug fixes in html ad hoc report function + 1.1.0 * Added ability to create ad-hoc html report * For Drive Space test, added Volume Name to output diff --git a/src/Generate Module Manifest.ps1 b/src/Generate Module Manifest.ps1 index 0240e6c..29127e3 100644 --- a/src/Generate Module Manifest.ps1 +++ b/src/Generate Module Manifest.ps1 @@ -1,4 +1,4 @@ -$version = "1.1.0" +$version = "1.1.1" $manifestPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) -ChildPath "\PoShMon.psd1" Remove-Item -Path $manifestPath -ErrorAction SilentlyContinue @@ -19,6 +19,11 @@ Some of the key features / benefits of PoShMon are: For more information, documentation etc. visit https://github.com/HiltonGiesenow/PoShMon as well as the Samples folder within the module itself." $releaseNotes = " +1.1.1 +* Various bug fixes in Web tests +* Renamed html ad hoc report function +* Various bug fixes in html ad hoc report function + 1.1.0 * Added ability to create ad-hoc html report * For Drive Space test, added Volume Name to output @@ -80,9 +85,6 @@ $releaseNotes = " * Add a check for any invalid TestsToSkip * Fixed bug in Update-PoShMon -0.9.2 -* Fixed bug in email output -* Fixed bug with not terminating Remote sessions correctly " New-ModuleManifest -Path $manifestPath -ModuleVersion $version -RootModule "PoShMon.psm1" -Guid '6e6cb274-1bed-4540-b288-95bc638bf679' -Author "Hilton Giesenow" -CompanyName "Experts Inside" -FunctionsToExport '*' -Copyright "2016 Hilton Giesenow, All Rights Reserved" -ProjectUri "https://github.com/HiltonGiesenow/PoShMon" -LicenseUri "https://github.com/HiltonGiesenow/PoShMon/blob/master/LICENSE" -Description $description -Tags 'Monitoring','Server','Farm','SharePoint' -ReleaseNotes $releaseNotes -Verbose diff --git a/src/PoShMon.psd1 b/src/PoShMon.psd1 index f11c06981c8c55cf52046d727e2c143b3639fa8e..f78ab6a71e22c2f759e10a1d27475098c1e14622 100644 GIT binary patch delta 297 zcmcasvZ!>zF>XT!GX@0)FNRWvoQ)S_85s>X>oaXtsW)WcW#D4a0!oE3Br+5+WHRIf zl@tT{NkBRsNT&hCDi~71VwntiK#_1DF9}GOfJIAyGB7iOfFgN7b8>-n3Q$D`P)#mF z4v>`y<>xab19?S2`2wI#MfE@hAS+6N+LD26ko9?RL5pzM!^pMyx>~=$W;F`~ FCICoQIWqtN delta 153 zcmZ2fdaY!_F>WIUQw9YFUxq}6%8eIe85s>W>oaXt+5ADhNr2OUL65-_h>a$HG}NEm zU??*Am!U{>IYTBx2}1@@R~|z?kfi{`sSHI7xj^wepgARAIvpq;1QgE&t4Rg&ih;ah fAj|}c