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

Introduce a type for loads and resources

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