Refactor implicit remoting tests to work in CI

This commit is contained in:
Dongbo Wang
2016-10-28 16:51:44 -07:00
committed by Dongbo Wang
parent c975b9f6a0
commit 4bb0b13e09
3 changed files with 1886 additions and 1762 deletions
+67
View File
@@ -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
}
+6 -24
View File
@@ -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
}
}
File diff suppressed because it is too large Load Diff