Improvements to CI build and validation output

This commit is contained in:
Yanbing 2017-01-27 10:47:20 -08:00 committed by Manoj Ampalam
parent fb51120093
commit e3bec44766
6 changed files with 278 additions and 115 deletions

View File

@ -1,4 +1,4 @@
version: 0.0.6.0.{build}
version: 0.0.8.0.{build}
image: Visual Studio 2015
branches:
@ -11,33 +11,34 @@ init:
build_script:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
Invoke-AppVeyorBuild
after_build:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Install-OpenSSH
- ps: Write-Verbose "Restart computer ..."
- ps: Restart-Computer -ComputerName localhost -Force
- ps: Restart-Computer -Force
- ps: Start-Sleep -s 5 # Needs to be proceeded with -ps: as it's interpreted by AppVeyor
- ps: Write-Verbose "Restart computer completed"
- ps: Write-Verbose "Restart computer completed!"
before_test:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -DisableNameChecking
Install-TestDependencies
Deploy-OpenSSHTests
test_script:
- cmd: |
"%ProgramFiles%\PowerShell\6.0.0.14\powershell.exe" -Command "Import-Module \"%APPVEYOR_BUILD_FOLDER%\contrib\win32\openssh\AppVeyor.psm1\" -WarningAction SilentlyContinue;Run-OpenSSHTests"
"%ProgramFiles%\PowerShell\6.0.0.14\powershell.exe" -Command "Import-Module \"%APPVEYOR_BUILD_FOLDER%\contrib\win32\openssh\AppVeyor.psm1\" -DisableNameChecking;Run-OpenSSHPesterTest"
- ps: |
Check-PesterTestResult
Run-OpenSSHUnitTest
after_test:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Upload-OpenSSHTestResults
on_finish:
- ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Publish-Artifact

View File

