Move CLI tests to the separate test file on Windows (#1363)

* move cli tests to the separate file

* switch install scripts

* unify CLI names
This commit is contained in:
Maxim Lobanov
2020-08-06 11:27:58 +03:00
committed by GitHub
parent 490f615019
commit 0f6fba462a
16 changed files with 81 additions and 206 deletions

View File

@@ -15,4 +15,4 @@ $env:Path = $env:Path + ";$env:ProgramFiles\Amazon\SessionManagerPlugin\bin"
# Install AWS SAM CLI # Install AWS SAM CLI
Install-Binary -Url "https://github.com/awslabs/aws-sam-cli/releases/latest/download/AWS_SAM_CLI_64_PY3.msi" -Name "AWS_SAM_CLI_64_PY3.msi" Install-Binary -Url "https://github.com/awslabs/aws-sam-cli/releases/latest/download/AWS_SAM_CLI_64_PY3.msi" -Name "AWS_SAM_CLI_64_PY3.msi"
Invoke-PesterTests -TestFile "Tools" -TestName "AWS" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "AWS"

View File

@@ -17,4 +17,4 @@ Extract-7Zip -Path $aliyunArchivePath -DestinationPath $aliyunPath
# Add aliyun-cli to path # Add aliyun-cli to path
Add-MachinePathItem $aliyunPath Add-MachinePathItem $aliyunPath
Invoke-PesterTests -TestFile "Tools" -TestName "AliyunCli" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Aliyun CLI"

View File

@@ -10,4 +10,4 @@ New-Item -ItemType "directory" -Path $AzureCliExtensionPath
[Environment]::SetEnvironmentVariable("AZURE_EXTENSION_DIR", $AzureCliExtensionPath, [System.EnvironmentVariableTarget]::Machine) [Environment]::SetEnvironmentVariable("AZURE_EXTENSION_DIR", $AzureCliExtensionPath, [System.EnvironmentVariableTarget]::Machine)
Invoke-PesterTests -TestFile "Tools" -TestName "AzureCli" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Azure CLI"

View File

@@ -5,4 +5,4 @@
az extension add -n azure-devops az extension add -n azure-devops
Invoke-PesterTests -TestFile "Tools" -TestName "Azure DevOps CLI" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Azure DevOps CLI"

View File

@@ -22,4 +22,4 @@ Extract-7Zip -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath
# Add cf to path # Add cf to path
Add-MachinePathItem $CloudFoundryCliPath Add-MachinePathItem $CloudFoundryCliPath
Invoke-PesterTests -TestFile "Tools" -TestName "CloudFoundryCli" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "CloudFoundry CLI"

View File

@@ -41,4 +41,4 @@ Choco-Install -PackageName hub
Add-MachinePathItem "C:\Program Files\Git\bin" Add-MachinePathItem "C:\Program Files\Git\bin"
Invoke-PesterTests -TestFile "Git" -TestName "Git" Invoke-PesterTests -TestFile "Git" -TestName "Git"
Invoke-PesterTests -TestFile "Git" -TestName "Hub" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Hub CLI"

View File

@@ -7,4 +7,4 @@ Choco-Install -PackageName gh
Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI" Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI"
Invoke-PesterTests -TestFile "Tools" -TestName "GitHub-CLI" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "GitHub CLI"

View File

@@ -1,78 +0,0 @@
################################################################################
## File: Install-SQLExpress.ps1
## Desc: Install SQL Express for Windows
################################################################################
Import-Module -Name ImageHelpers -Force;
function Download-FullSQLPackage {
param(
[String]$InstallerPath,
[String]$DownloadPath,
[String]$Arguments = ("/MEDIAPATH=$DownloadPath", "/MEDIATYPE=Core","/Action=Download", "/QUIET")
)
Write-Host "Downloading full package to $DownloadPath..."
$process = Start-Process -FilePath $InstallerPath -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode
if ($exitCode -eq 0)
{
Write-Host -Object "Full SQL Express package has been successfully downloaded to $DownloadPath : ExitCode: $exitCode"
}
else
{
Write-Host -Object "Full package downloading process was unsuccessful. Exit code: $exitCode."
exit $exitCode
}
}
function Unpack-SQLInstaller {
param(
[String]$InstallPath,
[String]$Arguments = ("/Q", "/IACCEPTSQLSERVERLICENSETERMS")
)
Write-Host "Start unpacking procedure to $InstallPath..."
$process = Start-Process -FilePath $InstallPath -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode
# Exit code -2067529716 is added since SQL Unpack procedure returns it on success.
if ($exitCode -eq 0 -or $exitCode -eq -2067529716)
{
Write-Host -Object "SQL installer unpacking has been completed."
}
else
{
Write-Host -Object "SQL installer unpacking was interrupted : $exitCode."
exit $exitCode
}
}
function Start-Installer {
param(
[String]$InstallerPath,
[String]$Arguments = ("/Q", "/IACCEPTSQLSERVERLICENSETERMS", "/Action=Install", "/INSTANCEID=SQL2019", "/INSTANCENAME=SQL2019", "/SECURITYMODE=SQL", "/SAPWD=P@ssword!!", "/TCPENABLED=1")
)
Write-Host "Installating SQL Express..."
$process = Start-Process -FilePath $InstallerPath -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode
if ($exitCode -eq 0)
{
Write-Host -Object "SQL Express has been successfully installed: ExitCode: $exitCode"
}
else
{
Write-Host -Object "Installation procedure was not correctly completed. Exit code: $exitCode."
exit $exitCode
}
}
#Main function
$installerUrl = "https://go.microsoft.com/fwlink/?linkid=866658"
$downloadPath = "C:\SQLInstall"
$setupPath = Join-Path $downloadPath "SQLEXPR_x64_ENU"
#Create directory for temporary files
New-Item -Path $downloadPath -ItemType Directory
Set-Location -Path $downloadPath
$installerPath = Start-DownloadWithRetry -Url $installerUrl -DownloadPath $downloadPath -Name "SQL2019-SSEI-Expr.exe"
Download-FullSQLPackage -InstallerPath $installerPath -DownloadPath $downloadPath
Unpack-SQLInstaller -InstallPath "$setupPath.exe"
$resultPath = Join-Path $setupPath "SETUP.exe"
Start-Installer -InstallerPath $resultPath
#Cleanup folder with installation packages.
Remove-Item $downloadPath -Recurse -Force

View File

@@ -1,15 +0,0 @@
################################################################################
## File: Validate-AzureCli.ps1
## Desc: Validate Azure CLI
################################################################################
if (Get-Command -Name 'az')
{
Write-Host "Azure Cli $(az --version) on path"
}
else
{
Write-Error "Azure Cli not on path"
exit 1
}

View File

@@ -1,40 +0,0 @@
################################################################################
## File: Validate-SQLExpress.ps1
## Desc: Validate Microsoft SQL Express installation
################################################################################
#Parameters for database access
$sqlUser = "sa"
$sqlPassword = "P@ssword!!"
$sqlInstance = "SQL2019"
function Test-SqlConnection {
param(
[Parameter(Mandatory)]
[string]$ServerName,
[Parameter(Mandatory)]
[string]$IntegratedSecurity,
[Parameter(Mandatory)]
[string]$UserName,
[Parameter(Mandatory)]
[string]$Password
)
$ErrorActionPreference = 'Stop'
try {
$connectionString = 'Server={0};Integrated Security={1};User ID={2};Password={3}' -f $ServerName,$IntegratedSecurity,$UserName,$Password
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $connectionString
$sqlConnection.Open()
Write-Host -Object "Connection to SQL Express was successful."
} catch {
Write-Host -Object "Connection to SQL Express cannot be established."
exit 1
} finally {
## Close the connection when we're done
$sqlConnection.Close()
}
}
$instanceName = "$env:computername\$sqlInstance"
Test-SqlConnection -ServerName $instanceName -IntegratedSecurity "false" -UserName $sqlUser -Password $sqlPassword

View File

@@ -6,16 +6,17 @@ function Get-PostgreSQLMarkdown
$pgRoot = $pgPath.split('"')[1].replace("\bin\pg_ctl.exe", "") $pgRoot = $pgPath.split('"')[1].replace("\bin\pg_ctl.exe", "")
$env:Path += ";${env:PGBIN}" $env:Path += ";${env:PGBIN}"
$pgVersion = (postgres --version).split()[2].Trim() $pgVersion = (postgres --version).split()[2].Trim()
$content = [PSCustomObject]@{
Version = $pgVersion $content = @(
UserName = $env:PGUSER [PSCustomObject]@{ Property = "ServiceName"; Value = $pgService.Name },
Password = $env:PGPASSWORD [PSCustomObject]@{ Property = "Version"; Value = $pgVersion },
EnvironmentVariables = "PGBIN=$env:PGBIN; <br> PGDATA=$env:PGDATA; <br> PGROOT=$env:PGROOT" [PSCustomObject]@{ Property = "ServiceStatus"; Value = $pgService.State },
Path = $pgRoot [PSCustomObject]@{ Property = "ServiceStartType"; Value = $pgService.StartMode },
ServiceName = $pgService.Name [PSCustomObject]@{ Property = "EnvironmentVariables"; Value = "`PGBIN=$env:PGBIN` <br> `PGDATA=$env:PGDATA` <br> `PGROOT=$env:PGROOT` " },
ServiceStatus = $pgService.State [PSCustomObject]@{ Property = "Path"; Value = $pgRoot },
ServiceStartType = $pgService.StartMode [PSCustomObject]@{ Property = "UserName"; Value = $env:PGUSER },
} | New-MDTable [PSCustomObject]@{ Property = "Password"; Value = $env:PGPASSWORD }
) | New-MDTable
Build-MarkdownElement -Head $name -Content $content Build-MarkdownElement -Head $name -Content $content
} }

