Skip to content
Snippets Groups Projects
Commit 165470ce authored by Sören Henning's avatar Sören Henning
Browse files

Allow for relative thresholds

parent 12ab42a4
No related branches found
No related tags found
No related merge requests found
Pipeline #10420 passed
...@@ -60,7 +60,7 @@ class AnalysisExecutor( ...@@ -60,7 +60,7 @@ class AnalysisExecutor(
sloType = slo.sloType, sloType = slo.sloType,
properties = slo.properties, properties = slo.properties,
load = load, load = load,
resource = resource, resources = resource,
metric = metric metric = metric
) )
......
...@@ -34,7 +34,9 @@ class SloCheckerFactory { ...@@ -34,7 +34,9 @@ class SloCheckerFactory {
* *
* @param sloType Type of the [SloChecker]. * @param sloType Type of the [SloChecker].
* @param properties map of properties to use for the SLO checker creation. * @param properties map of properties to use for the SLO checker creation.
* @param load that is executed in the experiment. * @param load Load that is generated in the experiment.
* @param resources Resources that are used in the experiment.
* @param metric Metric used in the benchmark execution.
* *
* @return A [SloChecker] * @return A [SloChecker]
* @throws IllegalArgumentException If [sloType] not supported. * @throws IllegalArgumentException If [sloType] not supported.
...@@ -43,7 +45,7 @@ class SloCheckerFactory { ...@@ -43,7 +45,7 @@ class SloCheckerFactory {
sloType: String, sloType: String,
properties: Map<String, String>, properties: Map<String, String>,
load: Int, load: Int,
resource: Int, resources: Int,
metric: Metric metric: Metric
): SloChecker { ): SloChecker {
return when (SloTypes.from(sloType)) { return when (SloTypes.from(sloType)) {
...@@ -59,7 +61,9 @@ class SloCheckerFactory { ...@@ -59,7 +61,9 @@ class SloCheckerFactory {
?: throw IllegalArgumentException("repetitionAggregation expected")), ?: throw IllegalArgumentException("repetitionAggregation expected")),
"operator" to (properties["operator"] ?: throw IllegalArgumentException("operator expected")), "operator" to (properties["operator"] ?: throw IllegalArgumentException("operator expected")),
"threshold" to (properties["threshold"]?.toDouble() "threshold" to (properties["threshold"]?.toDouble()
?: throw IllegalArgumentException("threshold expected")) ?: properties["thresholdRelToLoad"]?.toDouble()?.times(load)
?: properties["thresholdRelToResources"]?.toDouble()?.times(resources)
?: throw IllegalArgumentException("'threshold', 'thresholdRelToLoad' or 'thresholdRelToResources' expected"))
) )
) )
SloTypes.LAG_TREND, SloTypes.DROPPED_RECORDS -> ExternalSloChecker( SloTypes.LAG_TREND, SloTypes.DROPPED_RECORDS -> ExternalSloChecker(
...@@ -68,7 +72,9 @@ class SloCheckerFactory { ...@@ -68,7 +72,9 @@ class SloCheckerFactory {
metadata = mapOf( metadata = mapOf(
"warmup" to (properties["warmup"]?.toInt() ?: throw IllegalArgumentException("warmup expected")), "warmup" to (properties["warmup"]?.toInt() ?: throw IllegalArgumentException("warmup expected")),
"threshold" to (properties["threshold"]?.toDouble() "threshold" to (properties["threshold"]?.toDouble()
?: throw IllegalArgumentException("threshold expected")) ?: properties["thresholdRelToLoad"]?.toDouble()?.times(load)
?: properties["thresholdRelToResources"]?.toDouble()?.times(resources)
?: throw IllegalArgumentException("'threshold', 'thresholdRelToLoad' or 'thresholdRelToResources' expected"))
) )
) )
SloTypes.LAG_TREND_RATIO, SloTypes.DROPPED_RECORDS_RATIO -> { SloTypes.LAG_TREND_RATIO, SloTypes.DROPPED_RECORDS_RATIO -> {
......
...@@ -129,6 +129,52 @@ internal class SloCheckerFactoryTest { ...@@ -129,6 +129,52 @@ internal class SloCheckerFactoryTest {
} }
} }
@Test
fun testCreateGenericSloWithThresholdRelToLoad() {
val factory = SloCheckerFactory()
val sloChecker = factory.create(
SloTypes.GENERIC.value,
mapOf(
"externalSloUrl" to "http://localhost:1234",
"warmup" to "60",
"queryAggregation" to "median",
"repetitionAggregation" to "median",
"operator" to "lte",
"thresholdRelToLoad" to "0.1"
),
100,
5,
Metric.DEMAND
)
assertTrue(sloChecker is ExternalSloChecker)
val computedThreshold = (sloChecker as ExternalSloChecker).metadata["threshold"]
assertTrue(computedThreshold is Double)
assertEquals(10.0, computedThreshold as Double, 0.001)
}
@Test
fun testCreateGenericSloWithThresholdRelToResources() {
val factory = SloCheckerFactory()
val sloChecker = factory.create(
SloTypes.GENERIC.value,
mapOf(
"externalSloUrl" to "http://localhost:1234",
"warmup" to "60",
"queryAggregation" to "median",
"repetitionAggregation" to "median",
"operator" to "lte",
"thresholdRelToResources" to "0.1"
),
100,
5,
Metric.DEMAND
)
assertTrue(sloChecker is ExternalSloChecker)
val computedThreshold = (sloChecker as ExternalSloChecker).metadata["threshold"]
assertTrue(computedThreshold is Double)
assertEquals(0.5, computedThreshold as Double, 0.001)
}
@Test @Test
fun testCreateGenericSloFloatThreshold() { fun testCreateGenericSloFloatThreshold() {
val factory = SloCheckerFactory() val factory = SloCheckerFactory()
...@@ -224,6 +270,46 @@ internal class SloCheckerFactoryTest { ...@@ -224,6 +270,46 @@ internal class SloCheckerFactoryTest {
assertEquals(12.34, threshold as Double, 0.01) assertEquals(12.34, threshold as Double, 0.01)
} }
@Test
fun testCreateLagTrendSloWithThresholdRelToLoad() {
val factory = SloCheckerFactory()
val sloChecker = factory.create(
SloTypes.LAG_TREND.value,
mapOf(
"externalSloUrl" to "http://localhost:1234",
"warmup" to "60",
"thresholdRelToLoad" to "0.1"
),
100,
5,
Metric.DEMAND
)
assertTrue(sloChecker is ExternalSloChecker)
val computedThreshold = (sloChecker as ExternalSloChecker).metadata["threshold"]
assertTrue(computedThreshold is Double)
assertEquals(10.0, computedThreshold as Double, 0.001)
}
@Test
fun testCreateLagTrendSloWithThresholdRelToResources() {
val factory = SloCheckerFactory()
val sloChecker = factory.create(
SloTypes.LAG_TREND.value,
mapOf(
"externalSloUrl" to "http://localhost:1234",
"warmup" to "60",
"thresholdRelToResources" to "0.1"
),
100,
5,
Metric.DEMAND
)
assertTrue(sloChecker is ExternalSloChecker)
val computedThreshold = (sloChecker as ExternalSloChecker).metadata["threshold"]
assertTrue(computedThreshold is Double)
assertEquals(0.5, computedThreshold as Double, 0.001)
}
@Test @Test
fun testCreateLagTrendRatioSloWithoutUrl() { fun testCreateLagTrendRatioSloWithoutUrl() {
val factory = SloCheckerFactory() val factory = SloCheckerFactory()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment