Skip to content
Snippets Groups Projects
Commit a8da7d41 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

Enhance the way to configure overrides

parent e88755dd
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!85Introduce new Benchmark class and Patcher,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Showing
with 55 additions and 43 deletions
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
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
......
......@@ -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),
......
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()
}
......
......@@ -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.
......
......@@ -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()
......
......@@ -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 {
......
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
package theodolite.util
class ConfigurationOverride() {
lateinit var patcher: PatcherDefinition
lateinit var value: String
}
package theodolite.util
class OverridePatcherDefinition() {
lateinit var type: String
lateinit var resource: String
lateinit var container: String
lateinit var overrides: Map<String, String>
}
......@@ -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"
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