From e88755ddb29ffada52b0bab0f6b287218da02558 Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Fri, 19 Feb 2021 16:38:19 +0100 Subject: [PATCH] clean up and restructure move old and unused classes to the new a package called depcrecated and update all types to the new ones. --- .../src/main/kotlin/theodolite/Main.kt | 2 +- .../benchmark/KubernetesBenchmark.kt | 9 +-- .../KubernetesBenchmarkDeployment.kt | 2 +- .../theodolite/benchmark/TestBenchmark.kt | 16 ++++ .../benchmark/TestBenchmarkDeployment.kt | 9 +++ .../benchmark/TheodoliteBenchmarkExecutor.kt | 46 ----------- .../{util => deprecated}/AbstractBenchmark.kt | 7 +- .../{util => deprecated}/Benchmark.kt | 7 +- .../{k8s => deprecated}/ConfigMapManager.kt | 2 +- .../{k8s => deprecated}/ServiceManager.kt | 2 +- .../deprecated/TheodoliteExecutor.kt | 70 ++++++++++++++++ .../{k8s => deprecated}/UC1Benchmark.kt | 8 +- .../theodolite/execution/BenchmarkExecutor.kt | 1 - .../execution/BenchmarkExecutorImpl.kt | 2 +- .../execution/TestBenchmarkExecutorImpl.kt | 2 - .../execution/TheodoliteExecutor.kt | 80 +++++++------------ .../TheodoliteYamlExecutor.kt | 16 ++-- .../main/kotlin/theodolite/k8s/K8sManager.kt | 4 +- .../{YamlLoader.kt => K8sResourceLoader.kt} | 2 +- .../src/main/kotlin/theodolite/util/Parser.kt | 2 +- .../kotlin/theodolite/util/TestBenchmark.kt | 48 ----------- .../YamlParser.kt} | 5 +- .../resources/yaml/testBenchmarkType.yaml | 1 + .../theodolite/CompositeStrategyTest.kt | 2 + 24 files changed, 162 insertions(+), 183 deletions(-) create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmarkDeployment.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TheodoliteBenchmarkExecutor.kt rename theodolite-quarkus/src/main/kotlin/theodolite/{util => deprecated}/AbstractBenchmark.kt (90%) rename theodolite-quarkus/src/main/kotlin/theodolite/{util => deprecated}/Benchmark.kt (71%) rename theodolite-quarkus/src/main/kotlin/theodolite/{k8s => deprecated}/ConfigMapManager.kt (92%) rename theodolite-quarkus/src/main/kotlin/theodolite/{k8s => deprecated}/ServiceManager.kt (94%) create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/deprecated/TheodoliteExecutor.kt rename theodolite-quarkus/src/main/kotlin/theodolite/{k8s => deprecated}/UC1Benchmark.kt (98%) rename theodolite-quarkus/src/main/kotlin/theodolite/{benchmark => execution}/TheodoliteYamlExecutor.kt (62%) rename theodolite-quarkus/src/main/kotlin/theodolite/k8s/{YamlLoader.kt => K8sResourceLoader.kt} (97%) delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/util/TestBenchmark.kt rename theodolite-quarkus/src/main/kotlin/theodolite/{benchmark/BenchmarkYamlParser.kt => util/YamlParser.kt} (79%) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt b/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt index 89c9ac1fe..ef9e1a458 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt @@ -2,7 +2,7 @@ package theodolite import io.quarkus.runtime.annotations.QuarkusMain import mu.KotlinLogging -import theodolite.benchmark.TheodoliteYamlExecutor +import theodolite.execution.TheodoliteYamlExecutor private val logger = KotlinLogging.logger {} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index 8f08bf282..fc5515a4a 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -3,7 +3,7 @@ package theodolite.benchmark import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.client.DefaultKubernetesClient import org.apache.kafka.clients.admin.NewTopic -import theodolite.k8s.YamlLoader +import theodolite.k8s.K8sResourceLoader import theodolite.patcher.PatcherManager import theodolite.util.* import java.util.* @@ -21,8 +21,8 @@ class KubernetesBenchmark(): Benchmark { private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> { val basePath = "./../../../resources/main/yaml/" - var parser = theodolite.benchmark.BenchmarkYamlParser() - val loader = YamlLoader(DefaultKubernetesClient().inNamespace("default")) + var parser = YamlParser() + val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace("default")) return resources .map { resource -> val resourcePath = "$basePath/$resource" @@ -32,9 +32,6 @@ class KubernetesBenchmark(): Benchmark { } } - - - override fun buildDeployment(load: LoadDimension, res: Resource, overrides: List<OverridePatcherDefinition>): BenchmarkDeployment { // TODO("set node selector") val resources = loadKubernetesResources(this.appResource + this.loadGenResource) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt index 3c1473691..227934a00 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt @@ -9,7 +9,7 @@ import theodolite.k8s.WorkloadGeneratorStateCleaner import java.util.* class KubernetesBenchmarkDeployment( - val resources: List<KubernetesResource>, // List of already patched resources + val resources: List<KubernetesResource>, private val kafkaConfig: HashMap<String, Any>, private val zookeeperConfig: String, private val topics: Collection<NewTopic> diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt new file mode 100644 index 000000000..dc55d61fa --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt @@ -0,0 +1,16 @@ +package theodolite.benchmark + +import theodolite.util.LoadDimension +import theodolite.util.OverridePatcherDefinition +import theodolite.util.Resource + +class TestBenchmark : Benchmark { + + override fun buildDeployment( + load: LoadDimension, + res: Resource, + override: List<OverridePatcherDefinition> + ): BenchmarkDeployment { + return TestBenchmarkDeployment() + } +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmarkDeployment.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmarkDeployment.kt new file mode 100644 index 000000000..8c86fe317 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmarkDeployment.kt @@ -0,0 +1,9 @@ +package theodolite.benchmark + +class TestBenchmarkDeployment: BenchmarkDeployment { + override fun setup() { + } + + override fun teardown() { + } +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TheodoliteBenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TheodoliteBenchmarkExecutor.kt deleted file mode 100644 index cb4f0312c..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TheodoliteBenchmarkExecutor.kt +++ /dev/null @@ -1,46 +0,0 @@ -package theodolite.benchmark - -import theodolite.execution.BenchmarkExecutor -import theodolite.execution.BenchmarkExecutorImpl -import theodolite.strategies.StrategiesManager -import theodolite.strategies.searchstrategy.CompositeStrategy -import theodolite.util.Config -import theodolite.util.LoadDimension -import theodolite.util.Resource -import theodolite.util.Results -import java.time.Duration - -class TheodoliteBenchmarkExecutor( - private val benchmarkContext: BenchmarkContext, - private val kubernetesBenchmark: KubernetesBenchmark) -{ - - private fun buildConfig(): Config{ - val results = Results() - val strategyManager = StrategiesManager() - - val executionDuration = Duration.ofSeconds(this.benchmarkContext.execution.duration) - val executor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, this.benchmarkContext.configOverrides) - - return Config( - loads = benchmarkContext.loads.map { number -> LoadDimension(number) }, - resources = benchmarkContext.resources.map { number -> Resource(number) }, - compositeStrategy = CompositeStrategy( - benchmarkExecutor = executor, - searchStrategy = strategyManager.createSearchStrategy(executor, this.benchmarkContext.execution.strategy), - restrictionStrategies = strategyManager.createRestrictionStrategy(results, this.benchmarkContext.execution.restrictions)), - executionDuration = executionDuration) - } - - - - fun run() { - val config = buildConfig() - - // execute benchmarks for each load - for (load in config.loads) { - config.compositeStrategy.findSuitableResource(load, config.resources) - } - - } -} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/AbstractBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/AbstractBenchmark.kt similarity index 90% rename from theodolite-quarkus/src/main/kotlin/theodolite/util/AbstractBenchmark.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/deprecated/AbstractBenchmark.kt index 2411e1b8b..b5dce58d4 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/AbstractBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/AbstractBenchmark.kt @@ -1,4 +1,7 @@ -package theodolite.util +package theodolite.deprecated + +import theodolite.util.LoadDimension +import theodolite.util.Resource abstract class AbstractBenchmark(val config: Config): Benchmark { override fun start(load: LoadDimension, resources: Resource) { @@ -24,4 +27,4 @@ abstract class AbstractBenchmark(val config: Config): Benchmark { val ucImageURL: String, val wgImageURL: String ) {} -} +} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/Benchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/Benchmark.kt similarity index 71% rename from theodolite-quarkus/src/main/kotlin/theodolite/util/Benchmark.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/deprecated/Benchmark.kt index 44f98da2e..57652a5b7 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/Benchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/Benchmark.kt @@ -1,4 +1,7 @@ -package theodolite.util +package theodolite.deprecated + +import theodolite.util.LoadDimension +import theodolite.util.Resource interface Benchmark { fun start(load: LoadDimension, resources: Resource) { @@ -9,4 +12,4 @@ interface Benchmark { fun startSUT(resources: Resource); fun startWorkloadGenerator(load: LoadDimension) -} \ No newline at end of file +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/ConfigMapManager.kt b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/ConfigMapManager.kt similarity index 92% rename from theodolite-quarkus/src/main/kotlin/theodolite/k8s/ConfigMapManager.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/deprecated/ConfigMapManager.kt index bf18ff7df..f9b61c40b 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/ConfigMapManager.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/ConfigMapManager.kt @@ -1,4 +1,4 @@ -package theodolite.k8s +package theodolite.deprecated import io.fabric8.kubernetes.api.model.ConfigMap import io.fabric8.kubernetes.client.NamespacedKubernetesClient diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/ServiceManager.kt b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/ServiceManager.kt similarity index 94% rename from theodolite-quarkus/src/main/kotlin/theodolite/k8s/ServiceManager.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/deprecated/ServiceManager.kt index a976849fa..5245a00aa 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/ServiceManager.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/ServiceManager.kt @@ -1,4 +1,4 @@ -package theodolite.k8s +package theodolite.deprecated import io.fabric8.kubernetes.api.model.Service import io.fabric8.kubernetes.client.NamespacedKubernetesClient diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/TheodoliteExecutor.kt new file mode 100644 index 000000000..01d1075df --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/TheodoliteExecutor.kt @@ -0,0 +1,70 @@ +package theodolite.deprecated +/* +import mu.KotlinLogging +import theodolite.deprecated.AbstractBenchmark +import theodolite.k8s.UC1Benchmark +import theodolite.strategies.restriction.LowerBoundRestriction +import theodolite.strategies.searchstrategy.CompositeStrategy +import theodolite.strategies.searchstrategy.LinearSearch +import theodolite.util.* +import java.nio.file.Paths +import java.time.Duration + +private val logger = KotlinLogging.logger {} + +class TheodoliteExecutor() { + val projectDirAbsolutePath = Paths.get("").toAbsolutePath().toString() + val resourcesPath = Paths.get(projectDirAbsolutePath, "./../../../resources/main/yaml/") + private fun loadConfig(): Config { + logger.info { resourcesPath } + val benchmark: UC1Benchmark = UC1Benchmark( + AbstractBenchmark.Config( + clusterZookeeperConnectionString = "my-confluent-cp-zookeeper:2181", + clusterKafkaConnectionString = "my-confluent-cp-kafka:9092", + externalZookeeperConnectionString = "localhost:2181", + externalKafkaConnectionString = "localhost:9092", + schemaRegistryConnectionString = "http://my-confluent-cp-schema-registry:8081", + kafkaPartition = 40, + kafkaReplication = 1, + kafkaTopics = listOf("input", "output"), + // TODO("handle path in a more nice way (not absolut)") + ucDeploymentPath = "$resourcesPath/aggregation-deployment.yaml", + ucServicePath = "$resourcesPath/aggregation-service.yaml", + wgDeploymentPath = "$resourcesPath/workloadGenerator.yaml", + configMapPath = "$resourcesPath/jmx-configmap.yaml", + ucImageURL = "ghcr.io/cau-se/theodolite-uc1-kstreams-app:latest", + wgImageURL = "ghcr.io/cau-se/theodolite-uc1-workload-generator:theodolite-kotlin-latest" + ) + ) + val results: Results = Results() + + val executionDuration = Duration.ofSeconds(60 * 5) + + val executor: BenchmarkExecutor = BenchmarkExecutorImpl(benchmark, results, executionDuration) + + val restrictionStrategy = LowerBoundRestriction(results) + val searchStrategy = LinearSearch(executor) + + return Config( + loads = listOf(5000, 10000).map { number -> LoadDimension(number) }, + resources = (1..6).map { number -> Resource(number) }, + compositeStrategy = CompositeStrategy( + executor, + searchStrategy, + restrictionStrategies = setOf(restrictionStrategy) + ), + executionDuration = executionDuration + ) + } + + fun run() { + // read or get benchmark config + val config = this.loadConfig() + + // execute benchmarks for each load + for (load in config.loads) { + config.compositeStrategy.findSuitableResource(load, config.resources) + } + } +} +*/ \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/UC1Benchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/UC1Benchmark.kt similarity index 98% rename from theodolite-quarkus/src/main/kotlin/theodolite/k8s/UC1Benchmark.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/deprecated/UC1Benchmark.kt index af81e75b7..13ff2a5b3 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/UC1Benchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/deprecated/UC1Benchmark.kt @@ -1,12 +1,12 @@ -package theodolite.k8s - +package theodolite.deprecated +/* import io.fabric8.kubernetes.api.model.ConfigMap import io.fabric8.kubernetes.api.model.Service import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.client.DefaultKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient import mu.KotlinLogging -import theodolite.util.AbstractBenchmark +import theodolite.deprecated.AbstractBenchmark import theodolite.util.LoadDimension import theodolite.util.Resource @@ -93,5 +93,5 @@ class UC1Benchmark(config: Config) : AbstractBenchmark(config) { this.deploymentManager.setWorkloadEnv(this.wgDeployment, "workload-generator", environmentVariables) this.deploymentManager.deploy(this.wgDeployment) } - } + */ \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt index 714a27885..c78559dd0 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -2,7 +2,6 @@ package theodolite.execution import mu.KotlinLogging import theodolite.benchmark.Benchmark -import theodolite.benchmark.KubernetesBenchmark import theodolite.util.* import java.time.Duration diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index c034dd6e9..c38dd1c14 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -4,7 +4,7 @@ import theodolite.benchmark.Benchmark import theodolite.util.* import java.time.Duration -class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDuration: Duration, private val overrides: List<OverridePatcherDefinition>) : BenchmarkExecutor(benchmark, results, executionDuration, overrides) { +class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDuration: Duration, val overrides: List<OverridePatcherDefinition>) : BenchmarkExecutor(benchmark, results, executionDuration, overrides) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { val benchmarkDeployment = benchmark.buildDeployment(load, res, this.overrides) benchmarkDeployment.setup() diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutorImpl.kt index 66506055e..3b1b6b31d 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TestBenchmarkExecutorImpl.kt @@ -1,8 +1,6 @@ package theodolite.execution import theodolite.benchmark.Benchmark -import theodolite.benchmark.KubernetesBenchmark -import theodolite.util.AbstractBenchmark import theodolite.util.LoadDimension import theodolite.util.Resource import theodolite.util.Results diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index 3db21a87a..92d9a4ed9 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -1,69 +1,47 @@ package theodolite.execution -/* -import mu.KotlinLogging -import theodolite.k8s.UC1Benchmark -import theodolite.strategies.restriction.LowerBoundRestriction + +import theodolite.benchmark.BenchmarkContext +import theodolite.benchmark.KubernetesBenchmark +import theodolite.strategies.StrategiesManager import theodolite.strategies.searchstrategy.CompositeStrategy -import theodolite.strategies.searchstrategy.LinearSearch -import theodolite.util.* -import java.nio.file.Paths +import theodolite.util.Config +import theodolite.util.LoadDimension +import theodolite.util.Resource +import theodolite.util.Results import java.time.Duration -private val logger = KotlinLogging.logger {} - -class TheodoliteExecutor() { - val projectDirAbsolutePath = Paths.get("").toAbsolutePath().toString() - val resourcesPath = Paths.get(projectDirAbsolutePath, "./../../../resources/main/yaml/") - private fun loadConfig(): Config { - logger.info { resourcesPath } - val benchmark: UC1Benchmark = UC1Benchmark( - AbstractBenchmark.Config( - clusterZookeeperConnectionString = "my-confluent-cp-zookeeper:2181", - clusterKafkaConnectionString = "my-confluent-cp-kafka:9092", - externalZookeeperConnectionString = "localhost:2181", - externalKafkaConnectionString = "localhost:9092", - schemaRegistryConnectionString = "http://my-confluent-cp-schema-registry:8081", - kafkaPartition = 40, - kafkaReplication = 1, - kafkaTopics = listOf("input", "output"), - // TODO("handle path in a more nice way (not absolut)") - ucDeploymentPath = "$resourcesPath/aggregation-deployment.yaml", - ucServicePath = "$resourcesPath/aggregation-service.yaml", - wgDeploymentPath = "$resourcesPath/workloadGenerator.yaml", - configMapPath = "$resourcesPath/jmx-configmap.yaml", - ucImageURL = "ghcr.io/cau-se/theodolite-uc1-kstreams-app:latest", - wgImageURL = "ghcr.io/cau-se/theodolite-uc1-workload-generator:theodolite-kotlin-latest" - ) - ) - val results: Results = Results() - - val executionDuration = Duration.ofSeconds(60 * 5) +class TheodoliteExecutor( + private val benchmarkContext: BenchmarkContext, + private val kubernetesBenchmark: KubernetesBenchmark +) +{ - val executor: BenchmarkExecutor = BenchmarkExecutorImpl(benchmark, results, executionDuration) + private fun buildConfig(): Config{ + val results = Results() + val strategyManager = StrategiesManager() - val restrictionStrategy = LowerBoundRestriction(results) - val searchStrategy = LinearSearch(executor) + val executionDuration = Duration.ofSeconds(this.benchmarkContext.execution.duration) + val executor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, this.benchmarkContext.configOverrides) return Config( - loads = listOf(5000, 10000).map { number -> LoadDimension(number) }, - resources = (1..6).map { number -> Resource(number) }, - compositeStrategy = CompositeStrategy( - executor, - searchStrategy, - restrictionStrategies = setOf(restrictionStrategy) - ), - executionDuration = executionDuration - ) + loads = benchmarkContext.loads.map { number -> LoadDimension(number) }, + resources = benchmarkContext.resources.map { number -> Resource(number) }, + compositeStrategy = CompositeStrategy( + benchmarkExecutor = executor, + searchStrategy = strategyManager.createSearchStrategy(executor, this.benchmarkContext.execution.strategy), + restrictionStrategies = strategyManager.createRestrictionStrategy(results, this.benchmarkContext.execution.restrictions)), + executionDuration = executionDuration) } + + fun run() { - // read or get benchmark config - val config = this.loadConfig() + val config = buildConfig() // execute benchmarks for each load for (load in config.loads) { config.compositeStrategy.findSuitableResource(load, config.resources) } + } } -*/ diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TheodoliteYamlExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteYamlExecutor.kt similarity index 62% rename from theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TheodoliteYamlExecutor.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteYamlExecutor.kt index e80f98de8..4984f9bfe 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TheodoliteYamlExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteYamlExecutor.kt @@ -1,21 +1,19 @@ -package theodolite.benchmark +package theodolite.execution + +import theodolite.benchmark.BenchmarkContext +import theodolite.util.YamlParser +import theodolite.benchmark.KubernetesBenchmark class TheodoliteYamlExecutor { fun run() { // load the Benchmark context and the benchmark type - var parser = theodolite.benchmark.BenchmarkYamlParser() + var parser = YamlParser() val benchmarkContext = parser.parse("./../../../resources/main/yaml/testContext.yaml", BenchmarkContext::class.java) !! val benchmark = parser.parse("./../../../resources/main/yaml/testBenchmarkType.yaml", KubernetesBenchmark::class.java) !! // TheodoliteExecutor benchmarkContext, benchmark - val executor = TheodoliteBenchmarkExecutor(benchmarkContext, benchmark) + val executor = TheodoliteExecutor(benchmarkContext, benchmark) executor.run() - - - - System.out.println(benchmark.name) - System.out.println(benchmarkContext.name) - } } \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sManager.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sManager.kt index 3a9f64089..ef0c52207 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sManager.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sManager.kt @@ -21,7 +21,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) { this.client.configMaps().createOrReplace(resource) is StatefulSet -> this.client.apps().statefulSets().createOrReplace(resource) - else -> throw IllegalArgumentException("Unknown kubernetes resource.") + else -> throw IllegalArgumentException("Unknown Kubernetes resource.") } } @@ -35,7 +35,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) { this.client.configMaps().delete(resource) is StatefulSet -> this.client.apps().statefulSets().delete(resource) - else -> throw IllegalArgumentException("Unknown kubernetes resource.") + else -> throw IllegalArgumentException("Unknown Kubernetes resource.") } } } \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/YamlLoader.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt similarity index 97% rename from theodolite-quarkus/src/main/kotlin/theodolite/k8s/YamlLoader.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt index 1624c6d4e..e326ad3fe 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/YamlLoader.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt @@ -11,7 +11,7 @@ import mu.KotlinLogging private val logger = KotlinLogging.logger {} -class YamlLoader(private val client: NamespacedKubernetesClient) { +class K8sResourceLoader(private val client: NamespacedKubernetesClient) { /** * Parses a Service from a servive yaml diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/Parser.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/Parser.kt index 6e0803e6d..11e637c89 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/Parser.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/Parser.kt @@ -1,5 +1,5 @@ package theodolite.util interface Parser { - fun <T> parse(path: String, E:Class<T>): T? //Yaml + fun <T> parse(path: String, E:Class<T>): T? } \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/TestBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/TestBenchmark.kt deleted file mode 100644 index 9f386ba86..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/TestBenchmark.kt +++ /dev/null @@ -1,48 +0,0 @@ -package theodolite.util - -import theodolite.benchmark.Benchmark -import theodolite.benchmark.BenchmarkDeployment - -class TestBenchmark : AbstractBenchmark( - AbstractBenchmark.Config( - clusterZookeeperConnectionString = "", - clusterKafkaConnectionString = "", - externalZookeeperConnectionString = "", - externalKafkaConnectionString = "", - schemaRegistryConnectionString = "", - kafkaTopics = emptyList(), - kafkaReplication = 0, - kafkaPartition = 0, - ucServicePath = "", - ucDeploymentPath = "", - wgDeploymentPath = "", - configMapPath = "", - ucImageURL = "", - wgImageURL = "" - ) -), Benchmark { - - override fun initializeClusterEnvironment() { - TODO("Not yet implemented") - } - - override fun clearClusterEnvironment() { - TODO("Not yet implemented") - } - - override fun startSUT(resources: Resource) { - TODO("Not yet implemented") - } - - override fun startWorkloadGenerator(load: LoadDimension) { - TODO("Not yet implemented") - } - - override fun buildDeployment( - load: LoadDimension, - res: Resource, - override: List<OverridePatcherDefinition> - ): BenchmarkDeployment { - TODO("Not yet implemented") - } -} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkYamlParser.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/YamlParser.kt similarity index 79% rename from theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkYamlParser.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/util/YamlParser.kt index 51e0f1aa3..fb953a744 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkYamlParser.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/YamlParser.kt @@ -1,14 +1,13 @@ -package theodolite.benchmark +package theodolite.util import org.yaml.snakeyaml.Yaml import org.yaml.snakeyaml.constructor.Constructor -import theodolite.util.Parser import java.io.File import java.io.FileInputStream import java.io.InputStream -class BenchmarkYamlParser: Parser { +class YamlParser: Parser { override fun <T> parse(path: String, E: Class<T>): T? { val input: InputStream = FileInputStream(File(path)) val parser = Yaml(Constructor(E)) diff --git a/theodolite-quarkus/src/main/resources/yaml/testBenchmarkType.yaml b/theodolite-quarkus/src/main/resources/yaml/testBenchmarkType.yaml index dfc19f967..766422d5e 100644 --- a/theodolite-quarkus/src/main/resources/yaml/testBenchmarkType.yaml +++ b/theodolite-quarkus/src/main/resources/yaml/testBenchmarkType.yaml @@ -2,6 +2,7 @@ name: "theodolite ist cool" appResource: - "aggregation-deployment.yaml" - "aggregation-service.yaml" + - "jmx-configmap.yaml" loadGenResource: - "workloadGenerator.yaml" resourceTypes: diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt index fb98f11f2..573495037 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt @@ -3,12 +3,14 @@ package theodolite import io.quarkus.test.junit.QuarkusTest import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test +import theodolite.benchmark.TestBenchmark import theodolite.strategies.searchstrategy.LinearSearch import theodolite.strategies.searchstrategy.BinarySearch import theodolite.strategies.restriction.LowerBoundRestriction import theodolite.strategies.searchstrategy.CompositeStrategy import theodolite.execution.TestBenchmarkExecutorImpl import theodolite.util.* +import java.util.* @QuarkusTest class CompositeStrategyTest { -- GitLab