Skip to content

Commit a1b92c1

Browse files
committed
Add integration test for database connection in Reporting Services
1 parent 2e2473a commit a1b92c1

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ stages:
589589
'tests/Integration/Commands/Get-SqlDscRSServiceAccount.Integration.Tests.ps1'
590590
'tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1'
591591
'tests/Integration/Commands/Post.EncryptedInformation.RS.Integration.Tests.ps1'
592+
'tests/Integration/Commands/Post.DatabaseConnection.RS.Integration.Tests.ps1'
592593
'tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1'
593594
'tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1'
594595
'tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1'
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 have 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' 3>&1 4>&1 5>&1 6>&1 > $null
14+
}
15+
16+
# If the dependencies have 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 noop" first.'
23+
}
24+
}
25+
26+
BeforeAll {
27+
$script:moduleName = 'SqlServerDsc'
28+
29+
# Do not use -Force. Doing so, or unloading the module in AfterAll, causes
30+
# PowerShell class types to get new identities, breaking type comparisons.
31+
Import-Module -Name $script:moduleName -ErrorAction 'Stop'
32+
}
33+
34+
<#
35+
.NOTES
36+
This test is specifically for SQL Server 2017 where the encryption key
37+
operations have issues after removing encrypted information.
38+
39+
This test runs Set-SqlDscRSDatabaseConnection to re-establish the database
40+
connection after Post.EncryptedInformation.RS.Integration.Tests.ps1 has
41+
removed encrypted information.
42+
43+
This test runs after Post.EncryptedInformation.RS.Integration.Tests.ps1 and
44+
before Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1.
45+
#>
46+
Describe 'Post.DatabaseConnection.RS' {
47+
Context 'When re-establishing database connection for SQL Server Reporting Services on SQL Server 2017' -Tag @('Integration_SQL2017_RS') {
48+
BeforeAll {
49+
$script:configuration = Get-SqlDscRSConfiguration -InstanceName 'SSRS' -ErrorAction 'Stop'
50+
51+
$script:computerName = Get-ComputerName
52+
}
53+
54+
It 'Should set the database connection' {
55+
$script:configuration | Set-SqlDscRSDatabaseConnection -ServerName $script:computerName -InstanceName 'RSDB' -DatabaseName 'ReportServer' -Force -ErrorAction 'Stop'
56+
}
57+
}
58+
}

tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ BeforeAll {
6363
6464
Re-add tag 'Integration_SQL2017_RS' when fixed.
6565
#>
66-
Describe 'Post.Reinitialize.RS' -Tag @('Integration_SQL2019_RS', 'Integration_SQL2022_RS', 'Integration_PowerBI') {
66+
Describe 'Post.Reinitialize.RS' -Tag @('Integration_SQL2017_RS', 'Integration_SQL2019_RS', 'Integration_SQL2022_RS', 'Integration_PowerBI') {
6767
BeforeAll {
6868
if (Test-ContinuousIntegrationTaskCategory -Category 'Integration_PowerBI')
6969
{

0 commit comments

Comments
 (0)