Skip to content

Commit

Permalink
Added TestReferenceRsop task
Browse files Browse the repository at this point in the history
  • Loading branch information
raandree committed Apr 4, 2023
1 parent a7fe698 commit 77431de
Show file tree
Hide file tree
Showing 10 changed files with 673 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .build/TestReferenceRsop.build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
param
(
[Parameter()]
# Base directory of all output (default to 'output')
[System.String]
$OutputDirectory = (property OutputDirectory (Join-Path $BuildRoot 'output')),

[Parameter()]
[System.Object[]]
$PesterScript = (property PesterScript 'tests'),

[Parameter()]
[System.Object[]]
$ReferencePesterScript = (property ReferencePesterScript 'ReferenceFiles'),

[Parameter()]
[string[]]
$excludeTag = (property excludeTag @()),

[Parameter()]
[int]
$CurrentJobNumber = (property CurrentJobNumber 1),

[Parameter()]
[int]
$TotalJobCount = (property TotalJobCount 1),

# Build Configuration object
[Parameter()]
[System.Collections.Hashtable]
$BuildInfo = (property BuildInfo @{ })
)

task TestReferenceRsop -if ((Get-FilteredConfigurationData -Datum $datum -Filter { $_.Name -like 'ReferenceConfiguration*' } -ErrorAction SilentlyContinue).AllNodes) {

$PesterOutputFolder = Get-SamplerAbsolutePath -Path $PesterOutputFolder -RelativeTo $OutputDirectory
"`tPester Output Folder = '$PesterOutputFolder"
if (-not (Test-Path -Path $PesterOutputFolder))
{
Write-Build -Color 'Yellow' -Text "Creating folder $PesterOutputFolder"

$null = New-Item -Path $PesterOutputFolder -ItemType 'Directory' -Force -ErrorAction 'Stop'
}

$ReferencePesterScript = $ReferencePesterScript.Foreach({
Get-SamplerAbsolutePath -Path $_ -RelativeTo $PesterScript[0]
})

Write-Build Green "ReferenceRsop Data Pester Scripts = [$($ReferencePesterScript -join ';')]"

if (-not (Test-Path -Path $ReferencePesterScript))
{
Write-Build Yellow "Path for tests '$ReferencePesterScript' does not exist"
return
}

$testResultsPath = Get-SamplerAbsolutePath -Path ReferenceTestResults.xml -RelativeTo $PesterOutputFolder

Write-Build DarkGray "TestResultsPath is: $testResultsPath"
Write-Build DarkGray "BuildOutput is: $OutputDirectory"

Import-Module -Name Pester
$po = New-PesterConfiguration
$po.Run.PassThru = $true
$po.Run.Path = [string[]]$ReferencePesterScript
$po.Output.Verbosity = 'Detailed'
if ($excludeTag)
{
$po.Filter.ExcludeTag = $excludeTag
}
$po.Filter.Tag = 'ReferenceFiles'
$po.TestResult.Enabled = $true
$po.TestResult.OutputFormat = 'NUnitXml'
$po.TestResult.OutputPath = $testResultsPath
$testResults = Invoke-Pester -Configuration $po

assert ($testResults.FailedCount -eq 0 -and $testResults.FailedBlocksCount -eq 0 -and $testResults.FailedContainersCount -eq 0)

}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Pipeline YAMLs updated to configure unshallow fetch (Fixes issues with GitVersion).
- Added task `Set_PSModulePath` which required adding also `Build_Module_ModuleBuilder`
and a `DscWorkshop.psm1` dummy file.
- Added `TestReferenceRsop` task.
1 change: 1 addition & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ BuildWorkflow:
- LoadDatumConfigData
- TestConfigData
- CompileDatumRsop
- TestReferenceRsop
- Set_PSModulePath
- TestDscResources
- CompileRootConfiguration
Expand Down
37 changes: 37 additions & 0 deletions source/AllNodes/Dev/ReferenceConfigurationDev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
NodeName: '[x={ $Node.Name }=]'
Environment: '[x={ $File.Directory.BaseName } =]'
Role: FileServer
Description: '[x= "$($Node.Role) in $($Node.Environment)" =]'
Location: Frankfurt
Baseline: Server

