diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt index ef378d98e74a6ab821173cf2a6f8fca7e3f246c9..c734c22a99869a51f0b930505717ad0be70a988b 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt @@ -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> + } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index 545d368f5ca51ffde7e42ce37a4c4029c7591391..b998dcda41b026831f2003160cff5c26274663f8 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -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 ) }) } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt index abda15822503850828af2e521d5ede399c66887a..45802ec8b715396bb21fd7d3b8281176b7c2284a 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt @@ -9,7 +9,7 @@ class TestBenchmark : Benchmark { override fun buildDeployment( load: LoadDimension, res: Resource, - configurationOverride: List<ConfigurationOverride> + configurationOverrides: List<ConfigurationOverride> ): BenchmarkDeployment { return TestBenchmarkDeployment() } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index 92d9a4ed92e4bbf5b13eb159855621b3ff80d858..c94beee061e361e42cd2152753f44b693a8aa1ed 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -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) } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt index 093ef3b100ae53babf0b873d6133a9571196bcdd..aa5878ef2a7e789c48c76d8f166da26905f58f87 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt @@ -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()} } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt index 52d8650504f7a246c7a58a0332a959166a8152e0..9804dab401d75b11a21a5738e74488eb471b16f1 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt @@ -1,11 +1,11 @@ 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 } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt index 0afa4885153bcf56a48e0b58365e3ae10754bd44..fecb218b2744d6ea2b31d1bcb2599669b72fdacc 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt @@ -1,11 +1,11 @@ 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 diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt index fdd38896d664e6f793a1fffe7cc39a0c25d09067..11f0ba7cc0fe085810686ea1335635bb8e842614 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt @@ -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) { diff --git a/theodolite-quarkus/src/main/resources/yaml/testContext.yaml b/theodolite-quarkus/src/main/resources/yaml/testContext.yaml index 13c0ae3756b1955beba5ae9073d542badcb314bc..f3e73ca43ec4ba81b955f51df18294b0901d5f2c 100644 --- a/theodolite-quarkus/src/main/resources/yaml/testContext.yaml +++ b/theodolite-quarkus/src/main/resources/yaml/testContext.yaml @@ -1,11 +1,15 @@ 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" diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt index 5734950375d4c45eba6fc7e1a7a40e43d501191d..f982dd18b7e08a7dda3200cdde6c0de1b9a6a686 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt @@ -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))