-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
919cf60
commit 82c7e1c
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/kotlin/com/atlassian/performance/tools/infrastructure/api/jvm/VersionedOracleJdk.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.atlassian.performance.tools.infrastructure.api.jvm | ||
|
||
import com.atlassian.performance.tools.jvmtasks.api.ExponentialBackoff | ||
import com.atlassian.performance.tools.jvmtasks.api.IdempotentAction | ||
import com.atlassian.performance.tools.ssh.api.SshConnection | ||
import java.time.Duration.ofSeconds | ||
|
||
|
||
class VersionedOracleJdk private constructor( | ||
private val majorVersion: String, | ||
private val minorVersion: String, | ||
private val patchVersion: String | ||
) : VersionedJavaDevelopmentKit { | ||
private val version = "$majorVersion.$minorVersion.$patchVersion" | ||
private val downloadUrl = | ||
"https://download.oracle.com/java/$majorVersion/archive/jdk-${version}_linux-x64_bin.tar.gz" | ||
|
||
override fun getMajorVersion() = majorVersion.toInt() | ||
|
||
override fun install(connection: SshConnection) { | ||
IdempotentAction("download JDK $version") { | ||
connection.execute( | ||
cmd = "curl $downloadUrl > jdk.tar.gz", | ||
timeout = ofSeconds(120) | ||
) | ||
}.retry(3, ExponentialBackoff(ofSeconds(10))) | ||
connection.execute("tar --extract --gunzip --file jdk.tar.gz") | ||
connection.execute("echo '${use()}' >> ~/.profile") | ||
} | ||
|
||
override fun use(): String = "export PATH=~/jdk-$version/bin:\$PATH; export JAVA_HOME=~/jdk-$version" | ||
|
||
override fun command(options: String) = "~/jdk-$version/bin/java $options" | ||
|
||
override val jstatMonitoring = Jstat("~/jdk-$version/bin") | ||
|
||
class Builder { | ||
private var majorVersion: String = "17" | ||
private var minorVersion: String = "0" | ||
private var patchVersion: String = "11" | ||
|
||
fun version(majorVersion: String, minorVersion: String, patchVersion: String) = apply { | ||
this.majorVersion = majorVersion | ||
this.minorVersion = minorVersion | ||
this.patchVersion = patchVersion | ||
} | ||
|
||
fun build(): VersionedOracleJdk = VersionedOracleJdk( | ||
majorVersion = majorVersion, | ||
minorVersion = minorVersion, | ||
patchVersion = patchVersion | ||
) | ||
|
||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...est/kotlin/com/atlassian/performance/tools/infrastructure/api/jvm/VersionedOracleJdkIT.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.atlassian.performance.tools.infrastructure.api.jvm | ||
|
||
import org.junit.Test | ||
|
||
class VersionedOracleJdkIT { | ||
|
||
@Test | ||
fun shouldSupportJstat() { | ||
JstatSupport(VersionedOracleJdk.Builder().build()).shouldSupportJstat() | ||
} | ||
|
||
@Test | ||
fun shouldGatherThreadDump() { | ||
ThreadDumpTest(VersionedOracleJdk.Builder().build()).shouldGatherThreadDump() | ||
} | ||
|
||
@Test | ||
fun shouldHaveJavaHomeSet() { | ||
JdkSupport(VersionedOracleJdk.Builder().build()).shouldHaveJavaHomeSet("/jdk-17.0.11") | ||
} | ||
|
||
@Test | ||
fun shouldHaveJavaHomeSetForJdk21() { | ||
JdkSupport( | ||
VersionedOracleJdk.Builder() | ||
.version("21", "0", "2") | ||
.build() | ||
).shouldHaveJavaHomeSet("/jdk-21.0.2") | ||
} | ||
|
||
} |