-
Notifications
You must be signed in to change notification settings - Fork 21
Issue/jperf 273 transplant ssh jira nodes #7
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
Draft
dagguh
wants to merge
28
commits into
atlassian:master
Choose a base branch
from
dagguh:issue/JPERF-273-transplant-ssh-jira-nodes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0a4e1f0
Reduce test flakiness on WSL
dagguh 2d91665
JPERF-273: Very very very early WIP
dagguh 1946c51
JPERF-273: Model the Jira node flow
dagguh 41b1f87
JPERF-273: Test `InstallableJiraIT`
dagguh 6d1ffef
JPERF-273: Refactor the Jira lifecycle
dagguh ce3b38a
JPERF-273: Stop jira manually, because we can
dagguh f032696
Rename "track" to "flow"
dagguh 06bee9a
Resolve DB TODO
dagguh 336c278
Add DC hook
dagguh eec3e10
Let hooks be hooked in at any later stage
dagguh 2e3a2a9
JPERF-273: Offer DB-related Jira hooks
dagguh d129d08
JPERF-273: Test `JiraNodeFlow` concurrency
dagguh 58ba182
JPERF-273: Fix `JiraNodeFlowTest.shouldHookDuringListing`
dagguh 1984d8e
JPERF-273: Add `ParallelInstallation`
dagguh 7192b70
JPERF-273: Distinguish running hooks from hooking them in
dagguh fac32ba
Bump a bunch of timeouts, because my Internet is awful
dagguh ebf7325
JPERF-273: Poll hooks manually to avoid tail iteration
dagguh d311c65
JPERF-219: Block hooking to the past
wyrzyk c87d198
Fixup: 6ad30c059bcdcc8b05c4ec2f9c40cc0b3cdfb779
dagguh f036201
Extract `S3HostedJdk`
dagguh 13a0c5c
JPERF-273: Define default `JiraNodeFlow`
dagguh 1156aae
JPERF-273: Remove fluent hook API
dagguh 23a7138
JPERF-273: Rename "flows" to "hooks"
dagguh c18a5b0
Expose `Reports.listReports`
dagguh 26bdabb
JPERF-273 Postgres 9.6.15
2742b75
Refactor hooks: composition over inheritance
dagguh a336862
Repackage hooks
dagguh 8dc645b
Reuse StaticBackoff
dagguh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| [*.{kt,kts}] | ||
| indent_size = 4 | ||
| [*.{kt, kts}] | ||
| indent_size = 4 | ||
| insert_final_newline = true |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
25 changes: 25 additions & 0 deletions
25
...in/kotlin/com/atlassian/performance/tools/infrastructure/api/database/DatabaseIpConfig.kt
This file contains hidden or 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,25 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.database | ||
|
|
||
| import com.atlassian.performance.tools.infrastructure.api.Sed | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.install.hook.PostInstallHooks | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.install.InstalledJira | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.install.hook.PostInstallHook | ||
| import com.atlassian.performance.tools.ssh.api.SshConnection | ||
|
|
||
| class DatabaseIpConfig( | ||
| private val databaseIp: String | ||
| ) : PostInstallHook { | ||
|
|
||
| override fun call( | ||
| ssh: SshConnection, | ||
| jira: InstalledJira, | ||
| hooks: PostInstallHooks | ||
| ) { | ||
| Sed().replace( | ||
| connection = ssh, | ||
| expression = "(<url>.*(@(//)?|//))" + "([^:/]+)" + "(.*</url>)", | ||
| output = """\1$databaseIp\5""", | ||
| file = "${jira.home}/dbconfig.xml" | ||
| ) | ||
| } | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -61,4 +61,4 @@ class MySqlDatabase( | |
| Thread.sleep(Duration.ofSeconds(10).toMillis()) | ||
| } | ||
| } | ||
| } | ||
| } | ||
35 changes: 35 additions & 0 deletions
35
...main/kotlin/com/atlassian/performance/tools/infrastructure/api/database/MysqlConnector.kt
This file contains hidden or 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,35 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.database | ||
|
|
||
| import com.atlassian.performance.tools.infrastructure.api.jira.install.hook.PostInstallHooks | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.install.InstalledJira | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.install.hook.PostInstallHook | ||
| import com.atlassian.performance.tools.jvmtasks.api.Backoff | ||
| import com.atlassian.performance.tools.jvmtasks.api.IdempotentAction | ||
| import com.atlassian.performance.tools.ssh.api.SshConnection | ||
| import java.time.Duration | ||
|
|
||
| class MysqlConnector : PostInstallHook { | ||
|
|
||
| override fun call( | ||
| ssh: SshConnection, | ||
| jira: InstalledJira, | ||
| hooks: PostInstallHooks | ||
| ) { | ||
| val connector = "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.40.tar.gz" | ||
| IdempotentAction( | ||
| description = "Download MySQL connector", | ||
| action = { ssh.execute("wget -q $connector") } | ||
| ).retry( | ||
| maxAttempts = 3, | ||
| backoff = StaticBackoff(Duration.ofSeconds(5)) | ||
| ) | ||
| ssh.execute("tar -xzf mysql-connector-java-5.1.40.tar.gz") | ||
| ssh.execute("cp mysql-connector-java-5.1.40/mysql-connector-java-5.1.40-bin.jar ${jira.installation}/lib") | ||
| } | ||
| } | ||
|
|
||
| private class StaticBackoff( | ||
| private val backOff: Duration | ||
| ) : Backoff { | ||
| override fun backOff(attempt: Int): Duration = backOff | ||
| } |
51 changes: 51 additions & 0 deletions
51
...in/kotlin/com/atlassian/performance/tools/infrastructure/api/database/PostgresDatabase.kt
This file contains hidden or 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,51 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.database | ||
|
|
||
| import com.atlassian.performance.tools.infrastructure.DockerImage | ||
| import com.atlassian.performance.tools.infrastructure.api.dataset.DatasetPackage | ||
| import com.atlassian.performance.tools.ssh.api.SshConnection | ||
| import org.apache.logging.log4j.LogManager | ||
| import org.apache.logging.log4j.Logger | ||
| import java.net.URI | ||
| import java.time.Duration | ||
|
|
||
| class PostgresDatabase( | ||
| private val source: DatasetPackage, | ||
| private val maxConnections: Int | ||
| ) : Database { | ||
| private val logger: Logger = LogManager.getLogger(this::class.java) | ||
|
|
||
| private val image: DockerImage = DockerImage( | ||
| name = "postgres:9.6.15", | ||
| pullTimeout = Duration.ofMinutes(5) | ||
| ) | ||
|
|
||
| constructor( | ||
| source: DatasetPackage | ||
| ) : this( | ||
| source = source, | ||
| maxConnections = 200 | ||
| ) | ||
|
|
||
| override fun setup(ssh: SshConnection): String { | ||
| val data = source.download(ssh) | ||
| val containerName = image.run( | ||
| ssh = ssh, | ||
| // TODO Dataset for Postgres | ||
| // parameters = "-p 5432:5432 -v `realpath $data`:/", | ||
| parameters = "-p 5432:5432", | ||
| arguments = "-c 'listen_addresses='*'' -c 'max_connections=$maxConnections'" | ||
| ) | ||
| Thread.sleep(Duration.ofSeconds(15).toMillis()) | ||
| logger.debug("Postgres - creating jira user and database") | ||
| ssh.execute("sudo docker exec -u postgres $containerName psql --command \"CREATE USER jira WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN PASSWORD 'jira';\"") | ||
| ssh.execute("sudo docker exec -u postgres $containerName createdb -E UNICODE -l C -T template0 -O jira jira") | ||
| return data | ||
| } | ||
|
|
||
| override fun start(jira: URI, ssh: SshConnection) { | ||
| // TODO Check logs for the following entry | ||
| // LOG: database system is ready to accept connections | ||
| Thread.sleep(Duration.ofSeconds(15).toMillis()) | ||
| } | ||
|
|
||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/com/atlassian/performance/tools/infrastructure/api/jira/EmptyJiraHome.kt
This file contains hidden or 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,11 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.jira | ||
|
|
||
| import com.atlassian.performance.tools.ssh.api.SshConnection | ||
|
|
||
| class EmptyJiraHome : JiraHomeSource { | ||
| override fun download(ssh: SshConnection): String { | ||
| val jiraHome = "jira-home" | ||
| ssh.execute("mkdir $jiraHome") | ||
| return jiraHome | ||
| } | ||
| } |
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
...n/kotlin/com/atlassian/performance/tools/infrastructure/api/jira/install/InstalledJira.kt
This file contains hidden or 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,16 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.jira.install | ||
|
|
||
| import com.atlassian.performance.tools.infrastructure.api.jvm.JavaDevelopmentKit | ||
|
|
||
| class InstalledJira( | ||
| /** | ||
| * E.g. it contains `./dbconfig.xml` | ||
| */ | ||
| val home: String, | ||
| /** | ||
| * E.g. it contains `./conf/server.xml` | ||
| */ | ||
| val installation: String, | ||
| val jdk: JavaDevelopmentKit, | ||
| val server: TcpServer | ||
| ) |
13 changes: 13 additions & 0 deletions
13
...otlin/com/atlassian/performance/tools/infrastructure/api/jira/install/JiraInstallation.kt
This file contains hidden or 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,13 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.jira.install | ||
|
|
||
| import com.atlassian.performance.tools.ssh.api.SshConnection | ||
| import net.jcip.annotations.ThreadSafe | ||
|
|
||
| @ThreadSafe | ||
| interface JiraInstallation { | ||
|
|
||
| fun install( | ||
| ssh: SshConnection, | ||
| server: TcpServer | ||
| ): InstalledJira | ||
| } |
36 changes: 36 additions & 0 deletions
36
...n/com/atlassian/performance/tools/infrastructure/api/jira/install/ParallelInstallation.kt
This file contains hidden or 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,36 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.jira.install | ||
|
|
||
| import com.atlassian.performance.tools.concurrency.api.submitWithLogContext | ||
| import com.atlassian.performance.tools.infrastructure.api.distribution.ProductDistribution | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.JiraHomeSource | ||
| import com.atlassian.performance.tools.infrastructure.api.jvm.JavaDevelopmentKit | ||
| import com.atlassian.performance.tools.ssh.api.SshConnection | ||
| import java.util.concurrent.Executors | ||
|
|
||
| class ParallelInstallation( | ||
| private val jiraHomeSource: JiraHomeSource, | ||
| private val productDistribution: ProductDistribution, | ||
| private val jdk: JavaDevelopmentKit | ||
| ) : JiraInstallation { | ||
|
|
||
| override fun install( | ||
| ssh: SshConnection, | ||
| server: TcpServer | ||
| ): InstalledJira { | ||
| val pool = Executors.newCachedThreadPool { runnable -> | ||
| Thread(runnable, "jira-installation-${runnable.hashCode()}") | ||
| } | ||
| val product = pool.submitWithLogContext("product") { | ||
| productDistribution.install(ssh, ".") | ||
| } | ||
| val home = pool.submitWithLogContext("home") { | ||
| jiraHomeSource.download(ssh) | ||
| } | ||
| val java = pool.submitWithLogContext("java") { | ||
| jdk.also { it.install(ssh) } | ||
| } | ||
| val jira = InstalledJira(home.get(), product.get(), java.get(), server) | ||
| pool.shutdownNow() | ||
| return jira | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
...com/atlassian/performance/tools/infrastructure/api/jira/install/SequentialInstallation.kt
This file contains hidden or 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,23 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.jira.install | ||
|
|
||
| import com.atlassian.performance.tools.infrastructure.api.distribution.ProductDistribution | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.JiraHomeSource | ||
| import com.atlassian.performance.tools.infrastructure.api.jvm.JavaDevelopmentKit | ||
| import com.atlassian.performance.tools.ssh.api.SshConnection | ||
|
|
||
| class SequentialInstallation( | ||
| private val jiraHomeSource: JiraHomeSource, | ||
| private val productDistribution: ProductDistribution, | ||
| private val jdk: JavaDevelopmentKit | ||
| ) : JiraInstallation { | ||
|
|
||
| override fun install( | ||
| ssh: SshConnection, | ||
| server: TcpServer | ||
| ): InstalledJira { | ||
| val installation = productDistribution.install(ssh, ".") | ||
| val home = jiraHomeSource.download(ssh) | ||
| jdk.install(ssh) | ||
| return InstalledJira(home, installation, jdk, server) | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/atlassian/performance/tools/infrastructure/api/jira/install/TcpServer.kt
This file contains hidden or 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,19 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.jira.install | ||
|
|
||
| class TcpServer( | ||
| val ip: String, | ||
| val publicPort: Int, | ||
| val privatePort: Int, | ||
| val name: String | ||
| ) { | ||
| constructor( | ||
| ip: String, | ||
| port: Int, | ||
| name: String | ||
| ) : this( | ||
| ip, | ||
| port, | ||
| port, | ||
| name | ||
| ) | ||
| } |
57 changes: 57 additions & 0 deletions
57
...com/atlassian/performance/tools/infrastructure/api/jira/install/hook/AsyncProfilerHook.kt
This file contains hidden or 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,57 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.jira.install.hook | ||
|
|
||
| import com.atlassian.performance.tools.infrastructure.api.jira.install.TcpServer | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.report.Report | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.start.StartedJira | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.start.hook.PostStartHook | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.start.hook.PostStartHooks | ||
| import com.atlassian.performance.tools.ssh.api.SshConnection | ||
| import java.net.URI | ||
|
|
||
| class AsyncProfilerHook : PreInstallHook { | ||
|
|
||
| override fun call( | ||
| ssh: SshConnection, | ||
| server: TcpServer, | ||
| hooks: PreInstallHooks | ||
| ) { | ||
| val directory = "async-profiler" | ||
| val downloads = URI("https://github.com/jvm-profiling-tools/async-profiler/releases/download/") | ||
| val distribution = downloads.resolve("v1.4/async-profiler-1.4-linux-x64.tar.gz") | ||
| ssh.execute("wget -q $distribution") | ||
| ssh.execute("mkdir $directory") | ||
| ssh.execute("tar -xzf async-profiler-1.4-linux-x64.tar.gz -C $directory") | ||
| ssh.execute("sudo sh -c 'echo 1 > /proc/sys/kernel/perf_event_paranoid'") | ||
| ssh.execute("sudo sh -c 'echo 0 > /proc/sys/kernel/kptr_restrict'") | ||
| val profilerPath = "./$directory/profiler.sh" | ||
| val profiler = InstalledAsyncProfiler(profilerPath) | ||
| hooks.postStart.insert(profiler) | ||
| } | ||
| } | ||
|
|
||
| private class InstalledAsyncProfiler( | ||
| private val profilerPath: String | ||
| ) : PostStartHook { | ||
|
|
||
| override fun call( | ||
| ssh: SshConnection, | ||
| jira: StartedJira, | ||
| hooks: PostStartHooks | ||
| ) { | ||
| ssh.execute("$profilerPath -b 20000000 start ${jira.pid}") | ||
| val profiler = StartedAsyncProfiler(jira.pid, profilerPath) | ||
| hooks.reports.add(profiler) | ||
| } | ||
| } | ||
|
|
||
| private class StartedAsyncProfiler( | ||
| private val pid: Int, | ||
| private val profilerPath: String | ||
| ) : Report { | ||
|
|
||
| override fun locate(ssh: SshConnection): List<String> { | ||
| val flameGraphFile = "flamegraph.svg" | ||
| ssh.execute("$profilerPath stop $pid -o svg > $flameGraphFile") | ||
| return listOf(flameGraphFile) | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
...in/com/atlassian/performance/tools/infrastructure/api/jira/install/hook/DataCenterHook.kt
This file contains hidden or 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,24 @@ | ||
| package com.atlassian.performance.tools.infrastructure.api.jira.install.hook | ||
|
|
||
| import com.atlassian.performance.tools.infrastructure.api.jira.SharedHome | ||
| import com.atlassian.performance.tools.infrastructure.api.jira.install.InstalledJira | ||
| import com.atlassian.performance.tools.ssh.api.SshConnection | ||
|
|
||
| class DataCenterHook( | ||
| private val nodeId: String, | ||
| private val sharedHome: SharedHome | ||
| ) : PostInstallHook { | ||
|
|
||
| override fun call( | ||
| ssh: SshConnection, | ||
| jira: InstalledJira, | ||
| hooks: PostInstallHooks | ||
| ) { | ||
| val localSharedHome = sharedHome.localSharedHome | ||
| sharedHome.mount(ssh) | ||
| val jiraHome = jira.home // TODO what's the difference between localSharedHome and jiraHome? should both be hookable? | ||
| ssh.execute("echo ehcache.object.port = 40011 >> $jiraHome/cluster.properties") | ||
| ssh.execute("echo jira.node.id = $nodeId >> $jiraHome/cluster.properties") | ||
| ssh.execute("echo jira.shared.home = `realpath $localSharedHome` >> $jiraHome/cluster.properties") | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test to cover this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but right now it's externalized.
We can include this coverage in here via
SshUbuntu