Skip to content

Commit

Permalink
SqlAgListener: Fix v6 IPs failing Test-TargetResource (#1444)
Browse files Browse the repository at this point in the history
- SqlAgListener
  - Fix IPv6 addresses failing Test-TargetResource after listener creation.
  • Loading branch information
Michael Linback Jr authored and johlju committed Jan 17, 2020
1 parent 02a766a commit 3c2524e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md)
- SqlAlwaysOnService
- When failing to enable AlwaysOn the resource should now fail with an
error ([issue #1190](https://github.com/dsccommunity/SqlServerDsc/issues/1190)).
- SqlAgListener
- Fix IPv6 addresses failing Test-TargetResource after listener creation.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ function Get-TargetResource
$ipAddress = @()
foreach ($currentIpAddress in $presentIpAddress)
{
$ipAddress += "$($currentIpAddress.IPAddress)/$($currentIpAddress.SubnetMask)"
if ($currentIpAddress.SubnetMask)
{
$ipAddress += "$($currentIpAddress.IPAddress)/$($currentIpAddress.SubnetMask)"
}
else
{
$ipAddress += "$($currentIpAddress.IPAddress)"
}
}
}
else
Expand Down
9 changes: 7 additions & 2 deletions tests/Unit/MSFT_SqlAGListener.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,19 @@ try
Add-Member -MemberType NoteProperty -Name IsDHCP -Value $false -PassThru |
Add-Member -MemberType NoteProperty -Name IPAddress -Value '192.168.0.1' -PassThru |
Add-Member -MemberType NoteProperty -Name SubnetMask -Value '255.255.255.0' -PassThru
),
# TypeName: Microsoft.SqlServer.Management.Smo.AvailabilityGroupListenerIPAddressCollection
(New-Object -TypeName Object | # TypeName: Microsoft.SqlServer.Management.Smo.AvailabilityGroupListenerIPAddress
Add-Member -MemberType NoteProperty -Name IsDHCP -Value $false -PassThru |
Add-Member -MemberType NoteProperty -Name IPAddress -Value 'f00::ba12' -PassThru
)
)
} -PassThru -Force
} -Verifiable

It 'Should return that desired state is present when wanted desired state is to be Present, without DHCP' {
$testParameters['Ensure'] = 'Present'
$testParameters['IpAddress'] = '192.168.0.1/255.255.255.0'
$testParameters['IpAddress'] = @('192.168.0.1/255.255.255.0', 'f00::ba12')
$testParameters['Port'] = 5030
$testParameters['DHCP'] = $false

Expand All @@ -453,7 +458,7 @@ try
}

It 'Should return that desired state is present when IP address is the only set parameter' {
$testParameters['IpAddress'] = '192.168.0.1/255.255.255.0'
$testParameters['IpAddress'] = @('192.168.0.1/255.255.255.0', 'f00::ba12')

$result = Test-TargetResource @testParameters
$result | Should -Be $true
Expand Down

0 comments on commit 3c2524e

Please sign in to comment.