Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added adapted resource manifest generation to the build pipeline.
- Log ISO mount, volume, and drive details in the SQL Server command
integration tests to help diagnose missing drive letters in CI.
- SqlRS
- Added parameter `StatementTimeout` to configure the SQL connection and query
timeout used when creating the Reporting Services databases.
([issue #2481](https://github.com/dsccommunity/SqlServerDsc/issues/2481))

### Fixed

Expand Down
30 changes: 24 additions & 6 deletions source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ function Get-TargetResource
systems where the service may take longer to fully initialize. If not
specified, no additional wait time is applied after service restart.

.PARAMETER StatementTimeout
Specifies the SQL timeout in seconds when creating the Reporting
Services databases. The shared SQL connection implementation uses this
value for both connection establishment and query execution. Default
600 seconds (10 minutes).

.PARAMETER Encrypt
Specifies how encryption should be enforced. There are currently no
difference between using `Mandatory` or `Strict`.
Expand Down Expand Up @@ -270,6 +276,10 @@ function Set-TargetResource
[System.UInt32]
$RestartTimeout,

[Parameter()]
[System.Int32]
$StatementTimeout = 600,

[Parameter()]
[ValidateSet('Mandatory', 'Optional', 'Strict')]
[System.String]
Expand Down Expand Up @@ -408,12 +418,13 @@ function Set-TargetResource
Import-SqlDscPreferredModule

$invokeSqlDscQueryParameters = @{
ServerName = $DatabaseServerName
InstanceName = $DatabaseInstanceName
DatabaseName = 'master'
Force = $true
Verbose = $VerbosePreference
ErrorAction = 'Stop'
ServerName = $DatabaseServerName
InstanceName = $DatabaseInstanceName
DatabaseName = 'master'
StatementTimeout = $StatementTimeout
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Force = $true
Verbose = $VerbosePreference
ErrorAction = 'Stop'
}

if ($PSBoundParameters.ContainsKey('Encrypt') -and $Encrypt -ne 'Optional')
Expand Down Expand Up @@ -700,6 +711,9 @@ function Set-TargetResource
.PARAMETER RestartTimeout
Not used in Test-TargetResource.

.PARAMETER StatementTimeout
Not used in Test-TargetResource.

.PARAMETER Encrypt
Specifies how encryption should be enforced. There are currently no
difference between using `Mandatory` or `Strict`.
Expand Down Expand Up @@ -751,6 +765,10 @@ function Test-TargetResource
[System.UInt32]
$RestartTimeout,

[Parameter()]
[System.Int32]
$StatementTimeout,

[Parameter()]
[ValidateSet('Mandatory', 'Optional', 'Strict')]
[System.String]
Expand Down
1 change: 1 addition & 0 deletions source/DSCResources/DSC_SqlRS/DSC_SqlRS.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class DSC_SqlRS : OMI_BaseResource
[Write, Description("If connections to the _Reporting Services_ must use SSL. If this parameter is not assigned a value, the default is that _Reporting Services_ does not use SSL.")] Boolean UseSsl;
[Write, Description("_Reporting Services_ need to be restarted after initialization or settings change. If this parameter is set to `$true`, _Reporting Services_ will not be restarted, even after initialization.")] Boolean SuppressRestart;
[Write, Description("The number of seconds to wait after restarting _Reporting Services_ before continuing with configuration. This is useful on resource-constrained systems where the service may take longer to fully initialize. If not specified, no additional wait time is applied after service restart.")] UInt32 RestartTimeout;
[Write, Description("Specifies the SQL timeout in seconds when creating the _Reporting Services_ databases. The shared SQL connection implementation uses this value for both connection establishment and query execution. The default is 600 seconds (10 minutes).")] SInt32 StatementTimeout;
[Write, Description("Specifies how encryption should be enforced when using command `Invoke-SqlCmd`. When not specified, the default value is `Mandatory`."), ValueMap{"Mandatory","Optional","Strict"}, Values{"Mandatory","Optional","Strict"}] String Encrypt;
[Read, Description("Returns if the _Reporting Services_ instance initialized or not.")] Boolean IsInitialized;
};
4 changes: 4 additions & 0 deletions source/DSCResources/DSC_SqlRS/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ server.

For more details, see the article [Connect to SQL Server with strict encryption](https://learn.microsoft.com/en-us/sql/relational-databases/security/networking/connect-with-strict-encryption?view=sql-server-ver16)
and [Configure SQL Server Database Engine for encrypting connections](https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-sql-server-encryption?view=sql-server-ver16).
* Parameter `StatementTimeout` controls the SQL timeout used when creating the
Reporting Services databases. The shared SQL connection implementation uses
this value for both connection establishment and query execution. The default
is 600 seconds (10 minutes).

## Known issues

Expand Down
22 changes: 22 additions & 0 deletions tests/Unit/DSC_SqlRS.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,31 @@ Describe 'SqlRS\Set-TargetResource' -Tag 'Set' {

Should-Invoke -CommandName Get-CimInstance -Exactly -Scope It -Times 1
Should-Invoke -CommandName Invoke-SqlDscQuery -Exactly -Scope It -Times 2
Should-Invoke -CommandName Invoke-SqlDscQuery -Exactly -ParameterFilter {
Comment thread
bcullman marked this conversation as resolved.
Resolved
$StatementTimeout -eq 600
} -Scope It -Times 2
Should-Invoke -CommandName Restart-SqlDscRSService -Exactly -Scope It -Times 2
}

It 'Should use the specified statement timeout for both database scripts' {
InModuleScope -ScriptBlock {
Set-StrictMode -Version 1.0

$mockDefaultParameters = @{
InstanceName = $mockNamedInstanceName
DatabaseServerName = $mockReportingServicesDatabaseServerName
DatabaseInstanceName = $mockReportingServicesDatabaseNamedInstanceName
StatementTimeout = 30
}

$null = Set-TargetResource @mockDefaultParameters
}

Should-Invoke -CommandName Invoke-SqlDscQuery -Exactly -ParameterFilter {
$StatementTimeout -eq 30
} -Scope It -Times 2
}

Context 'When there is no Reporting Services instance after Set-TargetResource has been called' {
BeforeEach {
Mock -CommandName Get-ItemProperty
Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/SqlServerDsc.Common/Public/Connect-Sql.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ Describe 'SqlServerDsc.Common\Connect-SQL' -Tag 'ConnectSql' {

Should-Invoke -CommandName New-Object -Exactly -ParameterFilter $mockNewObject_MicrosoftDatabaseEngine_ParameterFilter -Scope It -Times 1
}

It 'Should use StatementTimeout for connection establishment and query execution' {
$databaseEngineServerObject = Connect-SQL -ServerName $mockExpectedDatabaseEngineServer -SetupCredential $mockSqlCredential -LoginType 'SqlLogin' -StatementTimeout 30 -ErrorAction 'Stop'

$databaseEngineServerObject.ConnectionContext.ConnectTimeout | Should-Be 30
$databaseEngineServerObject.ConnectionContext.StatementTimeout | Should-Be 30
}
}

# Skipping on Linux and macOS because they do not support Windows Authentication.
Expand Down
Loading