Skip to content

Commit b0ec59f

Browse files
committed
Fix integ test
1 parent 1ea707d commit b0ec59f

12 files changed

+152
-40
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Added
99

1010
- Public commands:
11-
- `Install-SqlDscReportingServices`
11+
- `Install-SqlDscReportingService`
1212
- `Install-SqlDscBIReportServer`
13-
- `Repair-SqlDscReportingServices`
13+
- `Repair-SqlDscReportingService`
1414
- `Repair-SqlDscBIReportServer`
15-
- `Uninstall-SqlDscReportingServices`
15+
- `Uninstall-SqlDscReportingService`
1616
- `Uninstall-SqlDscBIReportServer`
1717
- Private function:
1818
- `Invoke-ReportServerSetupAction`

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ stages:
255255
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
256256
# Group 1
257257
'tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1'
258+
'tests/Integration/Commands/Install-SqlDscReportingService.Integration.Tests.ps1'
258259
'tests/Integration/Commands/Connect-SqlDscDatabaseEngine.Integration.Tests.ps1'
259260
# Group 9
260261
'tests/Integration/Commands/Uninstall-SqlDscServer.Integration.Tests.ps1'

source/Private/Invoke-ReportServerSetupAction.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,13 @@ function Invoke-ReportServerSetupAction
237237

238238
if ($Edition)
239239
{
240-
$setupArgument += ' /Edition={0}' -f $Edition
240+
$editionMap = @{
241+
Developer = 'Dev'
242+
Evaluation = 'Eval'
243+
ExpressAdvanced = 'ExprAdv'
244+
}
245+
246+
$setupArgument += ' /Edition={0}' -f $editionMap.$Edition
241247
}
242248

243249
if ($LogPath)

source/Public/Install-SqlDscReportingServices.ps1 renamed to source/Public/Install-SqlDscReportingService.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,27 @@
5454
is used.
5555
5656
.EXAMPLE
57-
Install-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe'
57+
Install-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe'
5858
5959
Installs SQL Server Reporting Services with default settings.
6060
6161
.EXAMPLE
62-
Install-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -ProductKey '12345-12345-12345-12345-12345'
62+
Install-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -ProductKey '12345-12345-12345-12345-12345'
6363
6464
Installs SQL Server Reporting Services using a product key.
6565
6666
.EXAMPLE
67-
Install-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -Edition 'Evaluation' -InstallFolder 'C:\Program Files\Power BI Report Server'
67+
Install-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -Edition 'Evaluation' -InstallFolder 'C:\Program Files\Power BI Report Server'
6868
6969
Installs Power BI Report Server in evaluation edition to a custom folder.
7070
7171
.EXAMPLE
72-
Install-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -ProductKey '12345-12345-12345-12345-12345' -EditionUpgrade -LogPath 'C:\Logs\SSRS_Install.log'
72+
Install-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -ProductKey '12345-12345-12345-12345-12345' -EditionUpgrade -LogPath 'C:\Logs\SSRS_Install.log'
7373
7474
Installs SQL Server Reporting Services and upgrades the edition using a
7575
product key. Also specifies a custom log path.
7676
#>
77-
function Install-SqlDscReportingServices
77+
function Install-SqlDscReportingService
7878
{
7979
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
8080
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]

source/Public/Repair-SqlDscReportingServices.ps1 renamed to source/Public/Repair-SqlDscReportingService.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@
5555
is used.
5656
5757
.EXAMPLE
58-
Repair-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe'
58+
Repair-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe'
5959
6060
Repairs SQL Server Reporting Services with default settings.
6161
6262
.EXAMPLE
63-
Repair-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -ProductKey '12345-12345-12345-12345-12345' -EditionUpgrade
63+
Repair-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -ProductKey '12345-12345-12345-12345-12345' -EditionUpgrade
6464
6565
Repairs SQL Server Reporting Services and upgrades the edition using a
6666
product key.
6767
6868
.EXAMPLE
69-
Repair-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -LogPath 'C:\Logs\PowerBIReportServer_Repair.log'
69+
Repair-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -LogPath 'C:\Logs\PowerBIReportServer_Repair.log'
7070
7171
Repairs Power BI Report Server and specifies a custom log path.
7272
#>
73-
function Repair-SqlDscReportingServices
73+
function Repair-SqlDscReportingService
7474
{
7575
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
7676
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]

