diff --git a/theodolite/examples/operator/example-benchmark.yaml b/theodolite/examples/operator/example-benchmark.yaml index 62920091e831ff914fb67e85a67cd3f1d98995ab..be7116c46f8222eeba0f3bffd086f7cc2b6ee227 100644 --- a/theodolite/examples/operator/example-benchmark.yaml +++ b/theodolite/examples/operator/example-benchmark.yaml @@ -33,6 +33,15 @@ spec: resource: "uc1-load-generator-deployment.yaml" properties: loadGenMaxRecords: "150000" + slos: + - name: "lag trend" + sloType: "lag trend" + prometheusUrl: "http://prometheus-operated:9090" + offset: 0 + properties: + threshold: 3000 + externalSloUrl: "http://localhost:80/evaluate-slope" + warmup: 60 # in seconds kafkaConfig: bootstrapServer: "theodolite-kafka-kafka-bootstrap:9092" topics: diff --git a/theodolite/examples/operator/example-execution.yaml b/theodolite/examples/operator/example-execution.yaml index 576a74b90dfc38483de79502ac14d42f6bedfb49..d1573e3f47a0686118770f5cc541172326a77259 100644 --- a/theodolite/examples/operator/example-execution.yaml +++ b/theodolite/examples/operator/example-execution.yaml @@ -11,13 +11,9 @@ spec: resourceType: "Instances" resourceValues: [1, 2, 3, 4, 5] slos: - - sloType: "lag trend" - prometheusUrl: "http://prometheus-operated:9090" - offset: 0 + - name: "lag trend" properties: threshold: 2000 - externalSloUrl: "http://localhost:80/evaluate-slope" - warmup: 60 # in seconds execution: strategy: "LinearSearch" duration: 300 # in seconds diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt b/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt index 1b295116eeb2cd8d0bc79a6cdc571623eb8dbfa8..02e9553d2fd4c156b3dff41f2dd2d9e08352b97d 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt @@ -30,7 +30,7 @@ class BenchmarkExecution : KubernetesResource { lateinit var benchmark: String lateinit var load: LoadDefinition lateinit var resources: ResourceDefinition - lateinit var slos: List<KubernetesBenchmark.Slo> + lateinit var slos: List<Slo> lateinit var execution: Execution lateinit var configOverrides: MutableList<ConfigurationOverride?> @@ -49,25 +49,22 @@ class BenchmarkExecution : KubernetesResource { var afterTeardownDelay = 5L } - //TODO: use new SLO class since the values do not need to be set (just optional) /** * Measurable metric. - * [sloType] determines the type of the metric. * It is evaluated using the [theodolite.evaluation.ExternalSloChecker] by data measured by Prometheus. * The evaluation checks if a [threshold] is reached or not. * [offset] determines the shift in hours by which the start and end timestamps should be shifted. * The [warmup] determines after which time the metric should be evaluated to avoid starting interferences. * The [warmup] time unit depends on the Slo: for the lag trend it is in seconds. */ - /* @JsonDeserialize + @JsonDeserialize @RegisterForReflection class Slo : KubernetesResource { lateinit var name: String - lateinit var sloType: String - lateinit var prometheusUrl: String - var offset by Delegates.notNull<Int>() - lateinit var properties: MutableMap<String, String> - }*/ + var prometheusUrl: String? = null + var offset : Int? = null + var properties: MutableMap<String, String>? = null + } /** * Represents a Load that should be created and checked. diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index 62dd30c673eb5e004e1a501049899441ba019e1c..d4f9f58fc5b8e43dbfc0e827e105fad8ddc3ebcd 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -40,7 +40,7 @@ class KubernetesBenchmark : KubernetesResource, Benchmark { lateinit var name: String lateinit var resourceTypes: List<TypeName> lateinit var loadTypes: List<TypeName> - lateinit var slos: List<Slo> + lateinit var slos: MutableList<Slo> var kafkaConfig: KafkaConfig? = null lateinit var infrastructure: Resources lateinit var sut: Resources diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/SloConfigHandler.kt b/theodolite/src/main/kotlin/theodolite/evaluation/SloConfigHandler.kt index 75ae8672e6b132b300c5cbc49d40f147db0cfb54..b3e13362b079d387ba0dde32adc8b49ad82198d8 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/SloConfigHandler.kt +++ b/theodolite/src/main/kotlin/theodolite/evaluation/SloConfigHandler.kt @@ -7,12 +7,11 @@ import javax.enterprise.context.ApplicationScoped private const val CONSUMER_LAG_QUERY = "sum by(consumergroup) (kafka_consumergroup_lag >= 0)" private const val DROPPED_RECORDS_QUERY = "sum by(job) (kafka_streams_stream_task_metrics_dropped_records_total>=0)" -//TODO: slo.sloType.toLowerCase() is deprecated @ApplicationScoped class SloConfigHandler { companion object { fun getQueryString(slo: KubernetesBenchmark.Slo): String { - return when (slo.sloType.toLowerCase()) { + return when (slo.sloType.lowercase()) { SloTypes.GENERIC.value -> slo.properties["promQLQuery"] ?: throw IllegalArgumentException("promQLQuery expected") SloTypes.LAG_TREND.value, SloTypes.LAG_TREND_RATIO.value -> CONSUMER_LAG_QUERY SloTypes.DROPPED_RECORDS.value, SloTypes.DROPPED_RECORDS_RATIO.value -> DROPPED_RECORDS_QUERY diff --git a/theodolite/src/main/kotlin/theodolite/execution/SloFactory.kt b/theodolite/src/main/kotlin/theodolite/execution/SloFactory.kt index 89b815d0f6e30a8a75703b7f34bd9a3488ce7333..966e19bdc5089f70e593a49dbc556ae3424fbbe6 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/SloFactory.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/SloFactory.kt @@ -8,14 +8,16 @@ class SloFactory { fun createSlos(execution: BenchmarkExecution, benchmark: KubernetesBenchmark): List<KubernetesBenchmark.Slo> { var benchmarkSlos = benchmark.slos var executionSlos = execution.slos - //TODO: test if we can actually overwrite entries of the objects + for(executionSlo in executionSlos) { - for(benchmarkSlo in benchmarkSlos) { - if(executionSlo.name == benchmarkSlo.name) { - benchmarkSlo.offset = executionSlo.offset ?: benchmarkSlo.offset - benchmarkSlo.prometheusUrl = executionSlo.prometheusUrl ?: benchmarkSlo.prometheusUrl - for(executionProperty in executionSlo.properties) { - benchmarkSlo.properties[executionProperty.key] = executionProperty.value + for(i in 0..benchmarkSlos.size) { + if(executionSlo.name == benchmarkSlos[i].name) { + benchmarkSlos[i].offset = executionSlo.offset ?: benchmarkSlos[i].offset + benchmarkSlos[i].prometheusUrl = executionSlo.prometheusUrl ?: benchmarkSlos[i].prometheusUrl + if (executionSlo.properties != null) { + for (executionProperty in executionSlo.properties!!) { + benchmarkSlos[i].properties[executionProperty.key] = executionProperty.value + } } } } diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt b/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt index cbddbfbfc5d6f838677c6d04b0a0c79f59d8bc66..bf73ea9db360fb6f2dfa7d2c6079fa40edc96b00 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt +++ b/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt @@ -43,6 +43,7 @@ class BenchmarkCRDummy(name: String) { benchmark.resourceTypes = emptyList() benchmark.loadTypes = emptyList() + benchmark.slos = mutableListOf() benchmark.kafkaConfig = kafkaConfig benchmark.name = benchmarkCR.metadata.name } diff --git a/theodolite/src/test/resources/k8s-resource-files/test-benchmark.yaml b/theodolite/src/test/resources/k8s-resource-files/test-benchmark.yaml index 1ba204bb2821f9b734706d322322b28220ef19d5..a15b8259f14d35d983bb0f830c8f0cb820373d92 100644 --- a/theodolite/src/test/resources/k8s-resource-files/test-benchmark.yaml +++ b/theodolite/src/test/resources/k8s-resource-files/test-benchmark.yaml @@ -28,6 +28,15 @@ spec: resource: "uc1-load-generator-deployment.yaml" properties: loadGenMaxRecords: "15000" + slos: + - name: "lag trend" + sloType: "lag trend" + prometheusUrl: "http://prometheus-operated:9090" + offset: 0 + properties: + threshold: 3000 + externalSloUrl: "http://localhost:80/evaluate-slope" + warmup: 60 # in seconds kafkaConfig: bootstrapServer: "theodolite-kafka-kafka-bootstrap:9092" topics: diff --git a/theodolite/src/test/resources/k8s-resource-files/test-execution-1.yaml b/theodolite/src/test/resources/k8s-resource-files/test-execution-1.yaml index 1407a9952b7454053d204454841d51cfb4d7dbf4..27a24946e0ae6c3a08abc4f79d18043339dee9c7 100644 --- a/theodolite/src/test/resources/k8s-resource-files/test-execution-1.yaml +++ b/theodolite/src/test/resources/k8s-resource-files/test-execution-1.yaml @@ -12,7 +12,7 @@ spec: resourceType: "Instances" resourceValues: [1, 2, 3, 4, 5] slos: - - sloType: "lag trend" + - name: "lag trend" threshold: 2000 prometheusUrl: "http://prometheus-operated:9090" externalSloUrl: "http://localhost:80/evaluate-slope" diff --git a/theodolite/src/test/resources/k8s-resource-files/test-execution-update.yaml b/theodolite/src/test/resources/k8s-resource-files/test-execution-update.yaml index c075702da218397352f1dc1e5b283534fbb4d718..8c9c861f074808bcf4b08725eb5eabbd9275242a 100644 --- a/theodolite/src/test/resources/k8s-resource-files/test-execution-update.yaml +++ b/theodolite/src/test/resources/k8s-resource-files/test-execution-update.yaml @@ -12,13 +12,9 @@ spec: resourceType: "Instances" resourceValues: [1, 2, 3, 4, 5] slos: - - sloType: "lag trend" - prometheusUrl: "http://prometheus-operated:9090" - offset: 0 + - name: "lag trend" properties: threshold: 2000 - externalSloUrl: "http://localhost:80/evaluate-slope" - warmup: 60 # in seconds execution: strategy: "LinearSearch" duration: 300 # in seconds diff --git a/theodolite/src/test/resources/k8s-resource-files/test-execution.yaml b/theodolite/src/test/resources/k8s-resource-files/test-execution.yaml index e12c851da5d8a79f57b1fa59b86239c219370c0f..cafe0226097f3533bdadcb5e43c47ffacc6dbb78 100644 --- a/theodolite/src/test/resources/k8s-resource-files/test-execution.yaml +++ b/theodolite/src/test/resources/k8s-resource-files/test-execution.yaml @@ -12,13 +12,9 @@ spec: resourceType: "Instances" resourceValues: [1, 2, 3, 4, 5] slos: - - sloType: "lag trend" - prometheusUrl: "http://prometheus-operated:9090" - offset: 0 + - name: "lag trend" properties: threshold: 2000 - externalSloUrl: "http://localhost:80/evaluate-slope" - warmup: 60 # in seconds execution: strategy: "LinearSearch" duration: 300 # in seconds