mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Refactor implicit remoting tests to work in CI
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#
|
||||
# This module include help functions for writing remoting tests
|
||||
#
|
||||
|
||||
$Script:AppVeyorRemoteCred = $null
|
||||
|
||||
if ($IsWindows) {
|
||||
try { $Script:AppVeyorRemoteCred = Import-Clixml -Path "$env:TEMP\AppVeyorRemoteCred.xml" } catch { }
|
||||
}
|
||||
|
||||
|
||||
function New-RemoteRunspace
|
||||
{
|
||||
$wsmanConInfo = [System.Management.Automation.Runspaces.WSManConnectionInfo]::new()
|
||||
|
||||
if ($Script:AppVeyorRemoteCred)
|
||||
{
|
||||
Write-Verbose "Using Global AppVeyor Credential" -Verbose
|
||||
$wsmanConInfo.Credential = $Script:AppVeyorRemoteCred
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Verbose "Using Implicit Credential" -Verbose
|
||||
}
|
||||
|
||||
$remoteRunspace = [runspacefactory]::CreateRunspace($Host, $wsmanConInfo)
|
||||
$remoteRunspace.Open()
|
||||
|
||||
return $remoteRunspace
|
||||
}
|
||||
|
||||
|
||||
function New-RemoteSession
|
||||
{
|
||||
param (
|
||||
[string] $Name,
|
||||
[string] $ConfigurationName,
|
||||
[System.Management.Automation.Remoting.PSSessionOption] $SessionOption)
|
||||
|
||||
$parameters = @{ ComputerName = "."; }
|
||||
|
||||
if ($Name) {
|
||||
$parameters["Name"] = $Name
|
||||
}
|
||||
|
||||
if ($ConfigurationName) {
|
||||
$parameters["ConfigurationName"] = $ConfigurationName
|
||||
}
|
||||
|
||||
if ($SessionOption) {
|
||||
$parameters["SessionOption"] = $SessionOption
|
||||
}
|
||||
|
||||
if ($Script:AppVeyorRemoteCred)
|
||||
{
|
||||
Write-Verbose "Using Global AppVeyor Credential" -Verbose
|
||||
$parameters["Credential"] = $Script:AppVeyorRemoteCred
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Verbose "Using Implicit Credential" -Verbose
|
||||
}
|
||||
|
||||
$session = New-PSSession @parameters
|
||||
|
||||
return $session
|
||||
}
|
||||
@@ -1,26 +1,8 @@
|
||||
function Get-RemoteRunspace {
|
||||
$wc = [System.Management.Automation.Runspaces.WSManConnectionInfo]::new()
|
||||
|
||||
# Use AppVeyor credentials if running in AppVeyor, rather than implicit credentials.
|
||||
try
|
||||
{
|
||||
$appveyorRemoteCredential = Import-Clixml -Path "$env:TEMP\AppVeyorRemoteCred.xml"
|
||||
}
|
||||
catch { }
|
||||
if ($appveyorRemoteCredential)
|
||||
{
|
||||
Write-Verbose "Using global AppVeyor credential";
|
||||
$wc.Credential = $appveyorRemoteCredential
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Verbose "Using implicit credentials"
|
||||
}
|
||||
|
||||
$remoteRunspace = [runspacefactory]::CreateRunspace($host, $wc)
|
||||
$remoteRunspace.Open()
|
||||
|
||||
return $remoteRunspace
|
||||
if (-not (Get-Module TestRemoting -ErrorAction SilentlyContinue))
|
||||
{
|
||||
$root = git rev-parse --show-toplevel
|
||||
$remotingModule = Join-Path $root test/powershell/Common/TestRemoting.psm1
|
||||
Import-Module $remotingModule
|
||||
}
|
||||
|
||||
Describe "InvokeOnRunspace method argument error handling" -tags "Feature" {
|
||||
@@ -76,7 +58,7 @@ Describe "InvokeOnRunspace method on remote runspace" -tags "Feature" {
|
||||
BeforeAll {
|
||||
|
||||
if ($IsWindows) {
|
||||
$script:remoteRunspace = Get-RemoteRunspace
|
||||
$script:remoteRunspace = New-RemoteRunspace
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1813
-1738
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user