Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test-DscDnsParameterState: Move enhancements to Test-DscParameterState in module DscResource.Common #121

Open
johlju opened this issue Mar 4, 2020 · 5 comments
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.

Comments

@johlju
Copy link
Member

johlju commented Mar 4, 2020

The function Test-DscDnsParameterState is enhanced with additional parameters compared to the function Test-DscParameterState that is available in the module DscResource.Common.
These enhancements should be merged into the function in DscResource.Common so we can remove the duplicate code in this module.

This was discovered when converting this module to the new CI pipeline.

@johlju johlju added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. labels Mar 4, 2020
@gaelcolas
Copy link
Member

Tagging @raandree on that one...

@johlju johlju added in progress The issue is being actively worked on by someone. help wanted The issue is up for grabs for anyone in the community. and removed help wanted The issue is up for grabs for anyone in the community. in progress The issue is being actively worked on by someone. labels Feb 14, 2021
@johlju
Copy link
Member Author

johlju commented Feb 14, 2021

I tried to move this over to Test-DscParameterState in the module DscResource.Common, but the unit tests for xDnsServerRootHint fail - Test-DscParameterState returns true even if should return false. It looks like something is going on in the reverse check because it works when removing the parameter ReverseCheck though in this instance that parameter is important.

After 3 hours of debugging I'm no closer to a solution - Test-DscParameterState works from command line when I try to reproduce the problem - or more correctly I don't find the correct repro case.

@johlju
Copy link
Member Author

johlju commented Feb 14, 2021

This test fails:

https://github.com/dsccommunity/xDnsServer/blob/9d4f3ef34f7e1d2722594462256b2c60f0578e05/tests/Unit/MSFT_xDnsServerRootHint.Tests.ps1#L111-L114

I changed this row to Test-DscParameterState but then it always return $true:

https://github.com/dsccommunity/xDnsServer/blob/9d4f3ef34f7e1d2722594462256b2c60f0578e05/source/DSCResources/MSFT_xDnsServerRootHint/MSFT_xDnsServerRootHint.psm1#L121

Actually if I add these two rows without the parameter ReverseCheck then the variable $resultReverse will be $true even if both $result and $resultReverse should be $false. Both compares against an empty hashtable that is passed in $currentState for the key NameServers.

$result = Test-DscParameterState -CurrentValues $currentState -DesiredValues $desiredState -TurnOffTypeChecking
$resultReverse = Test-DscParameterState -CurrentValues $desiredState -DesiredValues $currentState -TurnOffTypeChecking

@johlju
Copy link
Member Author

johlju commented Feb 14, 2021

The problem is Compare-DscParameterState. The closest I got to a repro case is the below code which does not return a hashtable but $null from Compare-DscParameterState.

 $nameServers = [Microsoft.Management.Infrastructure.CimInstance[]] @(
    New-CimInstance -ClassName 'MSFT_KeyValuePair' -Namespace 'root/microsoft/Windows/DesiredStateConfiguration' -Property @{
        Key   = 'B.ROOT-SERVERS.NET.'
        Value = '199.9.14.201'
    } -ClientOnly

    New-CimInstance -ClassName 'MSFT_KeyValuePair' -Namespace 'root/microsoft/Windows/DesiredStateConfiguration' -Property @{
        Key   = 'M.ROOT-SERVERS.NET.'
        Value = '202.12.27.33'
    } -ClientOnly
 )

Compare-DscParameterState -CurrentValues @{
    IsSingleInstance = 'Yes'
    NameServer = @()
} -DesiredValues @{
    NameServers = $nameServers
    IsSingleInstance = 'Yes'
    Verbose = $true
} -TurnOffTypeChecking -ReverseCheck

@johlju
Copy link
Member Author

johlju commented Feb 14, 2021

Submitted a bug in issue dsccommunity/DscResource.Common#65

@johlju johlju changed the title Test-DscDnsParameterState: Move enhancements to Test-DscParameterState in module DscResource.Common Test-DscDnsParameterState: Move enhancements to Test-DscParameterState in module DscResource.Common Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

2 participants