Skip to content

Commit

Permalink
DFSReplicationGroup - update PrimaryMember to write-only but not test (
Browse files Browse the repository at this point in the history
…#138)

* Do not test PrimaryMember

* Update description for PrimaryMember

* Update PrimaryMember mismatch message

* Update PrimaryMember unit test

* Update CHANGELOG.md

* Update README.md

* Update style

* Style tweaks
  • Loading branch information
Borgquite authored Apr 18, 2024
1 parent 71e33c4 commit 7f1a53d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
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

0 comments on commit 7f1a53d

Please sign in to comment.