source/Public/Save-SqlDscSqlServerMediaFile.ps1

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,21 @@
3434
Forces the download of the media file even if the file already exists at the
3535
specified destination path.
3636
37+
.PARAMETER SkipExecution
38+
When specified, and the URL points to an executable (.exe), the function will
39+
download the executable file without executing it. The file will be saved using
40+
the provided FileName parameter.
41+
3742
.EXAMPLE
3843
Save-SqlDscSqlServerMediaFile -Url 'https://download.microsoft.com/download/c/c/9/cc9c6797-383c-4b24-8920-dc057c1de9d3/SQL2022-SSEI-Dev.exe' -DestinationPath 'C:\path\to\destination'
3944
4045
This downloads the SQL Server 2022 media and saves it to the specified destination path.
4146
47+
.EXAMPLE
48+
Save-SqlDscSqlServerMediaFile -Url 'https://download.microsoft.com/download/c/c/9/cc9c6797-383c-4b24-8920-dc057c1de9d3/SQL2022-SSEI-Dev.exe' -DestinationPath 'C:\path\to\destination' -SkipExecution
49+
50+
This downloads the SQL Server 2022 installer executable but does not execute it to extract the ISO.
51+
4252
.EXAMPLE
4353
Save-SqlDscSqlServerMediaFile -Url 'https://download.microsoft.com/download/d/a/2/da259851-b941-459d-989c-54a18a5d44dd/SQL2019-SSEI-Dev.exe' -DestinationPath 'C:\path\to\destination'
4454
@@ -85,15 +95,19 @@ function Save-SqlDscSqlServerMediaFile
8595

8696
[Parameter()]
8797
[System.Management.Automation.SwitchParameter]
88-
$Force
98+
$Force,
99+
100+
[Parameter()]
101+
[System.Management.Automation.SwitchParameter]
102+
$SkipExecution
89103
)
90104

91105
if ($Force.IsPresent -and -not $Confirm)
92106
{
93107
$ConfirmPreference = 'None'
94108
}
95109

96-
if ((Get-Item -Path "$DestinationPath/*.iso" -Force).Count -gt 0)
110+
if ((Get-Item -Path "$DestinationPath/*.iso" -Force).Count -gt 0 -and -not $SkipExecution)
97111
{
98112
$auditAlreadyPresentMessage = $script:localizedData.SqlServerMediaFile_Save_InvalidDestinationFolder
99113

@@ -165,7 +179,7 @@ function Save-SqlDscSqlServerMediaFile
165179
$ProgressPreference = $previousProgressPreference
166180
}
167181

