diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt index 6373262d8c6b6fce99347abb5eeaebb08d19130c..a21d2c747b3870567f7306de4fdf853470dc8c09 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt @@ -1,9 +1,9 @@ package theodolite.benchmark import theodolite.util.LoadDimension -import theodolite.util.OverridePatcherDefinition +import theodolite.util.ConfigurationOverride import theodolite.util.Resource interface Benchmark { - fun buildDeployment(load: LoadDimension, res: Resource, overrides: List<OverridePatcherDefinition>): BenchmarkDeployment + fun buildDeployment(load: LoadDimension, res: Resource, configurationOverrides: List<ConfigurationOverride>): BenchmarkDeployment } \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt index 596f768f7b864750d23d9971690752f962823c5f..ef378d98e74a6ab821173cf2a6f8fca7e3f246c9 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt @@ -1,7 +1,6 @@ package theodolite.benchmark -import theodolite.util.OverridePatcherDefinition -import theodolite.util.PatcherDefinition +import theodolite.util.ConfigurationOverride import kotlin.properties.Delegates @@ -12,7 +11,7 @@ class BenchmarkContext() { lateinit var resources: List<Int> lateinit var slos: List<Slo> lateinit var execution: Execution - lateinit var configOverrides: List<OverridePatcherDefinition> + lateinit var configOverrides: List<ConfigurationOverride> class Execution() { lateinit var strategy: String diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index fc5515a4a83b38f6fb040ebf09eb9713e5788739..545d368f5ca51ffde7e42ce37a4c4029c7591391 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -32,19 +32,20 @@ class KubernetesBenchmark(): Benchmark { } } - override fun buildDeployment(load: LoadDimension, res: Resource, overrides: List<OverridePatcherDefinition>): BenchmarkDeployment { + override fun buildDeployment(load: LoadDimension, res: Resource, configurationOverrides: List<ConfigurationOverride>): BenchmarkDeployment { // TODO("set node selector") val resources = loadKubernetesResources(this.appResource + this.loadGenResource) val patcherManager = PatcherManager() + // patch res and load - patcherManager.applyPatcher(res.getType(), this.resourceTypes, resources, res.get()) - patcherManager.applyPatcher(load.getType(), this.loadTypes, resources, load.get().toString()) + patcherManager.createAndApplyPatcher(res.getType(), this.resourceTypes, resources, res.get()) + patcherManager.createAndApplyPatcher(load.getType(), this.loadTypes, resources, load.get().toString()) // patch overrides - overrides.forEach {override -> patcherManager.applyPatcher(override, resources)} - println(zookeeperConfig["server"] !! ) + configurationOverrides.forEach{ override -> patcherManager.applyPatcher(listOf(override.patcher), resources, override.value)} + resources.forEach { r -> println(r) } return KubernetesBenchmarkDeployment( resources.map { r -> r.second }, kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapSever), diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt index dc55d61faf0c5f1406f20b57b0df3f8cec345bd1..abda15822503850828af2e521d5ede399c66887a 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt @@ -1,7 +1,7 @@ package theodolite.benchmark import theodolite.util.LoadDimension -import theodolite.util.OverridePatcherDefinition +import theodolite.util.ConfigurationOverride import theodolite.util.Resource class TestBenchmark : Benchmark { @@ -9,7 +9,7 @@ class TestBenchmark : Benchmark { override fun buildDeployment( load: LoadDimension, res: Resource, - override: List<OverridePatcherDefinition> + configurationOverride: List<ConfigurationOverride> ): BenchmarkDeployment { return TestBenchmarkDeployment() } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt index c78559dd09b1314d4c147b102661622fde1ec73b..6540004e019bc62cb743c578939a9b80edc0cd80 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -15,7 +15,7 @@ private val logger = KotlinLogging.logger {} * @property executionDuration * @constructor Create empty Benchmark executor */ -abstract class BenchmarkExecutor(val benchmark: Benchmark, val results: Results, val executionDuration: Duration, overrides: List<OverridePatcherDefinition>) { +abstract class BenchmarkExecutor(val benchmark: Benchmark, val results: Results, val executionDuration: Duration, configurationOverrides: List<ConfigurationOverride>) { /** * Run a experiment for the given parametrization, evaluate the experiment and save the result. diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index c38dd1c148c611cac1e40a9cd9308791beb9841b..ce0295b3f5f36edc2217250318f64654535ac6df 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -4,9 +4,9 @@ import theodolite.benchmark.Benchmark import theodolite.util.* import java.time.Duration -class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDuration: Duration, val overrides: List<OverridePatcherDefinition>) : BenchmarkExecutor(benchmark, results, executionDuration, overrides) { +class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDuration: Duration, val configurationOverrides: List<ConfigurationOverride>) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { - val benchmarkDeployment = benchmark.buildDeployment(load, res, this.overrides) + val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) benchmarkDeployment.setup() this.waitAndLog() benchmarkDeployment.teardown() diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutorImpl.kt index 3b1b6b31d7881533707a3aa3b50021af154ea72e..00afeb18dc7fff4bd50db4b77f514fc13e1e7771 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutorImpl.kt @@ -8,7 +8,7 @@ import java.time.Duration class TestBenchmarkExecutorImpl(private val mockResults: Array<Array<Boolean>>, benchmark: Benchmark, results: Results): BenchmarkExecutor(benchmark, results, executionDuration = Duration.ofSeconds(1), - overrides = emptyList() + configurationOverrides = emptyList() ) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt index b7e35b578d0f18c7a608050531813f90d012a5de..f7875cf397fc746a8d8ab17f9df62cd73b6a63d4 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt @@ -1,7 +1,6 @@ package theodolite.patcher import io.fabric8.kubernetes.api.model.KubernetesResource -import theodolite.util.OverridePatcherDefinition import theodolite.util.PatcherDefinition import theodolite.util.TypeName import java.lang.IllegalArgumentException @@ -23,22 +22,29 @@ class PatcherManager { .flatMap { type -> type.patchers} } - fun applyPatcher(type: String, patcherTypes: List<TypeName>, resources: List<Pair<String, KubernetesResource>>, value: Any) { + /** + * This function first creates a patcher definition and then patches the list of resources based on this patcher definition + * + * @param type Patcher type, for example "EnvVarPatcher" + * @param patcherTypes List of patcher types definitions, for example for resources and threads + * @param resources List of K8s resources, a patcher takes the resources that are needed + * @param value The value to patch + */ + fun createAndApplyPatcher(type: String, patcherTypes: List<TypeName>, resources: List<Pair<String, KubernetesResource>>, value: Any) { this.getPatcherDef(type, patcherTypes) .forEach {patcherDef -> createK8sPatcher(patcherDef, resources).patch(value) } } + /** + * Patch a resource based on the given patcher definition, a list of resources and a value to patch + * + * @param patcherDefinition The patcher definition + * @param resources List of patcher types definitions, for example for resources and threads + * @param value The value to patch + */ + fun applyPatcher(patcherDefinition: List<PatcherDefinition>, resources: List<Pair<String, KubernetesResource>>, value: Any) { + patcherDefinition.forEach { def -> this.createK8sPatcher(def, resources).patch(value) } - fun applyPatcher(overrides: OverridePatcherDefinition, resources: List<Pair<String, KubernetesResource>>){ - var pdef = PatcherDefinition() - pdef.type = overrides.type - pdef.container = overrides.container - pdef.resource = overrides.resource - overrides.overrides.forEach{ override -> - pdef.variableName = override.key - this.createK8sPatcher(pdef, resources).patch(override.value) - } - } - + } } \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt new file mode 100644 index 0000000000000000000000000000000000000000..f9099929c06b43a931ac210bd60629553777ffb1 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt @@ -0,0 +1,6 @@ +package theodolite.util + +class ConfigurationOverride() { + lateinit var patcher: PatcherDefinition + lateinit var value: String +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/OverridePatcherDefinition.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/OverridePatcherDefinition.kt deleted file mode 100644 index c996fbe90246d0ab0013dfacbf33d12f64e68d94..0000000000000000000000000000000000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/OverridePatcherDefinition.kt +++ /dev/null @@ -1,8 +0,0 @@ -package theodolite.util - -class OverridePatcherDefinition() { - lateinit var type: String - lateinit var resource: String - lateinit var container: String - lateinit var overrides: Map<String, String> -} diff --git a/theodolite-quarkus/src/main/resources/yaml/testContext.yaml b/theodolite-quarkus/src/main/resources/yaml/testContext.yaml index 46ba710c810df9afb3eccf66edc2591047a02e8b..289d15bbe40d77818a3bf22ecac18e4d00754767 100644 --- a/theodolite-quarkus/src/main/resources/yaml/testContext.yaml +++ b/theodolite-quarkus/src/main/resources/yaml/testContext.yaml @@ -15,10 +15,18 @@ execution: repititions: 1 restrictions: - "LowerBound" +#configOverrides: +# - type: "EnvVarPatcher" +# resource: "workloadGenerator.yaml" +# container: "workload-generator" +# overrides: +# overrideTestA: "8888" +# overrideTestB: "6666" configOverrides: - - type: "EnvVarPatcher" - resource: "workloadGenerator.yaml" - container: "workload-generator" - overrides: - overrideTestA: "8888" - overrideTestB: "6666" \ No newline at end of file + - patcher: + type: "EnvVarPatcher" + resource: "workloadGenerator.yaml" + container: "workload-generator" + variableName: "KAFKA_SERVER" + value: "localhost:9192" +