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

Minor code enhancements and clean up

parent da20d872
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 29 additions and 33 deletions
...@@ -3,6 +3,7 @@ package theodolite ...@@ -3,6 +3,7 @@ package theodolite
import io.quarkus.runtime.annotations.QuarkusMain import io.quarkus.runtime.annotations.QuarkusMain
import mu.KotlinLogging import mu.KotlinLogging
import theodolite.execution.TheodoliteYamlExecutor import theodolite.execution.TheodoliteYamlExecutor
import kotlin.system.exitProcess
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
...@@ -10,9 +11,9 @@ private val logger = KotlinLogging.logger {} ...@@ -10,9 +11,9 @@ private val logger = KotlinLogging.logger {}
object Main { object Main {
@JvmStatic @JvmStatic
fun main(args: Array<String>) { fun main(args: Array<String>) {
//val theodolite = TheodoliteExecutor() logger.info { "Theodolite started" }
val theodolite = TheodoliteYamlExecutor() TheodoliteYamlExecutor().run()
theodolite.run() logger.info { "Theodolite finished" }
logger.info("Application started") exitProcess(0)
} }
} }
...@@ -21,7 +21,7 @@ class KubernetesBenchmarkDeployment( ...@@ -21,7 +21,7 @@ class KubernetesBenchmarkDeployment(
override fun setup() { override fun setup() {
this.workloadGeneratorStateCleaner.deleteState() this.workloadGeneratorStateCleaner.deleteState()
kafkaController.createTopics(this.topics) kafkaController.createTopics(this.topics)
resources.forEach { resources.forEach {
kubernetesManager.deploy(it) kubernetesManager.deploy(it)
} }
} }
......
...@@ -30,8 +30,6 @@ class TheodoliteExecutor( ...@@ -30,8 +30,6 @@ class TheodoliteExecutor(
restrictionStrategies = strategyFactory.createRestrictionStrategy(results, config.execution.restrictions))) restrictionStrategies = strategyFactory.createRestrictionStrategy(results, config.execution.restrictions)))
} }
fun run() { fun run() {
val config = buildConfig() val config = buildConfig()
......
...@@ -6,7 +6,7 @@ import theodolite.benchmark.KubernetesBenchmark ...@@ -6,7 +6,7 @@ import theodolite.benchmark.KubernetesBenchmark
class TheodoliteYamlExecutor { class TheodoliteYamlExecutor {
fun run() { fun run() {
// load the Benchmark context and the benchmark type // load the BenchmarkExecution and the BenchmarkType
var parser = YamlParser() var parser = YamlParser()
val benchmarkExecution = parser.parse("./../../../resources/main/yaml/testBenchmarkExecution.yaml", BenchmarkExecution::class.java) !! val benchmarkExecution = parser.parse("./../../../resources/main/yaml/testBenchmarkExecution.yaml", BenchmarkExecution::class.java) !!
val benchmark = parser.parse("./../../../resources/main/yaml/testBenchmarkType.yaml", KubernetesBenchmark::class.java) !! val benchmark = parser.parse("./../../../resources/main/yaml/testBenchmarkType.yaml", KubernetesBenchmark::class.java) !!
......
...@@ -5,7 +5,6 @@ import io.fabric8.kubernetes.api.model.KubernetesResource ...@@ -5,7 +5,6 @@ import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.api.model.Service import io.fabric8.kubernetes.api.model.Service
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition
import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.Deployment
import io.fabric8.kubernetes.api.model.apps.StatefulSet
import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import mu.KotlinLogging import mu.KotlinLogging
...@@ -14,21 +13,21 @@ private val logger = KotlinLogging.logger {} ...@@ -14,21 +13,21 @@ private val logger = KotlinLogging.logger {}
class K8sResourceLoader(private val client: NamespacedKubernetesClient) { class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
/** /**
* Parses a Service from a servive yaml * Parses a Service from a service yaml
* @param path of the yaml file * @param path of the yaml file
* @return service from fabric8 * @return service from fabric8
*/ */
private fun loadService(path: String): Service { private fun loadService(path: String): Service {
return loadGenericRessource(path) { x: String -> client.services().load(x).get() } return loadGenericResource(path) { x: String -> client.services().load(x).get() }
} }
/** /**
* Parses a Service from a servive yaml * Parses a Service from a service yaml
* @param path of the yaml file * @param path of the yaml file
* @return service from fabric8 * @return service from fabric8
*/ */
private fun loadServiceMonitor(path: String): CustomResourceDefinition { private fun loadServiceMonitor(path: String): CustomResourceDefinition {
return loadGenericRessource(path) { x: String -> client.customResourceDefinitions().load(x).get() } return loadGenericResource(path) { x: String -> client.customResourceDefinitions().load(x).get() }
} }
/** /**
...@@ -37,7 +36,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { ...@@ -37,7 +36,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
* @return Deployment from fabric8 * @return Deployment from fabric8
*/ */
private fun loadDeployment(path: String): Deployment { private fun loadDeployment(path: String): Deployment {
return loadGenericRessource(path) { x: String -> client.apps().deployments().load(x).get() } return loadGenericResource(path) { x: String -> client.apps().deployments().load(x).get() }
} }
/** /**
...@@ -46,38 +45,37 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { ...@@ -46,38 +45,37 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
* @return ConfigMap from fabric8 * @return ConfigMap from fabric8
*/ */
private fun loadConfigmap(path: String): ConfigMap { private fun loadConfigmap(path: String): ConfigMap {
return loadGenericRessource(path) { x: String -> client.configMaps().load(x).get() } return loadGenericResource(path) { x: String -> client.configMaps().load(x).get() }
} }
/** /**
* Generic helper function to load a resource. * Generic helper function to load a resource.
* @param path of the resource * @param path of the resource
* @param f fuction that shall be applied to the resource. * @param f function that shall be applied to the resource.
*/ */
private fun <T> loadGenericRessource(path: String, f: (String) -> T): T { private fun <T> loadGenericResource(path: String, f: (String) -> T): T {
var resource: T? = null var resource: T? = null
try { try {
resource = f(path) resource = f(path)
} catch (e: Exception) { } catch (e: Exception) {
logger.info("You potentially misspelled the path: $path") logger.warn {"You potentially misspelled the path: $path"}
logger.info("$e") logger.warn { e }
} }
if (resource == null) { if (resource == null) {
throw IllegalArgumentException("The Resource at path: $path could not be loaded") throw IllegalArgumentException("The Resource at path: $path could not be loaded")
} }
return resource return resource
} }
public fun loadK8sResource(kind: String, path: String): KubernetesResource { fun loadK8sResource(kind: String, path: String): KubernetesResource {
return when (kind){ return when (kind){
"Deployment" -> loadDeployment(path) "Deployment" -> loadDeployment(path)
"Service" -> loadService(path) "Service" -> loadService(path)
"ServiceMonitor" -> loadServiceMonitor(path) "ServiceMonitor" -> loadServiceMonitor(path)
"ConfigMap" -> loadConfigmap(path) "ConfigMap" -> loadConfigmap(path)
else -> return loadConfigmap(path) // throw java.lang.IllegalArgumentException("Resource typ $kind not known") else -> throw IllegalArgumentException("Unknown resource with type $kind located in $path")
} }
} }
} }
package theodolite.util package theodolite.util
import theodolite.util.LoadDimension
import theodolite.util.Resource
import kotlin.math.exp
class Results { class Results {
private val results: MutableMap<Pair<LoadDimension, Resource>, Boolean> = mutableMapOf() private val results: MutableMap<Pair<LoadDimension, Resource>, Boolean> = mutableMapOf()
......
...@@ -13,7 +13,7 @@ slos: ...@@ -13,7 +13,7 @@ slos:
threshold: 1000 threshold: 1000
execution: execution:
strategy: "LinearSearch" strategy: "LinearSearch"
duration: 120 duration: 300
repititions: 1 repititions: 1
restrictions: restrictions:
- "LowerBound" - "LowerBound"
......
...@@ -21,7 +21,7 @@ kafkaConfig: ...@@ -21,7 +21,7 @@ kafkaConfig:
bootstrapServer: "localhost:31290" bootstrapServer: "localhost:31290"
topics: topics:
- name: "input" - name: "input"
numPartitions: 1 numPartitions: 40
replicationFactor: 1 replicationFactor: 1
zookeeperConfig: zookeeperConfig:
server: "localhost:31953" server: "localhost:31953"
\ No newline at end of file
...@@ -3,12 +3,10 @@ package theodolite ...@@ -3,12 +3,10 @@ package theodolite
import io.quarkus.test.junit.QuarkusTest import io.quarkus.test.junit.QuarkusTest
import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import theodolite.benchmark.TestBenchmark
import theodolite.strategies.searchstrategy.LinearSearch import theodolite.strategies.searchstrategy.LinearSearch
import theodolite.strategies.searchstrategy.BinarySearch import theodolite.strategies.searchstrategy.BinarySearch
import theodolite.strategies.restriction.LowerBoundRestriction import theodolite.strategies.restriction.LowerBoundRestriction
import theodolite.strategies.searchstrategy.CompositeStrategy import theodolite.strategies.searchstrategy.CompositeStrategy
import theodolite.execution.TestBenchmarkExecutorImpl
import theodolite.util.* import theodolite.util.*
import java.util.* import java.util.*
......
package theodolite.benchmark package theodolite
import theodolite.benchmark.Benchmark
import theodolite.benchmark.BenchmarkDeployment
import theodolite.util.LoadDimension import theodolite.util.LoadDimension
import theodolite.util.ConfigurationOverride import theodolite.util.ConfigurationOverride
import theodolite.util.Resource import theodolite.util.Resource
......
package theodolite.benchmark package theodolite
import theodolite.benchmark.BenchmarkDeployment
class TestBenchmarkDeployment: BenchmarkDeployment { class TestBenchmarkDeployment: BenchmarkDeployment {
override fun setup() { override fun setup() {
......
package theodolite.execution package theodolite
import theodolite.benchmark.Benchmark import theodolite.benchmark.Benchmark
import theodolite.execution.BenchmarkExecutor
import theodolite.util.LoadDimension import theodolite.util.LoadDimension
import theodolite.util.Resource import theodolite.util.Resource
import theodolite.util.Results import theodolite.util.Results
......
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