@ -1,8 +1,9 @@
$ErrorActionPreference = 'Stop'
Import-Module $PSScriptRoot\build.psm1
Import-Module $PSScriptRoot\build.psm1 -Force -DisableNameChecking
$repoRoot = Get-RepositoryRoot
$script:logFile = join-path $repoRoot.FullName "appveyorlog.log"
$script:logFile = join-path $repoRoot.FullName "appveyor.log"
$script:messageFile = join-path $repoRoot.FullName "BuildMessage.log"
$testfailed = $false
<#
Called by Write-BuildMsg to write to the build log, if it exists.
@ -22,6 +23,28 @@ function Write-Log
}
}
# Sets a build variable
Function Write-BuildMessage
{
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $Message,
$Category,
[string] $Details)
if($env:AppVeyor)
{
Add-AppveyorMessage @PSBoundParameters
}
# write it to the log file, if present.
if (-not ([string]::IsNullOrEmpty($script:messageFile)))
{
Add-Content -Path $script:messageFile -Value "$Category--$Message"
}
}
# Sets a build variable
Function Set-BuildVariable
{
@ -35,13 +58,17 @@ Function Set-BuildVariable
$Value
)
if($env:AppVeyor)
if($env:AppVeyor -and (Get-Command Set-AppveyorBuildVariable -ErrorAction Ignore) -ne $null)
{
Set-AppveyorBuildVariable @PSBoundParameters
}
elseif($env:AppVeyor)
{
appveyor SetVariable -Name $Name -Value $Value
}
else
{
Set-Item env:/$name -Value $Value
Set-Item env:$Name -Value $Value
}
}
@ -71,7 +98,6 @@ function Invoke-AppVeyorFull
Invoke-AppVeyorBuild
Install-OpenSSH
Install-TestDependencies
& "$env:ProgramFiles\PowerShell\6.0.0.12\powershell.exe" -Command {Import-Module $($repoRoot.FullName)\contrib\win32\openssh\AppVeyor.psm1;Run-OpenSSHTests -uploadResults}
Run-OpenSSHTests
Publish-Artifact
}
@ -86,8 +112,10 @@ function Invoke-AppVeyorFull
# Implements the AppVeyor 'build_script' step
function Invoke-AppVeyorBuild
{
Set-BuildVariable TestPassed True
Start-SSHBuild -Configuration Release -NativeHostArch x64
Start-SSHBuild -Configuration Debug -NativeHostArch x86
Write-BuildMessage -Message "OpenSSH binaries build success!" -Category Information
}
<#
@ -193,6 +221,7 @@ function Download-PSCoreMSI
if ($v)
{
Write-BuildMessage -Message "Failed to download PSCore MSI package from $url" -Category Error
throw "Failed to download PSCore MSI package from $url"
}
else
@ -216,14 +245,37 @@ function Install-TestDependencies
if (-not ($isModuleAvailable))
{
Write-Log -Message "Installing Pester..."
choco install Pester -y --force --limitoutput
choco install Pester -y --force --limitoutput 2>&1 >> $script:logFile
}
if ( -not (Test-Path "$env:ProgramData\chocolatey\lib\sysinternals\tools" ) ) {
Write-Log -Message "sysinternals not present. Installing sysinternals."
choco install sysinternals -y --force --limitoutput
choco install sysinternals -y --force --limitoutput 2>&1 >> $script:logFile
}
<#if ( (-not (Test-Path "${env:ProgramFiles(x86)}\Windows Kits\8.1\Debuggers\" )) -and (-not (Test-Path "${env:ProgramFiles(x86)}\Windows Kits\10\Debuggers\" ))) {
Write-Log -Message "debugger not present. Installing windbg."
choco install windbg --force --limitoutput -y 2>&1 >> $script:logFile
}#>
Install-PSCoreFromGithub
$psCorePath = GetLocalPSCorePath
Set-BuildVariable -Name psPath -Value $psCorePath
Write-BuildMessage -Message "All testDependencies installed!" -Category Information
}
<#
.Synopsis
Get the path to the installed powershell score
#>
function GetLocalPSCorePath {
$psPath = Get-ChildItem "$env:ProgramFiles\PowerShell\*\powershell.exe" -Recurse -ErrorAction SilentlyContinue
if($psPath.Count -eq 0)
{
""
}
else
{
$psPath[-1].FullName
}
}
<#
.Synopsis
@ -246,7 +298,7 @@ function Install-OpenSSH
Build-Win32OpenSSHPackage @PSBoundParameters
Push-Location $OpenSSHDir
&( "$OpenSSHDir\install-sshd.ps1")
& ( "$OpenSSHDir\install-sshd.ps1")
.\ssh-keygen.exe -A
Start-Service ssh-agent
&( "$OpenSSHDir\install-sshlsa.ps1")
@ -256,6 +308,7 @@ function Install-OpenSSH
Start-Service sshd
Pop-Location
Write-BuildMessage -Message "OpenSSH installed!" -Category Information
}
<#
@ -338,7 +391,6 @@ function Build-Win32OpenSSHPackage
$RealConfiguration = $Configuration
}
[System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHDir -Include *.exe,*.dll -Exclude *unittest*.* -Force -ErrorAction Stop
@ -350,7 +402,16 @@ function Build-Win32OpenSSHPackage
if (-not (Test-Path -Path $rktoolsPath))
{
Write-Log -Message "$packageName not present. Installing $packageName."
choco install $packageName -y --force
choco install $packageName -y --force 2>&1 >> $script:logFile
if (-not (Test-Path -Path $rktoolsPath))
{
choco install $packageName -y --force 2>&1 >> $script:logFile
if (-not (Test-Path -Path $rktoolsPath))
{
Write-BuildMessage "Installation dependencies: failed to download $packageName. try again please." -Category Error
throw "failed to download $packageName"
}
}
}
Copy-Item -Path $rktoolsPath -Destination $OpenSSHDir -Force -ErrorAction Stop
@ -440,6 +501,36 @@ function Deploy-OpenSSHTests
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Exclude ssh-agent.exe, sshd.exe -Force -ErrorAction Stop
$sshdConfigFile = "$OpenSSHTestDir\sshd_config"
if (-not (Test-Path -Path $sshdConfigFile -PathType Leaf))
{
Write-BuildMessage "Installation dependencies: $OpenSSHTestDir\sshd_config is missing in the folder" -Category Error
throw "$OpenSSHTestDir\sshd_config is missing in the folder"
}
if ($env:DebugMode)
{
$strToReplace = "#LogLevel INFO"
(Get-Content $sshdConfigFile).Replace($strToReplace,"LogLevel Debug3") | Set-Content $sshdConfigFile
}
if(-not ($env:psPath))
{
$psCorePath = GetLocalPSCorePath
Set-BuildVariable -Name psPath -Value $psCorePath
}
$strToReplace = "Subsystem sftp sftp-server.exe"
if($env:psPath)
{
$strNewsubSystem = @"
Subsystem sftp sftp-server.exe
Subsystem powershell $env:psPath
"@
}
(Get-Content $sshdConfigFile).Replace($strToReplace, $strNewsubSystem) | Set-Content $sshdConfigFile
}
@ -491,7 +582,7 @@ function Add-Artifact
(
[ValidateNotNull()]
[System.Collections.ArrayList] $artifacts,
[string] $FileToAdd = "$env:SystemDrive\Win32OpenSSH*.zip"
[string] $FileToAdd
)
$files = Get-ChildItem -Path $FileToAdd -ErrorAction Ignore
@ -503,7 +594,7 @@ function Add-Artifact
}
else
{
Write-Warning "Skip publishing package artifacts. $FileToAdd does not exist"
Write-Log -Message "Skip publishing package artifacts. $FileToAdd does not exist"
}
}
@ -513,7 +604,7 @@ function Add-Artifact
#>
function Publish-Artifact
{
Write-Output "Publishing project artifacts"
Write-Host -ForegroundColor Yellow "Publishing project artifacts"
[System.Collections.ArrayList] $artifacts = [System.Collections.ArrayList]::new()
$packageFolder = $env:SystemDrive
@ -524,14 +615,17 @@ function Publish-Artifact
Add-Artifact -artifacts $artifacts -FileToAdd "$packageFolder\Win32OpenSSH*.zip"
Add-Artifact -artifacts $artifacts -FileToAdd "$env:SystemDrive\OpenSSH\UnitTestResults.txt"
Add-Artifact -artifacts $artifacts -FileToAdd "$script:logFile"
Add-Artifact -artifacts $artifacts -FileToAdd "$env:SystemDrive\OpenSSH\TestError.txt"
# Get the build.log file for each build configuration
Add-BuildLog -artifacts $artifacts -buildLog (Get-BuildLogFile -root $repoRoot.FullName)
Add-Artifact -artifacts $artifacts -FileToAdd "$script:logFile"
Add-Artifact -artifacts $artifacts -FileToAdd "$script:messageFile"
foreach ($artifact in $artifacts)
{
Write-Output "Publishing $artifact as Appveyor artifact"
Write-Log -Message "Publishing $artifact as Appveyor artifact"
# NOTE: attempt to publish subsequent artifacts even if the current one fails
Push-AppveyorArtifact $artifact -ErrorAction "Continue"
}
@ -543,24 +637,51 @@ function Publish-Artifact
#>
function Run-OpenSSHPesterTest
{
param($testRoot, $outputXml)
param($testRoot = "$env:SystemDrive\OpenSSH",
$outputXml = "$env:SystemDrive\OpenSSH\TestResults.xml")
# Discover all CI tests and run them.
Push-Location $testRoot
Write-Log -Message "Running OpenSSH Pester tests..."
$testFolders = Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique
Invoke-Pester $testFolders -OutputFormat NUnitXml -OutputFile $outputXml -Tag 'CI'
Pop-Location
}
function Check-PesterTestResult
{
param($outputXml = "$env:SystemDrive\OpenSSH\TestResults.xml")
if (-not (Test-Path $outputXml))
{
Write-Warning "$($xml.'test-results'.failures) tests in regress\pesterTests failed"
Write-BuildMessage -Message "Test result file $outputXml not found after tests." -Category Error
Set-BuildVariable TestPassed False
}
$xml = [xml](Get-Content -raw $outputXml)
if ([int]$xml.'test-results'.failures -gt 0)
{
$errorMessage = "$($xml.'test-results'.failures) tests in regress\pesterTests failed. Detail test log is at TestResults.xml."
Write-Warning $errorMessage
Write-BuildMessage -Message $errorMessage -Category Error
Set-BuildVariable TestPassed False
}
# Writing out warning when the $Error.Count is non-zero. Tests Should clean $Error after success.
if ($Error.Count -gt 0)
{
Write-BuildMessage -Message "Tests Should clean $Error after success." -Category Warning
$Error| Out-File "$testInstallFolder\TestError.txt" -Append
}
}
<#
.Synopsis
Run unit tests.
#>
function Run-OpenSSHUnitTest
{
param($testRoot, $unitTestOutputFile)
param($testRoot = "$env:SystemDrive\OpenSSH",
$unitTestOutputFile = "$env:SystemDrive\OpenSSH\UnitTestResults.txt")
# Discover all CI tests and run them.
Push-Location $testRoot
@ -570,27 +691,28 @@ function Run-OpenSSHUnitTest
Remove-Item -Path $unitTestOutputFile -Force -ErrorAction SilentlyContinue
}
$unitTestFiles = Get-ChildItem -Path "$testRoot\unittest*.exe"
$testFailed = $false
$unitTestFiles = Get-ChildItem -Path "$testRoot\unittest*.exe" -Exclude unittest-kex.exe
$testfailed = $false
if ($unitTestFiles -ne $null)
{
$unitTestFiles | % {
Write-Log -Message "Running OpenSSH unit $($_.FullName)..."
Write-Output "Running OpenSSH unit $($_.FullName)..."
& $_.FullName >> $unitTestOutputFile
$errorCode = $LASTEXITCODE
if ($errorCode -ne 0)
{
$testFailed = $true
Write-Log -Message "$($_.FullName) test failed for OpenSSH.`nExitCode: $error"
$testfailed = $true
$errorMessage = "$($_.FullName) test failed for OpenSSH.`nExitCode: $errorCode. Detail test log is at UnitTestResults.txt."
Write-Warning $errorMessage
Write-BuildMessage -Message $errorMessage -Category Error
Set-BuildVariable TestPassed False
}
}
if($testFailed)
if(-not $testfailed)
{
throw "SSH unit tests failed"
Write-BuildMessage -Message "All Unit tests passed!" -Category Information
}
}
Pop-Location
}
@ -602,17 +724,9 @@ function Run-OpenSSHUnitTest
The name of the xml file to write pester results.
The default value is '.\testResults.xml'
.Parameter uploadResults
Uploads the tests results.
.Example
.\RunTests.ps1
Runs the tests and creates the default 'testResults.xml'
.Example
.\RunTests.ps1 -uploadResults
Runs the tests and creates teh default 'testResults.xml' and uploads it to appveyor.
#>
function Run-OpenSSHTests
{
@ -625,23 +739,9 @@ function Run-OpenSSHTests
)
Deploy-OpenSSHTests -OpenSSHTestDir $testInstallFolder
Run-OpenSSHUnitTest -testRoot $testInstallFolder -unitTestOutputFile $unitTestResultsFile
# Run all pester tests.
Run-OpenSSHPesterTest -testRoot $testInstallFolder -outputXml $testResultsFile
$xml = [xml](Get-Content -raw $testResultsFile)
if ([int]$xml.'test-results'.failures -gt 0)
{
throw "$($xml.'test-results'.failures) tests in regress\pesterTests failed"
}
# Writing out warning when the $Error.Count is non-zero. Tests Should clean $Error after success.
if ($Error.Count -gt 0)
{
$Error| Out-File "$env:SystemDrive\OpenSSH\TestError.txt" -Append
}
Run-OpenSSHUnitTest -testRoot $testInstallFolder -unitTestOutputFile $unitTestResultsFile
}
function Upload-OpenSSHTestResults
@ -654,6 +754,28 @@ function Upload-OpenSSHTestResults
if ($env:APPVEYOR_JOB_ID)
{
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
$resultFile = Resolve-Path $testResultsFile -ErrorAction Ignore
if($resultFile)
{
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $resultFile)
Write-BuildMessage -Message "Test results uploaded!" -Category Information
}
}
if ($env:DebugMode)
{
Remove-Item $env:DebugMode
}
if($env:TestPassed -ieq 'True')
{
Write-BuildMessage -Message "The checkin validation success!"
}
else
{
Write-BuildMessage -Message "The checkin validation failed!" -Category Error
throw "The checkin validation failed!"
}
}
Export-ModuleMember -Function Set-BuildVariable, Invoke-AppVeyorBuild, Install-OpenSSH, Install-TestDependencies, GetLocalPSCorePath, Upload-OpenSSHTestResults, Run-OpenSSHTests, Publish-Artifact, Start-SSHBuild, Deploy-OpenSSHTests, Run-OpenSSHUnitTest,Run-OpenSSHPesterTest,Check-PesterTestResult

