Skip to content

Commit

Permalink
Fix Show-SqlBootstrapLog
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed May 9, 2024
1 parent f6e722d commit c867775
Showing 1 changed file with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,59 @@ BeforeDiscovery {
}
}

BeforeAll {
<#
.SYNOPSIS
This function will output the Setup Bootstrap Summary.txt log file.
.DESCRIPTION
This function will output the Summary.txt log file, this is to be
able to debug any problems that potentially occurred during setup.
This will pick up the newest Summary.txt log file, so any
other log files will be ignored (AppVeyor build worker has
SQL Server instances installed by default).
This code is meant to work regardless what SQL Server
major version is used for the integration test.
#>
function Show-SqlBootstrapLog
{
[CmdletBinding()]
param
(
)

$summaryLogPath = Get-ChildItem -Path 'C:\Program Files\Microsoft SQL Server\**\Setup Bootstrap\Log\Summary.txt' |
Sort-Object -Property LastWriteTime -Descending |
Select-Object -First 1

$summaryLog = Get-Content $summaryLogPath

Write-Verbose -Message $('-' * 80) -Verbose
Write-Verbose -Message 'Summary.txt' -Verbose
Write-Verbose -Message $('-' * 80) -Verbose

$summaryLog | ForEach-Object -Process {
Write-Verbose $_ -Verbose
}

Write-Verbose -Message $('-' * 80) -Verbose
}
}

Describe 'Install-SqlDscServer' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
Context 'When using Install parameter set' {
Context 'When installing database engine default instance' {
AfterAll {
<#
Check if previous It-block failed. If so output the
SQL Server setup log file.
#>
if ( $itBlockError.Count -ne 0 )
{
Show-SqlBootstrapLog
}
}

It 'Should run the command without throwing' {
{
# Set splatting parameters for Install-SqlDscServer
Expand All @@ -43,7 +93,7 @@ Describe 'Install-SqlDscServer' -Tag @('Integration_SQL2016', 'Integration_SQL20

Install-SqlDscServer @installSqlDscServerParameters
} | Should -Not -Throw
}
} -ErrorVariable itBlockError
}
}
}

0 comments on commit c867775

Please sign in to comment.