Skip to content
Snippets Groups Projects
Commit f1146238 authored by Benedikt Wetzel's avatar Benedikt Wetzel Committed by Sören Henning
Browse files

Introduce a type for loads and resources

for example resourceType = Instances, loadType = NumSensors
parent 6f036a62
Branches
Tags
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 48 additions and 41 deletions
...@@ -7,8 +7,8 @@ import kotlin.properties.Delegates ...@@ -7,8 +7,8 @@ import kotlin.properties.Delegates
class BenchmarkContext() { class BenchmarkContext() {
lateinit var name: String lateinit var name: String
lateinit var benchmark: String lateinit var benchmark: String
lateinit var loads: List<Int> lateinit var load: LoadDefinition
lateinit var resources: List<Int> lateinit var resources: ResourceDefinition
lateinit var slos: List<Slo> lateinit var slos: List<Slo>
lateinit var execution: Execution lateinit var execution: Execution
lateinit var configOverrides: List<ConfigurationOverride> lateinit var configOverrides: List<ConfigurationOverride>
...@@ -24,4 +24,14 @@ class BenchmarkContext() { ...@@ -24,4 +24,14 @@ class BenchmarkContext() {
lateinit var sloType: String lateinit var sloType: String
var threshold by Delegates.notNull<Int>() var threshold by Delegates.notNull<Int>()
} }
class LoadDefinition() {
lateinit var loadType: String
lateinit var loadValues: List<Int>
}
class ResourceDefinition() {
lateinit var resourceType: String
lateinit var resourceValues: List<Int>
}
} }
...@@ -49,7 +49,7 @@ class KubernetesBenchmark(): Benchmark { ...@@ -49,7 +49,7 @@ class KubernetesBenchmark(): Benchmark {
return KubernetesBenchmarkDeployment( return KubernetesBenchmarkDeployment(
resources.map { r -> r.second }, resources.map { r -> r.second },
kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapSever), kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapSever),
zookeeperConfig = zookeeperConfig["server"].toString() !!, zookeeperConfig = zookeeperConfig["server"].toString(),
topics = kafkaConfig.topics.map { topic -> NewTopic(topic.name, topic.partition, topic.replication ) }) topics = kafkaConfig.topics.map { topic -> NewTopic(topic.name, topic.partition, topic.replication ) })
} }
} }
......
...@@ -9,7 +9,7 @@ class TestBenchmark : Benchmark { ...@@ -9,7 +9,7 @@ class TestBenchmark : Benchmark {
override fun buildDeployment( override fun buildDeployment(
load: LoadDimension, load: LoadDimension,
res: Resource, res: Resource,
configurationOverride: List<ConfigurationOverride> configurationOverrides: List<ConfigurationOverride>
): BenchmarkDeployment { ): BenchmarkDeployment {
return TestBenchmarkDeployment() return TestBenchmarkDeployment()
} }
......
...@@ -11,7 +11,7 @@ import theodolite.util.Results ...@@ -11,7 +11,7 @@ import theodolite.util.Results
import java.time.Duration import java.time.Duration
class TheodoliteExecutor( class TheodoliteExecutor(
private val benchmarkContext: BenchmarkContext, private val config: BenchmarkContext,
private val kubernetesBenchmark: KubernetesBenchmark private val kubernetesBenchmark: KubernetesBenchmark
) )
{ {
...@@ -20,16 +20,16 @@ class TheodoliteExecutor( ...@@ -20,16 +20,16 @@ class TheodoliteExecutor(
val results = Results() val results = Results()
val strategyManager = StrategiesManager() val strategyManager = StrategiesManager()
val executionDuration = Duration.ofSeconds(this.benchmarkContext.execution.duration) val executionDuration = Duration.ofSeconds(config.execution.duration)
val executor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, this.benchmarkContext.configOverrides) val executor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, config.configOverrides)
return Config( return Config(
loads = benchmarkContext.loads.map { number -> LoadDimension(number) }, loads = config.load.loadValues.map { load -> LoadDimension(load, config.load.loadType ) },
resources = benchmarkContext.resources.map { number -> Resource(number) }, resources = config.resources.resourceValues.map { resource -> Resource(resource, config.load.loadType) },
compositeStrategy = CompositeStrategy( compositeStrategy = CompositeStrategy(
benchmarkExecutor = executor, benchmarkExecutor = executor,
searchStrategy = strategyManager.createSearchStrategy(executor, this.benchmarkContext.execution.strategy), searchStrategy = strategyManager.createSearchStrategy(executor, config.execution.strategy),
restrictionStrategies = strategyManager.createRestrictionStrategy(results, this.benchmarkContext.execution.restrictions)), restrictionStrategies = strategyManager.createRestrictionStrategy(results, config.execution.restrictions)),
executionDuration = executionDuration) executionDuration = executionDuration)
} }
......
...@@ -13,9 +13,9 @@ import theodolite.util.Resource ...@@ -13,9 +13,9 @@ import theodolite.util.Resource
class LowerBoundRestriction(results: Results) : RestrictionStrategy(results) { class LowerBoundRestriction(results: Results) : RestrictionStrategy(results) {
override fun next(load: LoadDimension, resources: List<Resource>): List<Resource> { override fun next(load: LoadDimension, resources: List<Resource>): List<Resource> {
val maxLoad: LoadDimension? = this.results.getMaxBenchmarkedLoad(load) val maxLoad: LoadDimension? = this.results.getMaxBenchmarkedLoad(load)
var lowerBound: Resource? = this.results.getMinRequiredInstances(maxLoad) var lowerBound: Resource? = this.results.getMinRequiredInstances(maxLoad, resources[0].getType())
if(lowerBound == null) { if(lowerBound == null) {
lowerBound = resources.get(0) lowerBound = resources[0]
} }
return resources.filter{x -> x.get() >= lowerBound.get()} return resources.filter{x -> x.get() >= lowerBound.get()}
} }
......
package theodolite.util package theodolite.util
data class LoadDimension(private val number: Int) { data class LoadDimension(private val number: Int, private val type: String) {
public fun get(): Int { public fun get(): Int {
return this.number; return this.number;
} }
public fun getType(): String { public fun getType(): String {
return "NumSensors" return this.type
} }
} }
package theodolite.util package theodolite.util
data class Resource(private val number: Int) { data class Resource(private val number: Int, private val type: String) {
public fun get(): Int { public fun get(): Int {
return this.number; return this.number;
} }
public fun getType(): String { public fun getType(): String {
return "Instances" return this.type
} }
} }
\ No newline at end of file
...@@ -16,10 +16,10 @@ class Results { ...@@ -16,10 +16,10 @@ class Results {
return this.results[experiment] return this.results[experiment]
} }
public fun getMinRequiredInstances(load: LoadDimension?): Resource? { public fun getMinRequiredInstances(load: LoadDimension?, resourceTyp: String): Resource? {
if (this.results.isEmpty()) return Resource(Int.MIN_VALUE) if (this.results.isEmpty()) return Resource(Int.MIN_VALUE, resourceTyp)
var requiredInstances: Resource? = Resource(Int.MAX_VALUE) var requiredInstances: Resource? = Resource(Int.MAX_VALUE, resourceTyp)
for(experiment in results) { for(experiment in results) {
if(experiment.key.first == load && experiment.value){ if(experiment.key.first == load && experiment.value){
if(requiredInstances == null) { if(requiredInstances == null) {
......
name: "Theodolite Test Context" name: "Theodolite Test Context"
benchmark: "benchmarkType" benchmark: "benchmarkType"
loads: load:
loadType: "NumSensors"
loadValues:
- 1000 - 1000
- 2000 - 2000
resources: resources:
resourceType: "Instances"
resourceValues:
- 1 - 1
- 2 - 2
slos: slos:
...@@ -15,13 +19,6 @@ execution: ...@@ -15,13 +19,6 @@ execution:
repititions: 1 repititions: 1
restrictions: restrictions:
- "LowerBound" - "LowerBound"
#configOverrides:
# - type: "EnvVarPatcher"
# resource: "workloadGenerator.yaml"
# container: "workload-generator"
# overrides:
# overrideTestA: "8888"
# overrideTestB: "6666"
configOverrides: configOverrides:
- patcher: - patcher:
type: "EnvVarPatcher" type: "EnvVarPatcher"
......
...@@ -26,8 +26,8 @@ class CompositeStrategyTest { ...@@ -26,8 +26,8 @@ class CompositeStrategyTest {
arrayOf( false, false, false, false, false, false, true), arrayOf( false, false, false, false, false, false, true),
arrayOf( false, false, false, false, false, false, false) arrayOf( false, false, false, false, false, false, false)
) )
val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number)} val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number, "NumSensors")}
val mockResources: List<Resource> = (0..6).map{number -> Resource(number)} val mockResources: List<Resource> = (0..6).map{number -> Resource(number, "Instances")}
val results: Results = Results(); val results: Results = Results();
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val benchmarkExecutor: TestBenchmarkExecutorImpl = TestBenchmarkExecutorImpl(mockResults, benchmark, results) val benchmarkExecutor: TestBenchmarkExecutorImpl = TestBenchmarkExecutorImpl(mockResults, benchmark, results)
...@@ -36,7 +36,7 @@ class CompositeStrategyTest { ...@@ -36,7 +36,7 @@ class CompositeStrategyTest {
val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutor, linearSearch, setOf(lowerBoundRestriction)) val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutor, linearSearch, setOf(lowerBoundRestriction))
val actual: ArrayList<Resource?> = ArrayList<Resource?>() val actual: ArrayList<Resource?> = ArrayList<Resource?>()
val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6).map{ x -> Resource(x)}) val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6).map{ x -> Resource(x, "Instances")})
expected.add(null) expected.add(null)
for(load in mockLoads) { for(load in mockLoads) {
...@@ -57,8 +57,8 @@ class CompositeStrategyTest { ...@@ -57,8 +57,8 @@ class CompositeStrategyTest {
arrayOf( false, false, false, false, false, false, true), arrayOf( false, false, false, false, false, false, true),
arrayOf( false, false, false, false, false, false, false) arrayOf( false, false, false, false, false, false, false)
) )
val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number)} val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number, "NumSensors")}
val mockResources: List<Resource> = (0..6).map{number -> Resource(number)} val mockResources: List<Resource> = (0..6).map{number -> Resource(number, "Instances")}
val results: Results = Results(); val results: Results = Results();
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val benchmarkExecutorImpl: TestBenchmarkExecutorImpl = TestBenchmarkExecutorImpl(mockResults, benchmark, results) val benchmarkExecutorImpl: TestBenchmarkExecutorImpl = TestBenchmarkExecutorImpl(mockResults, benchmark, results)
...@@ -67,7 +67,7 @@ class CompositeStrategyTest { ...@@ -67,7 +67,7 @@ class CompositeStrategyTest {
val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutorImpl, binarySearch, setOf(lowerBoundRestriction)) val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutorImpl, binarySearch, setOf(lowerBoundRestriction))
val actual: ArrayList<Resource?> = ArrayList<Resource?>() val actual: ArrayList<Resource?> = ArrayList<Resource?>()
val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6).map{ x -> Resource(x)}) val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6).map{ x -> Resource(x, "Instances")})
expected.add(null) expected.add(null)
for(load in mockLoads) { for(load in mockLoads) {
...@@ -88,8 +88,8 @@ class CompositeStrategyTest { ...@@ -88,8 +88,8 @@ class CompositeStrategyTest {
arrayOf( false, false, false, false, false, false, true, true), arrayOf( false, false, false, false, false, false, true, true),
arrayOf( false, false, false, false, false, false, false, true) arrayOf( false, false, false, false, false, false, false, true)
) )
val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number)} val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number, "NumSensors")}
val mockResources: List<Resource> = (0..7).map{number -> Resource(number)} val mockResources: List<Resource> = (0..7).map{number -> Resource(number, "Instances")}
val results: Results = Results(); val results: Results = Results();
val benchmark = TestBenchmark() val benchmark = TestBenchmark()
val benchmarkExecutor: TestBenchmarkExecutorImpl = TestBenchmarkExecutorImpl(mockResults, benchmark, results) val benchmarkExecutor: TestBenchmarkExecutorImpl = TestBenchmarkExecutorImpl(mockResults, benchmark, results)
...@@ -98,7 +98,7 @@ class CompositeStrategyTest { ...@@ -98,7 +98,7 @@ class CompositeStrategyTest {
val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutor, binarySearch, setOf(lowerBoundRestriction)) val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutor, binarySearch, setOf(lowerBoundRestriction))
val actual: ArrayList<Resource?> = ArrayList<Resource?>() val actual: ArrayList<Resource?> = ArrayList<Resource?>()
val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6,7).map{ x -> Resource(x)}) val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6,7).map{ x -> Resource(x, "Instances")})
for(load in mockLoads) { for(load in mockLoads) {
actual.add(strategy.findSuitableResource(load, mockResources)) actual.add(strategy.findSuitableResource(load, mockResources))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment