-
Notifications
You must be signed in to change notification settings - Fork 141
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
Conversation
Unit tests also added
Tests for add, remove, rename default sites. Restores at the end back to default settings.
increase codecov score
Also had to tweak unit tests for updated logic
Integration Test completed before adding config
Options now being set to enable Change Notification Replication. Unit and Integration tests all completed.
Codecov Report
@@ 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 |
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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#L54cd /source/ActiveDirectoryDsc import-module ./DscResource.Tests/DscResource.DocumentationHelper/PowerShellHelp.psm1 New-DscResourcePowerShellHelp -$ModulePath .
Done.
There was a problem hiding this 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.
There was a problem hiding this 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?
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 7 files at r3.
Reviewable status: complete! all files reviewed, all discussions resolved
@1800Zeta Thank you for this! The integration tests worked perfectly! 😃 |
Thank you so much @johlju |
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
Entry should say what was changed, and how that affects users (if applicable).
and comment-based help.
This change is