Skip to content

Commit 4fe1c4b

Browse files
committed
Fix more integ tests
1 parent 678a873 commit 4fe1c4b

5 files changed

+145
-3
lines changed

azure-pipelines.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ stages:
323323
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
324324
# Group 1
325325
'tests/Integration/Commands/Install-SqlDscReportingService.Integration.Tests.ps1'
326+
# Group 8
327+
'tests/Integration/Commands/Repair-SqlDscReportingService.Integration.Tests.ps1'
326328
# Group 9
327329
'tests/Integration/Commands/Uninstall-SqlDscReportingService.Integration.Tests.ps1'
328330
)
@@ -380,6 +382,8 @@ stages:
380382
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
381383
# Group 1
382384
'tests/Integration/Commands/Install-SqlDscBIReportServer.Integration.Tests.ps1'
385+
# Group 8
386+
'tests/Integration/Commands/Repair-SqlDscBIReportServer.Integration.Tests.ps1'
383387
# Group 9
384388
'tests/Integration/Commands/Uninstall-SqlDscBIReportServer.Integration.Tests.ps1'
385389
)
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 'Repair-SqlDscBIReportServer' -Tag @('Integration_PowerBI') {
27+
BeforeAll {
28+
Write-Verbose -Message ('Running integration test as user ''{0}''.' -f $env:UserName) -Verbose
29+
30+
# Starting the Power BI Report Server service prior to running tests.
31+
Start-Service -Name 'PowerBIReportServer' -Verbose -ErrorAction 'Stop'
32+
33+
$script:temporaryFolder = Get-TemporaryFolder
34+
35+
# Get the path to the Power BI Report Server executable
36+
$powerBIReportServerExecutable = Join-Path -Path $script:temporaryFolder -ChildPath 'PowerBIReportServer.exe'
37+
}
38+
39+
It 'Should have the BI Report Server service running' {
40+
$getServiceResult = Get-Service -Name 'PowerBIReportServer' -ErrorAction 'Stop'
41+
42+
$getServiceResult.Status | Should -Be 'Running'
43+
}
44+
45+
Context 'When repairing BI Report Server' {
46+
It 'Should run the command without throwing' {
47+
{
48+
# Set splatting parameters for Repair-SqlDscBIReportServer
49+
$repairSqlDscBIReportServerParameters = @{
50+
MediaPath = $powerBIReportServerExecutable
51+
LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'SSRS_Repair.log'
52+
SuppressRestart = $true
53+
Verbose = $true
54+
ErrorAction = 'Stop'
55+
Force = $true
56+
}
57+
58+
Repair-SqlDscBIReportServer @repairSqlDscBIReportServerParameters
59+
} | Should -Not -Throw
60+
}
61+
62+
It 'Should still have a Power BI Report Server service running after repair' {
63+
$getServiceResult = Get-Service -Name 'PowerBIReportServer' -ErrorAction 'Stop'
64+
65+
$getServiceResult | Should -Not -BeNullOrEmpty
66+
$getServiceResult.Status | Should -Be 'Running'
67+
}
68+
}
69+
}
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 'Repair-SqlDscReportingService' -Tag @('Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
27+
BeforeAll {
28+
Write-Verbose -Message ('Running integration test as user ''{0}''.' -f $env:UserName) -Verbose
29+
30+
# Starting the Power BI Report Server service prior to running tests.
31+
Start-Service -Name 'SQLServerReportingServices' -Verbose -ErrorAction 'Stop'
32+
33+
$script:temporaryFolder = Get-TemporaryFolder
34+
35+
# Get the path to the Reporting Services executable
36+
$reportingServicesExecutable = Join-Path -Path $script:temporaryFolder -ChildPath 'SQLServerReportingServices.exe'
37+
}
38+
39+
It 'Should have the Reporting Services service running' {
40+
$getServiceResult = Get-Service -Name 'SQLServerReportingServices' -ErrorAction 'Stop'
41+
42+
$getServiceResult.Status | Should -Be 'Running'
43+
}
44+
45+
Context 'When repairing Reporting Services' {
46+
It 'Should run the repair command without throwing' {
47+
{
48+
# Set splatting parameters for Repair-SqlDscReportingService
49+
$repairSqlDscReportingServiceParameters = @{
50+
MediaPath = $reportingServicesExecutable
51+
LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'SSRS_Repair.log'
52+
SuppressRestart = $true
53+
Verbose = $true
54+
ErrorAction = 'Stop'
55+
Force = $true
56+
}
57+
58+
Repair-SqlDscReportingService @repairSqlDscReportingServiceParameters
59+
} | Should -Not -Throw
60+
}
61+
62+
It 'Should still have the SQL Server Reporting Services service running after repair' {
63+
$getServiceResult = Get-Service -Name 'SQLServerReportingServices' -ErrorAction 'Stop'
64+
65+
$getServiceResult | Should -Not -BeNullOrEmpty
66+
$getServiceResult.Status | Should -Be 'Running'
67+
}
68+
}
69+
}

tests/Integration/Commands/Uninstall-SqlDscBIReportServer.Integration.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Describe 'Uninstall-SqlDscBIReportServer' -Tag @('Integration_PowerBI') {
4747
{
4848
# Set splatting parameters for Uninstall-SqlDscBIReportServer
4949
$uninstallSqlDscBIReportServerParameters = @{
50-
MediaPath = $reportingServicesExecutable
51-
LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'SSRS_Install.log'
50+
MediaPath = $powerBIReportServerExecutable
51+
LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'SSRS_Uninstall.log'
5252
SuppressRestart = $true
5353
Verbose = $true
5454
ErrorAction = 'Stop'

tests/Integration/Commands/Uninstall-SqlDscReportingService.Integration.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Describe 'Uninstall-SqlDscReportingService' -Tag @('Integration_SQL2017', 'Integ
4848
# Set splatting parameters for Uninstall-SqlDscReportingService
4949
$uninstallSqlDscReportingServiceParameters = @{
5050
MediaPath = $reportingServicesExecutable
51-
LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'SSRS_Install.log'
51+
LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'SSRS_Uninstall.log'
5252
SuppressRestart = $true
5353
Verbose = $true
5454
ErrorAction = 'Stop'

0 commit comments

Comments
 (0)