ComputerSettings:
Name: '[x={ $Node.NodeName }=]'
Description: '[x= "$($Node.Role) in $($Node.Environment)" =]'

NetworkIpConfiguration:
Interfaces:
- InterfaceAlias: DscWorkshop 0
IpAddress: 127.0.0.1
Prefix: 24
Gateway: 127.0.0.1
DnsServer:
- 192.168.111.10
DisableNetbios: true

PSDscAllowPlainTextPassword: True
PSDscAllowDomainUser: True

LcmConfig:
ConfigurationRepositoryWeb:
Server:
ConfigurationNames: '[x={ $Node.NodeName }=]'

DscTagging:
Layers:
- '[x={ Get-DatumSourceFile -Path $File } =]'

FilesAndFolders:
Items:
- DestinationPath: Z:\DoesNotWork
Type: Directory
32 changes: 32 additions & 0 deletions source/AllNodes/Prod/ReferenceConfigurationProd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
NodeName: '[x={ $Node.Name }=]'
Environment: '[x={ $File.Directory.BaseName } =]'
Role: FileServer
Description: '[x= "$($Node.Role) in $($Node.Environment)" =]'
Location: Frankfurt
Baseline: Server

ComputerSettings:
Name: '[x={ $Node.NodeName }=]'
Description: '[x= "$($Node.Role) in $($Node.Environment)" =]'

NetworkIpConfiguration:
Interfaces:
- InterfaceAlias: DscWorkshop 0
IpAddress: 127.0.0.3
Prefix: 24
Gateway: 127.0.0.3
DnsServer:
- 192.168.111.10
DisableNetbios: true

PSDscAllowPlainTextPassword: True
PSDscAllowDomainUser: True

LcmConfig:
ConfigurationRepositoryWeb:
Server:
ConfigurationNames: '[x={ $Node.NodeName }=]'

DscTagging:
Layers:
- '[x={ Get-DatumSourceFile -Path $File } =]'
32 changes: 32 additions & 0 deletions source/AllNodes/Test/ReferenceConfigurationTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
NodeName: '[x={ $Node.Name }=]'
Environment: '[x={ $File.Directory.BaseName } =]'
Role: WebServer
Description: '[x= "$($Node.Role) in $($Node.Environment)" =]'
Location: Singapore
Baseline: Server

ComputerSettings:
Name: '[x={ $Node.NodeName }=]'
Description: '[x= "$($Node.Role) in $($Node.Environment)" =]'

NetworkIpConfiguration:
Interfaces:
- InterfaceAlias: DscWorkshop 0
IpAddress: 127.0.0.2
Prefix: 24
Gateway: 127.0.0.2
DnsServer:
- 192.168.111.10
DisableNetbios: true

PSDscAllowPlainTextPassword: True
PSDscAllowDomainUser: True

LcmConfig:
ConfigurationRepositoryWeb:
Server:
ConfigurationNames: '[x={ $Node.NodeName }=]'

