Replace current validates with pester testing approach #5 (#1232)

* ,oving to the pester approach part #5

* moving to the pester approach part #5

* fixed PostgreSQL tests

* return Validate-Svn.ps1

* fixed Selenium test

* fixed rust test

* fix rust test
This commit is contained in:
Aleksandr Chebotov
2020-07-20 18:57:00 +03:00
committed by GitHub
parent 956b8a0093
commit 0c4dca229d
18 changed files with 145 additions and 161 deletions

View File

@@ -19,7 +19,25 @@ $pgBin = Split-Path -Path $pgPath.split('"')[1]
$pgRoot = Split-Path -Path $pgPath.split('"')[5]
$pgData = Join-Path $pgRoot "data"
#Validate PostgreSQL installation
$pgReadyPath = Join-Path $pgBin "pg_isready.exe"
$pgReady = Start-Process -FilePath $pgReadyPath -Wait -PassThru
$exitCode = $pgReady.ExitCode
if ($exitCode -ne 0)
{
Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode"
exit $exitCode
}
#Added PostgreSQL environment variable
Set-SystemVariable -SystemVariable PGBIN -Value $pgBin
Set-SystemVariable -SystemVariable PGROOT -Value $pgRoot
Set-SystemVariable -SystemVariable PGDATA -Value $pgData
#Stop and disable PostgreSQL service
$pgService = Get-Service -Name postgresql*
Stop-Service -InputObject $pgService
Set-Service -InputObject $pgService -StartupType Disabled
Invoke-PesterTests -TestFile "Databases" -TestName "PostgreSQL"

View File

@@ -4,3 +4,5 @@
################################################################################
Invoke-Expression "& { $(Invoke-RestMethod https://aka.ms/install-powershell.ps1) } -UseMSI -Quiet"
Invoke-PesterTests -TestFile "Tools" -TestName "PowerShell Core"

View File

@@ -6,8 +6,8 @@
Import-Module -Name ImageHelpers
# Rust Env
$env:RUSTUP_HOME="C:\Rust\.rustup"
$env:CARGO_HOME="C:\Rust\.cargo"
$env:RUSTUP_HOME = "C:\Rust\.rustup"
$env:CARGO_HOME = "C:\Rust\.cargo"
# Download the latest rustup-init.exe for Windows x64
# See https://rustup.rs/#
@@ -49,3 +49,10 @@ Remove-Item "${env:CARGO_HOME}\registry\*" -Recurse -Force
# Update Run key to run a script at logon
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "RUSTSYM" -Value $cmdPath
# Create temporary symlinks to properly validate tools version
Set-Location -Path $env:UserProfile
$null = New-Item -Name ".rustup" -Value $env:RUSTUP_HOME -ItemType Junction
$null = New-Item -Name ".cargo" -Value $env:CARGO_HOME -ItemType Junction
Invoke-PesterTests -TestFile "Rust"

View File

@@ -14,7 +14,5 @@ $env:SBT_HOME="${env:ProgramFiles(x86)}\sbt"
# Add sbt binaries to the path
Add-MachinePathItem "$env:SBT_HOME\bin"
$env:Path = Get-MachinePath
# Done
exit 0
Invoke-PesterTests -TestFile "Tools" -TestName "Sbt"

View File

@@ -32,3 +32,5 @@ Start-DownloadWithRetry -Url $seleniumReleaseUrl -Name $seleniumFileName -Downlo
Write-Host "Add selenium jar to the environment variables..."
$seleniumBinPath = Join-Path $seleniumDirectory $seleniumFileName
setx "SELENIUM_JAR_PATH" "$($seleniumBinPath)" /M
Invoke-PesterTests -TestFile "Browsers" -TestName "Selenium"

View File

@@ -11,3 +11,5 @@ New-Item -Path $temp_install_dir -ItemType Directory -Force
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
WebpiCmd.exe /Install /Products:MicrosoftAzure-ServiceFabric-CoreSDK /AcceptEula /XML:https://webpifeed.blob.core.windows.net/webpifeed/5.1/WebProductList.xml
Invoke-PesterTests -TestFile "Tools" -TestName "ServiceFabricSDK"

View File

@@ -1,18 +0,0 @@
$pgReadyPath = Join-Path ${env:PGBIN} "pg_isready.exe"
$pgReady = Start-Process -FilePath $pgReadyPath -Wait -PassThru
$exitCode = $pgReady.ExitCode
if ($exitCode -eq 0)
{
Write-Host -Object "PostgreSQL has been successfully installed."
}
else
{
Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode"
exit $exitCode
}
#Stop and disable PostgreSQL service
$pgService = Get-Service -Name postgresql*
Stop-Service -InputObject $pgService
Set-Service -InputObject $pgService -StartupType Disabled

View File

@@ -1,15 +0,0 @@
################################################################################
## File: Validate-PowershellCore.ps1
## Desc: Validate Powershell Core
################################################################################
if (Get-Command -Name 'pwsh')
{
Write-Host 'pwsh is on PATH'
}
else
{
Write-Host 'pwsh is not on PATH'
exit 1
}

View File

@@ -1,29 +0,0 @@
################################################################################
## File: Validate-Rust.ps1
## Desc: Verify that Rust is on the path and output version information.
################################################################################
if (Get-Command -Name 'rustc')
{
Push-Location -Path $env:UserProfile
New-Item -Name ".rustup" -Value "C:\Rust\.rustup" -ItemType Junction
New-Item -Name ".cargo" -Value "C:\Rust\.cargo" -ItemType Junction
$RustcVersion = rustc --version
Write-Host "$RustcVersion is on the path"
Pop-Location
}
else
{
Write-Host "rustc is not on the path"
exit 1
}
if (-Not (Get-Command -Name 'cargo-audit')){
Write-Host "cargo audit is not on the path"
exit 1
}
if (-Not (Get-Command -Name 'cargo-outdated')){
Write-Host "cargo outdated is not on the path"
exit 1
}

View File

@@ -1,15 +0,0 @@
################################################################################
## File: Validate-Sbt.ps1
## Desc: Validate sbt for Windows
################################################################################
if (Get-Command -Name 'sbt')
{
Write-Host 'sbt is on the path'
}
else
{
Write-Host 'sbt is not on path.'
exit 1
}

View File

@@ -1,17 +0,0 @@
################################################################################
## File: Validate-ServiceFabricSDK.ps1
## Desc: Validate ServiceFabricSDK
################################################################################
$modules = Get-Module -Name ServiceFabric -ListAvailable
if (($modules | Measure-Object).Count -gt 0)
{
$modules
}
else
{
Write-Host "ServiceFabric Module is not present, it might not be installed"
throw "ServiceFabric Module is not present, it might not be installed"
}