Fix test failures on Windows for time zone and remoting (#19466)

This commit is contained in:
Aditya Patwardhan
2023-04-25 11:06:34 -07:00
committed by GitHub
parent 543b20b4ed
commit cf6fc53c9f
12 changed files with 199 additions and 140 deletions
@@ -7,7 +7,7 @@ Describe 'OutputRendering tests' -Tag 'CI' {
# Console host does not support VT100 escape sequences on Windows 2012R2 or earlier
if (-not $host.ui.SupportsVirtualTerminal) {
$global:PSDefaultParameterValues["it:skip"] = $true
$PSDefaultParameterValues["it:skip"] = $true
}
}
@@ -7,7 +7,15 @@ Describe "WinRM based remoting session abrupt disconnect" -Tags 'Feature','Requi
BeforeAll {
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
if (! $IsWindows -or (Test-IsWinWow64))
$pendingTest = (Test-IsWinWow64)
$skipTest = !$IsWindows
if ($pendingTest)
{
$PSDefaultParameterValues["it:pending"] = $true
return
}
elseif ($skipTest)
{
$PSDefaultParameterValues["it:skip"] = $true
return
@@ -56,6 +64,11 @@ Describe "WinRM based remoting session abrupt disconnect" -Tags 'Feature','Requi
AfterAll {
$global:PSDefaultParameterValues = $originalDefaultParameterValues
if ($pendingTest -or $skipTest)
{
return
}
if ($ps -ne $null) { $ps.Dispose() }
if ($session -ne $null) { Remove-PSSession -Session $session }
if ($script:job -ne $null) { Remove-Job -Job $script:job -Force }
@@ -8,40 +8,44 @@ Describe "Remote runspace pool should expose commands in endpoint configuration"
BeforeAll {
if ($IsWindows -and (Test-CanWriteToPsHome) -and -not (Test-IsWinWow64))
{
$configName = "restrictedV"
$configPath = Join-Path $TestDrive ($configName + ".pssc")
$pendingTest = (Test-IsWinWow64)
$skipTest = !$IsWindows -or !(Test-CanWriteToPsHome)
New-PSSessionConfigurationFile -Path $configPath -SessionType RestrictedRemoteServer -VisibleCmdlets 'Get-CimInstance'
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
$null = Register-PSSessionConfiguration -Name $configName -Path $configPath -Force -ErrorAction SilentlyContinue
$remoteRunspacePool = New-RemoteRunspacePool -ConfigurationName $configName
if ($pendingTest) {
$PSDefaultParameterValues["it:pending"] = $true
return
}
elseif (Test-IsWinWow64)
{
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
if ($skipTest) {
$PSDefaultParameterValues["it:skip"] = $true
return
}
$configName = "restrictedV"
$configPath = Join-Path $TestDrive ($configName + ".pssc")
New-PSSessionConfigurationFile -Path $configPath -SessionType RestrictedRemoteServer -VisibleCmdlets 'Get-CimInstance'
$null = Register-PSSessionConfiguration -Name $configName -Path $configPath -Force -ErrorAction SilentlyContinue
$remoteRunspacePool = New-RemoteRunspacePool -ConfigurationName $configName
}
AfterAll {
if (Test-IsWinWow64) {
if ($pendingTest -or $skipTest) {
$global:PSDefaultParameterValues = $originalDefaultParameterValues
return
}
if ($IsWindows -and (Test-CanWriteToPsHome))
if ($remoteRunspacePool -ne $null)
{
if ($remoteRunspacePool -ne $null)
{
$remoteRunspacePool.Dispose()
}
Unregister-PSSessionConfiguration -Name $configName -Force -ErrorAction SilentlyContinue
$remoteRunspacePool.Dispose()
}
Unregister-PSSessionConfiguration -Name $configName -Force -ErrorAction SilentlyContinue
}
It "Verifies that the configured endpoint cmdlet is available in all runspace pool instances" -Skip:(!$IsWindows -or !(Test-CanWriteToPsHome)) {