Skip to content

Commit

Permalink
SqlAG: unit tests converted to Pester 5 (#1987)
Browse files Browse the repository at this point in the history
- SqlAGReplica
  - Fix unit test FailedRemoveAvailabilityGroupReplica
- SqlAG
  - Converted unit test to Pester 5
  - DtcSupportEnabled option in Set-TargetResource and TestTargetResource
  • Loading branch information
Sidoran authored Dec 15, 2023
1 parent 22b25f6 commit a9f8f26
Show file tree
Hide file tree
Showing 4 changed files with 1,360 additions and 1,192 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix sort to get the latest version
- `Assert-Feature`
- Fixed unit tests.
- SqlAGReplica
- Fix unit test FailedRemoveAvailabilityGroupReplica

### Changed

- SqlAG
- Converted unit test to Pester 5
- DtcSupportEnabled option in Set-TargetResource and TestTargetResource
- SqlServerDsc
- Bump PSResourceGet to v1.0.0 (used when resolving dependencies).
- Update markdown highlights with newly supported keywords.
Expand Down
8 changes: 7 additions & 1 deletion source/DSCResources/DSC_SqlAG/DSC_SqlAG.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ function Set-TargetResource
Update-AvailabilityGroup -AvailabilityGroup $availabilityGroup
}

if ( ( $submittedParameters -contains 'DtcSupportEnabled' ) -and ( $sqlMajorVersion -ge 13 ) -and ( $DtcSupportEnabled -ne $availabilityGroup.DtcSupportEnabled ) )
{
$availabilityGroup.DtcSupportEnabled = $DtcSupportEnabled
Update-AvailabilityGroup -AvailabilityGroup $availabilityGroup
}

# Make sure ConnectionModeInPrimaryRole has a value in order to avoid false positive matches when the parameter is not defined
if ( ( $submittedParameters -contains 'ConnectionModeInPrimaryRole' ) -and ( -not [System.String]::IsNullOrEmpty($ConnectionModeInPrimaryRole) ) -and ( $ConnectionModeInPrimaryRole -ne $availabilityGroup.AvailabilityReplicas[$serverObject.DomainInstanceName].ConnectionModeInPrimaryRole ) )
{
Expand Down Expand Up @@ -746,13 +752,13 @@ function Test-TargetResource

<#
Add properties compatible with SQL Server 2016 or later versions
DtcSupportEnabled is enabled at the creation of the Availability Group only, hence it will not be checked in this block
SeedingMode should be checked only in case if New-SqlAvailabilityReplica support the SeedingMode parameter
#>
if ( $sqlMajorVersion -ge 13 )
{
$parametersToCheck += 'BasicAvailabilityGroup'
$parametersToCheck += 'DatabaseHealthTrigger'
$parametersToCheck += 'DtcSupportEnabled'
if ( $getTargetResourceResult.SeedingMode )
{
$parametersToCheck += 'SeedingMode'
Expand Down
Loading

0 comments on commit a9f8f26

Please sign in to comment.