-
Notifications
You must be signed in to change notification settings - Fork 32
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
JPERF-1106: Gather Apache2 logs #163
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.atlassian.performance.tools.awsinfrastructure | ||
|
||
internal class FailSafeRunnable( | ||
private val delegates: Iterable<Runnable> | ||
) : Runnable { | ||
override fun run() { | ||
val exceptions = delegates.mapNotNull { | ||
try { | ||
it.run() | ||
null | ||
} catch (e: Exception) { | ||
e | ||
} | ||
} | ||
|
||
when { | ||
exceptions.isEmpty() -> return | ||
exceptions.size == 1 -> throw exceptions[0] | ||
else -> { | ||
val root = Exception("Multiple exceptions were thrown and are added suppressed into this one") | ||
exceptions.forEach { root.addSuppressed(it) } | ||
throw root | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import com.atlassian.performance.tools.awsinfrastructure.api.hardware.M4ExtraLar | |
import com.atlassian.performance.tools.awsinfrastructure.api.hardware.Volume | ||
import com.atlassian.performance.tools.awsinfrastructure.api.loadbalancer.ApacheEc2LoadBalancerFormula | ||
import com.atlassian.performance.tools.awsinfrastructure.api.loadbalancer.ApacheProxyLoadBalancer | ||
import com.atlassian.performance.tools.awsinfrastructure.api.loadbalancer.DiagnosableLoadBalancer | ||
import com.atlassian.performance.tools.awsinfrastructure.api.loadbalancer.LoadBalancerFormula | ||
import com.atlassian.performance.tools.awsinfrastructure.api.network.Network | ||
import com.atlassian.performance.tools.awsinfrastructure.api.network.NetworkFormula | ||
|
@@ -19,6 +20,7 @@ import com.atlassian.performance.tools.awsinfrastructure.jira.DataCenterNodeForm | |
import com.atlassian.performance.tools.awsinfrastructure.jira.DiagnosableNodeFormula | ||
import com.atlassian.performance.tools.awsinfrastructure.jira.StandaloneNodeFormula | ||
import com.atlassian.performance.tools.awsinfrastructure.jira.home.SharedHomeFormula | ||
import com.atlassian.performance.tools.awsinfrastructure.loadbalancer.LoadBalancerMeasurementSource.Extension.asMeasurementSource | ||
import com.atlassian.performance.tools.concurrency.api.AbruptExecutorService | ||
import com.atlassian.performance.tools.concurrency.api.submitWithLogContext | ||
import com.atlassian.performance.tools.infrastructure.api.app.Apps | ||
|
@@ -326,6 +328,8 @@ class DataCenterFormula private constructor( | |
loadBalancer.waitUntilHealthy(Duration.ofMinutes(5)) | ||
} | ||
|
||
val loadBalancerResultsSource = (provisionedLoadBalancer.loadBalancer as? DiagnosableLoadBalancer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First time used this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed casts are bad. See https://github.com/atlassian/aws-infrastructure/blob/release-2.29.0/src/main/kotlin/com/atlassian/performance/tools/awsinfrastructure/api/jira/DataCenterFormula.kt#L360: if (loadBalancer is ApacheProxyLoadBalancer) listOf(loadBalancer::updateJiraConfiguration) else emptyList() Fortunately, |
||
?.asMeasurementSource(resultsTransport.location) | ||
val jira = Jira.Builder( | ||
nodes = nodes, | ||
jiraHome = RemoteLocation( | ||
|
@@ -336,6 +340,7 @@ class DataCenterFormula private constructor( | |
address = loadBalancer.uri | ||
) | ||
.jmxClients(jiraNodes.mapIndexed { i, node -> configs[i].remoteJmx.getClient(node.publicIpAddress) }) | ||
.extraMeasurementSources(listOfNotNull(loadBalancerResultsSource)) | ||
.build() | ||
|
||
logger.info("$jira is set up, will expire ${jiraStack.expiry}") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.atlassian.performance.tools.awsinfrastructure.api.loadbalancer | ||
|
||
import com.atlassian.performance.tools.aws.api.StorageLocation | ||
import com.atlassian.performance.tools.infrastructure.api.loadbalancer.LoadBalancer | ||
|
||
interface DiagnosableLoadBalancer : LoadBalancer { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name suggestions welcome There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could make that |
||
fun gatherEvidence(location: StorageLocation) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.atlassian.performance.tools.awsinfrastructure.loadbalancer | ||
|
||
import com.atlassian.performance.tools.aws.api.StorageLocation | ||
import com.atlassian.performance.tools.awsinfrastructure.api.loadbalancer.DiagnosableLoadBalancer | ||
import com.atlassian.performance.tools.infrastructure.api.MeasurementSource | ||
|
||
internal class LoadBalancerMeasurementSource( | ||
private val loadBalancer: DiagnosableLoadBalancer, | ||
private val target: StorageLocation | ||
) : MeasurementSource { | ||
internal object Extension { | ||
fun DiagnosableLoadBalancer.asMeasurementSource( | ||
target: StorageLocation | ||
) = LoadBalancerMeasurementSource( | ||
loadBalancer = this, | ||
target = target | ||
) | ||
} | ||
|
||
override fun gatherResults() { | ||
loadBalancer.gatherEvidence(target) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.atlassian.performance.tools.awsinfrastructure | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
|
||
class FailSafeRunnableTest { | ||
@Test | ||
fun shouldExecuteAllEvenIfFirstFails() { | ||
var executed1 = false | ||
var executed2 = false | ||
var executed3 = false | ||
val runnable = FailSafeRunnable( | ||
listOf( | ||
Runnable { executed1 = true; throw Exception("Fail 1") }, | ||
Runnable { executed2 = true; throw Exception("Fail 2") }, | ||
Runnable { executed3 = true; throw Exception("Fail 3") } | ||
) | ||
) | ||
|
||
try { | ||
runnable.run() | ||
} catch (e: Exception) { | ||
// Expected and ignored, so that we can go to asserts | ||
} | ||
|
||
assertThat(executed1).isTrue() | ||
assertThat(executed2).isTrue() | ||
assertThat(executed3).isTrue() | ||
} | ||
|
||
@Test | ||
fun shouldThrowAllFailures() { | ||
val runnable = FailSafeRunnable( | ||
listOf( | ||
Runnable { throw Exception("Banana") }, | ||
Runnable { throw Exception("Apple") }, | ||
Runnable { throw Exception("Pear") }, | ||
Runnable { throw Exception("Peach") } | ||
) | ||
) | ||
|
||
val exception = try { | ||
runnable.run() | ||
null | ||
} catch (e: Exception) { | ||
e | ||
} | ||
|
||
val allExceptions = listOf(exception!!) + exception.suppressed.toList() | ||
val allMessages = allExceptions.map { it.message } | ||
assertThat(allMessages).contains("Banana", "Apple", "Pear", "Peach") | ||
} | ||
|
||
|
||
@Test | ||
fun shouldExecuteAll() { | ||
val allIndexes = Array(20) { it } | ||
val finishedIndexes = mutableListOf<Int>() | ||
val runnable = FailSafeRunnable( | ||
allIndexes.map { index -> Runnable { finishedIndexes.add(index) } } | ||
) | ||
|
||
runnable.run() | ||
|
||
assertThat(finishedIndexes).contains(*allIndexes) | ||
} | ||
} |
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.
Let's split those changes. One sounds good, while the other needs some further considerations.