Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JAVA_HOME #184

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Dropping a requirement of a major version of a dependency is a new contract.
## [Unreleased]
[Unreleased]: https://github.com/atlassian/infrastructure/compare/release-4.29.0...master

### Fixed
- Fix `JAVA_HOME` in `OpenJDK` and `OpenJDK11`.

## [4.29.0] - 2024-06-04
[4.29.0]: https://github.com/atlassian/infrastructure/compare/release-4.28.3...release-4.29.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.atlassian.performance.tools.infrastructure.api.jvm

import com.atlassian.performance.tools.infrastructure.PreinstalledJDK
import com.atlassian.performance.tools.infrastructure.api.os.Ubuntu
import com.atlassian.performance.tools.infrastructure.jvm.UbuntuJavaHome
import com.atlassian.performance.tools.ssh.api.SshConnection
import java.time.Duration

Expand All @@ -16,10 +17,11 @@ class OpenJDK : VersionedJavaDevelopmentKit {
listOf("openjdk-8-jdk"),
Duration.ofMinutes(10)
)
UbuntuJavaHome().install(connection)
}

override fun use(): String {
return ""
return UbuntuJavaHome().use()
}

override fun command(options: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.atlassian.performance.tools.infrastructure.api.jvm

import com.atlassian.performance.tools.infrastructure.PreinstalledJDK
import com.atlassian.performance.tools.infrastructure.api.os.Ubuntu
import com.atlassian.performance.tools.infrastructure.jvm.UbuntuJavaHome
import com.atlassian.performance.tools.ssh.api.SshConnection
import java.time.Duration

Expand All @@ -16,10 +17,11 @@ class OpenJDK11 : VersionedJavaDevelopmentKit {
listOf("openjdk-11-jdk"),
Duration.ofMinutes(5)
)
UbuntuJavaHome().install(connection)
}

override fun use(): String {
return ""
return UbuntuJavaHome().use()
}

override fun command(options: String): String {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.atlassian.performance.tools.infrastructure.jvm

import com.atlassian.performance.tools.infrastructure.PreinstalledJDK
import com.atlassian.performance.tools.infrastructure.api.os.Ubuntu
import com.atlassian.performance.tools.ssh.api.SshConnection
import java.time.Duration

internal class UbuntuJavaHome {
fun install(connection: SshConnection) {
// parse `java-1.8.0-openjdk-arm64 1081 /usr/lib/jvm/java-1.8.0-openjdk-arm64`
val javaHome = connection.safeExecute("update-java-alternatives --list").output.split(" ").last().trim()
connection.execute("echo 'export JAVA_HOME=$javaHome' >> ~/.profile")
}

fun use(): String {
return "source ~/.profile"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class JdkSupport(
val ssh = ubuntu.toSsh()
ssh.newConnection().use { connection ->
jdk.install(connection)
val javaHomeOutput = connection.execute("source ~/.profile; echo \$JAVA_HOME").output
val javaHomeOutput = connection.execute("${jdk.use()}; echo \$JAVA_HOME").output

assertThat(javaHomeOutput).contains(expectedJavaPath)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ class OpenJdk11IT {
fun shouldSupportJstat() {
JstatSupport(OpenJDK11()).shouldSupportJstat()
}

@Test
fun shouldHaveJavaHome() {
JdkSupport(OpenJDK11()).shouldHaveJavaHomeSet("/usr/lib/jvm/java-1.11.0-openjdk-")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ class OpenJdkIT {
fun shouldSupportJstat() {
JstatSupport(OpenJDK()).shouldSupportJstat()
}

@Test
fun shouldHaveJavaHome() {
JdkSupport(OpenJDK()).shouldHaveJavaHomeSet("/usr/lib/jvm/java-1.8.0-openjdk-")
}
}
Loading