Skip to content

Commit

Permalink
Add Java 21 Windows container (#1820)
Browse files Browse the repository at this point in the history
* Add Java 21 container for Windows

Change also includes an experiment to limit the tests that are run so
that we don't spend so much time in the Windows tests.

Goal: Save time and money by not duplicating slow tests on JDK versions

Many of the Windows tests run for a long time and don't tell us much
when we run them on all Java versions.  The change attempts to skip the
long running tests that are unlikely to detect a difference between JDK
versions.

* Fix syntax error

Co-authored-by: Hervé Le Meur <91831478+lemeurherve@users.noreply.github.com>

* Run more tests only on Java 21

---------

Co-authored-by: Hervé Le Meur <91831478+lemeurherve@users.noreply.github.com>
  • Loading branch information
MarkEWaite and lemeurherve authored Jan 28, 2024
1 parent aa4b7ba commit 4d39d42
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 14 deletions.
17 changes: 17 additions & 0 deletions build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,20 @@ services:
- ${DOCKERHUB_ORGANISATION}/${DOCKERHUB_REPO}:${JENKINS_VERSION}-jdk17-hotspot-${WINDOWS_FLAVOR}-${WINDOWS_VERSION}
- ${DOCKERHUB_ORGANISATION}/${DOCKERHUB_REPO}:${JENKINS_VERSION}-${WINDOWS_FLAVOR}-${WINDOWS_VERSION}
- ${DOCKERHUB_ORGANISATION}/${DOCKERHUB_REPO}${SEPARATOR_LTS_PREFIX}${WINDOWS_FLAVOR}-${WINDOWS_VERSION}
jdk21:
image: ${DOCKERHUB_ORGANISATION}/${DOCKERHUB_REPO}${SEPARATOR_LTS_PREFIX}jdk21-hotspot-${WINDOWS_FLAVOR}-${WINDOWS_VERSION}
build:
context: ./
dockerfile: ./windows/${WINDOWS_FLAVOR}/hotspot/Dockerfile
args:
COMMIT_SHA: ${COMMIT_SHA}
JAVA_HOME: "C:/openjdk-21"
JAVA_VERSION: "21.0.2_13"
JENKINS_SHA: ${JENKINS_SHA}
JENKINS_VERSION: ${JENKINS_VERSION}
TOOLS_WINDOWS_VERSION: ${TOOLS_WINDOWS_VERSION}
WINDOWS_VERSION: ${WINDOWS_VERSION}
tags:
- ${DOCKERHUB_ORGANISATION}/${DOCKERHUB_REPO}:${JENKINS_VERSION}-jdk21-hotspot-${WINDOWS_FLAVOR}-${WINDOWS_VERSION}
- ${DOCKERHUB_ORGANISATION}/${DOCKERHUB_REPO}:${JENKINS_VERSION}-${WINDOWS_FLAVOR}-${WINDOWS_VERSION}
- ${DOCKERHUB_ORGANISATION}/${DOCKERHUB_REPO}${SEPARATOR_LTS_PREFIX}${WINDOWS_FLAVOR}-${WINDOWS_VERSION}
6 changes: 4 additions & 2 deletions tests/functions.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Describe "[functions > $global:TEST_TAG] build image" {
}
}

Describe "[functions > $global:TEST_TAG] Check-VersionLessThan" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[functions > $global:TEST_TAG] Check-VersionLessThan" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'exit codes work' {
docker run --rm $global:SUT_IMAGE "exit -1"
$LastExitCode | Should -Be -1
Expand Down Expand Up @@ -72,7 +73,8 @@ Describe "[functions > $global:TEST_TAG] Check-VersionLessThan" {
}
}

Describe "[functions > $global:TEST_TAG] Copy-ReferenceFile" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[functions > $global:TEST_TAG] Copy-ReferenceFile" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'build test image' {
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE $PSScriptRoot/functions
$exitCode | Should -Be 0
Expand Down
27 changes: 18 additions & 9 deletions tests/plugins-cli.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Describe "[plugins-cli > $global:TEST_TAG] cleanup container" {
}
}

Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'builds child image' {
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE-plugins-cli $PSScriptRoot/plugins-cli
$exitCode | Should -Be 0
Expand Down Expand Up @@ -62,7 +63,8 @@ Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-pl
}
}

Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli with non-default REF" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli with non-default REF" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'builds child image' {
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE-plugins-cli-ref $PSScriptRoot/plugins-cli/ref
$exitCode | Should -Be 0
Expand Down Expand Up @@ -99,7 +101,8 @@ Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-pl
}
}

Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli from a plugins file" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli from a plugins file" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'builds child image' {
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE-plugins-cli $PSScriptRoot/plugins-cli
$exitCode | Should -Be 0
Expand Down Expand Up @@ -136,7 +139,8 @@ Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-pl
}
}

Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli even when already exist" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli even when already exist" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'builds child image' {
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE-plugins-cli $PSScriptRoot/plugins-cli
$exitCode | Should -Be 0
Expand All @@ -162,7 +166,8 @@ Describe "[plugins-cli > $global:TEST_TAG] clean work directory" {
}
}

