mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 06:08:07 +00:00
Databases and java pester tests (#2338)
* added mongodb postgres java tests * fixed 1.7 and 12 Java on Ubuntu 20 * several improvments * removed update-environment function * add etc-environment import * removed sourcing invoke-tests Co-authored-by: Leonid Lapshin <originalnoe-nazvanie@yandex.ru>
This commit is contained in:
53
images/linux/scripts/tests/Java.Tests.ps1
Normal file
53
images/linux/scripts/tests/Java.Tests.ps1
Normal file
@@ -0,0 +1,53 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -DisableNameChecking
|
||||
|
||||
Describe "Java" {
|
||||
|
||||
if (Test-IsUbuntu20) {
|
||||
$defaultJavaVersion = "11"
|
||||
$javaTestCases = @(
|
||||
@{ Version = "1.8" }
|
||||
@{ Version = "11" }
|
||||
)
|
||||
}
|
||||
|
||||
if ((Test-IsUbuntu16) -or (Test-IsUbuntu18)) {
|
||||
$defaultJavaVersion = "8"
|
||||
$javaTestCases = @(
|
||||
@{ Version = "1.7" }
|
||||
@{ Version = "1.8" }
|
||||
@{ Version = "11" }
|
||||
@{ Version = "12" }
|
||||
)
|
||||
}
|
||||
|
||||
It "Java <DefaultJavaVersion> is default" -TestCases @{ defaultJavaVersion = $defaultJavaVersion } {
|
||||
$actualJavaPath = Get-EnvironmentVariable "JAVA_HOME"
|
||||
$expectedJavaPath = Get-EnvironmentVariable "JAVA_HOME_${defaultJavaVersion}_X64"
|
||||
|
||||
$actualJavaPath | Should -Not -BeNullOrEmpty
|
||||
$expectedJavaPath | Should -Not -BeNullOrEmpty
|
||||
$actualJavaPath | Should -Be $expectedJavaPath
|
||||
}
|
||||
|
||||
It "<ToolName>" -TestCases @(
|
||||
@{ ToolName = "java" }
|
||||
@{ ToolName = "javac" }
|
||||
@{ ToolName = "mvn" }
|
||||
@{ ToolName = "ant" }
|
||||
@{ ToolName = "gradle" }
|
||||
) {
|
||||
"$ToolName -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Java <Version>" -TestCases $javaTestCases {
|
||||
$versionNumber = $version.Split(".") | Select-Object -Last 1
|
||||
|
||||
$javaVariableValue = Get-EnvironmentVariable "JAVA_HOME_${versionNumber}_X64"
|
||||
$javaVariableValue | Should -Not -BeNullOrEmpty
|
||||
$javaPath = Join-Path $javaVariableValue "bin/java"
|
||||
|
||||
$result = Get-CommandResult "`"$javaPath`" -version"
|
||||
$result.ExitCode | Should -Be 0
|
||||
$result.Output | Should -Match ([regex]::Escape("openjdk version `"${Version}."))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user