168-
if ($isExecutable)
182+
if ($isExecutable -and -not $SkipExecution)
169183
{
170184
Write-Verbose -Message $script:localizedData.SqlServerMediaFile_Save_IsExecutable
171185

source/Public/Uninstall-SqlDscReportingServices.ps1 renamed to source/Public/Uninstall-SqlDscReportingService.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@
2828
is used.
2929
3030
.EXAMPLE
31-
Uninstall-SqlDscReportingServices -MediaPath 'E:\SQLServerReportingServices.exe'
31+
Uninstall-SqlDscReportingService -MediaPath 'E:\SQLServerReportingServices.exe'
3232
3333
Uninstalls SQL Server Reporting Services.
3434
3535
.EXAMPLE
36-
Uninstall-SqlDscReportingServices -MediaPath 'E:\PowerBIReportServer.exe' -LogPath 'C:\Logs\PowerBIReportServer_Uninstall.log'
36+
Uninstall-SqlDscReportingService -MediaPath 'E:\PowerBIReportServer.exe' -LogPath 'C:\Logs\PowerBIReportServer_Uninstall.log'
3737
3838
Uninstalls Power BI Report Server and specifies a custom log path.
3939
4040
.EXAMPLE
41-
Uninstall-SqlDscReportingServices -MediaPath 'E:\SQLServerReportingServices.exe' -Force
41+
Uninstall-SqlDscReportingService -MediaPath 'E:\SQLServerReportingServices.exe' -Force
4242
4343
Uninstalls SQL Server Reporting Services without prompting for confirmation.
4444
#>
45-
function Uninstall-SqlDscReportingServices
45+
function Uninstall-SqlDscReportingService
4646
{
4747
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
4848
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')]
2+
param ()
3+
4+
BeforeDiscovery {
5+
try
6+
{
7+
if (-not (Get-Module -Name 'DscResource.Test'))
8+
{
9+
# Assumes dependencies has been resolved, so if this module is not available, run 'noop' task.
10+
if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable))
11+
{
12+
# Redirect all streams to $null, except the error stream (stream 2)
13+
& "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 2>&1 4>&1 5>&1 6>&1 > $null
14+
}
15+
16+
# If the dependencies has not been resolved, this will throw an error.
17+
Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop'
18+
}
19+
}
20+
catch [System.IO.FileNotFoundException]
21+
{
22+
throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.'
23+
}
24+
}
25+
26+
Describe 'Install-SqlDscReportingService' -Tag @('Integration_SQL2022') {
27+
BeforeAll {
28+
Write-Verbose -Message ('Running integration test as user ''{0}''.' -f $env:UserName) -Verbose
29+
30+
# Get the path to the Reporting Services executable
31+
$reportingServicesExecutable = Join-Path -Path (Get-TemporaryFolder) -ChildPath 'SQLServerReportingServices.exe'
32+
}
33+
34+
Context 'When installing SQL Server 2022 Reporting Services' {
35+
It 'Should run the command without throwing' {
36+
{
37+
# Set splatting parameters for Install-SqlDscReportingService
38+
$installSqlDscReportingServicesParameters = @{
39+
AcceptLicensingTerms = $true
40+
MediaPath = $reportingServicesExecutable
41+
Edition = 'Developer'
42+
LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'SSRS_Install.log'
43+
SuppressRestart = $true
44+
Verbose = $true
45+
Force = $true
46+
}
47+
48+
Install-SqlDscReportingService @installSqlDscReportingServicesParameters
49+
} | Should -Not -Throw
50+
}
51+
52+
It 'Should have installed SQL Server 2022 Reporting Services' {
53+
# Validate the Reporting Services installation
54+
$reportServerService = Get-Service -Name 'SQLServerReportingServices'
55+
56+
$reportServerService | Should -Not -BeNullOrEmpty
57+
$reportServerService.Status | Should -Be 'Running'
58+
}
59+
60+
It 'Should stop the Reporting Services service' {
61+
# Stop the Reporting Services service to save memory on the build worker
62+
$stopServiceResult = Stop-Service -Name 'SQLServerReportingServices' -Force -PassThru -Verbose -ErrorAction 'Stop'
63+
64+
write-verbose -Message ($stopServiceResult | Out-String) -Verbose
65+
66+
$stopServiceResult.Status | Should -Be 'Stopped'
67+
}
68+
}
69+
}

tests/Integration/Commands/Prerequisites.Integration.Tests.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,28 @@ Describe 'Prerequisites' {
125125
}
126126
}
127127