View File

@ -151,7 +151,7 @@ function Start-SSHBootstrap
else
{
Write-BuildMsg -AsInfo -Message "Chocolatey not present. Installing chocolatey." -Silent:$silent
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) 2>&1 >> $script:BuildLogFile
if (-not ($machinePath.ToLower().Contains($chocolateyPath.ToLower())))
{
@ -207,7 +207,7 @@ function Start-SSHBootstrap
if (-not (Test-Path -Path $nasmPath -PathType Container))
{
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName." -Silent:$silent
choco install $packageName -y --force --limitoutput --execution-timeout 10000
choco install $packageName -y --force --limitoutput --execution-timeout 10000 2>&1 >> $script:BuildLogFile
}
else
{
@ -220,9 +220,9 @@ function Start-SSHBootstrap
if ($null -eq $VSPackageInstalled)
{
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName." -Silent:$silent
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName."
$adminFilePath = "$script:OpenSSHRoot\contrib\win32\openssh\VSWithBuildTools.xml"
choco install $packageName -packageParameters "--AdminFile $adminFilePath" -y --force --limitoutput --execution-timeout 10000
choco install $packageName -packageParameters "--AdminFile $adminFilePath" -y --force --limitoutput --execution-timeout 10000 2>&1 >> $script:BuildLogFile
}
else
{
@ -235,8 +235,8 @@ function Start-SSHBootstrap
if (-not (Test-Path -Path $sdkPath))
{
Write-BuildMsg -AsInfo -Message "Windows 8.1 SDK not present. Installing $packageName." -Silent:$silent
choco install $packageName -y --limitoutput --force
Write-BuildMsg -AsInfo -Message "Windows 8.1 SDK not present. Installing $packageName."
choco install $packageName -y --limitoutput --force 2>&1 >> $script:BuildLogFile
}
else
{
@ -330,7 +330,7 @@ function Start-SSHBuild
$script:BuildLogFile = Get-BuildLogFile -root $repositoryRoot.FullName -Configuration $Configuration -NativeHostArch $NativeHostArch
if (Test-Path -Path $script:BuildLogFile)
{
Remove-Item -Path $script:BuildLogFile
Remove-Item -Path $script:BuildLogFile -force
}
Write-BuildMsg -AsInfo -Message "Starting Open SSH build; Build Log: $($script:BuildLogFile)"
@ -341,9 +341,7 @@ function Start-SSHBuild
Copy-OpenSSLSDK
$msbuildCmd = "msbuild.exe"
$solutionFile = Get-SolutionFile -root $repositoryRoot.FullName
$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/noconlog", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
#$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/m", "/noconlog", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
& $msbuildCmd $cmdMsg
$errorCode = $LASTEXITCODE
@ -353,7 +351,7 @@ function Start-SSHBuild
Write-BuildMsg -AsError -ErrorAction Stop -Message "Build failed for OpenSSH.`nExitCode: $error."
}
Write-BuildMsg -AsInfo -Message "SSH build passed."
Write-BuildMsg -AsInfo -Message "SSH build passed." -Silent:$silent
}
function Get-BuildLogFile

View File

@ -112,7 +112,7 @@ AuthorizedKeysFile .ssh/authorized_keys
#Banner none
# override default of no subsystems
Subsystem sftp C:/Program Files/OpenSSH/sftp-server.exe
Subsystem sftp sftp-server.exe
# Example of overriding settings on a per-user basis
#Match User anoncvs

View File

@ -25,6 +25,7 @@ Describe "Tests for scp command" -Tags "CI" {
[Machine] $server = [Machine]::new([MachineRole]::Server)
$client.SetupClient($server)
$server.SetupServer($client)
$script:logNum = 0
$testData = @(
@{
@ -76,6 +77,19 @@ Describe "Tests for scp command" -Tags "CI" {
Destination = $DestinationDir
}
)
function CheckTarget {
param([string]$target)
if(-not (Test-path $target))
{
Copy-Item .\logs\ssh-agent.log ".\logs\failedagent$script:logNum.log" -Force
Copy-Item .\logs\sshd.log ".\logs\failedsshd$script:logNum.log" -Force
$script:logNum++
return $false
}
return $true
}
}
AfterAll {
@ -87,7 +101,7 @@ Describe "Tests for scp command" -Tags "CI" {
}
BeforeAll {
$null = New-Item $DestinationDir -ItemType directory -Force
$null = New-Item $DestinationDir -ItemType directory -Force -ErrorAction SilentlyContinue
}
AfterEach {
@ -105,6 +119,16 @@ Describe "Tests for scp command" -Tags "CI" {
$Server.SecureHostKeys($server.PrivateHostKeyPaths)
$privateKeyFile = $client.clientPrivateKeyPaths[0]
}
BeforeEach {
if ($env:DebugMode)
{
Stop-Service ssh-agent -Force
Start-Sleep 2
Remove-Item .\logs\ssh-agent.log -Force -ErrorAction ignore
Remove-Item .\logs\sshd.log -Force -ErrorAction ignore
Start-Service sshd
}
}
AfterAll {
$Server.CleanupHostKeys()
@ -113,7 +137,10 @@ Describe "Tests for scp command" -Tags "CI" {
It 'File copy with -i option and private key: <Title> ' -TestCases:$testData {
param([string]$Title, $Source, $Destination)
.\scp -i $privateKeyFile $Source $Destination
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length).Length -eq 0
$equal | Should Be $true
}
@ -122,11 +149,12 @@ Describe "Tests for scp command" -Tags "CI" {
param([string]$Title, $Source, $Destination)
.\scp -r -i $privateKeyFile $Source $Destination
$LASTEXITCODE | Should Be 0
CheckTarget -target (join-path $DestinationDir $SourceDirName) | Should Be $true
$equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length).Length -eq 0
$equal | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -Recurse -path $SourceDir) (Get-ChildItem -Recurse -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length).Length -eq 0
$equal | Should Be $true
}
@ -147,26 +175,32 @@ Describe "Tests for scp command" -Tags "CI" {
.\ssh-add.exe -D
}
It 'File copy with -S option (positive)' {
.\scp -S .\ssh.exe $SourceFilePath "$($server.localAdminUserName)@$($server.MachineName):$DestinationFilePath"
It 'File copy with -S -v option (positive)' {
.\scp -S .\ssh.exe -v $SourceFilePath "$($server.localAdminUserName)@$($server.MachineName):$DestinationFilePath"
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length).Length -eq 0
$equal | Should Be $true
}
It 'File copy with -p -c -v option: <Title> ' -TestCases:$testData {
It 'File copy with -p -c option: <Title> ' -TestCases:$testData {
param([string]$Title, $Source, $Destination)
.\scp -p -c aes128-ctr -v -C $Source $Destination
.\scp -p -c aes128-ctr -C $Source $Destination
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true
}
It 'Directory recursive copy with -r -p -v option: <Title> ' -TestCases:$testData1 {
It 'Directory recursive copy with -r -p -c option: <Title> ' -TestCases:$testData1 {
param([string]$Title, $Source, $Destination)
.\scp -r -p -c aes128-ctr -v $Source $Destination
.\scp -r -p -c aes128-ctr $Source $Destination
$LASTEXITCODE | Should Be 0
CheckTarget -target (join-path $DestinationDir $SourceDirName) | Should Be $true
$equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true
@ -184,7 +218,9 @@ Describe "Tests for scp command" -Tags "CI" {
param([string]$Title, $Source, $Destination)
.\scp -i $identifyFile -C -q $Source $Destination
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length).Length -eq 0
$equal | Should Be $true
}
@ -193,6 +229,8 @@ Describe "Tests for scp command" -Tags "CI" {
param([string]$Title, $Source, $Destination)
.\scp -i $identifyFile -C -r -q $Source $Destination
$LASTEXITCODE | Should Be 0
CheckTarget -target (join-path $DestinationDir $SourceDirName) | Should Be $true
$equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length).Length -eq 0
$equal | Should Be $true
@ -214,7 +252,9 @@ Describe "Tests for scp command" -Tags "CI" {
param([string]$Title, $Source, $Destination)
.\scp -p $Source $Destination
$LASTEXITCODE | Should Be 0
#validate file content. DestPath is the path to the file.
CheckTarget -target $DestinationFilePath | Should Be $true
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true
}
@ -223,6 +263,8 @@ Describe "Tests for scp command" -Tags "CI" {
param([string]$Title, $Source, $Destination)
.\scp -r -p $Source $Destination
$LASTEXITCODE | Should Be 0
CheckTarget -target (join-path $DestinationDir $SourceDirName) | Should Be $true
$equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true

View File

@ -14,9 +14,9 @@ Describe "Tests for ssh command" -Tags "CI" {
$testData = @(
@{
Title = 'Simple logon -v option';
Title = 'Simple logon no option';
LogonStr = "$($server.localAdminUserName)@$($server.MachineName)"
Options = "-v"
Options = ""
},
@{
Title = 'Simple logon using -C -l option'
@ -32,9 +32,9 @@ Describe "Tests for ssh command" -Tags "CI" {
Options = '-i $identifyFile -q'
},
@{
Title = "logon using -i -v option"
Title = "logon using -i option"
LogonStr = "$($server.localAdminUserName)@$($server.MachineName)"
Options = '-i $identifyFile -v'
Options = '-i $identifyFile'
},
@{
Title = "logon using -i -c option"