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

ADReplicationSiteLink: Add Integration tests, add setting 'options' #509

Merged
merged 32 commits into from
Oct 15, 2019
Merged

ADReplicationSiteLink: Add Integration tests, add setting 'options' #509

merged 32 commits into from
Oct 15, 2019

Conversation

1800Zeta
Copy link
Contributor

@1800Zeta 1800Zeta commented Sep 23, 2019

Pull Request (PR) description

Add integration testing ability. Adds ability to enable options such as Change Notification Replication

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry under the Unreleased section in the CHANGELOG.md.
    Entry should say what was changed, and how that affects users (if applicable).
  • Resource documentation added/updated in resource directory README.md.
  • Resource parameter descriptions added/updated in schema.mof
    and comment-based help.
  • Comment-based help added/updated.
  • Conceptual help topic added/updated (cultureFolder\about_ResourceName.help.txt).
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Resource Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Resource Testing Guidelines.
  • New/changed code adheres to DSC Resource Style Guidelines and Best Practices.

This change is Reviewable

@codecov-io
Copy link

codecov-io commented Sep 23, 2019

Codecov Report

Merging #509 into dev will increase coverage by <1%.
The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff          @@
##            dev   #509    +/-   ##
====================================
+ Coverage    98%    98%   +<1%     
====================================
  Files        23     23            
  Lines      3117   3161    +44     
  Branches     10     10            
====================================
+ Hits       3073   3117    +44     
  Misses       34     34            
  Partials     10     10

@johlju johlju added waiting for author response The pull request is waiting for the author to respond to comments in the pull request. and removed waiting for author response The pull request is waiting for the author to respond to comments in the pull request. labels Sep 24, 2019
@1800Zeta 1800Zeta marked this pull request as ready for review September 27, 2019 10:39
@johlju johlju added the needs review The pull request needs a code review. label Sep 27, 2019
@1800Zeta
Copy link
Contributor Author

1800Zeta commented Oct 7, 2019

Hi @johlju , are you able to review this and #510 at all please? I know there will be a conflict on the changelog.md when one is merged. Thank you

Copy link
Contributor Author

@1800Zeta 1800Zeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 4 of 7 files reviewed, 17 unresolved discussions (waiting on @1800Zeta and @johlju)


