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

DFSReplicationGroup - update PrimaryMember to write-only but not test #138

Merged
merged 8 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- DFSReplicationGroupMembership
- Make PrimaryMember write-only when testing resources - fixes [Issue #58](https://github.com/dsccommunity/DFSDsc/issues/58).

## [5.1.0] - 2024-03-02

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function Get-TargetResource
.PARAMETER PrimaryMember
Used to configure this as the Primary Member. Every folder must
have at least one primary member for initial replication to take
place.
place. Only set during initial creation of membership.

.PARAMETER DfsnPath
Specify the DFS Namespace folder path of the membership. This value does not affect replication.
Expand Down Expand Up @@ -307,7 +307,7 @@ function Set-TargetResource
.PARAMETER PrimaryMember
Used to configure this as the Primary Member. Every folder must
have at least one primary member for initial replication to take
place.
place. Only set during initial creation of membership.

.PARAMETER DfsnPath
Specify the DFS Namespace folder path of the membership. This value does not affect replication.
Expand Down Expand Up @@ -534,7 +534,10 @@ function Test-TargetResource
-f $GroupName,$FolderName,$ComputerName
) -join '' )

$desiredConfigurationMatch = $false
<#
See https://techcommunity.microsoft.com/t5/storage-at-microsoft/the-primary-member-in-dfs-replication/ba-p/423127
Do not flag as a change required as flag is cleared after initial sync
#>
} # if

# Check the DfsnPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DSC_DFSReplicationGroupMembership : OMI_BaseResource
[Write, Description("The local conflict and deleted path quota size in MB.")] UInt32 ConflictAndDeletedQuotaInMB;
[Write, Description("Specify if this content path should be read only.")] Boolean ReadOnly;
[Write, Description("Specify if a member computer deletes files and folders immediately following inbound replication.")] Boolean RemoveDeletedFiles;
[Write, Description("Used to configure this as the Primary Member. Every folder must have at least one primary member for initial replication to take place.")] Boolean PrimaryMember;
[Write, Description("Used to configure this as the Primary Member. Every folder must have at least one primary member for initial replication to take place. Only set during initial creation of membership.")] Boolean PrimaryMember;
[Write, Description("Specify the DFS Namespace folder path of the membership. This value does not affect replication.")] String DfsnPath;
[Write, Description("The name of the AD Domain the DFS Replication Group this replication group is in.")] String DomainName;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ usually used to set the **ContentPath** for each Replication Group folder on eac
Member computer. It can also be used to set additional properties of the Membership.
This resource shouldn't be used for folders where the Content Path is set in the
DFSReplicationGroup.

> Note: The PrimaryMember flag is automatically cleared by DFS once an initial
> replication sync takes place, so is not tested by this resource.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ ConvertFrom-StringData @'
ReplicationGroupMembershipConflictAndDeletedMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect ConflictAndDeletedQuotaInMB. Change required.
ReplicationGroupMembershipReadOnlyMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect ReadOnly. Change required.
ReplicationGroupMembershipRemoveDeletedFilesMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect RemoveDeletedFiles. Change required.
ReplicationGroupMembershipPrimaryMemberMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect PrimaryMember. Change required.
ReplicationGroupMembershipPrimaryMemberMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect PrimaryMember. Ignoring as flag clears after initial sync.
ReplicationGroupMembershipDfsnPathMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect DfsnPath. Change required.
'@
5 changes: 3 additions & 2 deletions tests/Unit/DSC_DFSReplicationGroupMembership.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,12 @@ try
Context 'Replication group membership exists but has different PrimaryMember' {
Mock Get-DfsrMembership -MockWith { return @($mockReplicationGroupMembership) }

It 'Should return false' {
# Return *true* - should not flag as changed required as cleared after initial sync
It 'Should return true' {
$splat = $replicationGroupMemberships[0].Clone()
$splat.Remove('ConflictAndDeletedPath')
$splat.PrimaryMember = (-not $splat.PrimaryMember)
Test-TargetResource @splat | Should -BeFalse
Test-TargetResource @splat | Should -BeTrue
}

It 'Should call expected Mocks' {
Expand Down