Skip to content

Commit

Permalink
[JENKINS-44851] Agents JVM must be 1.8+ now (#2915)
Browse files Browse the repository at this point in the history
* [JENKINS-44851] Agents JVM must be 1.8+ now

* [JENKINS-44851] Fix tests

* Fix old Java 6 and 7 tests (an exception is expected now)
* Add new tests to Java 8
* Fix messages
  • Loading branch information
amuniz authored and oleg-nenashev committed Oct 28, 2017
1 parent 6e75f73 commit f546ffc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/slaves/ComputerLauncher.java
Expand Up @@ -187,7 +187,7 @@ protected static void checkJavaVersion(final PrintStream logger, String javaComm
final String versionStr = m.group(1);
logger.println(Messages.ComputerLauncher_JavaVersionResult(javaCommand, versionStr));
try {
if (new DeweyDecimal(versionStr).isLessThan(new DeweyDecimal("1.6"))) {
if (new DeweyDecimal(versionStr).isLessThan(new DeweyDecimal("1.8"))) {
throw new IOException(Messages
.ComputerLauncher_NoJavaFound(line));
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/hudson/slaves/Messages.properties
Expand Up @@ -36,7 +36,7 @@ SimpleScheduledRetentionStrategy.displayName=Take this agent online according to
EnvironmentVariablesNodeProperty.displayName=Environment variables
SlaveComputer.DisconnectedBy=Disconnected by {0}{1}
NodeDescriptor.CheckName.Mandatory=Name is mandatory
ComputerLauncher.NoJavaFound=Java version {0} was found but 1.6 or later is needed.
ComputerLauncher.NoJavaFound=Java version {0} was found but 1.8 or later is needed.
ComputerLauncher.JavaVersionResult={0} -version returned {1}.
ComputerLauncher.UnknownJavaVersion=Couldn\u2019t figure out the Java version of {0}
Cloud.ProvisionPermission.Description=Provision new nodes
14 changes: 11 additions & 3 deletions core/src/test/java/hudson/slaves/ComputerLauncherTest.java
Expand Up @@ -36,15 +36,15 @@

public class ComputerLauncherTest {

@Test public void jdk7() throws IOException {
@Test(expected=IOException.class) public void jdk7() throws IOException {
assertChecked("java version \"1.7.0_05\"\nJava(TM) SE Runtime Environment (build 1.7.0_05-b05)\nJava HotSpot(TM) Server VM (build 23.1-b03, mixed mode)\n", "1.7.0");
}

@Test public void openJDK7() throws IOException {
@Test(expected=IOException.class) public void openJDK7() throws IOException {
assertChecked("openjdk version \"1.7.0-internal\"\nOpenJDK Runtime Environment (build 1.7.0-internal-pkgsrc_2010_01_03_06_54-b00)\nOpenJDK 64-Bit Server VM (build 17.0-b04, mixed mode)\n", "1.7.0");
}

@Test public void jdk6() throws IOException {
@Test(expected=IOException.class) public void jdk6() throws IOException {
assertChecked("java version \"1.6.0_33\"\nJava(TM) SE Runtime Environment (build 1.6.0_33-b03)\nJava HotSpot(TM) Server VM (build 20.8-b03, mixed mode)\n", "1.6.0");
}

Expand All @@ -56,6 +56,14 @@ public class ComputerLauncherTest {
ComputerLauncher.checkJavaVersion(new PrintStream(new NullOutputStream()), "-", new BufferedReader(new StringReader("java version \"1.4.2_19\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)\nJava HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)\n")));
}

@Test public void jdk8() throws IOException {
assertChecked("java version \"1.8.0_05\"\nJava(TM) SE Runtime Environment (build 1.8.0_05-b05)\nJava HotSpot(TM) Server VM (build 23.1-b03, mixed mode)\n", "1.8.0");
}

@Test public void openJDK8() throws IOException {
assertChecked("openjdk version \"1.8.0-internal\"\nOpenJDK Runtime Environment (build 1.8.0-internal-pkgsrc_2015_01_03_06_54-b00)\nOpenJDK 64-Bit Server VM (build 17.0-b04, mixed mode)\n", "1.8.0");
}

@Test public void jdk10() throws IOException { // predicted
assertChecked("java version \"1.10.0_02\"\nJava(TM) SE Runtime Environment (build 1.10.0_02-b01)\nJava HotSpot(TM) Server VM (build 23.1-b03, mixed mode)\n", "1.10.0");
}
Expand Down

0 comments on commit f546ffc

Please sign in to comment.