Skip to content

Commit

Permalink
fixing...
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilton Giesenow authored and Hilton Giesenow committed Mar 7, 2017
1 parent ef747d8 commit 613f4ed
Show file tree
Hide file tree
Showing 13 changed files with 415 additions and 387 deletions.
12 changes: 12 additions & 0 deletions appveyor.yml
@@ -0,0 +1,12 @@
version: 1.0.{build}

image: WMF 5

install:
- cinst pester

build: false

test_script:
# Test with native PS version
- ps: . .\src\Tests\appveyorCITests.ps1

Large diffs are not rendered by default.

634 changes: 290 additions & 344 deletions src/Tests/CI/Unit/PoShMon.Monitoring.OS/Test-ComputerTime.Tests.ps1

Large diffs are not rendered by default.

Expand Up @@ -34,14 +34,12 @@ Describe "Test-SPDatabaseHealth" {

$headerKeyCount = 3

$actual.Keys.Count | Should Be 7
$actual.Keys.Count | Should Be 5
$actual.ContainsKey("NoIssuesFound") | Should Be $true
$actual.ContainsKey("OutputHeaders") | Should Be $true
$actual.ContainsKey("OutputValues") | Should Be $true
$actual.ContainsKey("SectionHeader") | Should Be $true
$actual.ContainsKey("ElapsedTime") | Should Be $true
$actual.ContainsKey("HeaderUrl") | Should Be $true
$actual.ContainsKey("LinkColumn") | Should Be $true
$headers = $actual.OutputHeaders
$headers.Keys.Count | Should Be $headerKeyCount
$values1 = $actual.OutputValues[0]
Expand Down
Expand Up @@ -36,13 +36,12 @@ Describe "Test-SPJobHealth" {

$headerKeyCount = 4

$actual.Keys.Count | Should Be 6
$actual.Keys.Count | Should Be 5
$actual.ContainsKey("NoIssuesFound") | Should Be $true
$actual.ContainsKey("OutputHeaders") | Should Be $true
$actual.ContainsKey("OutputValues") | Should Be $true
$actual.ContainsKey("SectionHeader") | Should Be $true
$actual.ContainsKey("ElapsedTime") | Should Be $true
$actual.ContainsKey("HeaderUrl") | Should Be $true
$headers = $actual.OutputHeaders
$headers.Keys.Count | Should Be $headerKeyCount
$actual.OutputValues[0].JobDefinitionTitle | Should Be 'Job 123'
Expand Down
Expand Up @@ -36,13 +36,12 @@ Describe "Test-SPSearchHealth" {

$headerKeyCount = 3

$actual.Keys.Count | Should Be 6
$actual.Keys.Count | Should Be 5
$actual.ContainsKey("NoIssuesFound") | Should Be $true
$actual.ContainsKey("OutputHeaders") | Should Be $true
$actual.ContainsKey("OutputValues") | Should Be $true
$actual.ContainsKey("SectionHeader") | Should Be $true
$actual.ContainsKey("ElapsedTime") | Should Be $true
$actual.ContainsKey("HeaderUrl") | Should Be $true
$headers = $actual.OutputHeaders
$headers.Keys.Count | Should Be $headerKeyCount
$actual.OutputValues[1].ServerName | Should Be 'Server1'
Expand Down Expand Up @@ -73,12 +72,11 @@ Describe "Test-SPSearchHealth" {
$actual = Test-SPSearchHealth $poShMonConfiguration -Verbose
$output = $($actual = Test-SPSearchHealth $poShMonConfiguration -Verbose) 4>&1

$output.Count | Should Be 5
$output[0].ToString() | Should Be "Getting Search Service App..."
$output[1].ToString() | Should Be "Initiating 'Search Status' Test..."
$output[2].ToString() | Should Be "`tComponent1 is in the following state: Active"
$output[3].ToString() | Should Be "`tComponent2 is in the following state: Active"
$output[4].ToString() | Should Be "Complete 'Search Status' Test, Issues Found: No"
$output.Count | Should Be 4
$output[0].ToString() | Should Be "Initiating 'Search Status' Test..."
$output[1].ToString() | Should Be "`tComponent1 is in the following state: Active"
$output[2].ToString() | Should Be "`tComponent2 is in the following state: Active"
$output[3].ToString() | Should Be "Complete 'Search Status' Test, Issues Found: No"
}

It "Should write the expected Warning output" {
Expand Down
Expand Up @@ -33,13 +33,12 @@ Describe "Test-SPServerStatus" {

$headerKeyCount = 4

$actual.Keys.Count | Should Be 6
$actual.Keys.Count | Should Be 5
$actual.ContainsKey("NoIssuesFound") | Should Be $true
$actual.ContainsKey("OutputHeaders") | Should Be $true
$actual.ContainsKey("OutputValues") | Should Be $true
$actual.ContainsKey("SectionHeader") | Should Be $true
$actual.ContainsKey("ElapsedTime") | Should Be $true
$actual.ContainsKey("HeaderUrl") | Should Be $true
$headers = $actual.OutputHeaders
$headers.Keys.Count | Should Be $headerKeyCount
$actual.OutputValues[1].ServerName | Should Be 'Server2'
Expand Down
Expand Up @@ -184,13 +184,12 @@ Describe "Test-SPUPSSyncHealth" {

$headerKeyCount = 4

$actual.Keys.Count | Should Be 6
$actual.Keys.Count | Should Be 5
$actual.ContainsKey("NoIssuesFound") | Should Be $true
$actual.ContainsKey("OutputHeaders") | Should Be $true
$actual.ContainsKey("OutputValues") | Should Be $true
$actual.ContainsKey("SectionHeader") | Should Be $true
$actual.ContainsKey("ElapsedTime") | Should Be $true
$actual.ContainsKey("HeaderUrl") | Should Be $true
$headers = $actual.OutputHeaders
$headers.Keys.Count | Should Be $headerKeyCount
$actual.OutputValues[1].ManagementAgent.Count | Should Be 0
Expand Down Expand Up @@ -357,11 +356,10 @@ Describe "Test-SPUPSSyncHealth" {
$actual = Test-SPUPSSyncHealth $poShMonConfiguration -Verbose
$output = $($actual = Test-SPUPSSyncHealth $poShMonConfiguration -Verbose) 4>&1

$output.Count | Should Be 4
$output[0].ToString() | Should Be "Getting UPS Service App..."
$output[1].ToString() | Should Be "Initiating 'User Profile Sync State' Test..."
$output[2].ToString() | Should Be "`tGetting SharePoint service list to locate UPS Sync server..."
$output[3].ToString() | Should Be "Complete 'User Profile Sync State' Test, Issues Found: No"
$output.Count | Should Be 3
$output[0].ToString() | Should Be "Initiating 'User Profile Sync State' Test..."
$output[1].ToString() | Should Be "`tGetting SharePoint service list to locate UPS Sync server..."
$output[2].ToString() | Should Be "Complete 'User Profile Sync State' Test, Issues Found: No"
}

It "Should write the expected Warning output" {
Expand Down
@@ -1,4 +1,4 @@
$rootPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) -ChildPath ('..\..\..\') -Resolve
$rootPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) -ChildPath ('..\..\..\..\') -Resolve
Remove-Module PoShMon -ErrorAction SilentlyContinue
Import-Module (Join-Path $rootPath -ChildPath "PoShMon.psd1")

Expand Down
@@ -1,4 +1,4 @@
$rootPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) -ChildPath ('..\..\..\') -Resolve
$rootPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) -ChildPath ('..\..\..\..\') -Resolve
Remove-Module PoShMon -ErrorAction SilentlyContinue
Import-Module (Join-Path $rootPath -ChildPath "PoShMon.psd1")

Expand Down
@@ -1,4 +1,4 @@
$rootPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) -ChildPath ('..\..\..\') -Resolve
$rootPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) -ChildPath ('..\..\..\..\') -Resolve
Remove-Module PoShMon -ErrorAction SilentlyContinue
Import-Module (Join-Path $rootPath -ChildPath "PoShMon.psd1")

Expand Down
34 changes: 27 additions & 7 deletions src/Tests/PoShMon.Tests.ps1
@@ -1,18 +1,38 @@
Import-Module Pester

$path = (Split-Path -Parent $MyInvocation.MyCommand.Path)

#$scriptFiles = @( Get-ChildItem -Path "$path\Integration\*\*.ps1" -Recurse -ErrorAction SilentlyContinue )
#$scriptFiles = @( Get-ChildItem -Path "$path\Unit\*\*.ps1" -Recurse -ErrorAction SilentlyContinue )
$testsPath = "$path\CI\Unit"

Invoke-Pester -Path $testsPath -CodeCoverage "$sutPath\*\*.ps1"

#$scriptFiles = @( Get-ChildItem -Path "$path\*\*.ps1" -Recurse -ErrorAction SilentlyContinue )
$scriptFiles = @( Get-ChildItem -Path "$path\Integration\*\*.ps1" -Recurse -ErrorAction SilentlyContinue ) + `
@( Get-ChildItem -Path "$path\Unit\*\*.ps1" -Recurse -ErrorAction SilentlyContinue )
#$scriptFiles = @( Get-ChildItem -Path "$path\CI\*\*.ps1" -Recurse -ErrorAction SilentlyContinue )
#$scriptFiles = @( Get-ChildItem -Path "$path\CI\Integration\*\*.ps1" -Recurse -ErrorAction SilentlyContinue )
#$scriptFiles = @( Get-ChildItem -Path "$path\CI\Unit\*\*.ps1" -Recurse -ErrorAction SilentlyContinue )

#$testResultSettings = @{ }

$testResultSettings = @{ }
#$testsPath = "$path\CI"
#$testsPath = "$path\CI\Integration"

<#
$filesToTest = @()
$sutPath = Join-Path (Split-Path -Parent $path) -ChildPath ('\Functions') -Resolve
Foreach($import in $scriptFiles)
{
$sutFileName = (Split-Path -Leaf $import).Replace(".Tests", "")
if (!$filesToTest.Contains($sutFileName))
{
$fileToTest = Get-ChildItem -Path "$sutPath\*\$sutFileName" -Recurse
$filesToTest += $fileToTest.FullName
}
#Invoke-Pester -Script $import # -PassThru $testResultSettings
#$import
. $import
#. $import
}
#>

# $testResultSettings
58 changes: 58 additions & 0 deletions src/Tests/appveyorCITests.ps1
@@ -0,0 +1,58 @@
#based on code from https://github.com/RamblingCookieMonster/PSDiskPart/
$ProjectRoot = $ENV:APPVEYOR_BUILD_FOLDER
Set-Location $ProjectRoot

#$path = (Split-Path -Parent $MyInvocation.MyCommand.Path)

Import-Module Pester

Invoke-Pester -Path "$ProjectRoot\src\Tests\CI" -CodeCoverage "$ProjectRoot\src\Functions\*\*.ps1" -OutputFormat NUnitXml -OutputFile "$ProjectRoot\RawTestResults.xml" -PassThru | `
Export-Clixml -Path "$ProjectRoot\PesterTestResults.xml"

#Invoke-Pester -Path "$ProjectRoot\src\Tests\Integration" -OutputFormat NUnitXml -OutputFile "$ProjectRoot\RawIntegrationTestResults.xml" -PassThru | `
# Export-Clixml -Path "$ProjectRoot\PesterIntegrationTestResults.xml"

#Show status...
$AllFiles = Get-ChildItem -Path $ProjectRoot\*Results.xml | Select -ExpandProperty FullName
"`n`tSTATUS: Finalizing results`n"
"COLLATING FILES:`n$($AllFiles | Out-String)"

#Upload results for test page
Get-ChildItem -Path $ProjectRoot\Raw*TestResults.xml | Foreach-Object {
$Address = "https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)"
$Source = $_.FullName

"UPLOADING FILES: $Address $Source"

(New-Object 'System.Net.WebClient').UploadFile( $Address, $Source )
}

#What failed?
$Results = @( Get-ChildItem -Path "$ProjectRoot\Pester*TestResults.xml" | Import-Clixml )

$FailedCount = $Results |
Select -ExpandProperty FailedCount |
Measure-Object -Sum |
Select -ExpandProperty Sum

if ($FailedCount -gt 0) {

$FailedItems = $Results |
Select -ExpandProperty TestResult |
Where {$_.Passed -notlike $True}

"FAILED TESTS SUMMARY:`n"
$FailedItems | ForEach-Object {
$Test = $_
[pscustomobject]@{
Describe = $Test.Describe
Context = $Test.Context
Name = "It $($Test.Name)"
Result = $Test.Result
}
} |
Sort Describe, Context, Name, Result |
Format-List

throw "$FailedCount tests failed."
}

0 comments on commit 613f4ed

Please sign in to comment.