DscTagging:
Layers:
- '[x={ Get-DatumSourceFile -Path $File } =]'
142 changes: 142 additions & 0 deletions source/TestRsopReferences/ReferenceConfigurationDev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
WindowsFeatures:
Names:
- File-Services
- -Telnet-Client
Description: 'FileServer in '
DscDiagnostic: {}
Name: ReferenceConfigurationDev
DscLcmController:
MonitorInterval: 00:15:00
SendDscTaggingData: true
AutoCorrectInterval: 00:30:00
MaintenanceWindowMode: AutoCorrect
RefreshIntervalOverride: false
MaintenanceWindowOverride: false
ControllerInterval: 00:05:00
RefreshInterval: 00:30:00
MaxLcmRuntime: 00:30:00
LogHistoryTimeSpan: 7.00:00:00
WriteTranscripts: true
AutoCorrectIntervalOverride: false
PSDscAllowPlainTextPassword: true
PSDscAllowDomainUser: true
ComputerSettings:
Name: ReferenceConfigurationDev
Description: 'FileServer in '
TimeZone: Greenwich Standard Time
DomainName: contoso.com
JoinOU: CN=Computers,dc=contoso,dc=com
Credential: install@contoso:*********
DscLcmMaintenanceWindows:
MaintenanceWindows:
Name: Always
StartTime: 00:00:00
Timespan: 24:00:00
DependsOn: '[DscLcmController]DscLcmController'
Configurations:
- FilesAndFolders
- RegistryValues
- SecurityBase
- WindowsFeatures
- ComputerSettings
- NetworkIpConfiguration
- WindowsEventLogs
- DscLcmController
- DscLcmMaintenanceWindows
- DscTagging
- DscDiagnostic
SecurityBase:
DependsOn: '[WindowsFeatures]WindowsFeatures'
Role: Baseline
Baseline: Server
NetworkIpConfiguration:
Interfaces:
DnsServer: 192.168.111.10
Gateway: 127.0.0.1
DisableNetbios: true
Prefix: 24
InterfaceAlias: DscWorkshop 0
IpAddress: 127.0.0.1
DscTagging:
Environment: Dev
Version: 0.3.0
Layers:
- AllNodes\Dev\ReferenceConfigurationDev
- Environment\Dev
- Locations\Frankfurt
- Roles\FileServer
- Baselines\Security
- Baselines\Server
- Baselines\DscLcm
FilesAndFolders:
Items:
- DestinationPath: Z:\DoesNotWork
Type: Directory
- DestinationPath: C:\Test\Dev-Environment
Type: Directory
- DestinationPath: C:\Test\Frankfurt
Type: Directory
- DestinationPath: C:\Test
Type: Directory
- Contents: Some test data
Type: File
DependsOn: '[File]file_C__Test'
DestinationPath: C:\Test\Test1File1.txt
- Contents: Some test data
Type: File
DependsOn: '[File]file_C__Test'
DestinationPath: C:\Test\Test1File2.txt
- DestinationPath: C:\GpoBackup
Type: Directory
SourcePath: '\\DSCDC01\SYSVOL\contoso.com\Policies'
NodeName: ReferenceConfigurationDev
Environment: Dev
Location: Frankfurt
RegistryValues:
DependsOn: '[FilesAndFolders]FilesAndFolders'
Values:
- ValueName: DBFlag
ValueType: DWORD
ValueData: 545325055
Ensure: Present
Force: true
Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters
- ValueName: NtpServer
ValueType: String
ValueData: pool.ntp.org,0x9
Ensure: Present
Force: true
Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
LcmConfig:
ConfigurationRepositoryWeb:
Server:
ConfigurationNames: ReferenceConfigurationDev
RegistrationKey: ec717ee9-b343-49ee-98a2-26e53939eecf
ServerURL: https://dscpull01.contoso.com:8080/PSDSCPullServer.svc
ReportServerWeb:
RegistrationKey: ec717ee9-b343-49ee-98a2-26e53939eecf
ServerURL: https://dscpull01.contoso.com:8080/PSDSCPullServer.svc
Settings:
RefreshFrequencyMins: 30
AllowModuleOverwrite: true
ActionAfterReboot: ContinueConfiguration
RefreshMode: Pull
RebootNodeIfNeeded: true
ConfigurationMode: ApplyAndMonitor
ConfigurationModeFrequencyMins: 30
Role: FileServer
WindowsEventLogs:
Logs:
- LogMode: Circular
IsEnabled: true
LogName: System
MaximumSizeInBytes: 20971520
- LogMode: Circular
IsEnabled: true
LogName: Application
MaximumSizeInBytes: 20971520
- LogMode: Circular
IsEnabled: true
LogName: Security
MaximumSizeInBytes: 134217728
DependsOn: '[ComputerSettings]ComputerSettings'
Loading

0 comments on commit 77431de

Please sign in to comment.