128+
Context 'Download correct SQL Server 2022 Reporting Services installation executable' {
129+
It 'Should download SQL Server 2022 Reporting Services installation executable' -Tag @('Integration_SQL2022') {
130+
$url = 'https://download.microsoft.com/download/8/3/2/832616ff-af64-42b5-a0b1-5eb07f71dec9/SQLServerReportingServices.exe'
131+
132+
# Put the executable in a temporary folder that can be accessed by other tests
133+
$script:mediaFile = Save-SqlDscSqlServerMediaFile -SkipExecution -Url $url -FileName 'SQLServerReportingServices.exe' -DestinationPath (Get-TemporaryFolder) -Force -Quiet -ErrorAction 'Stop'
134+
135+
$mediaFile.Name | Should -Be 'SQLServerReportingServices.exe'
136+
}
137+
}
138+
139+
Context 'Download correct Power BI Report Server installation executable' {
140+
It 'Should download Power BI Report Server (January 2025) installation executable' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
141+
$url = 'https://download.microsoft.com/download/2/7/3/2739a88a-4769-4700-8748-1a01ddf60974/PowerBIReportServer.exe'
142+
143+
# Put the executable in a temporary folder that can be accessed by other tests
144+
$script:mediaFile = Save-SqlDscSqlServerMediaFile -SkipExecution -Url $url -FileName 'PowerBIReportServer.exe' -DestinationPath (Get-TemporaryFolder) -Force -Quiet -ErrorAction 'Stop'
145+
146+
$mediaFile.Name | Should -Be 'PowerBIReportServer.exe'
147+
}
148+
}
149+
128150
Context 'Mount SQL Server media' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
129151
It 'Should mount the media to a drive letter' {
130152
$mountedImage = Mount-DiskImage -ImagePath $script:mediaFile

tests/Unit/Public/Install-SqlDscReportingServices.Tests.ps1 renamed to tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ AfterAll {
4646
Remove-Item -Path 'env:SqlServerDscCI'
4747
}
4848

49-
Describe 'Install-SqlDscReportingServices' -Tag 'Public' {
49+
Describe 'Install-SqlDscReportingService' -Tag 'Public' {
5050
It 'Should have the correct parameters in parameter set <MockParameterSetName>' -ForEach @(
5151
@{
5252
MockParameterSetName = '__AllParameterSets'
5353
MockExpectedParameters = '[-MediaPath] <string> [[-ProductKey] <string>] [[-Edition] <string>] [[-LogPath] <string>] [[-InstallFolder] <string>] [[-Timeout] <uint>] -AcceptLicensingTerms [-EditionUpgrade] [-SuppressRestart] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
5454
}
5555
) {
56-
$result = (Get-Command -Name 'Install-SqlDscReportingServices').ParameterSets |
56+
$result = (Get-Command -Name 'Install-SqlDscReportingService').ParameterSets |
5757
Where-Object -FilterScript {
5858
$_.Name -eq $mockParameterSetName
5959
} |
@@ -91,7 +91,7 @@ Describe 'Install-SqlDscReportingServices' -Tag 'Public' {
9191

9292
Context 'When using parameter Confirm with value $false' {
9393
It 'Should call the Invoke-ReportServerSetupAction with Install action' {
94-
Install-SqlDscReportingServices -Confirm:$false @mockDefaultParameters
94+
Install-SqlDscReportingService -Confirm:$false @mockDefaultParameters
9595

9696
Should -Invoke -CommandName Invoke-ReportServerSetupAction -ParameterFilter {
9797
$Install -eq $true -and
@@ -103,7 +103,7 @@ Describe 'Install-SqlDscReportingServices' -Tag 'Public' {
103103

104104
Context 'When using parameter Force' {
105105
It 'Should call the Invoke-ReportServerSetupAction with Install action' {
106-
Install-SqlDscReportingServices -Force @mockDefaultParameters
106+
Install-SqlDscReportingService -Force @mockDefaultParameters
107107

108108
Should -Invoke -CommandName Invoke-ReportServerSetupAction -ParameterFilter {
109109
$Install -eq $true -and
@@ -114,7 +114,7 @@ Describe 'Install-SqlDscReportingServices' -Tag 'Public' {
114114

115115
Context 'When using parameter WhatIf' {
116116
It 'Should call Invoke-ReportServerSetupAction' {
117-
Install-SqlDscReportingServices -WhatIf @mockDefaultParameters
117+
Install-SqlDscReportingService -WhatIf @mockDefaultParameters
118118

119119
Should -Invoke -CommandName Invoke-ReportServerSetupAction -Exactly -Times 1 -Scope It
120120
}
@@ -138,7 +138,7 @@ Describe 'Install-SqlDscReportingServices' -Tag 'Public' {
138138
}
139139

140140
It 'Should pass all parameters to Invoke-ReportServerSetupAction' {
141-
Install-SqlDscReportingServices @installParameters
141+
Install-SqlDscReportingService @installParameters
142142

143143
Should -Invoke -CommandName Invoke-ReportServerSetupAction -ParameterFilter {
144144
$Install -eq $true -and
@@ -167,7 +167,7 @@ Describe 'Install-SqlDscReportingServices' -Tag 'Public' {
167167
}
168168

169169
It 'Should pass the Edition parameter to Invoke-ReportServerSetupAction' {
170-
Install-SqlDscReportingServices @installParameters
170+
Install-SqlDscReportingService @installParameters
171171

172172
Should -Invoke -CommandName Invoke-ReportServerSetupAction -ParameterFilter {
173173
$Install -eq $true -and

0 commit comments

Comments
 (0)