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

xPSDesiredStateConfiguration: Multiple AppVeyor jobs #509

Merged
merged 12 commits into from
Feb 2, 2019
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,19 @@ Publishes a 'FileInfo' object(s) to the pullserver configuration repository. It

### Unreleased

* Changes to xPSDesiredStateConfiguration
* In AppVeyor CI the tests are split into three separate jobs, and also
running tests on two different build worker images (Windows Server
2012R2 and Windows Server 2016). The common tests are run on only
one of the build worker images (Windows Server 2012R2). Helps with
[issue #477](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/477).
* xWindowsOptionalFeature
* Suppress useless verbose output from `Import-Module` cmdlet. ([issue 453](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/453))
* Changes to xRemoteFile
* Corrected a resource name in the example xRemoteFile_DownloadFileConfig.ps1
* Fix `MSFT_xDSCWebService` to find
`Microsoft.Powershell.DesiredStateConfiguration.Service.Resources.dll`
when server is configured with pt-BR Locales ([issue #284](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/284)).
when server is configured with pt-BR Locales ([issue #284](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/284)).
* Changes to xDSCWebService
* Fixed an issue which prevented the removal of the IIS Application Pool created during deployment of an DSC Pull Server instance. ([issue #464](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/464))
* Fixed an issue where a Pull Server cannot be deployed on a machine when IIS Express is installed aside a full blown IIS ([issue #191](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/191))
Expand Down
44 changes: 43 additions & 1 deletion Tests/CommonTestHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,47 @@ function Exit-DscResourceTestEnvironment
Restore-TestEnvironment -TestEnvironment $TestEnvironment
}

<#
.SYNOPSIS
Returns $true if the the environment variable APPVEYOR is set to $true,
and the environment variable CONFIGURATION is set to the value passed
in the parameter Type.

.PARAMETER Name
Name of the test script that is called. Defaults to the name of the
calling script.

.PARAMETER Type
Type of tests in the test file. Can be set to Unit or Integration.
#>
function Test-SkipCi
{
[OutputType([System.Boolean])]
[CmdletBinding()]
param
(
[Parameter()]
[ValidateNotNullOrEmpty()]
[System.String]
$Name = $MyInvocation.PSCommandPath.Split('\')[-1],

[Parameter(Mandatory = $true)]
[ValidateSet('Unit', 'Integration')]
[System.String]
$Type
)

$result = $false

if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne $Type)
{
Write-Verbose -Message ('{1} tests for {0} will be skipped unless $env:CONFIGURATION is set to ''{1}''.' -f $Name, $Type) -Verbose
$result = $true
}

return $result
}

Export-ModuleMember -Function @(
'Test-GetTargetResourceResult', `
'Wait-ScriptBlockReturnTrue', `
Expand All @@ -801,5 +842,6 @@ Export-ModuleMember -Function @(
'Invoke-SetTargetResourceUnitTest', `
'Invoke-TestTargetResourceUnitTest', `
'Invoke-ExpectedMocksAreCalledTest', `
'Invoke-GenericUnitTest'
'Invoke-GenericUnitTest',
'Test-SkipCi'
)
15 changes: 10 additions & 5 deletions Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
$errorActionPreference = 'Stop'
Set-StrictMode -Version 'Latest'

# Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment
$testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

Describe 'xArchive End to End Tests' {
BeforeAll {
# Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment
$testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xArchive' `
Expand Down
13 changes: 8 additions & 5 deletions Tests/Integration/MSFT_xArchive.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
$errorActionPreference = 'Stop'
Set-StrictMode -Version 'Latest'

Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) `
-ChildPath 'CommonTestHelper.psm1')

if ((Test-SkipCi -Type 'Integration'))
{
return
}

if ($PSVersionTable.PSVersion -lt [Version] '5.1')
{
Write-Warning -Message 'Cannot run PSDscResources integration tests on PowerShell versions lower than 5.1'
Expand All @@ -9,11 +17,6 @@ if ($PSVersionTable.PSVersion -lt [Version] '5.1')

Describe 'xArchive Integration Tests' {
BeforeAll {
# Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment
$testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xArchive' `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xEnvironmentResource' `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
$errorActionPreference = 'Stop'
Set-StrictMode -Version 'Latest'


# Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment
$script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xEnvironmentResource' `
Expand Down
5 changes: 5 additions & 0 deletions Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xGroupResource' `
Expand Down
15 changes: 10 additions & 5 deletions Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
$errorActionPreference = 'Stop'
Set-StrictMode -Version 'Latest'

# Import CommonTestHelper
$testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

Describe 'xMsiPackage End to End Tests' {
BeforeAll {
# Import CommonTestHelper
$testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xMsiPackage' `
Expand Down
5 changes: 5 additions & 0 deletions Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$script:commonTestHelperFilePath = Join-Path -Path $script:testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $script:commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xMsiPackage' `
Expand Down
5 changes: 5 additions & 0 deletions Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Import-Module "$PSScriptRoot\..\CommonTestHelper.psm1"

if ((Test-SkipCi -Type 'Integration'))
{
return
}

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xPackageResource' `
Expand Down
5 changes: 5 additions & 0 deletions Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xRegistryResource' `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xRegistryResource' `
Expand Down
9 changes: 8 additions & 1 deletion Tests/Integration/MSFT_xRemoteFile.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) `
-ChildPath 'CommonTestHelper.psm1')

$Global:DSCModuleName = 'xPSDesiredStateConfiguration' # Example xNetworking
$Global:DSCResourceName = 'MSFT_xRemoteFile' # Example MSFT_xFirewall

if ((Test-SkipCi -Type 'Integration'))
{
return
}

#region HEADER
# Integration Test Template Version: 1.1.0
[String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))
Expand All @@ -15,7 +22,7 @@ Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHel
$TestEnvironment = Initialize-TestEnvironment `
-DSCModuleName $Global:DSCModuleName `
-DSCResourceName $Global:DSCResourceName `
-TestType Integration
-TestType Integration
#endregion

# Using try/finally to always cleanup even if something awful happens.
Expand Down
5 changes: 5 additions & 0 deletions Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xScriptResource' `
Expand Down
17 changes: 11 additions & 6 deletions Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $commonTestHelperFilePath

if ((Test-SkipCi -Type 'Integration'))
{
return
}

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'xPSDesiredStateConfiguration' `
-DscResourceName 'MSFT_xServiceResource' `
Expand Down Expand Up @@ -116,7 +121,7 @@ try
$resourceParameters = $script:existingServiceProperties

It 'Should compile and apply the MOF without throwing' {
{
{
. $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName
& $configurationName -OutputPath $TestDrive @resourceParameters
Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force
Expand Down Expand Up @@ -179,7 +184,7 @@ try
$resourceParameters = $script:newServiceProperties

It 'Should compile and apply the MOF without throwing' {
{
{
. $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName
& $configurationName -OutputPath $TestDrive @resourceParameters
Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force
Expand Down Expand Up @@ -247,7 +252,7 @@ try
}

It 'Should compile and apply the MOF without throwing' {
{
{
. $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName
& $configurationName -OutputPath $TestDrive @resourceParameters
Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force
Expand Down Expand Up @@ -297,7 +302,7 @@ try
}

It 'Should compile and apply the MOF without throwing' {
{
{
. $script:configurationCredentialOnlyFilePath -ConfigurationName $configurationName
& $configurationName -OutputPath $TestDrive -ConfigurationData $configData @resourceParameters
Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force
Expand Down Expand Up @@ -342,7 +347,7 @@ try
}

It 'Should compile and apply the MOF without throwing' {
{
{
. $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName
& $configurationName -OutputPath $TestDrive @resourceParameters
Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force
Expand Down Expand Up @@ -380,7 +385,7 @@ try
}

It 'Should compile and apply the MOF without throwing' {
{
{
. $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName
& $configurationName -OutputPath $TestDrive @resourceParameters
Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force
Expand Down
Loading