Skip to content

Commit

Permalink
Avoid flaky OracleJDK in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dagguh committed Jun 17, 2024
1 parent db12b6f commit b89389a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.atlassian.performance.tools.awsinfrastructure.api.jira

import com.atlassian.performance.tools.aws.api.Investment
import com.atlassian.performance.tools.aws.api.SshKeyFormula
import com.atlassian.performance.tools.aws.api.Storage
import com.atlassian.performance.tools.awsinfrastructure.IntegrationTestRuntime
import com.atlassian.performance.tools.awsinfrastructure.api.DatasetCatalogue
import com.atlassian.performance.tools.awsinfrastructure.api.hardware.C5NineExtraLargeEphemeral
Expand All @@ -12,6 +11,7 @@ import com.atlassian.performance.tools.infrastructure.api.dataset.Dataset
import com.atlassian.performance.tools.infrastructure.api.distribution.PublicJiraSoftwareDistribution
import com.atlassian.performance.tools.infrastructure.api.jira.JiraNodeConfig
import com.atlassian.performance.tools.infrastructure.api.jira.MinimalMysqlJiraHome
import com.atlassian.performance.tools.infrastructure.api.jvm.OpenJDK
import com.atlassian.performance.tools.infrastructure.api.jvm.jmx.EnabledRemoteJmx
import com.atlassian.performance.tools.workspace.api.TaskWorkspace
import com.atlassian.performance.tools.workspace.api.TestWorkspace
Expand All @@ -20,11 +20,9 @@ import org.apache.logging.log4j.CloseableThreadContext
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.data.Percentage
import org.junit.Test
import java.lang.Exception
import java.lang.Thread.sleep
import java.net.HttpURLConnection
import java.net.URI
import java.net.URL
import java.time.Duration
import java.time.Duration.ofSeconds
import java.util.*
Expand All @@ -40,6 +38,13 @@ class DataCenterFormulaIT {
private val datasetSeven = DatasetCatalogue().smallJiraSeven()
private val datasetEight = DatasetCatalogue().largeJiraEight()

/**
* The default JDK in [JiraNodeConfig] is flaky to install.
*/
private val stableJdk = JiraNodeConfig.Builder()
.versionedJdk(OpenJDK())
.build()

@Test
fun shouldProvisionDataCenter() {
val executor = Executors.newFixedThreadPool(
Expand Down Expand Up @@ -90,6 +95,7 @@ class DataCenterFormulaIT {
).computer(C5NineExtraLargeEphemeral())
.databaseComputer(C5NineExtraLargeEphemeral())
.waitForRunning(true)
.configs(stableJdk.multipleNodes(2))
.build()

val provisionedJira = dcFormula.provision(
Expand Down Expand Up @@ -161,7 +167,7 @@ class DataCenterFormulaIT {
lifespan = lifespan,
prefix = nonce
)
val config = JiraNodeConfig.Builder()
val config = JiraNodeConfig.Builder(stableJdk)
.remoteJmx(EnabledRemoteJmx())
.build()
val dcFormula = DataCenterFormula.Builder(
Expand All @@ -170,13 +176,7 @@ class DataCenterFormulaIT {
database = dataset.database
).computer(C5NineExtraLargeEphemeral())
.databaseComputer(C5NineExtraLargeEphemeral())
.configs(
(1..2).map {
JiraNodeConfig.Builder(config)
.name("${config.name}-$it")
.build()
}
)
.configs(config.multipleNodes(2))
.build()

val provisionedJira = dcFormula.provision(
Expand Down Expand Up @@ -223,7 +223,7 @@ class DataCenterFormulaIT {
val jiraHome = MinimalMysqlJiraHome()
val database = MinimalMysqlDatabase.Builder().build()
val jiraFormula = DataCenterFormula.Builder(distribution, jiraHome, database)
.configs(listOf(JiraNodeConfig.Builder().build()))
.configs(listOf(stableJdk))
.waitForUpgrades(false)
.build()
val investment = Investment(
Expand Down Expand Up @@ -259,4 +259,12 @@ class DataCenterFormulaIT {
catch (e: Exception) { -1 }
finally { it.disconnect() }
}
}

private fun JiraNodeConfig.multipleNodes(nodeCount: Int): List<JiraNodeConfig> {
return (1..nodeCount).map { nodeIndex ->
JiraNodeConfig.Builder(this)
.name("${this.name}-$nodeIndex")
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import com.atlassian.performance.tools.infrastructure.api.distribution.PublicJir
import com.atlassian.performance.tools.infrastructure.api.distribution.PublicJiraSoftwareDistribution
import com.atlassian.performance.tools.infrastructure.api.jira.JiraNodeConfig
import com.atlassian.performance.tools.infrastructure.api.jira.MinimalMysqlJiraHome
import com.atlassian.performance.tools.infrastructure.api.jvm.OpenJDK
import org.assertj.core.api.Assertions
import org.junit.Test
import java.lang.Exception
import java.net.HttpURLConnection
import java.net.URI
import java.time.Duration
Expand All @@ -27,6 +27,13 @@ class StandaloneFormulaIT {
private val workspace = taskWorkspace.isolateTest(javaClass.simpleName)
private val dataset = DatasetCatalogue().smallJiraSeven()

/**
* The default JDK in [JiraNodeConfig] is flaky to install.
*/
private val stableJdk = JiraNodeConfig.Builder()
.versionedJdk(OpenJDK())
.build()

@Test
fun shouldProvisionServer() {
val nonce = UUID.randomUUID().toString()
Expand All @@ -45,6 +52,7 @@ class StandaloneFormulaIT {
.jiraVolume(Volume(80))
.databaseComputer(C5NineExtraLargeEphemeral())
.databaseVolume(Volume(90))
.config(stableJdk)
.build()
val copiedFormula = StandaloneFormula.Builder(serverFormula).build()

Expand All @@ -69,6 +77,7 @@ class StandaloneFormulaIT {
val jiraHome = MinimalMysqlJiraHome()
val database = MinimalMysqlDatabase.Builder().build()
val jiraFormula = StandaloneFormula.Builder(distribution, jiraHome, database)
.config(stableJdk)
.waitForUpgrades(false)
.build()
val investment = Investment(
Expand Down

0 comments on commit b89389a

Please sign in to comment.