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

Generalize Jira start API #101

Merged
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Dropping a requirement of a major version of a dependency is a new contract.
- Point to remote files on SSH hosts via `RemotePath`.

Progress on [JPERF-273]:
- Allow multiple ways of installing Jira via `JiraInstallation`.
- Represent the information required to use an already installed Jira via `InstalledJira`.
- Allow multiple ways of installing Jira via `JiraInstallation` or starting it via `JiraStart`.
- Represent the information required to use an already installed Jira via `InstalledJira` or `JiraStart` if started.
- Represent a brand-new Jira instance via `EmptyJiraHome`.

### Fixed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.atlassian.performance.tools.infrastructure.api.jira.start

import com.atlassian.performance.tools.infrastructure.api.jira.install.InstalledJira
import com.atlassian.performance.tools.ssh.api.Ssh
import java.time.Duration

class JiraLaunchScript : JiraStart {

override fun start(
installed: InstalledJira
): StartedJira {
val installation = installed.installation
Ssh(installation.host).newConnection().use { ssh ->
ssh.execute(
"${installed.jdk.use()}; ${installation.path}/bin/start-jira.sh",
Duration.ofMinutes(1)
)
val pid = ssh
.execute("cat ${installation.path}/work/catalina.pid")
.output
.trim()
.toInt()
return StartedJira(installed, pid)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.atlassian.performance.tools.infrastructure.api.jira.start

import com.atlassian.performance.tools.infrastructure.api.jira.install.InstalledJira
import net.jcip.annotations.ThreadSafe

@ThreadSafe
interface JiraStart {

fun start(
installed: InstalledJira
): StartedJira
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.atlassian.performance.tools.infrastructure.api.jira.start

import com.atlassian.performance.tools.infrastructure.api.jira.install.InstalledJira

class StartedJira(
val installed: InstalledJira,
val pid: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,39 @@ package com.atlassian.performance.tools.infrastructure.api.jira.install

import com.atlassian.performance.tools.infrastructure.api.distribution.PublicJiraSoftwareDistribution
import com.atlassian.performance.tools.infrastructure.api.jira.EmptyJiraHome
import com.atlassian.performance.tools.infrastructure.api.jvm.AdoptOpenJDK11
import com.atlassian.performance.tools.infrastructure.api.jira.start.JiraLaunchScript
import com.atlassian.performance.tools.infrastructure.api.jvm.AdoptOpenJDK
import com.atlassian.performance.tools.infrastructure.toSsh
import com.atlassian.performance.tools.sshubuntu.api.SshUbuntuContainer
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import java.nio.file.Files
import java.util.function.Consumer

class ParallelInstallationIT {
class JiraLaunchScriptIT {
Copy link
Contributor Author

@dagguh dagguh Feb 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm renaming the integration test to point to the biggest top-level chunk. E.g now it tests both ParallelInstallation and JiraLaunchScript, but the launch script goes further and relies on the installation, so it encompasses a bigger chunk of the system. When I'll add hooks API, they will be the top level.


@Test
fun shouldInstallJira() {
// given
val installation = ParallelInstallation(
jiraHomeSource = EmptyJiraHome(),
productDistribution = PublicJiraSoftwareDistribution("7.13.0"),
jdk = AdoptOpenJDK11()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that Jira 7.13.0 didn't like this JDK during start:

Wrong JVM version! You are running with openjdk version "11.0.1" 2018-10-16 but JIRA requires at least 1.8 to run.

jdk = AdoptOpenJDK()
)
val start = JiraLaunchScript()

testOnServer { server ->
// when
val installed = installation.install(server)
val started = start.start(installed)

// then
val serverXml = installed
.installation
.resolve("conf/server.xml")
.download(Files.createTempFile("downloaded-config", ".xml"))
assertThat(serverXml.readText()).contains("<Connector port=\"${server.privatePort}\"")
assertThat(started.pid).isPositive()
}
}

Expand Down