diff --git a/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml b/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml index ebc2fe9e44fe303e342cabee301cb63664867cfb..cdc2122d9e6b568f1a75b0d55eff8a0af6450983 100644 --- a/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml +++ b/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml @@ -22,7 +22,7 @@ loadTypes: - type: "NumSensorsLoadGeneratorReplicaPatcher" resource: "uc1-load-generator-deployment.yaml" kafkaConfig: - bootstrapServer: "theodolite-cp-kafka:9092" + bootstrapServer: "localhost:31290" topics: - name: "input" numPartitions: 40 diff --git a/theodolite-quarkus/config/example-execution-yaml-resource.yaml b/theodolite-quarkus/config/example-execution-yaml-resource.yaml index 23c1587ec1e5c2a88fcf69d7127edbcc1ffdb00f..e0b327a022099410fea8028fb5d37fee5672a857 100644 --- a/theodolite-quarkus/config/example-execution-yaml-resource.yaml +++ b/theodolite-quarkus/config/example-execution-yaml-resource.yaml @@ -17,6 +17,7 @@ execution: strategy: "LinearSearch" duration: 300 # in seconds repetitions: 1 + loadGenerationDelay: 30 # in seconds, optional field, default is 0 seconds restrictions: - "LowerBound" configOverrides: [] diff --git a/theodolite-quarkus/config/example-operator-execution.yaml b/theodolite-quarkus/config/example-operator-execution.yaml index 3df1a723dd771453ab1b267335176e4ae74c3ed5..882c38a97c882ac180a2416e0b5046fa6d467efd 100644 --- a/theodolite-quarkus/config/example-operator-execution.yaml +++ b/theodolite-quarkus/config/example-operator-execution.yaml @@ -21,6 +21,7 @@ execution: strategy: "LinearSearch" duration: 300 # in seconds repetitions: 1 + delay: 30 # in seconds restrictions: - "LowerBound" configOverrides: [] diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt index db7999b205c61d94fa17791a5d549a2620601b6b..95af36d1b14eb4d664ffd0d3d463df17fd8fb534 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt @@ -21,6 +21,7 @@ interface Benchmark { fun buildDeployment( load: LoadDimension, res: Resource, - configurationOverrides: List<ConfigurationOverride?> + configurationOverrides: List<ConfigurationOverride?>, + delay: Long ): BenchmarkDeployment } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt index 2d5d15b3389cf723be3a8ceb0fff8b27bd700419..40ab663e179735be61356947df7c37e9edd0a2ea 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt @@ -47,6 +47,7 @@ class BenchmarkExecution : CustomResource(), Namespaced { var duration by Delegates.notNull<Long>() var repetitions by Delegates.notNull<Int>() lateinit var restrictions: List<String> + var loadGenerationDelay = 0L } /** diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index bbcb8a957fb2f04ca678b231a878be0a23d46748..b5316a3df78e7291569ec1d36e561a5445b6f86d 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -22,7 +22,7 @@ private var DEFAULT_NAMESPACE = "default" * - [loadGenResource] resource that generates the load, * - [resourceTypes] types of scaling resources, * - [loadTypes] types of loads that can be scaled for the benchmark, - * - [kafkaConfig] for the [TopicManager], + * - [kafkaConfig] for the [theodolite.k8s.TopicManager], * - [namespace] for the client, * - [path] under which the resource yamls can be found. * @@ -63,38 +63,43 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced { * First loads all required resources and then patches them to the concrete load and resources for the experiment. * Afterwards patches additional configurations(cluster depending) into the resources. * @param load concrete load that will be benchmarked in this experiment. - * @param res concrete resoruce that will be scaled for this experiment. + * @param res concrete resource that will be scaled for this experiment. * @param configurationOverrides * @return a [BenchmarkDeployment] */ override fun buildDeployment( load: LoadDimension, res: Resource, - configurationOverrides: List<ConfigurationOverride?> + configurationOverrides: List<ConfigurationOverride?>, + loadGenerationDelay: Long ): BenchmarkDeployment { logger.info { "Using $namespace as namespace." } logger.info { "Using $path as resource path." } - val resources = loadKubernetesResources(this.appResource + this.loadGenResource) + val appResources = loadKubernetesResources(this.appResource) + val loadGenResources = loadKubernetesResources(this.loadGenResource) + val patcherFactory = PatcherFactory() // patch the load dimension the resources load.getType().forEach { patcherDefinition -> - patcherFactory.createPatcher(patcherDefinition, resources).patch(load.get().toString()) + patcherFactory.createPatcher(patcherDefinition, loadGenResources).patch(load.get().toString()) } res.getType().forEach { patcherDefinition -> - patcherFactory.createPatcher(patcherDefinition, resources).patch(res.get().toString()) + patcherFactory.createPatcher(patcherDefinition, appResources).patch(res.get().toString()) } // Patch the given overrides configurationOverrides.forEach { override -> override?.let { - patcherFactory.createPatcher(it.patcher, resources).patch(override.value) + patcherFactory.createPatcher(it.patcher, appResources + loadGenResources).patch(override.value) } } return KubernetesBenchmarkDeployment( namespace = namespace, - resources = resources.map { r -> r.second }, + appResources = appResources.map { it.second }, + loadGenResources = loadGenResources.map { it.second }, + loadGenerationDelay = loadGenerationDelay, kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer), topics = kafkaConfig.topics, client = DefaultKubernetesClient().inNamespace(namespace) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt index a6bf881d6ded7b0936b400a37b572c77c95bb241..7d1c3f4ba727b8c149e3c5678ad406fa293c8f5b 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt @@ -8,6 +8,7 @@ import org.apache.kafka.clients.admin.NewTopic import theodolite.k8s.K8sManager import theodolite.k8s.TopicManager import theodolite.util.KafkaConfig +import java.time.Duration private val logger = KotlinLogging.logger {} @@ -22,7 +23,9 @@ private val logger = KotlinLogging.logger {} @RegisterForReflection class KubernetesBenchmarkDeployment( val namespace: String, - val resources: List<KubernetesResource>, + val appResources: List<KubernetesResource>, + val loadGenResources: List<KubernetesResource>, + private val loadGenerationDelay: Long, private val kafkaConfig: HashMap<String, Any>, private val topics: List<KafkaConfig.TopicWrapper>, private val client: NamespacedKubernetesClient @@ -39,9 +42,12 @@ class KubernetesBenchmarkDeployment( */ override fun setup() { val kafkaTopics = this.topics.filter { !it.removeOnly } - .map{ NewTopic(it.name, it.numPartitions, it.replicationFactor) } + .map { NewTopic(it.name, it.numPartitions, it.replicationFactor) } kafkaController.createTopics(kafkaTopics) - resources.forEach { kubernetesManager.deploy(it) } + appResources.forEach { kubernetesManager.deploy(it) } + logger.info { "Wait ${this.loadGenerationDelay} seconds before starting the load generator." } + Thread.sleep(Duration.ofSeconds(this.loadGenerationDelay).toMillis()) + loadGenResources.forEach { kubernetesManager.deploy(it) } } /** @@ -51,9 +57,8 @@ class KubernetesBenchmarkDeployment( * - Remove the [KubernetesResource]s. */ override fun teardown() { - resources.forEach { - kubernetesManager.remove(it) - } + loadGenResources.forEach { kubernetesManager.remove(it) } + appResources.forEach { kubernetesManager.remove(it) } kafkaController.removeTopics(this.topics.map { topic -> topic.name }) KafkaLagExporterRemover(client).remove(LAG_EXPORTER_POD_LABEL) logger.info { "Teardown complete. Wait $SLEEP_AFTER_TEARDOWN ms to let everything come down." } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SloChecker.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SloChecker.kt index 94d816d87923f4d8343c6c83dd9747f1cc25ff81..758dcdefcaee79654d8ff65f0f798832aafc1294 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SloChecker.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SloChecker.kt @@ -4,7 +4,7 @@ import theodolite.util.PrometheusResponse import java.time.Instant /** - * A SloChecker can be used to evaluate data from Promehteus. + * A SloChecker can be used to evaluate data from Prometheus. * @constructor Creates an empty SloChecker */ interface SloChecker { diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt index 6d4cd9ea9b5d03dda360b2ddcefcfb9682fd8383..909ae77a95dfef7dfc1dafd7bd0a326a72ef1424 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -24,9 +24,10 @@ abstract class BenchmarkExecutor( val benchmark: Benchmark, val results: Results, val executionDuration: Duration, - configurationOverrides: List<ConfigurationOverride?>, + val configurationOverrides: List<ConfigurationOverride?>, val slo: BenchmarkExecution.Slo, - val executionId: Int + val executionId: Int, + val loadGenerationDelay: Long ) { var run: AtomicBoolean = AtomicBoolean(true) @@ -41,7 +42,7 @@ abstract class BenchmarkExecutor( * given load, false otherwise. */ abstract fun runExperiment(load: LoadDimension, res: Resource): Boolean - + /** * Wait while the benchmark is running and log the number of minutes executed every 1 minute. * diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index cd85c143e3c416f115a4d301629caf4d46b7459f..22db5076bee51e03318aa9ac95e66c2d61d27f28 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -18,13 +18,14 @@ class BenchmarkExecutorImpl( benchmark: Benchmark, results: Results, executionDuration: Duration, - private val configurationOverrides: List<ConfigurationOverride?>, + configurationOverrides: List<ConfigurationOverride?>, slo: BenchmarkExecution.Slo, - executionId: Int -) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo, executionId) { + executionId: Int, + loadGenerationDelay: Long +) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo, executionId, loadGenerationDelay) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { var result = false - val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) + val benchmarkDeployment = benchmark.buildDeployment(load, res, configurationOverrides, loadGenerationDelay) try { benchmarkDeployment.setup() diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/Main.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/Main.kt index 64a40c0b11854d61900ab1fde3797e17427cac15..bf883529967a8b24229fe8256ba0e4edd11b342c 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/Main.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/Main.kt @@ -16,14 +16,14 @@ object Main { val mode = System.getenv("MODE") ?: "standalone" logger.info { "Start Theodolite with mode $mode" } - when(mode) { + when (mode) { "standalone" -> TheodoliteYamlExecutor().start() "yaml-executor" -> TheodoliteYamlExecutor().start() // TODO remove (#209) "operator" -> TheodoliteOperator().start() - else -> { + else -> { logger.error { "MODE $mode not found" } exitProcess(1) } } } -} \ No newline at end of file +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt index a50a38e79b52a72fa68eb9eda70cf1072f80df74..80e1ac2341d9f8608d70b39a0d99f7b88dd7f108 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt @@ -30,7 +30,8 @@ class Shutdown(private val benchmarkExecution: BenchmarkExecution, private val b benchmark.buildDeployment( load = LoadDimension(0, emptyList()), res = Resource(0, emptyList()), - configurationOverrides = benchmarkExecution.configOverrides + configurationOverrides = benchmarkExecution.configOverrides, + loadGenerationDelay = 0L ) deployment.teardown() } catch (e: Exception) { diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index 5fd2eedecdc42b575d69760025a31f45eb71fec0..c297251e30c17e5824c2541365164d9824718073 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -71,7 +71,8 @@ class TheodoliteExecutor( executionDuration = executionDuration, configurationOverrides = config.configOverrides, slo = config.slos[0], - executionId = config.executionId + executionId = config.executionId, + loadGenerationDelay = config.execution.loadGenerationDelay ) return Config( @@ -128,7 +129,7 @@ class TheodoliteExecutor( fun run() { val resultsFolder = getResultFolderString() storeAsFile(this.config, "$resultsFolder${this.config.executionId}-execution-configuration") - storeAsFile(kubernetesBenchmark, "$resultsFolder/${this.config.executionId}-benchmark-configuration") + storeAsFile(kubernetesBenchmark, "$resultsFolder${this.config.executionId}-benchmark-configuration") val config = buildConfig() // execute benchmarks for each load diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/BenchmarkEventHandler.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/BenchmarkEventHandler.kt index 69c53a3792d86d0ad1c3e973b1d53ea5defff8d9..7c8188e3c342cfc1b22fefdd3ca91e7dbce85905 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/BenchmarkEventHandler.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/BenchmarkEventHandler.kt @@ -3,6 +3,7 @@ package theodolite.execution.operator import io.fabric8.kubernetes.client.informers.ResourceEventHandler import mu.KotlinLogging import theodolite.benchmark.KubernetesBenchmark + private val logger = KotlinLogging.logger {} /** @@ -13,7 +14,7 @@ private val logger = KotlinLogging.logger {} * @see TheodoliteController * @see KubernetesBenchmark */ -class BenchmarkEventHandler(private val controller: TheodoliteController): ResourceEventHandler<KubernetesBenchmark> { +class BenchmarkEventHandler(private val controller: TheodoliteController) : ResourceEventHandler<KubernetesBenchmark> { /** * Add a KubernetesBenchmark. @@ -39,7 +40,7 @@ class BenchmarkEventHandler(private val controller: TheodoliteController): Resou override fun onUpdate(oldBenchmark: KubernetesBenchmark, newBenchmark: KubernetesBenchmark) { logger.info { "Update benchmark ${newBenchmark.metadata.name}." } newBenchmark.name = newBenchmark.metadata.name - if (this.controller.isInitialized() && this.controller.executor.getBenchmark().name == oldBenchmark.metadata.name) { + if (this.controller.isInitialized() && this.controller.executor.getBenchmark().name == oldBenchmark.metadata.name) { this.controller.isUpdated.set(true) this.controller.executor.executor.run.compareAndSet(true, false) } else { @@ -57,7 +58,7 @@ class BenchmarkEventHandler(private val controller: TheodoliteController): Resou override fun onDelete(benchmark: KubernetesBenchmark, b: Boolean) { logger.info { "Delete benchmark ${benchmark.metadata.name}." } this.controller.benchmarks.remove(benchmark.metadata.name) - if ( this.controller.isInitialized() && this.controller.executor.getBenchmark().name == benchmark.metadata.name) { + if (this.controller.isInitialized() && this.controller.executor.getBenchmark().name == benchmark.metadata.name) { this.controller.isUpdated.set(true) this.controller.executor.executor.run.compareAndSet(true, false) logger.info { "Current benchmark stopped." } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt index 971d3428ffde9cf776711bbd68bae68f66597823..ea62b7b895fce772a1f89019ea4aaac0f3957dc1 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt @@ -3,7 +3,6 @@ package theodolite.execution.operator import io.fabric8.kubernetes.client.informers.ResourceEventHandler import mu.KotlinLogging import theodolite.benchmark.BenchmarkExecution -import java.lang.NullPointerException private val logger = KotlinLogging.logger {} @@ -15,7 +14,7 @@ private val logger = KotlinLogging.logger {} * @see TheodoliteController * @see BenchmarkExecution */ -class ExecutionHandler(private val controller: TheodoliteController): ResourceEventHandler<BenchmarkExecution> { +class ExecutionHandler(private val controller: TheodoliteController) : ResourceEventHandler<BenchmarkExecution> { /** * Add an execution to the end of the queue of the TheodoliteController. @@ -29,17 +28,19 @@ class ExecutionHandler(private val controller: TheodoliteController): ResourceEv } /** - * Update an execution. If this execution is running at the time this function is called, it is stopped and added to - * the beginning of the queue of the TheodoliteController. Otherwise, it is just added to the beginning of the queue. + * Updates an execution. If this execution is running at the time this function is called, it is stopped and + * added to the beginning of the queue of the TheodoliteController. + * Otherwise, it is just added to the beginning of the queue. * - * @param execution the execution to update + * @param oldExecution the old execution + * @param newExecution the new execution */ override fun onUpdate(oldExecution: BenchmarkExecution, newExecution: BenchmarkExecution) { logger.info { "Add updated execution to queue." } newExecution.name = newExecution.metadata.name try { this.controller.executionsQueue.removeIf { e -> e.name == newExecution.metadata.name } - } catch(e: NullPointerException) { + } catch (e: NullPointerException) { logger.warn { "No execution found for deletion" } } this.controller.executionsQueue.addFirst(newExecution) @@ -58,7 +59,7 @@ class ExecutionHandler(private val controller: TheodoliteController): ResourceEv try { this.controller.executionsQueue.removeIf { e -> e.name == execution.metadata.name } logger.info { "Delete execution ${execution.metadata.name} from queue." } - } catch(e: NullPointerException) { + } catch (e: NullPointerException) { logger.warn { "No execution found for deletion" } } if (this.controller.isInitialized() && this.controller.executor.getExecution().name == execution.metadata.name) { diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt index 532185841a7a8ee000722c1dc513219177f00cae..0e889e0393e17fd65f4d8f12c5b95a3dbed7f593 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt @@ -2,7 +2,6 @@ package theodolite.execution.operator import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext -import khttp.patch import mu.KotlinLogging import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.KubernetesBenchmark diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sContextFactory.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sContextFactory.kt index c0e07610171b40c6704602ffa86ec15accb14c19..7eb209bfbab02bb94d34c985aa308173e509d4e4 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sContextFactory.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sContextFactory.kt @@ -21,12 +21,12 @@ class K8sContextFactory { * * @see CustomResourceDefinitionContext */ - fun create(api: String, scope: String, group: String, plural: String ) : CustomResourceDefinitionContext { - return CustomResourceDefinitionContext.Builder() + fun create(api: String, scope: String, group: String, plural: String): CustomResourceDefinitionContext { + return CustomResourceDefinitionContext.Builder() .withVersion(api) .withScope(scope) .withGroup(group) .withPlural(plural) .build() } -} \ No newline at end of file +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt index 324b02b74b2c53eb1292667f037f3fdbcc114b73..fd5ec3b2e744b5e096187626a2fd756f71f87e67 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt @@ -32,7 +32,14 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @return CustomResource from fabric8 */ private fun loadServiceMonitor(path: String): ServiceMonitorWrapper { - return loadGenericResource(path) { x: String -> ServiceMonitorWrapper(YamlParser().parse(path, HashMap<String, String>()::class.java)!!) } + return loadGenericResource(path) { x: String -> + ServiceMonitorWrapper( + YamlParser().parse( + path, + HashMap<String, String>()::class.java + )!! + ) + } } /** diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/TopicManager.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/TopicManager.kt index ef5715e248ae6c64df0035a94d57fea12202787e..3bbae82d77dc5b01a5827c7ee713bf2566be1bab 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/TopicManager.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/TopicManager.kt @@ -45,7 +45,7 @@ class TopicManager(private val kafkaConfig: Map<String, Any>) { "Topics creation finished with result: ${ result .values() - .map { it -> it.key + ": " + it.value.isDone } + .map { it.key + ": " + it.value.isDone } .joinToString(separator = ",") } " } @@ -59,16 +59,17 @@ class TopicManager(private val kafkaConfig: Map<String, Any>) { fun removeTopics(topics: List<String>) { val kafkaAdmin: AdminClient = AdminClient.create(this.kafkaConfig) val currentTopics = kafkaAdmin.listTopics().names().get() - delete(currentTopics.filter{ matchRegex(it, topics) }, kafkaAdmin) + delete(currentTopics.filter { matchRegex(it, topics) }, kafkaAdmin) kafkaAdmin.close() } /** - * This function checks whether one string in `topics` can be used as prefix of a regular expression to create the string `existingTopic` + * This function checks whether one string in `topics` can be used as prefix of a regular expression + * to create the string `existingTopic`. * - * @param existingTopic string for which should be checked if it could be created - * @param topics list of string which are used as possible prefixes to create `existingTopic` - * @return true, `existingTopics` matches a created regex, else false + * @param existingTopic string for which should be checked if it could be created. + * @param topics list of string which are used as possible prefixes to create `existingTopic`. + * @return true, `existingTopics` matches a created regex, else false. */ private fun matchRegex(existingTopic: String, topics: List<String>): Boolean { for (t in topics) { @@ -89,7 +90,7 @@ class TopicManager(private val kafkaConfig: Map<String, Any>) { result.all().get() // wait for the future to be completed logger.info { "Topics deletion finished with result: ${ - result.values().map { it -> it.key + ": " + it.value.isDone } + result.values().map { it.key + ": " + it.value.isDone } .joinToString(separator = ",") }" } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ImagePatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ImagePatcher.kt index e5e5f6cb67641c71ad0fd31375752cbb03fa62db..b29d8d9925311aa25b7336dcd6805783ca62c3e7 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ImagePatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ImagePatcher.kt @@ -12,7 +12,7 @@ import io.fabric8.kubernetes.api.model.apps.StatefulSet */ class ImagePatcher(private val k8sResource: KubernetesResource, private val container: String) : AbstractPatcher(k8sResource, container) { - + override fun <String> patch(imagePath: String) { if (k8sResource is Deployment) { k8sResource.spec.template.spec.containers.filter { it.name == container }.forEach { diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt index 7cf56f8452949e387a186aa8f8c962e1ee1aad15..d7136740a7e17f956eed16bc6e3fcd4954ab91b8 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt @@ -7,12 +7,13 @@ import kotlin.math.pow private const val NUM_SENSORS = 4.0 private const val LOAD_GEN_MAX_RECORDS = 150000 -class NumNestedGroupsLoadGeneratorReplicaPatcher(private val k8sResource: KubernetesResource) : AbstractPatcher(k8sResource) { +class NumNestedGroupsLoadGeneratorReplicaPatcher(private val k8sResource: KubernetesResource) : + AbstractPatcher(k8sResource) { override fun <String> patch(value: String) { if (k8sResource is Deployment) { if (value is kotlin.String) { val approxNumSensors = NUM_SENSORS.pow(Integer.parseInt(value).toDouble()) - val loadGenInstances = (approxNumSensors + LOAD_GEN_MAX_RECORDS -1) / LOAD_GEN_MAX_RECORDS + val loadGenInstances = (approxNumSensors + LOAD_GEN_MAX_RECORDS - 1) / LOAD_GEN_MAX_RECORDS this.k8sResource.spec.replicas = loadGenInstances.toInt() } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt index 6f2ebcb8b1eb37801c7f6bb2f28c251a07ae44e8..d29280a648cd4c912b8e2717b51c4f9c3f8a2271 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt @@ -5,7 +5,8 @@ import io.fabric8.kubernetes.api.model.apps.Deployment private const val LOAD_GEN_MAX_RECORDS = 150000 -class NumSensorsLoadGeneratorReplicaPatcher(private val k8sResource: KubernetesResource) : AbstractPatcher(k8sResource) { +class NumSensorsLoadGeneratorReplicaPatcher(private val k8sResource: KubernetesResource) : + AbstractPatcher(k8sResource) { override fun <String> patch(value: String) { if (k8sResource is Deployment) { if (value is kotlin.String) { diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt index eab82effbc084e91ba57c1bea7103b2a3239c922..30f82e804f23b770457ec968f25ba7c00d72aefd 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt @@ -6,7 +6,6 @@ import io.fabric8.kubernetes.api.model.Quantity import io.fabric8.kubernetes.api.model.ResourceRequirements import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.StatefulSet -import java.lang.IllegalArgumentException /** * The Resource limit [Patcher] set resource limits for deployments and statefulSets. diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt index f4ef38edebab67022066394e149716ab9ffbce00..24b2a6d40525f16448b77c50fba8aba0969d075a 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt @@ -6,7 +6,6 @@ import io.fabric8.kubernetes.api.model.Quantity import io.fabric8.kubernetes.api.model.ResourceRequirements import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.StatefulSet -import java.lang.IllegalArgumentException /** * The Resource request [Patcher] set resource limits for deployments and statefulSets. diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt index 589bceff78158a422d923169bd35a1e11e2f4caa..348f0c50090a34c91221d3e099c3532375a578da 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt @@ -4,14 +4,14 @@ import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.api.model.apps.Deployment /** - * The Scheduler name [Patcher] make it possible to set the scheduler which should be used to deploy the given deployment. - * + * The Scheduler name [Patcher] make it possible to set the scheduler which should + * be used to deploy the given deployment. * @param k8sResource Kubernetes resource to be patched. */ -class SchedulerNamePatcher(private val k8sResource: KubernetesResource): Patcher { +class SchedulerNamePatcher(private val k8sResource: KubernetesResource) : Patcher { override fun <String> patch(value: String) { if (k8sResource is Deployment) { k8sResource.spec.template.spec.schedulerName = value as kotlin.String } } -} \ No newline at end of file +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/CompositeStrategy.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/CompositeStrategy.kt index 6ae06d70c9effe0a0a4bbd9abffa665fb08636c9..41cc5c325163ade54469398e815fdb8d95c6e6cd 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/CompositeStrategy.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/CompositeStrategy.kt @@ -10,7 +10,7 @@ import theodolite.util.Resource * Composite strategy that combines a SearchStrategy and a set of RestrictionStrategy. * * @param searchStrategy the [SearchStrategy] that is executed as part of this [CompositeStrategy]. - * @param restrictionStrategies the set of [RestrictionStrategy] that are connected conjuntively to restrict the [Resource] + * @param restrictionStrategies the set of [RestrictionStrategy] that are connected conjunctive to restrict the [Resource] * @param benchmarkExecutor Benchmark executor which runs the individual benchmarks. */ @RegisterForReflection diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/FullSearch.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/FullSearch.kt index 20290a9477f16c7d479d32ec4435da0c1bb26514..cb0dd2d8ab528e42e8290f59f26c8b9b32f384c7 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/FullSearch.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/searchstrategy/FullSearch.kt @@ -18,7 +18,7 @@ private val logger = KotlinLogging.logger {} class FullSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchmarkExecutor) { override fun findSuitableResource(load: LoadDimension, resources: List<Resource>): Resource? { - var minimalSuitableResources: Resource? = null; + var minimalSuitableResources: Resource? = null for (res in resources) { logger.info { "Running experiment with load '${load.get()}' and resources '${res.get()}'" } val result = this.benchmarkExecutor.runExperiment(load, res) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt index f304d8cd06969d4650329b9b9f410a56985a2002..398ff90bed8f48683321e2375458b3a065c39463 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt @@ -2,7 +2,7 @@ package theodolite.util import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.quarkus.runtime.annotations.RegisterForReflection -import org.apache.kafka.clients.admin.NewTopic +import theodolite.util.KafkaConfig.TopicWrapper import kotlin.properties.Delegates import kotlin.reflect.KProperty @@ -60,6 +60,7 @@ class DelegatesFalse { operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { return state } + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) { state = value } diff --git a/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml b/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml index ef625dfe6ec78c2cc0ed099dfee0f767d57263bb..7f76b1bca0db77df08861e0611487642e19bbc1a 100644 --- a/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml +++ b/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml @@ -22,6 +22,7 @@ execution: strategy: "LinearSearch" duration: 60 repetitions: 1 + delay: 30 # in seconds restrictions: - "LowerBound" configOverrides: diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt index 7802529bfda309131cafc0ab3f39fda43285c32f..726d4490b053b5c56f0a0387f54ad557d4c1865c 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt @@ -31,7 +31,7 @@ class CompositeStrategyTest { val results = Results() val benchmark = TestBenchmark() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0) + val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0, 0) val linearSearch = LinearSearch(benchmarkExecutor) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = @@ -65,7 +65,7 @@ class CompositeStrategyTest { val benchmark = TestBenchmark() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val benchmarkExecutorImpl = - TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0) + TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0, 0) val binarySearch = BinarySearch(benchmarkExecutorImpl) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = @@ -98,7 +98,7 @@ class CompositeStrategyTest { val results = Results() val benchmark = TestBenchmark() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0) + val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0, 0) val binarySearch = BinarySearch(benchmarkExecutor) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt index 6f476278d08eacfc9857c1e5431636e5a219f26c..71e3cbcc78208cc4227e369d59d841e39adb87ed 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt @@ -11,7 +11,8 @@ class TestBenchmark : Benchmark { override fun buildDeployment( load: LoadDimension, res: Resource, - configurationOverrides: List<ConfigurationOverride?> + configurationOverrides: List<ConfigurationOverride?>, + loadGenerationDelay: Long ): BenchmarkDeployment { return TestBenchmarkDeployment() } diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt index 2bafcb76dfc3463d9aa350b88c9f73d52cea6629..294727d6a252a29e312ff532937e7fdf9f079ac7 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt @@ -13,7 +13,8 @@ class TestBenchmarkExecutorImpl( benchmark: Benchmark, results: Results, slo: BenchmarkExecution.Slo, - executionId: Int + executionId: Int, + loadGenerationDelay: Long ) : BenchmarkExecutor( benchmark, @@ -21,7 +22,8 @@ class TestBenchmarkExecutorImpl( executionDuration = Duration.ofSeconds(1), configurationOverrides = emptyList(), slo = slo, - executionId = executionId + executionId = executionId, + loadGenerationDelay = loadGenerationDelay ) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/strategies/restriction/LowerBoundRestrictionTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/strategies/restriction/LowerBoundRestrictionTest.kt index b6b9eaecd9fc35b25b9447611835c3d8469cea0e..b368647e314a4d803b444268c8218aefbee00ad4 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/strategies/restriction/LowerBoundRestrictionTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/strategies/restriction/LowerBoundRestrictionTest.kt @@ -1,6 +1,7 @@ package theodolite.strategies.restriction -import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import theodolite.util.LoadDimension @@ -41,7 +42,7 @@ internal class LowerBoundRestrictionTest { val restriction = strategy.apply(load, resources) assertEquals(2, restriction.size) - assertEquals(resources.subList(1,3), restriction) + assertEquals(resources.subList(1, 3), restriction) } @Test @@ -111,6 +112,7 @@ internal class LowerBoundRestrictionTest { buildLoadDimension(load), buildResourcesDimension(resources) ), - successful) + successful + ) } -} \ No newline at end of file +}