View File

@@ -70,6 +70,7 @@ $markdown += New-MDList -Style Unordered -Lines @(
$markdown += New-MDHeader "Tools" -Level 3 $markdown += New-MDHeader "Tools" -Level 3
$markdown += New-MDList -Style Unordered -Lines @( $markdown += New-MDList -Style Unordered -Lines @(
(Get-AzCosmosDBEmulatorVersion), (Get-AzCosmosDBEmulatorVersion),
(Get-AzCopyVersion),
(Get-BazelVersion), (Get-BazelVersion),
(Get-BazeliskVersion), (Get-BazeliskVersion),
(Get-CMakeVersion), (Get-CMakeVersion),
@@ -78,6 +79,7 @@ $markdown += New-MDList -Style Unordered -Lines @(
(Get-DockerComposeVersion), (Get-DockerComposeVersion),
(Get-GitVersion), (Get-GitVersion),
(Get-GitLFSVersion), (Get-GitLFSVersion),
(Get-GoogleCloudSDKVersion),
(Get-InnoSetupVersion), (Get-InnoSetupVersion),
(Get-JQVersion), (Get-JQVersion),
(Get-KubectlVersion), (Get-KubectlVersion),
@@ -105,7 +107,6 @@ $markdown += New-MDList -Style Unordered -Lines @(
$markdown += New-MDHeader "CLI Tools" -Level 3 $markdown += New-MDHeader "CLI Tools" -Level 3
$markdown += New-MDList -Style Unordered -Lines @( $markdown += New-MDList -Style Unordered -Lines @(
(Get-AzureCLIVersion), (Get-AzureCLIVersion),
(Get-AzCopyVersion),
(Get-AzureDevopsExtVersion), (Get-AzureDevopsExtVersion),
(Get-AWSCLIVersion), (Get-AWSCLIVersion),
(Get-AWSSAMVersion), (Get-AWSSAMVersion),
@@ -113,7 +114,7 @@ $markdown += New-MDList -Style Unordered -Lines @(
(Get-AlibabaCLIVersion), (Get-AlibabaCLIVersion),
(Get-CloudFoundryVersion), (Get-CloudFoundryVersion),
(Get-HubVersion), (Get-HubVersion),
(Get-GoogleCloudSDKVersion) (Get-GHVersion)
) )
$markdown += New-MDHeader "Rust Tools" -Level 3 $markdown += New-MDHeader "Rust Tools" -Level 3

View File

@@ -220,4 +220,8 @@ function Get-GoogleCloudSDKVersion {
function Get-NewmanVersion { function Get-NewmanVersion {
return "Newman $(newman --version)" return "Newman $(newman --version)"
}
function Get-GHVersion {
return "GitHub CLI $(gh --version)"
} }

View File

@@ -0,0 +1,56 @@
Describe "Azure CLI" {
It "Azure CLI" {
"az --version" | Should -ReturnZeroExitCode
}
}
Describe "Azure DevOps CLI" {
It "az devops" {
"az devops -h" | Should -ReturnZeroExitCode
}
}
Describe "Aliyun CLI" {
It "Aliyun CLI" {
"aliyun version" | Should -ReturnZeroExitCode
}
}
Describe "AWS" {
It "AWS CLI" {
"aws --version" | Should -ReturnZeroExitCode
}
It "Session Manager Plugin for the AWS CLI" {
session-manager-plugin | Out-String | Should -Match "plugin was installed successfully"
}
It "AWS SAM CLI" {
"sam --version" | Should -ReturnZeroExitCode
}
}
Describe "GitHub CLI" {
It "gh" {
"gh --version" | Should -ReturnZeroExitCode
}
}
Describe "CloudFoundry CLI" {
It "cf is located in C:\cf-cli" {
"C:\cf-cli\cf.exe" | Should -Exist
}
It "cf" {
"cf --version" | Should -ReturnZeroExitCode
}
}
Describe "Hub CLI" {
It "hub is installed" {
"hub --version" | Should -ReturnZeroExitCode
}
}

View File

@@ -24,12 +24,6 @@ Describe "Git" {
} }
} }
Describe "Hub" {
It "hub is installed" {
"hub --version" | Should -ReturnZeroExitCode
}
}
Describe "GitVersion" { Describe "GitVersion" {
It "gitversion is installed" { It "gitversion is installed" {
"gitversion /version" | Should -ReturnZeroExitCode "gitversion /version" | Should -ReturnZeroExitCode

View File

@@ -6,26 +6,6 @@ Describe "7-Zip" {
} }
} }
Describe "AliyunCli" {
It "AliyunCli" {
"aliyun version" | Should -ReturnZeroExitCode
}
}
Describe "AWS" {
It "AWS CLI" {
"aws --version" | Should -ReturnZeroExitCode
}
It "Session Manager Plugin for the AWS CLI" {
session-manager-plugin | Out-String | Should -Match "plugin was installed successfully"
}
It "AWS SAM CLI" {
"sam --version" | Should -ReturnZeroExitCode
}
}
Describe "AzCopy" { Describe "AzCopy" {
It "AzCopy" { It "AzCopy" {
"azcopy --version" | Should -ReturnZeroExitCode "azcopy --version" | Should -ReturnZeroExitCode
@@ -46,18 +26,6 @@ Describe "Azure Cosmos DB Emulator" {
} }
} }
Describe "AzureCli" {
It "AzureCli" {
"az --version" | Should -ReturnZeroExitCode
}
}
Describe "Azure DevOps CLI" {
It "az devops" {
"az devops -h" | Should -ReturnZeroExitCode
}
}
Describe "Bazel" { Describe "Bazel" {
It "<ToolName>" -TestCases @( It "<ToolName>" -TestCases @(
@{ ToolName = "bazel" } @{ ToolName = "bazel" }
@@ -162,22 +130,6 @@ Describe "InnoSetup" {
} }
} }
Describe "GitHub-CLI" {
It "gh" {
"gh --version" | Should -ReturnZeroExitCode
}
}
Describe "CloudFoundryCli" {
It "cf is located in C:\cf-cli" {
"C:\cf-cli\cf.exe" | Should -Exist
}
It "cf" {
"cf --version" | Should -ReturnZeroExitCode
}
}
Describe "GoogleCouldSDK" { Describe "GoogleCouldSDK" {
It "<ToolName>" -TestCases @( It "<ToolName>" -TestCases @(
@{ ToolName = "bq" } @{ ToolName = "bq" }