Skip to content

Commit

Permalink
JPERF-273: Distinguish running hooks from hooking them in
Browse files Browse the repository at this point in the history
  • Loading branch information
dagguh committed Jul 5, 2019
1 parent d5b3ada commit d3c7a96
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DatabaseIpConfig(
private val databaseIp: String
) : InstalledJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.time.Duration

class MysqlConnector : InstalledJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DataCenterHook(
private val sharedHome: SharedHome
) : InstalledJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DefaultPostInstallHook(
private val config: JiraNodeConfig
) : InstalledJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
Expand All @@ -23,6 +23,6 @@ class DefaultPostInstallHook(
ProfilerHook(config.profiler),
SplunkForwarderHook(config.splunkForwarder),
UbuntuSysstat()
).forEach { it.hook(ssh, jira, flow) }
).forEach { it.run(ssh, jira, flow) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.atlassian.performance.tools.ssh.api.SshConnection

class DisabledAutoBackup : InstalledJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class HookedJiraInstallation(
server: TcpServer,
flow: JiraNodeFlow
): InstalledJira {
flow.listPreInstallHooks().forEach { it.hook(ssh, server, flow) }
flow.listPreInstallHooks().forEach { it.run(ssh, server, flow) }
val installed = installation.install(ssh, server, flow)
flow.listPostInstallHooks().forEach { it.hook(ssh, installed, flow) }
flow.listPostInstallHooks().forEach { it.run(ssh, installed, flow) }
return installed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import com.atlassian.performance.tools.infrastructure.api.jira.flow.start.Starte
import com.atlassian.performance.tools.ssh.api.SshConnection

interface InstalledJiraHook : StartedJiraHook {
fun hook(

fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
)

override fun hook(
override fun run(
ssh: SshConnection,
jira: StartedJira,
flow: JiraNodeFlow
) {
hook(ssh, jira.installed, flow)
run(ssh, jira.installed, flow)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.atlassian.performance.tools.ssh.api.SshConnection

class JiraHomeProperty : InstalledJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.atlassian.performance.tools.ssh.api.SshConnection

class JiraLogs : InstalledJiraHook {

override fun hook(ssh: SshConnection, jira: InstalledJira, flow: JiraNodeFlow) {
override fun run(ssh: SshConnection, jira: InstalledJira, flow: JiraNodeFlow) {
listOf(
StaticReport("${jira.home}/log/atlassian-jira.log"),
StaticReport("${jira.installation}/logs/catalina.out")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class JvmConfig(
private val config: JiraNodeConfig
) : InstalledJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.net.URI

class AsyncProfilerHook : TcpServerHook {

override fun hook(
override fun run(
ssh: SshConnection,
server: TcpServer,
flow: JiraNodeFlow
Expand All @@ -32,7 +32,7 @@ private class InstalledAsyncProfiler(
private val profilerPath: String
) : StartedJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: StartedJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import com.atlassian.performance.tools.infrastructure.api.jira.flow.install.Inst
import com.atlassian.performance.tools.ssh.api.SshConnection

interface TcpServerHook : InstalledJiraHook {
fun hook(

fun run(
ssh: SshConnection,
server: TcpServer,
flow: JiraNodeFlow
)

override fun hook(
override fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
) {
hook(ssh, jira.server, flow)
run(ssh, jira.server, flow)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.atlassian.performance.tools.ssh.api.SshConnection

class UbuntuSysstat : TcpServerHook {

override fun hook(
override fun run(
ssh: SshConnection,
server: TcpServer,
flow: JiraNodeFlow
Expand All @@ -28,7 +28,7 @@ private class InstalledOsMetric(
private val metric: OsMetric
) : TcpServerHook {

override fun hook(ssh: SshConnection, server: TcpServer, flow: JiraNodeFlow) {
override fun run(ssh: SshConnection, server: TcpServer, flow: JiraNodeFlow) {
val process = metric.start(ssh)
flow.reports.add(RemoteMonitoringProcessReport(process))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.atlassian.performance.tools.ssh.api.SshConnection

class AccessLogs : StartedJiraHook {

override fun hook(ssh: SshConnection, jira: StartedJira, flow: JiraNodeFlow) {
override fun run(ssh: SshConnection, jira: StartedJira, flow: JiraNodeFlow) {
flow.reports.add(FileListing("${jira.installed.installation}/logs/*access*"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import com.atlassian.performance.tools.ssh.api.SshConnection

class DefaultStartedJiraHook : StartedJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: StartedJira,
flow: JiraNodeFlow
) {
listOf(
JiraLogs(),
JstatHook()
).forEach { it.hook(ssh, jira, flow) }
).forEach { it.run(ssh, jira, flow) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class HookedJiraStart(
installed: InstalledJira,
flow: JiraNodeFlow
): StartedJira {
flow.listPreStartHooks().forEach { it.hook(ssh, installed, flow) }
flow.listPreStartHooks().forEach { it.run(ssh, installed, flow) }
val started = start.start(ssh, installed, flow)
flow.listPostStartHooks().forEach { it.hook(ssh, started, flow) }
flow.listPostStartHooks().forEach { it.run(ssh, started, flow) }
return started
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.atlassian.performance.tools.ssh.api.SshConnection

class JstatHook : StartedJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: StartedJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RestUpgrade(
private val adminPassword: String
) : StartedJiraHook {

override fun hook(ssh: SshConnection, jira: StartedJira, flow: JiraNodeFlow) {
override fun run(ssh: SshConnection, jira: StartedJira, flow: JiraNodeFlow) {
val threadDump = ThreadDump(jira.pid, jira.installed.jdk)
val privatePort = jira.installed.server.privatePort
val upgradesEndpoint = URI("http://$adminUsername:$adminPassword@localhost:$privatePort/rest/api/2/upgrade")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import com.atlassian.performance.tools.infrastructure.api.jira.flow.server.Start
import com.atlassian.performance.tools.ssh.api.SshConnection

interface StartedJiraHook {
fun hook(

fun run(
ssh: SshConnection,
jira: StartedJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.atlassian.performance.tools.ssh.api.SshConnection
class ProfilerHook(
private val profiler: Profiler
) : InstalledJiraHook {
override fun hook(ssh: SshConnection, jira: InstalledJira, flow: JiraNodeFlow) {
override fun run(ssh: SshConnection, jira: InstalledJira, flow: JiraNodeFlow) {
profiler.install(ssh)
flow.hookPostStart(InstalledProfiler(profiler))
}
Expand All @@ -26,7 +26,7 @@ private class InstalledProfiler(
private val profiler: Profiler
) : StartedJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: StartedJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal class SplunkForwarderHook(
private val splunk: SplunkForwarder
) : InstalledJiraHook {

override fun hook(
override fun run(
ssh: SshConnection,
jira: InstalledJira,
flow: JiraNodeFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class JiraNodeFlowTest {
val server = TcpServer("doesn't matter", 123, "fake-server")

flow.listPreInstallHooks().forEach {
it.hook(FailingSshConnection(), server, flow)
it.run(FailingSshConnection(), server, flow)
}

assertThat(counter.count).isEqualTo(3)
Expand All @@ -34,15 +34,15 @@ private class CountingHook : TcpServerHook {

var count = 0

override fun hook(ssh: SshConnection, server: TcpServer, flow: JiraNodeFlow) {
override fun run(ssh: SshConnection, server: TcpServer, flow: JiraNodeFlow) {
count++
}
}

private class HookingHook(
private val hook: TcpServerHook
) : TcpServerHook {
override fun hook(ssh: SshConnection, server: TcpServer, flow: JiraNodeFlow) {
override fun run(ssh: SshConnection, server: TcpServer, flow: JiraNodeFlow) {
flow.hookPreInstall(hook)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ class HookedJiraStartIT {
}

private class FailingHook : TcpServerHook, InstalledJiraHook {
override fun hook(ssh: SshConnection, server: TcpServer, flow: JiraNodeFlow) {
override fun run(ssh: SshConnection, server: TcpServer, flow: JiraNodeFlow) {
throw Exception("Failed")
}

override fun hook(ssh: SshConnection, jira: InstalledJira, flow: JiraNodeFlow) {
override fun run(ssh: SshConnection, jira: InstalledJira, flow: JiraNodeFlow) {
throw Exception("Failed")
}
}

0 comments on commit d3c7a96

Please sign in to comment.