From 59e8dcc945b16c59fba3c408936599b42d8f9dcf Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 21 Jan 2020 20:10:37 +0100 Subject: [PATCH] Integration tests are running on more Microsoft-hosted agents (#564) ### Added - xWebAdminstration - Integration tests are running on more Microsoft-hosted agents to test all possible operating systems (issue #550). ### Changed - xWebAdminstration - Azure Pipelines will no longer trigger on changes to just the CHANGELOG.md (when merging to master). - The deploy step is no longer run if the Azure DevOps organization URL does not contain 'dsccommunity'. - Changed the VS Code project settings to trim trailing whitespace for markdown files too. ### Fixed - WebApplicationHandler - Integration test should no longer fail intermittent (issue #558). --- .vscode/settings.json | 1 - CHANGELOG.md | 24 +++- RequiredModules.psd1 | 1 + azure-pipelines.yml | 129 +++++++++++++++++- ...ebApplicationHandler.Integration.Tests.ps1 | 6 +- ... => MSFT_WebApplicationHandler.config.ps1} | 0 .../MSFT_XIISLogging.Integration.Tests.ps1 | 6 +- ...IISFeatureDelegation.Integration.Tests.ps1 | 6 +- .../MSFT_xIISHandler.Integration.Tests.ps1 | 6 +- ..._xIISMimeTypeMapping.Integration.Tests.ps1 | 6 +- .../MSFT_xSslSettings.Integration.Tests.ps1 | 6 +- .../MSFT_xWebAppPool.Integration.Tests.ps1 | 6 +- ..._xWebAppPoolDefaults.Integration.Tests.ps1 | 11 +- ...MSFT_xWebApplication.Integration.Tests.ps1 | 6 +- ...T_xWebConfigKeyValue.Integration.Tests.ps1 | 6 +- ...T_xWebConfigProperty.Integration.Tests.ps1 | 6 +- ...igPropertyCollection.Integration.Tests.ps1 | 6 +- .../MSFT_xWebSite.Integration.Tests.ps1 | 6 +- ...SFT_xWebSiteDefaults.Integration.Tests.ps1 | 6 +- ...xWebVirtualDirectory.Integration.Tests.ps1 | 6 +- tests/TestHelper/CommonTestHelper.psm1 | 12 +- 21 files changed, 201 insertions(+), 61 deletions(-) rename tests/Integration/{MSFT_WebApplicationHandler.Config.ps1 => MSFT_WebApplicationHandler.config.ps1} (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 93d9aae73..503b70247 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,7 +32,6 @@ "steppable" ], "[markdown]": { - "files.trimTrailingWhitespace": false, "files.encoding": "utf8" } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 28adbabd6..ee12d4e7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,27 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md) ## [Unreleased] +### Added + +- xWebAdminstration + - Integration tests are running on more Microsoft-hosted agents to + test all possible operating systems ([issue #550](https://github.com/PowerShell/xWebAdministration/issues/550)). + +### Changed + +- xWebAdminstration + - Azure Pipelines will no longer trigger on changes to just the CHANGELOG.md + (when merging to master). + - The deploy step is no longer run if the Azure DevOps organization URL + does not contain 'dsccommunity'. + - Changed the VS Code project settings to trim trailing whitespace for + markdown files too. + +### Fixed + +- WebApplicationHandler + - Integration test should no longer fail intermittent ([issue #558](https://github.com/PowerShell/xWebAdministration/issues/558)). + ## [3.1.1] - 2020-01-10 ### Changed @@ -16,7 +37,7 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md) displayed in Azure DevOps for each test file artifact. - Update Visual Studio Code workspace settings for the repository. - Set a display name on all the jobs and tasks in the CI pipeline. - + ### Fixed - xWebAdministration @@ -28,7 +49,6 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md) multiple certificates. - Fix an issue where changes to LogFlags would fail to apply. - ## [3.1.0] - 2019-12-30 ### Added diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index c59e076a2..3354aec55 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -17,4 +17,5 @@ 'DscResource.Test' = 'latest' 'DscResource.AnalyzerRules' = 'latest' xDscResourceDesigner = 'latest' + PSPKI = 'latest' } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 53f55b5fd..61a27352e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,6 +2,9 @@ trigger: branches: include: - master + paths: + exclude: + - CHANGELOG.md tags: include: - "v*" @@ -110,8 +113,46 @@ stages: summaryFileLocation: 'output/testResults/CodeCov*.xml' pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)' - - job: Test_Integration - displayName: 'Integration' + - job: Test_Integration_2012R2 + displayName: 'Integration 2012R2' + pool: + vmImage: 'vs2015-win2012r2' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + Install-WindowsFeature -IncludeAllSubFeature -IncludeManagementTools -Name 'Web-Server' -Verbose + name: InstallWebServerFeature + - task: PowerShell@2 + name: test + displayName: 'Run Integration Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0" + pwsh: false + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Integration (Windows Server Core)' + + - job: Test_Integration_2016 + displayName: 'Integration 2016' pool: vmImage: 'vs2017-win2016' timeoutInMinutes: 0 @@ -131,7 +172,86 @@ stages: script: 'winrm quickconfig -quiet' pwsh: false - powershell: | - Install-WindowsFeature -IncludeAllSubFeature -IncludeManagementTools -Name 'Web-Server' + Install-WindowsFeature -IncludeAllSubFeature -IncludeManagementTools -Name 'Web-Server' -Verbose + name: InstallWebServerFeature + - task: PowerShell@2 + name: test + displayName: 'Run Integration Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0" + pwsh: false + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Integration (Windows Server Core)' + + - job: Test_Integration_2019 + displayName: 'Integration 2019' + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + Install-WindowsFeature -IncludeAllSubFeature -IncludeManagementTools -Name 'Web-Server' -Verbose + name: InstallWebServerFeature + - task: PowerShell@2 + name: test + displayName: 'Run Integration Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0" + pwsh: false + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Integration (Windows Server Core)' + + - job: Test_Integration_ServerCore_ltsc2019 + displayName: 'Integration Server Core LTSC 2019' + pool: + vmImage: 'windows-2019' + container: mcr.microsoft.com/windows/servercore:ltsc2019 + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + Set-Service -Name wuauserv -StartupType Manual -Verbose + Start-Service -name wuauserv -Verbose + Install-WindowsFeature -IncludeAllSubFeature -Name 'Web-Server' -Verbose name: InstallWebServerFeature - task: PowerShell@2 name: test @@ -156,7 +276,8 @@ stages: or( eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/') - ) + ), + contains(variables['System.TeamFoundationCollectionUri'], 'dsccommunity') ) jobs: - job: Deploy_Module diff --git a/tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 b/tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 index 255202474..a20993d7d 100644 --- a/tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 @@ -213,9 +213,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_WebApplicationHandler.Config.ps1 b/tests/Integration/MSFT_WebApplicationHandler.config.ps1 similarity index 100% rename from tests/Integration/MSFT_WebApplicationHandler.Config.ps1 rename to tests/Integration/MSFT_WebApplicationHandler.config.ps1 diff --git a/tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 b/tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 index d0569eaa3..3978f0bc0 100644 --- a/tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 @@ -135,9 +135,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 b/tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 index 8652ab3f5..49762c9ac 100644 --- a/tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 @@ -134,9 +134,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 b/tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 index 2dfb8b2a3..dc98ad452 100644 --- a/tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 @@ -72,9 +72,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 b/tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 index fc87ea94d..22f98dbc1 100644 --- a/tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 @@ -209,9 +209,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 b/tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 index b9da0cbd0..e92459779 100644 --- a/tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 @@ -119,9 +119,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xWebAppPool.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebAppPool.Integration.Tests.ps1 index 0f6a5221a..f31738eb2 100644 --- a/tests/Integration/MSFT_xWebAppPool.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebAppPool.Integration.Tests.ps1 @@ -100,9 +100,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 index 8851b91f8..e4b4ffa1e 100644 --- a/tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 @@ -23,8 +23,6 @@ $tempName = "$($script:dscResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss try { - #region Integration Tests - # some constants [string]$constPsPath = 'MACHINE/WEBROOT/APPHOST' [string]$constAPDFilter = 'system.applicationHost/applicationPools/applicationPoolDefaults' @@ -41,7 +39,6 @@ try } Describe "$($script:dscResourceName)_Integration" { - #region DEFAULT TESTS It 'Should compile without throwing' { { Invoke-Expression -Command "$($script:dscResourceName)_Config -OutputPath `$TestDrive" @@ -52,7 +49,6 @@ try It 'Should be able to call Get-DscConfiguration without throwing' { { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw } - #endregion It 'Changing ManagedRuntimeVersion' { { @@ -150,13 +146,12 @@ try } } - #endregion } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 index 460d1b0ea..fbc34602e 100644 --- a/tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 @@ -147,9 +147,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 index 5a3bb1e53..bb4b2b441 100644 --- a/tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 @@ -88,10 +88,10 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 index 1fdeafdf2..ca990cf14 100644 --- a/tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 @@ -178,9 +178,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 index 08826c2bb..a3addf856 100644 --- a/tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 @@ -194,9 +194,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 index 92c753bd1..e65c25986 100644 --- a/tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 @@ -317,9 +317,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose Remove-Item -PSPath $selfSignedCert.PSPath @@ -329,5 +329,5 @@ finally Remove-Item -Path $webConfigPath } - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 index 9f671bbf3..f107e247d 100644 --- a/tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 @@ -65,9 +65,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 index aaa74713a..bc5f57d2f 100644 --- a/tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 @@ -93,9 +93,9 @@ try } finally { - Restore-WebConfigurationWrapper -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName -Verbose - Remove-WebConfigurationBackup -Name $tempName + Remove-WebConfigurationBackup -Name $tempName -Verbose if ((Test-Path -Path $DSCConfig.AllNodes.PhysicalPath)) { Remove-Item -Path $DSCConfig.AllNodes.PhysicalPath @@ -105,5 +105,5 @@ finally Remove-Item -Path $DSCConfig.AllNodes.WebApplicationPhysicalPath } - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -Verbose } diff --git a/tests/TestHelper/CommonTestHelper.psm1 b/tests/TestHelper/CommonTestHelper.psm1 index 6dbbc5146..c0c48f1d3 100644 --- a/tests/TestHelper/CommonTestHelper.psm1 +++ b/tests/TestHelper/CommonTestHelper.psm1 @@ -72,6 +72,7 @@ function Install-NewSelfSignedCertificateExScript #> function Restore-WebConfigurationWrapper { + [CmdletBinding()] param ( [Parameter(Mandatory = $true)] @@ -86,15 +87,15 @@ function Restore-WebConfigurationWrapper { try { - Write-Verbose -Message ('Restoring web configuration - attempt {0}' -f $retryCount) -Verbose + Write-Verbose -Message ('Restoring web configuration - attempt {0}' -f $retryCount) Restore-WebConfiguration -Name $Name - Write-Verbose -Message ('Successfully restored web configuration' -f $retryCount) -Verbose + Write-Verbose -Message ('Successfully restored web configuration' -f $retryCount) $backupRestored = $true } - catch [System.IO.IOException] + catch [System.IO.IOException], [System.ComponentModel.Win32Exception] { # On the fifth try, throw an error. if ($retryCount -eq 5) @@ -102,7 +103,7 @@ function Restore-WebConfigurationWrapper throw $_ } - Write-Verbose -Message ('Failed to restore web configuration. Retrying in 5 seconds. For reference the error message was "{0}".' -f $_) -Verbose + Write-Verbose -Message ('Failed to restore web configuration. Retrying in 5 seconds. For reference the error message was "{0}".' -f $_) $retryCount += 1 @@ -113,6 +114,9 @@ function Restore-WebConfigurationWrapper throw $_ } } while (-not $backupRestored) + + # Wait a bit for the restore to free resources. + Start-Sleep -Seconds 10 } Export-ModuleMember -Function @(