Describe "[plugins-cli > $global:TEST_TAG] plugins are getting upgraded but not downgraded" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[plugins-cli > $global:TEST_TAG] plugins are getting upgraded but not downgraded" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'builds child image' {
# Initial execution
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE-plugins-cli $PSScriptRoot/plugins-cli
Expand Down Expand Up @@ -212,7 +217,8 @@ Describe "[plugins-cli > $global:TEST_TAG] clean work directory" {
}
}

Describe "[plugins-cli > $global:TEST_TAG] do not upgrade if plugin has been manually updated" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[plugins-cli > $global:TEST_TAG] do not upgrade if plugin has been manually updated" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {

It 'builds child image' {
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE-plugins-cli $PSScriptRoot/plugins-cli
Expand Down Expand Up @@ -261,7 +267,8 @@ Describe "[plugins-cli > $global:TEST_TAG] clean work directory" {
}
}

Describe "[plugins-cli > $global:TEST_TAG] upgrade plugin even if it has been manually updated when PLUGINS_FORCE_UPGRADE=true" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[plugins-cli > $global:TEST_TAG] upgrade plugin even if it has been manually updated when PLUGINS_FORCE_UPGRADE=true" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'builds child image' {
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE-plugins-cli $PSScriptRoot/plugins-cli
$exitCode | Should -Be 0
Expand Down Expand Up @@ -307,14 +314,16 @@ Describe "[plugins-cli > $global:TEST_TAG] clean work directory" {
}
}

Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli and no war" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[plugins-cli > $global:TEST_TAG] plugins are installed with jenkins-plugin-cli and no war" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'builds child image' {
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE-plugins-cli-no-war $PSScriptRoot/plugins-cli/no-war
$exitCode | Should -Be 0
}
}

Describe "[plugins-cli > $global:TEST_TAG] Use a custom jenkins.war" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[plugins-cli > $global:TEST_TAG] Use a custom jenkins.war" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'builds child image' {
$exitCode, $stdout, $stderr = Build-DockerChild $global:SUT_IMAGE-plugins-cli-custom-war $PSScriptRoot/plugins-cli/custom-war --no-cache
$exitCode | Should -Be 0
Expand Down
9 changes: 6 additions & 3 deletions tests/runtime.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Describe "[runtime > $global:TEST_TAG] cleanup container" {
}
}

Describe "[runtime > $global:TEST_TAG] test multiple JENKINS_OPTS" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[runtime > $global:TEST_TAG] test multiple JENKINS_OPTS" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It '"--help --version" should return the version, not the help' {
# need the last line of output
$exitCode, $stdout, $stderr = Run-Program 'docker.exe' "run --rm -e JENKINS_OPTS=`"--help --version`" --name $global:SUT_CONTAINER -P $global:SUT_IMAGE"
Expand All @@ -35,7 +36,8 @@ Describe "[runtime > $global:TEST_TAG] test multiple JENKINS_OPTS" {
}
}

Describe "[runtime > $global:TEST_TAG] test jenkins arguments" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[runtime > $global:TEST_TAG] test jenkins arguments" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
It 'running --help --version should return the version, not the help' {
# need the last line of output
$exitCode, $stdout, $stderr = Run-Program 'docker.exe' "run --rm --name $global:SUT_CONTAINER -P $global:SUT_IMAGE --help --version"
Expand All @@ -56,7 +58,8 @@ Describe "[runtime > $global:TEST_TAG] test jenkins arguments" {
}
}

Describe "[runtime > $global:TEST_TAG] passing JVM parameters" {
# Only test on Java 21, one JDK is enough to test all versions
Describe "[runtime > $global:TEST_TAG] passing JVM parameters" -Skip:(-not $global:TEST_TAG.StartsWith('jdk21-')) {
BeforeAll {
$tzSetting = '-Duser.timezone=Europe/Madrid'
$tzRegex = [regex]::Escape("Europe/Madrid")
Expand Down

0 comments on commit 4d39d42

Please sign in to comment.