From 1810eb2c3b191b5e2d40f863140695cc51b59649 Mon Sep 17 00:00:00 2001 From: lorenz <stu203404@mail.uni-kiel.de> Date: Mon, 29 Mar 2021 14:07:10 +0200 Subject: [PATCH] Add Saving of results + rename prefix --- .../benchmark/BenchmarkExecution.kt | 2 +- .../benchmark/KubernetesBenchmark.kt | 13 ++++++--- .../theodolite/evaluation/AnalysisExecutor.kt | 4 +-- .../theodolite/execution/BenchmarkExecutor.kt | 2 +- .../execution/BenchmarkExecutorImpl.kt | 6 ++-- .../execution/TheodoliteExecutor.kt | 28 +++++++++---------- 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt index 48fdbe3dc..da59a7e95 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt @@ -6,7 +6,7 @@ import kotlin.properties.Delegates @RegisterForReflection class BenchmarkExecution { - var prefix: Int = 0 + var executionId: Int = 0 lateinit var name: String lateinit var benchmark: String lateinit var load: LoadDefinition diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index dea845ec4..f5a922254 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -49,12 +49,17 @@ class KubernetesBenchmark : Benchmark { val patcherFactory = PatcherFactory() // patch the load dimension the resources - load.getType().forEach { patcherDefinition -> patcherFactory.createPatcher(patcherDefinition, resources).patch(load.get().toString()) } - res.getType().forEach{ patcherDefinition -> patcherFactory.createPatcher(patcherDefinition, resources).patch(res.get().toString()) } + load.getType().forEach { patcherDefinition -> + patcherFactory.createPatcher(patcherDefinition, resources).patch(load.get().toString()) + } + res.getType().forEach { patcherDefinition -> + patcherFactory.createPatcher(patcherDefinition, resources).patch(res.get().toString()) + } // Patch the given overrides - configurationOverrides.forEach { override -> override?.let { patcherFactory.createPatcher(it.patcher, resources).patch(override.value) } } - + configurationOverrides.forEach { override -> + override?.let { patcherFactory.createPatcher(it.patcher, resources).patch(override.value) } + } return KubernetesBenchmarkDeployment( namespace = namespace, diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt index 6be20df08..47a27501f 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt @@ -11,7 +11,7 @@ private val logger = KotlinLogging.logger {} class AnalysisExecutor( private val slo: BenchmarkExecution.Slo, - private val prefix: Int + private val executionId: Int ) { private val fetcher = MetricFetcher( @@ -29,7 +29,7 @@ class AnalysisExecutor( query = "sum by(group)(kafka_consumergroup_group_lag >= 0)" ) - CsvExporter().toCsv(name = "$prefix-${load.get()}-${res.get()}-${slo.sloType}", prom = prometheusData) + CsvExporter().toCsv(name = "$executionId-${load.get()}-${res.get()}-${slo.sloType}", prom = prometheusData) val sloChecker = SloCheckerFactory().create( slotype = slo.sloType, externalSlopeURL = slo.externalSloUrl, diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt index 93d1d729f..d30ae8687 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -25,7 +25,7 @@ abstract class BenchmarkExecutor( val executionDuration: Duration, configurationOverrides: List<ConfigurationOverride?>, val slo: BenchmarkExecution.Slo, - val prefix: Int + val executionId: Int ) { /** diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index 3c68d9a65..0a1e37128 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -20,14 +20,14 @@ class BenchmarkExecutorImpl( executionDuration: Duration, private val configurationOverrides: List<ConfigurationOverride?>, slo: BenchmarkExecution.Slo, - prefix: Int -) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo, prefix) { + executionId: Int +) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo, executionId) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) benchmarkDeployment.setup() this.waitAndLog() - val result = AnalysisExecutor(slo = slo, prefix = prefix).analyse( + val result = AnalysisExecutor(slo = slo, executionId = executionId).analyse( load = load, res = res, executionDuration = executionDuration diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index cfbd5d176..ebddce037 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -33,12 +33,12 @@ class TheodoliteExecutor( val executor = BenchmarkExecutorImpl( - kubernetesBenchmark, - results, - executionDuration, - config.configOverrides, - config.slos[0], - prefix = config.prefix + benchmark = kubernetesBenchmark, + results = results, + executionDuration = executionDuration, + configurationOverrides = config.configOverrides, + slo = config.slos[0], + executionId = config.executionId ) return Config( @@ -61,22 +61,22 @@ class TheodoliteExecutor( } fun run() { - saveConfiguration() + storeAsFile(this.config, "${this.config.executionId}-execution-configuration") + storeAsFile(kubernetesBenchmark, "${this.config.executionId}-benchmark-configuration") + val config = buildConfig() // execute benchmarks for each load for (load in config.loads) { config.compositeStrategy.findSuitableResource(load, config.resources) } + storeAsFile(config.compositeStrategy.benchmarkExecutor.results, "${this.config.executionId}-result") } - fun saveConfiguration() { - val gson = GsonBuilder().setPrettyPrinting().create() + private fun <T> storeAsFile(saveObject: T, filename: String) { + val gson = GsonBuilder().enableComplexMapKeySerialization().setPrettyPrinting().create() - PrintWriter("${this.config.prefix}-execution-configuration").use { pw -> - pw.println(gson.toJson(this.config)) - } - PrintWriter("${this.config.prefix}-benchmark-configuration").use { pw -> - pw.println(gson.toJson(kubernetesBenchmark)) + PrintWriter(filename).use { pw -> + pw.println(gson.toJson(saveObject)) } } } -- GitLab