CHANGELOG.md, line 116 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
- Changes to ADReplicationSite
  - Added 'Description' attribute parameter ([issue #500](https://github.com/PowerShell/ActiveDirectoryDsc/issues/500)).
  - Added Integration testing ([issue #355](https://github.com/PowerShell/ActiveDirectoryDsc/issues/355)).
  - Correct value returned for RenameDefaultFirstSiteName ([issue #502](https://github.com/PowerShell/ActiveDirectoryDsc/issues/502)).

Should any of these be moved to the Unreleased section?

Done


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 74 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
$Sitelink

$siteLink (lower-case 's', upper-case 'L')

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 76 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
$SiteLinkOptions

$siteLinkOptions (lower-case 's'). Same for the ones below.

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 80 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
        else
        {
            $SiteLinkOptions = Get-EnabledOptions -OptionValue 0
        }

Should we need this if we can pass zero (0) to the parameter? 🤔

If nothing is configured it will return an empty/null value. If everything has been explicitly turned off you get a 0.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 209 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
$replacePraams

Can we use $replaceParameters to not use abbreviations? Throughout.

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 210 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
$clearParams

Can we use $clearParameters to not use abbreviations? Throughout.

Removed as it was no longer needed


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 244 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
$ChangeNotification

$changeNotification Lower-case 'c' . We should use camelCase for local variable namess and PascalCase for parameter variable names. Throughout.

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 273 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
'clear'

Should we have upper-case 'C' here?

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 273 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
'options'

Should we have upper-case 'O' here as the next row have?

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 464 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
OptionsValue

Should be OptionValue (no 's')

Should be without 's' even though the attribute it refers to is 'Options'? (have already switched them to camelCase.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 472 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
# Parameter help description

We can remove this comment.

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 481 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
$returnvalue

$returnValue (upper-case 'V'). Throughout.

Done.

Copy link
Contributor Author

@1800Zeta 1800Zeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 7 files reviewed, 17 unresolved discussions (waiting on @1800Zeta and @johlju)


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 489 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Could we instead do Bitwise AND? 🤔

Assuming $OptionValue contain the value 1-7.

if (1 -band $OptionValue)
{
    $returnvalue.USE_NOTIFY = $true
}

if (2 -band $OptionValue)
{
    $returnvalue.TWOWAY_SYNC = $true
}

if (4 -band $OptionValue)
{
    $returnvalue.DISABLE_COMPRESSION = $true
}

Done.

Copy link
Contributor Author

@1800Zeta 1800Zeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 7 files reviewed, 17 unresolved discussions (waiting on @1800Zeta and @johlju)


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 467 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
Get-EnabledOptions

Can we please add a unit test that test this function separately. Add a separate Describe-block in the unit test for this resource, see example here https://github.com/PowerShell/SqlServerDsc/blob/da8ebe4539018c059bfb6ddbb4cf2bd9ca0ffc9d/Tests/Unit/MSFT_SqlSetup.Tests.ps1#L4077

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 527 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
ConvertTo-EnabledOptions

Can we please add a unit test that test this function separately. Add a separate Describe-block in the unit test for this resource, see example here https://github.com/PowerShell/SqlServerDsc/blob/da8ebe4539018c059bfb6ddbb4cf2bd9ca0ffc9d/Tests/Unit/MSFT_SqlSetup.Tests.ps1#L4077

Done.

Copy link
Contributor Author

@1800Zeta 1800Zeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 8 files reviewed, 17 unresolved discussions (waiting on @1800Zeta and @johlju)


DSCResources/MSFT_ADReplicationSiteLink/en-US/about_ADReplicationSiteLink.help.txt, line 96 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
Configuration ADReplicationSiteLink_ModifyExistingReplicationSiteLink_Config

We should add this as an example to the correct example folder https://github.com/PowerShell/ActiveDirectoryDsc/tree/dev/Examples/Resources/ADReplicationSiteLink.

Then the New-DscResourcePowerShellHelp -$ModulePath . will generate this file correctly (when run manually)
https://github.com/PowerShell/DscResource.Tests/blob/dev/DscResource.DocumentationHelper/PowerShellHelp.psm1#L54

cd /source/ActiveDirectoryDsc
import-module ./DscResource.Tests/DscResource.DocumentationHelper/PowerShellHelp.psm1
New-DscResourcePowerShellHelp -$ModulePath .

Done.

Copy link
Contributor Author

@1800Zeta 1800Zeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 8 files reviewed, 17 unresolved discussions (waiting on @johlju)


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 94 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
            OptionChangeNotification      = $SiteLinkOptions.USE_NOTIFY
            OptionTwoWaySync              = $SiteLinkOptions.TWOWAY_SYNC
            OptionDisableCompression      = $SiteLinkOptions.DISABLE_COMPRESSION

See previous comment.

Done.

Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will verify the integration tests once these comments are resolved. Awesome work! 😃

Reviewed 5 of 5 files at r5.
Reviewable status: 6 of 8 files reviewed, 18 unresolved discussions (waiting on @1800Zeta)


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 74 at r4 (raw file):

Previously, 1800Zeta (Mark Lewis) wrote…

Done.

It looks this was resolved in all other rows but this one (line 74). :)


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 80 at r4 (raw file):

if ($Sitelink.Options -gt 0)

Then I suggest we change this check to be against and empty or null value instead of checking if the value is an integer.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 464 at r4 (raw file):

Previously, 1800Zeta (Mark Lewis) wrote…

Should be without 's' even though the attribute it refers to is 'Options'? (have already switched them to camelCase.

This should be the same as the parameter name.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 252 at r5 (raw file):

$TwoWaySync

We should use camelCase for local variable namess and PascalCase for parameter variable names. Throughout.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 261 at r5 (raw file):

$DisableCompression

We should use camelCase for local variable namess and PascalCase for parameter variable names. Throughout.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 475 at r5 (raw file):

$optionValue

$OptionValue. We should use PascalCase for parameter variable names.


DSCResources/MSFT_ADReplicationSiteLink/en-US/about_ADReplicationSiteLink.help.txt, line 96 at r5 (raw file):

ADReplicationSiteLink_EnableReplicationSiteLinkOptions_Config

This does not match the new example actual name. Did you run the cmdlet mentioned in previous review comment? 🤔


Examples/Resources/ADReplicationSiteLink/3-ADReplicationSiteLink_EnableOptions_Config.ps1, line 3 at r5 (raw file):

cd618e81-b903-4ae9-9dd0-ab794931505c

Please update the GUID with the output from New-Guid


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 262 at r5 (raw file):

It 'Should return $false with OptionChangeNotification $true is non compliant' {

Can we also test where it returns $true for each property?


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 334 at r5 (raw file):

;

Please remove the semi-colons in the hashtable.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 338 at r5 (raw file):

} }

Please move the closing braces to each separate rows.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 379 at r5 (raw file):

;

Please remove the semi-colons in the hashtable.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 383 at r5 (raw file):

} }

Please move the closing braces to each separate rows.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 406 at r5 (raw file):

Describe 'ADReplicationSiteLink\Get-EnabledOptions' {

Can we add a new line before this row?


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 408 at r5 (raw file):

"Should Return False False False"

Maybe we can say something like 'Should return the correct values in the hashtable'. Throughout.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 408 at r5 (raw file):

"Should Return False False False"

We should use single-quote around strings where we can'.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 490 at r5 (raw file):

It "Should return 0"{

Space before the open brace. Throughout below.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 501 at r5 (raw file):

Context 'When Change Notification Replication is enabled' {

Can we add a blank line before this row?

Copy link
Contributor Author

@1800Zeta 1800Zeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 of 8 files reviewed, 18 unresolved discussions (waiting on @1800Zeta and @johlju)


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 464 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

This should be the same as the parameter name.

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 252 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
$TwoWaySync

We should use camelCase for local variable namess and PascalCase for parameter variable names. Throughout.

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 261 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
$DisableCompression

We should use camelCase for local variable namess and PascalCase for parameter variable names. Throughout.

Done.


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 475 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
$optionValue

$OptionValue. We should use PascalCase for parameter variable names.

Done.


DSCResources/MSFT_ADReplicationSiteLink/en-US/about_ADReplicationSiteLink.help.txt, line 96 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
ADReplicationSiteLink_EnableReplicationSiteLinkOptions_Config

This does not match the new example actual name. Did you run the cmdlet mentioned in previous review comment? 🤔

Done.


Examples/Resources/ADReplicationSiteLink/3-ADReplicationSiteLink_EnableOptions_Config.ps1, line 3 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
cd618e81-b903-4ae9-9dd0-ab794931505c

Please update the GUID with the output from New-Guid

Done.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 334 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
;

Please remove the semi-colons in the hashtable.

Done.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 338 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
} }

Please move the closing braces to each separate rows.

Done.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 379 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
;

Please remove the semi-colons in the hashtable.

Done.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 383 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
} }

Please move the closing braces to each separate rows.

Done.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 406 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
Describe 'ADReplicationSiteLink\Get-EnabledOptions' {

Can we add a new line before this row?

Done


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 408 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
"Should Return False False False"

Maybe we can say something like 'Should return the correct values in the hashtable'. Throughout.

Done


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 408 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
"Should Return False False False"

We should use single-quote around strings where we can'.

Done.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 490 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
It "Should return 0"{

Space before the open brace. Throughout below.

Done.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 501 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
Context 'When Change Notification Replication is enabled' {

Can we add a blank line before this row?

Done.

Copy link
Contributor Author

@1800Zeta 1800Zeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 8 files reviewed, 18 unresolved discussions (waiting on @johlju)


DSCResources/MSFT_ADReplicationSiteLink/MSFT_ADReplicationSiteLink.psm1, line 80 at r4 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
if ($Sitelink.Options -gt 0)

Then I suggest we change this check to be against and empty or null value instead of checking if the value is an integer.

Done.


Tests/Unit/MSFT_ADReplicationSiteLink.tests.ps1, line 262 at r5 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
It 'Should return $false with OptionChangeNotification $true is non compliant' {

Can we also test where it returns $true for each property?

This is tested on line 200. Where in the desired state it tests all 3 properties.

Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will run the integration test in by lab to verify them. But they look perfect. 😃 I will get back to you tomorrow.

Reviewed 4 of 4 files at r6.
Reviewable status: 6 of 8 files reviewed, all discussions resolved

@johlju johlju added needs review The pull request needs a code review. and removed waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. labels Oct 14, 2019
Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 7 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@johlju johlju added ready for merge The pull request was approved by the community and is ready to be merged by a maintainer. and removed needs review The pull request needs a code review. labels Oct 15, 2019
@johlju johlju changed the title ADReplicationSiteLink Add Integration tests, add setting 'options' ADReplicationSiteLink: Add Integration tests, add setting 'options' Oct 15, 2019
@johlju johlju merged commit c3c93ba into dsccommunity:dev Oct 15, 2019
@johlju johlju removed the ready for merge The pull request was approved by the community and is ready to be merged by a maintainer. label Oct 15, 2019
@johlju
Copy link
Member

johlju commented Oct 15, 2019

@1800Zeta Thank you for this! The integration tests worked perfectly! 😃

@1800Zeta
Copy link
Contributor Author

Thank you so much @johlju

@1800Zeta 1800Zeta deleted the ADReplicationSiteLink branch October 15, 2019 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants