Skip to content

Commit f5e17c4

Browse files
authored
Test updates for new resource base (#311)
1 parent 818ed0a commit f5e17c4

File tree

63 files changed

+2042
-808
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2042
-808
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Added new resource
1414
- _DnsRecordTxt_ - resource to manage DNS TXT records ([issue #150](https://github.com/dsccommunity/DnsServerDsc/issues/150)).
1515
- _DnsRecordTxtScoped_ - resource to manage DNS TXT records ([issue #296](https://github.com/dsccommunity/DnsServerDsc/issues/296)).
16+
- build.yml
17+
- Added config for merge task.
1618

1719
### Fixed
1820

1921
- DnsServerSetting
2022
- Set-TargetResource was not correctly retrieving current settings from remote computers.
2123
- Updated comment based help for various settings to include allowed values in decimal.
24+
- Tests
25+
- Remove use of -TestCases and replace with -ForEach.
26+
- Update tests for class-based resources which use DscResource.Base.
27+
- DnsServerCache
28+
- Cast properties which were timestamps to strings.
29+
- DnsServerDsSetting
30+
- Cast properties which were timestamps to strings.
31+
- DnsServerEDns
32+
- Cast properties which were timestamps to strings.
33+
- DnsServerScavenging
34+
- Cast properties which were timestamps to strings.
2235

2336
### Changed
2437

2538
- DnsServerSetting
2639
- Allow MaximumUdpPacketSize to be read/write. Fixes [issue #307](https://github.com/dsccommunity/DnsServerDsc/issues/307).
2740
- Add input validation to RemoteIPv4RankBoost, RemoteIPv6RankBoost, MaximumRodcRsoQueueLength,
2841
MaximumRodcRsoAttemptsPerCycle, TcpReceivePacketSize, MaximumUdpPacketSize.
42+
- Pipelines
43+
- Used matrix strategy to test OSes.
44+
- Integration tests
45+
- Updated file name casing.
46+
47+
### Removed
48+
49+
- Ensure Enum
50+
- This is provided by DscResource.Base.
51+
- build.psd1
2952

3053
## [3.0.1] - 2025-08-28
3154

tests/Integration/Classes/DnsRecordA.integration.tests.ps1 renamed to Tests/Integration/Classes/DnsRecordA.Integration.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BeforeDiscovery {
1111
if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable))
1212
{
1313
# Redirect all streams to $null, except the error stream (stream 2)
14-
& "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
14+
& "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
1515
}
1616

1717
# If the dependencies has not been resolved, this will throw an error.

tests/Integration/Classes/DnsRecordAScoped.integration.tests.ps1 renamed to Tests/Integration/Classes/DnsRecordAScoped.Integration.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BeforeDiscovery {
1111
if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable))
1212
{
1313
# Redirect all streams to $null, except the error stream (stream 2)
14-
& "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
14+
& "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
1515
}
1616

1717
# If the dependencies has not been resolved, this will throw an error.

tests/Integration/Classes/DnsRecordAaaa.integration.tests.ps1 renamed to Tests/Integration/Classes/DnsRecordAaaa.Integration.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BeforeDiscovery {
1111
if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable))
1212
{
1313
# Redirect all streams to $null, except the error stream (stream 2)
14-
& "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
14+
& "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
1515
}
1616

1717
# If the dependencies has not been resolved, this will throw an error.

tests/Integration/Classes/DnsRecordAaaaScoped.integration.tests.ps1 renamed to Tests/Integration/Classes/DnsRecordAaaaScoped.Integration.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BeforeDiscovery {
1111
if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable))
1212
{
1313
# Redirect all streams to $null, except the error stream (stream 2)
14-
& "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
14+
& "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
1515
}
1616

1717
# If the dependencies has not been resolved, this will throw an error.

azure-pipelines.yml

Lines changed: 92 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
trigger:
22
branches:
33
include:
4-
- main
4+
- main
55
paths:
66
include:
7-
- source/*
7+
- source/*
88
tags:
99
include:
10-
- "v*"
10+
- 'v*'
1111
exclude:
12-
- "*-*"
12+
- '*-*'
1313
variables:
1414
buildFolderName: output
1515
buildArtifactName: output
1616
testResultFolderName: testResults
1717
testArtifactName: testResults
18+
sourceFolderName: source
1819

1920
stages:
2021
- stage: Build
@@ -33,6 +34,7 @@ stages:
3334
}
3435
Write-Host -Object "##vso[build.updatebuildnumber]$($gitVersionObject.FullSemVer)"
3536
displayName: Calculate ModuleVersion (GitVersion)
37+
3638
- task: PowerShell@2
3739
name: package
3840
displayName: 'Build & Package Module'
@@ -42,6 +44,7 @@ stages:
4244
pwsh: true
4345
env:
4446
ModuleVersion: $(NuGetVersionV2)
47+
4548
- task: PublishPipelineArtifact@1
4649
displayName: 'Publish Build Artifact'
4750
inputs:
@@ -50,28 +53,31 @@ stages:
5053
publishLocation: 'pipeline'
5154
parallel: true
5255

53-
- stage: Test
56+
- stage: Quality_Test_and_Unit_Test
57+
displayName: 'Quality Test and Unit Test'
5458
dependsOn: Build
5559
jobs:
5660
- job: Test_HQRM
5761
displayName: 'HQRM'
5862
pool:
5963
vmImage: 'windows-latest'
60-
timeoutInMinutes: 0
64+
timeoutInMinutes: '0'
6165
steps:
6266
- task: DownloadPipelineArtifact@2
6367
displayName: 'Download Build Artifact'
6468
inputs:
6569
buildType: 'current'
6670
artifactName: $(buildArtifactName)
6771
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
72+
6873
- task: PowerShell@2
6974
name: test
7075
displayName: 'Run HQRM Test'
7176
inputs:
7277
filePath: './build.ps1'
7378
arguments: '-Tasks hqrmtest'
7479
pwsh: false
80+
7581
- task: PublishTestResults@2
7682
displayName: 'Publish Test Results'
7783
condition: succeededOrFailed()
@@ -82,112 +88,143 @@ stages:
8288

8389
- job: Test_Unit
8490
displayName: 'Unit'
91+
strategy:
92+
matrix:
93+
Windows Server 2022:
94+
vmImage: 'windows-2022'
95+
Windows Server 2025:
96+
vmImage: 'windows-2025'
8597
pool:
86-
vmImage: 'windows-latest'
87-
timeoutInMinutes: 0
98+
vmImage: $(vmImage)
99+
timeoutInMinutes: '0'
88100
steps:
89101
- task: DownloadPipelineArtifact@2
90102
displayName: 'Download Build Artifact'
91103
inputs:
92104
buildType: 'current'
93105
artifactName: $(buildArtifactName)
94106
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
107+
95108
- task: PowerShell@2
96109
name: test
97110
displayName: 'Run Unit Test'
98111
inputs:
99112
filePath: './build.ps1'
100113
arguments: "-Tasks test -PesterScript 'tests/Unit'"
101114
pwsh: true
115+
102116
- task: PublishTestResults@2
103117
displayName: 'Publish Test Results'
104118
condition: succeededOrFailed()
105119
inputs:
106120
testResultsFormat: 'NUnit'
107121
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
108-
testRunTitle: 'Unit'
122+
testRunTitle: 'Unit $(vmImage)'
123+
109124
- task: PublishPipelineArtifact@1
110125
displayName: 'Publish Test Artifact'
111126
inputs:
112127
targetPath: '$(buildFolderName)/$(testResultFolderName)/'
113-
artifactName: $(testArtifactName)
114-
parallel: true
128+
artifactName: '$(testArtifactName)_$(vmImage)'
129+
130+
- job: Code_Coverage
131+
displayName: 'Publish Code Coverage'
132+
dependsOn: Test_Unit
133+
pool:
134+
vmImage: 'ubuntu-latest'
135+
timeoutInMinutes: '0'
136+
steps:
137+
- task: DownloadPipelineArtifact@2
138+
displayName: 'Download Build Artifact'
139+
inputs:
140+
buildType: 'current'
141+
artifactName: $(buildArtifactName)
142+
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
143+
144+
- task: DownloadPipelineArtifact@2
145+
displayName: 'Download Test Artifact'
146+
inputs:
147+
buildType: 'current'
148+
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)'
149+
itemPattern: '$(testArtifactName)_*/**'
150+
151+
- task: PowerShell@2
152+
name: merge
153+
displayName: 'Merge Code Coverage files'
154+
inputs:
155+
filePath: './build.ps1'
156+
arguments: '-tasks merge'
157+
pwsh: true
158+
159+
- task: PublishCodeCoverageResults@2
160+
displayName: 'Publish Code Coverage to Azure DevOps'
161+
inputs:
162+
summaryFileLocation: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml'
163+
pathToSources: '$(Build.SourcesDirectory)/$(sourceFolderName)/'
164+
165+
- script: |
166+
bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml"
167+
displayName: 'Upload to Codecov.io'
115168
169+
- stage: Integration_Test
170+
displayName: 'Integration Test'
171+
dependsOn: Quality_Test_and_Unit_Test
172+
jobs:
116173
- job: Test_Integration
117174
displayName: 'Integration'
175+
strategy:
176+
matrix:
177+
Windows Server 2022:
178+
vmImage: 'windows-2022'
179+
Windows Server 2025:
180+
vmImage: 'windows-2025'
118181
pool:
119-
vmImage: 'windows-latest'
120-
timeoutInMinutes: 0
182+
vmImage: $(vmImage)
183+
timeoutInMinutes: '0'
121184
steps:
122185
- task: DownloadPipelineArtifact@2
123186
displayName: 'Download Build Artifact'
124187
inputs:
125188
buildType: 'current'
126189
artifactName: $(buildArtifactName)
127190
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
191+
128192
- task: PowerShell@2
129193
name: configureWinRM
130194
displayName: 'Configure WinRM'
131195
inputs:
132196
targetType: 'inline'
133197
script: 'winrm quickconfig -quiet'
134198
pwsh: false
135-
- powershell: |
136-
Install-WindowsFeature -Name DNS
137-
name: InstallDNSRole
199+
200+
- task: PowerShell@2
201+
name: installDNS
138202
displayName: 'Install DNS role'
203+
inputs:
204+
targetType: 'inline'
205+
script: 'Install-WindowsFeature -Name DNS'
206+
pwsh: false
207+
139208
- task: PowerShell@2
140209
name: test
141210
displayName: 'Run Integration Test'
142211
inputs:
143212
filePath: './build.ps1'
144213
arguments: "-Tasks test -CodeCoverageThreshold 0 -PesterScript 'tests/Integration'"
145214
pwsh: false
215+
146216
- task: PublishTestResults@2
147217
displayName: 'Publish Test Results'
148218
condition: succeededOrFailed()
149219
inputs:
150220
testResultsFormat: 'NUnit'
151221
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
152-
testRunTitle: 'Integration'
153-
154-
- job: Code_Coverage
155-
displayName: 'Publish Code Coverage'
156-
dependsOn: Test_Unit
157-
pool:
158-
vmImage: 'ubuntu-latest'
159-
timeoutInMinutes: 0
160-
steps:
161-
- pwsh: |
162-
$repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/'
163-
echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner"
164-
echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName"
165-
name: dscBuildVariable
166-
displayName: 'Set Environment Variables'
167-
- task: DownloadPipelineArtifact@2
168-
displayName: 'Download Build Artifact'
169-
inputs:
170-
buildType: 'current'
171-
artifactName: $(buildArtifactName)
172-
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
173-
- task: DownloadPipelineArtifact@2
174-
displayName: 'Download Test Artifact'
175-
inputs:
176-
buildType: 'current'
177-
artifactName: $(testArtifactName)
178-
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)'
179-
- task: PublishCodeCoverageResults@1
180-
displayName: 'Publish Azure Code Coverage'
181-
inputs:
182-
codeCoverageTool: 'JaCoCo'
183-
summaryFileLocation: '$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml'
184-
pathToSources: '$(Build.SourcesDirectory)/source/'
185-
- script: |
186-
bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml"
187-
displayName: 'Upload to Codecov.io'
222+
testRunTitle: 'Integration $(vmImage)'
188223

189224
- stage: Deploy
190-
dependsOn: Test
225+
dependsOn:
226+
- Quality_Test_and_Unit_Test
227+
- Integration_Test
191228
condition: |
192229
and(
193230
succeeded(),
@@ -209,6 +246,7 @@ stages:
209246
buildType: 'current'
210247
artifactName: $(buildArtifactName)
211248
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
249+
212250
- task: PowerShell@2
213251
name: publishRelease
214252
displayName: 'Publish Release'
@@ -221,6 +259,7 @@ stages:
221259
GalleryApiToken: $(GalleryApiToken)
222260
ReleaseBranch: main
223261
MainGitBranch: main
262+
224263
- task: PowerShell@2
225264
name: sendChangelogPR
226265
displayName: 'Send Changelog PR'

build.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ BuildWorkflow:
3333
- Convert_Pester_Coverage
3434
- Pester_if_Code_Coverage_Under_Threshold
3535

36+
merge:
37+
- Merge_CodeCoverage_Files
38+
3639
publish:
3740
- Publish_Module_To_gallery
3841
- Publish_Release_To_GitHub
@@ -98,8 +101,7 @@ Pester:
98101
StackTraceVerbosity: Full
99102
CIFormat: Auto
100103
CodeCoverage:
101-
CoveragePercentTarget: 80
102-
OutputPath: JaCoCo_coverage.xml
104+
CoveragePercentTarget: 85
103105
OutputEncoding: ascii
104106
UseBreakpoints: false
105107
TestResult:
@@ -109,6 +111,16 @@ Pester:
109111
- Modules/DscResource.Common
110112
- Modules/DscResource.Base
111113

114+
####################################################
115+
# Code Coverage Configuration #
116+
####################################################
117+
CodeCoverage:
118+
# Filename of the file that will be outputted by the task Merge_CodeCoverage_Files.
119+
CodeCoverageMergedOutputFile: JaCoCo_coverage.xml
120+
# File pattern used to search for files under the ./output/testResults folder
121+
# by task Merge_CodeCoverage_Files.
122+
CodeCoverageFilePattern: Codecov*.xml
123+
112124
####################################################
113125
# Pester Configuration (DscResource.Test) #
114126
####################################################

0 commit comments

Comments
 (0)