diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt index d57a28e8bbcf4dc101e4814ecaa0d52fe28c08a9..05d021b1bcfb77fa8ffeb0522510d49e39ef501c 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt @@ -1,8 +1,5 @@ package theodolite.benchmark -import io.fabric8.kubernetes.api.model.KubernetesResource -import io.fabric8.kubernetes.api.model.Namespaced -import io.fabric8.kubernetes.client.CustomResource import io.quarkus.runtime.annotations.RegisterForReflection import theodolite.util.ConfigurationOverride import theodolite.util.LoadDimension diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index 753fd0805fcfa3fbf7fe5c26e8591e881195323a..16d3b371286c113d47f13e2646f172decc939336 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -32,7 +32,7 @@ private var DEFAULT_THEODOLITE_APP_RESOURCES = "./config" */ @JsonDeserialize @RegisterForReflection -class KubernetesBenchmark: KubernetesResource, Benchmark{ +class KubernetesBenchmark : KubernetesResource, Benchmark { lateinit var name: String lateinit var appResource: List<String> lateinit var loadGenResource: List<String> diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt index e086f7f885c62c55747f9de798bc5e5bf77573d5..423ac92c654ff55057796d9642c2cb408bc62fe5 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt @@ -33,8 +33,8 @@ class KubernetesBenchmarkDeployment( ) : BenchmarkDeployment { private val kafkaController = TopicManager(this.kafkaConfig) private val kubernetesManager = K8sManager(client) - private val LAG_EXPORTER_POD_LABEL_NAME= "app.kubernetes.io/name" - private val LAG_EXPORTER_POD_LABEL_VALUE= "kafka-lag-exporter" + private val LAG_EXPORTER_POD_LABEL_NAME = "app.kubernetes.io/name" + private val LAG_EXPORTER_POD_LABEL_VALUE = "kafka-lag-exporter" /** * Setup a [KubernetesBenchmark] using the [TopicManager] and the [K8sManager]: @@ -62,7 +62,7 @@ class KubernetesBenchmarkDeployment( appResources.forEach { kubernetesManager.remove(it) } kafkaController.removeTopics(this.topics.map { topic -> topic.name }) ResourceByLabelHandler(client).removePods( - labelName = LAG_EXPORTER_POD_LABEL_NAME, + labelName = LAG_EXPORTER_POD_LABEL_NAME, labelValue = LAG_EXPORTER_POD_LABEL_VALUE ) logger.info { "Teardown complete. Wait $afterTeardownDelay ms to let everything come down." } diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt b/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt index 050094b88d5ddc803d831da9030fb81109859246..9037b994d359dbfa67e099d311ca63707dad7c26 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt +++ b/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt @@ -46,16 +46,20 @@ class AnalysisExecutor( val fileURL = "${resultsFolder}exp${executionId}_${load.get()}_${res.get()}_${slo.sloType.toSlug()}" val prometheusData = executionIntervals - .map { interval -> fetcher.fetchMetric( + .map { interval -> + fetcher.fetchMetric( start = interval.first, end = interval.second, - query = RECORD_LAG_QUERY) } + query = RECORD_LAG_QUERY + ) + } - prometheusData.forEach{ data -> + prometheusData.forEach { data -> ioHandler.writeToCSVFile( fileURL = "${fileURL}_${repetitionCounter++}", data = data.getResultAsList(), - columns = listOf("group", "timestamp", "value")) + columns = listOf("group", "timestamp", "value") + ) } val sloChecker = SloCheckerFactory().create( diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt b/theodolite/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt index 797798eff38699350e45f481f599644e7c01f2d1..448a2a05f8dbeb1aef153895360bfb40e7275224 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt +++ b/theodolite/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt @@ -36,10 +36,13 @@ class ExternalSloChecker( */ override fun evaluate(fetchedData: List<PrometheusResponse>): Boolean { var counter = 0 - val data = Gson().toJson(mapOf( - "total_lags" to fetchedData.map { it.data?.result}, - "threshold" to threshold, - "warmup" to warmup)) + val data = Gson().toJson( + mapOf( + "total_lags" to fetchedData.map { it.data?.result }, + "threshold" to threshold, + "warmup" to warmup + ) + ) while (counter < RETRIES) { val result = post(externalSlopeURL, data = data, timeout = TIMEOUT) diff --git a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index 4908cfa31b855e7968fda2a62df463ab9e1a3efc..c54d1878d4957a0b8ec6a8fdfb18ec6342d7bfc1 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -25,7 +25,17 @@ class BenchmarkExecutorImpl( executionId: Int, loadGenerationDelay: Long, afterTeardownDelay: Long -) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo, repetitions, executionId, loadGenerationDelay, afterTeardownDelay) { +) : BenchmarkExecutor( + benchmark, + results, + executionDuration, + configurationOverrides, + slo, + repetitions, + executionId, + loadGenerationDelay, + afterTeardownDelay +) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { var result = false val executionIntervals: MutableList<Pair<Instant, Instant>> = ArrayList() @@ -33,7 +43,7 @@ class BenchmarkExecutorImpl( for (i in 1.rangeTo(repetitions)) { logger.info { "Run repetition $i/$repetitions" } if (this.run.get()) { - executionIntervals.add(runSingleExperiment(load,res)) + executionIntervals.add(runSingleExperiment(load, res)) } else { break } @@ -43,18 +53,25 @@ class BenchmarkExecutorImpl( * Analyse the experiment, if [run] is true, otherwise the experiment was canceled by the user. */ if (this.run.get()) { - result =AnalysisExecutor(slo = slo, executionId = executionId) - .analyze( - load = load, - res = res, - executionIntervals = executionIntervals) + result = AnalysisExecutor(slo = slo, executionId = executionId) + .analyze( + load = load, + res = res, + executionIntervals = executionIntervals + ) this.results.setResult(Pair(load, res), result) } return result } private fun runSingleExperiment(load: LoadDimension, res: Resource): Pair<Instant, Instant> { - val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides, this.loadGenerationDelay, this.afterTeardownDelay) + val benchmarkDeployment = benchmark.buildDeployment( + load, + res, + this.configurationOverrides, + this.loadGenerationDelay, + this.afterTeardownDelay + ) val from = Instant.now() // TODO(restructure try catch in order to throw exceptions if there are significant problems by running a experiment) try { @@ -72,6 +89,6 @@ class BenchmarkExecutorImpl( logger.warn { "Error while tearing down the benchmark deployment." } logger.debug { "Teardown failed, caused by: $e" } } - return Pair(from,to) + return Pair(from, to) } } diff --git a/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt b/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt index 8317ba980eb36eed46ee5954d1e41fb20e9caf37..dfef29f6507d79955f8834fb9b6716ae3866699d 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt @@ -24,23 +24,27 @@ class Shutdown(private val benchmarkExecution: BenchmarkExecution, private val b override fun run() { // Build Configuration to teardown try { - logger.info { "Received shutdown signal -> Shutting down" } - val deployment = - benchmark.buildDeployment( - load = LoadDimension(0, emptyList()), - res = Resource(0, emptyList()), - configurationOverrides = benchmarkExecution.configOverrides, - loadGenerationDelay = 0L, - afterTeardownDelay = 5L - ) + logger.info { "Received shutdown signal -> Shutting down" } + val deployment = + benchmark.buildDeployment( + load = LoadDimension(0, emptyList()), + res = Resource(0, emptyList()), + configurationOverrides = benchmarkExecution.configOverrides, + loadGenerationDelay = 0L, + afterTeardownDelay = 5L + ) deployment.teardown() } catch (e: Exception) { // TODO(throw exception in order to make it possible to mark an experiment as unsuccessfully) - logger.warn { "Could not delete all specified resources from Kubernetes. " + - "This could be the case, if not all resources are deployed and running." } + logger.warn { + "Could not delete all specified resources from Kubernetes. " + + "This could be the case, if not all resources are deployed and running." + } } - logger.info { "Teardown everything deployed. " + - "\n Teardown completed" } + logger.info { + "Teardown everything deployed. " + + "\n Teardown completed" + } } } diff --git a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index 97d658743580ad78c989b9f61da74bf4e3292e45..f5054dc2d8c3525562118b559ab8987215dc4ea1 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -70,14 +70,18 @@ class TheodoliteExecutor( if (config.load.loadValues != config.load.loadValues.sorted()) { config.load.loadValues = config.load.loadValues.sorted() - logger.info { "Load values are not sorted correctly, Theodolite sorts them in ascending order." + - "New order is: ${config.load.loadValues}" } + logger.info { + "Load values are not sorted correctly, Theodolite sorts them in ascending order." + + "New order is: ${config.load.loadValues}" + } } if (config.resources.resourceValues != config.resources.resourceValues.sorted()) { config.resources.resourceValues = config.resources.resourceValues.sorted() - logger.info { "Load values are not sorted correctly, Theodolite sorts them in ascending order." + - "New order is: ${config.resources.resourceValues}" } + logger.info { + "Load values are not sorted correctly, Theodolite sorts them in ascending order." + + "New order is: ${config.resources.resourceValues}" + } } return Config( @@ -110,9 +114,12 @@ class TheodoliteExecutor( fun run() { val ioHandler = IOHandler() val resultsFolder = ioHandler.getResultFolderURL() - this.config.executionId = getAndIncrementExecutionID(resultsFolder+"expID.txt") + this.config.executionId = getAndIncrementExecutionID(resultsFolder + "expID.txt") ioHandler.writeToJSONFile(this.config, "$resultsFolder${this.config.executionId}-execution-configuration") - ioHandler.writeToJSONFile(kubernetesBenchmark, "$resultsFolder${this.config.executionId}-benchmark-configuration") + ioHandler.writeToJSONFile( + kubernetesBenchmark, + "$resultsFolder${this.config.executionId}-benchmark-configuration" + ) val config = buildConfig() // execute benchmarks for each load @@ -121,17 +128,20 @@ class TheodoliteExecutor( config.compositeStrategy.findSuitableResource(load, config.resources) } } - ioHandler.writeToJSONFile(config.compositeStrategy.benchmarkExecutor.results, "$resultsFolder${this.config.executionId}-result") + ioHandler.writeToJSONFile( + config.compositeStrategy.benchmarkExecutor.results, + "$resultsFolder${this.config.executionId}-result" + ) } - private fun getAndIncrementExecutionID(fileURL: String): Int { - val ioHandler = IOHandler() - var executionID = 0 - if (File(fileURL).exists()) { - executionID = ioHandler.readFileAsString(fileURL).toInt() + 1 - } - ioHandler.writeStringToTextFile(fileURL, (executionID).toString()) - return executionID + private fun getAndIncrementExecutionID(fileURL: String): Int { + val ioHandler = IOHandler() + var executionID = 0 + if (File(fileURL).exists()) { + executionID = ioHandler.readFileAsString(fileURL).toInt() + 1 + } + ioHandler.writeStringToTextFile(fileURL, (executionID).toString()) + return executionID } } diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/AbstractStateHandler.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/AbstractStateHandler.kt index 5ff822e794445eb070f9755590485ab9754fe716..9d7436526f18081c7130870956d8a5eea5fc8997 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/AbstractStateHandler.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/AbstractStateHandler.kt @@ -9,40 +9,45 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation import io.fabric8.kubernetes.client.dsl.Resource import java.lang.Thread.sleep -abstract class AbstractStateHandler<T,L,D>( +abstract class AbstractStateHandler<T, L, D>( private val client: NamespacedKubernetesClient, private val crd: Class<T>, private val crdList: Class<L> - ): StateHandler<T> where T : CustomResource<*, *>?, T: HasMetadata, T: Namespaced, L: KubernetesResourceList<T> { +) : StateHandler<T> where T : CustomResource<*, *>?, T : HasMetadata, T : Namespaced, L : KubernetesResourceList<T> { - private val crdClient: MixedOperation<T, L,Resource<T>> = + private val crdClient: MixedOperation<T, L, Resource<T>> = this.client.customResources(this.crd, this.crdList) @Synchronized override fun setState(resourceName: String, f: (T) -> T?) { this.crdClient .list().items - .filter {it.metadata.name == resourceName } + .filter { it.metadata.name == resourceName } .map { customResource -> f(customResource) } .forEach { this.crdClient.updateStatus(it) } - } + } @Synchronized override fun getState(resourceName: String, f: (T) -> String?): String? { return this.crdClient .list().items - .filter {it.metadata.name == resourceName } + .filter { it.metadata.name == resourceName } .map { customResource -> f(customResource) } .firstOrNull() } @Synchronized - override fun blockUntilStateIsSet(resourceName: String, desiredStatusString: String, f: (T) -> String?, maxTries: Int): Boolean { + override fun blockUntilStateIsSet( + resourceName: String, + desiredStatusString: String, + f: (T) -> String?, + maxTries: Int + ): Boolean { for (i in 0.rangeTo(maxTries)) { val currentStatus = getState(resourceName, f) - if(currentStatus == desiredStatusString) { - return true - } + if (currentStatus == desiredStatusString) { + return true + } sleep(50) } return false diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt index b4259003e96855fe57e5117978064447995d4f83..c3a2b7b25ed71e797c45d8b497bad6cad15e21e8 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt @@ -16,7 +16,7 @@ class ClusterSetup( private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>, private val client: NamespacedKubernetesClient - ) { +) { private val serviceMonitorContext = K8sContextFactory().create( api = "v1", scope = "Namespaced", @@ -24,7 +24,7 @@ class ClusterSetup( plural = "servicemonitors" ) - fun clearClusterState(){ + fun clearClusterState() { stopRunningExecution() clearByLabel() } @@ -41,7 +41,7 @@ class ClusterSetup( .list() .items .asSequence() - .filter { it.status.executionState == States.RUNNING.value } + .filter { it.status.executionState == States.RUNNING.value } .forEach { execution -> val benchmark = benchmarkCRDClient .inNamespace(client.namespace) @@ -56,13 +56,14 @@ class ClusterSetup( } else { logger.error { "Execution with state ${States.RUNNING.value} was found, but no corresponding benchmark. " + - "Could not initialize cluster." } + "Could not initialize cluster." + } throw IllegalStateException("Cluster state is invalid, required Benchmark for running execution not found.") } } - } + } - private fun clearByLabel() { + private fun clearByLabel() { val resourceRemover = ResourceByLabelHandler(client = client) resourceRemover.removeServices( labelName = "app.kubernetes.io/created-by", diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt index 653366010725a8db816c92aece7bb572b659426b..62c1ddd4eecb41aecde7000eb048455c95cab949 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt @@ -36,10 +36,10 @@ class ExecutionHandler( States.NO_STATE -> this.stateHandler.setExecutionState(execution.spec.name, States.PENDING) States.RUNNING -> { this.stateHandler.setExecutionState(execution.spec.name, States.RESTART) - if(this.controller.isExecutionRunning(execution.spec.name)){ - this.controller.stop(restart=true) - } + if (this.controller.isExecutionRunning(execution.spec.name)) { + this.controller.stop(restart = true) } + } } } @@ -55,20 +55,21 @@ class ExecutionHandler( override fun onUpdate(oldExecution: ExecutionCRD, newExecution: ExecutionCRD) { newExecution.spec.name = newExecution.metadata.name oldExecution.spec.name = oldExecution.metadata.name - if(gson.toJson(oldExecution.spec) != gson.toJson(newExecution.spec)) { + if (gson.toJson(oldExecution.spec) != gson.toJson(newExecution.spec)) { logger.info { "Receive update event for execution ${oldExecution.metadata.name}" } - when(this.stateHandler.getExecutionState(newExecution.metadata.name)) { + when (this.stateHandler.getExecutionState(newExecution.metadata.name)) { States.RUNNING -> { - this.stateHandler.setExecutionState(newExecution.spec.name, States.RESTART) - if (this.controller.isExecutionRunning(newExecution.spec.name)){ - this.controller.stop(restart=true) - } - } - States.RESTART -> {} // should this set to pending? - else -> this.stateHandler.setExecutionState(newExecution.spec.name, States.PENDING) + this.stateHandler.setExecutionState(newExecution.spec.name, States.RESTART) + if (this.controller.isExecutionRunning(newExecution.spec.name)) { + this.controller.stop(restart = true) + } } + States.RESTART -> { + } // should this set to pending? + else -> this.stateHandler.setExecutionState(newExecution.spec.name, States.PENDING) } } + } /** * Delete an execution from the queue of the TheodoliteController. @@ -78,8 +79,9 @@ class ExecutionHandler( @Synchronized override fun onDelete(execution: ExecutionCRD, b: Boolean) { logger.info { "Delete execution ${execution.metadata.name}" } - if(execution.status.executionState == States.RUNNING.value - && this.controller.isExecutionRunning(execution.spec.name)) { + if (execution.status.executionState == States.RUNNING.value + && this.controller.isExecutionRunning(execution.spec.name) + ) { this.controller.stop() } } diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionStateHandler.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionStateHandler.kt index 425127eeab097a06e9543594db7e1182f8dd946e..bcc86c8f2a9b233fa9a1972a866936e14688ecf8 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionStateHandler.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionStateHandler.kt @@ -10,8 +10,8 @@ import java.time.Duration import java.time.Instant import java.util.concurrent.atomic.AtomicBoolean -class ExecutionStateHandler(val client: NamespacedKubernetesClient): - AbstractStateHandler<ExecutionCRD, BenchmarkExecutionList, ExecutionStatus >( +class ExecutionStateHandler(val client: NamespacedKubernetesClient) : + AbstractStateHandler<ExecutionCRD, BenchmarkExecutionList, ExecutionStatus>( client = client, crd = ExecutionCRD::class.java, crdList = BenchmarkExecutionList::class.java @@ -24,13 +24,13 @@ class ExecutionStateHandler(val client: NamespacedKubernetesClient): private fun getDurationLambda() = { cr: ExecutionCRD -> cr.status.executionDuration } fun setExecutionState(resourceName: String, status: States): Boolean { - setState(resourceName) {cr -> cr.status.executionState = status.value; cr} + setState(resourceName) { cr -> cr.status.executionState = status.value; cr } return blockUntilStateIsSet(resourceName, status.value, getExecutionLambda()) } - fun getExecutionState(resourceName: String) : States { + fun getExecutionState(resourceName: String): States { val status = this.getState(resourceName, getExecutionLambda()) - return if(status.isNullOrBlank()){ + return if (status.isNullOrBlank()) { States.NO_STATE } else { States.values().first { it.value == status } diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/LeaderElector.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/LeaderElector.kt index 98aea0444987126840d2c3ebbe713284cfb2f8c0..1ce94c2fdd1ce13d50a21e01b9d4692c87d0da6f 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/LeaderElector.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/LeaderElector.kt @@ -13,15 +13,15 @@ import kotlin.reflect.KFunction0 private val logger = KotlinLogging.logger {} class LeaderElector( - val client: NamespacedKubernetesClient, + val client: NamespacedKubernetesClient, val name: String - ) { +) { // TODO(what is the name of the lock? .withName() or LeaseLock(..,name..) ?) fun getLeadership(leader: KFunction0<Unit>) { val lockIdentity: String = UUID.randomUUID().toString() - DefaultKubernetesClient().use { kc -> - kc.leaderElector() + DefaultKubernetesClient().use { kc -> + kc.leaderElector() .withConfig( LeaderElectionConfigBuilder() .withName("Theodolite") @@ -30,10 +30,10 @@ class LeaderElector( .withRenewDeadline(Duration.ofSeconds(10L)) .withRetryPeriod(Duration.ofSeconds(2L)) .withLeaderCallbacks(LeaderCallbacks( - { Thread{leader()}.start() }, + { Thread { leader() }.start() }, { logger.info { "STOPPED LEADERSHIP" } } ) { newLeader: String? -> - logger.info { "New leader elected $newLeader" } + logger.info { "New leader elected $newLeader" } }) .build() ) diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/StateHandler.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/StateHandler.kt index cefcf2ec97986375205205fd95ddcd2ff7eacf5a..e2cfaa354443cdc940abf92ef2c7474d028daecf 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/StateHandler.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/StateHandler.kt @@ -9,6 +9,7 @@ interface StateHandler<T> { resourceName: String, desiredStatusString: String, f: (T) -> String?, - maxTries: Int = MAX_TRIES): Boolean + maxTries: Int = MAX_TRIES + ): Boolean } \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt index 751ceb9a94220e7cdda86b81b3431a970b69858d..e5fbf578bc46af6bca5b4f545cdbc62ec58e21fa 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt @@ -27,6 +27,7 @@ class TheodoliteController( private val executionStateHandler: ExecutionStateHandler ) { lateinit var executor: TheodoliteExecutor + /** * * Runs the TheodoliteController forever. @@ -62,7 +63,8 @@ class TheodoliteController( private fun runExecution(execution: BenchmarkExecution, benchmark: KubernetesBenchmark) { val modifier = ConfigOverrideModifier( execution = execution, - resources = benchmark.appResource + benchmark.loadGenResource) + resources = benchmark.appResource + benchmark.loadGenResource + ) modifier.setAdditionalLabels( labelValue = execution.name, labelName = "deployed-for-execution" @@ -114,7 +116,7 @@ class TheodoliteController( .list() .items .map { - it.spec.name = it.metadata.name; + it.spec.name = it.metadata.name it.spec } } diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt index 7896e5908ac96236fda1ab7a4020d09645aedc56..2aaba77c03884d94c4d5745db270e84324482878 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt @@ -75,7 +75,10 @@ class TheodoliteOperator { } } - fun getExecutionEventHandler(controller: TheodoliteController, client: NamespacedKubernetesClient): SharedInformerFactory { + fun getExecutionEventHandler( + controller: TheodoliteController, + client: NamespacedKubernetesClient + ): SharedInformerFactory { val factory = client.informers() .inNamespace(client.namespace) diff --git a/theodolite/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt b/theodolite/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt index f262201626c772537713f66afc96905218c457ff..ab355677ec53216072fb58a170610aa5f12dba28 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt +++ b/theodolite/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt @@ -7,7 +7,10 @@ import mu.KotlinLogging private val logger = KotlinLogging.logger {} -class CustomResourceWrapper(private val crAsMap: Map<String, String>, private val context: CustomResourceDefinitionContext) : KubernetesResource { +class CustomResourceWrapper( + private val crAsMap: Map<String, String>, + private val context: CustomResourceDefinitionContext +) : KubernetesResource { /** * Deploy a service monitor * diff --git a/theodolite/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt b/theodolite/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt index d231c70c02a77f02a77e3e1c695bbeb1672f97d0..faae5ade28deb579df6a463007cbdfbc9cc7706e 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt +++ b/theodolite/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt @@ -24,7 +24,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @return Service from fabric8 */ private fun loadService(path: String): Service { - return loadGenericResource(path) {client.services().load(it).get() } + return loadGenericResource(path) { client.services().load(it).get() } } @@ -34,17 +34,20 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @param context specific crd context for this custom resource * @return CustomResourceWrapper from fabric8 */ - private fun loadCustomResourceWrapper(path: String, context: CustomResourceDefinitionContext): CustomResourceWrapper { - return loadGenericResource(path) { - CustomResourceWrapper( - YamlParser().parse( - path, - HashMap<String, String>()::class.java - )!!, - context - ) - } - } + private fun loadCustomResourceWrapper( + path: String, + context: CustomResourceDefinitionContext + ): CustomResourceWrapper { + return loadGenericResource(path) { + CustomResourceWrapper( + YamlParser().parse( + path, + HashMap<String, String>()::class.java + )!!, + context + ) + } + } private fun loadServiceMonitor(path: String): CustomResourceWrapper { val context = K8sContextFactory().create( @@ -83,7 +86,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @return Deployment from fabric8 */ private fun loadDeployment(path: String): Deployment { - return loadGenericResource(path) {client.apps().deployments().load(it).get() } + return loadGenericResource(path) { client.apps().deployments().load(it).get() } } /** @@ -92,7 +95,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @return ConfigMap from fabric8 */ private fun loadConfigmap(path: String): ConfigMap { - return loadGenericResource(path) {client.configMaps().load(it).get() } + return loadGenericResource(path) { client.configMaps().load(it).get() } } /** @@ -101,7 +104,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @return StatefulSet from fabric8 */ private fun loadStatefulSet(path: String): KubernetesResource { - return loadGenericResource(path) {client.apps().statefulSets().load(it).get() } + return loadGenericResource(path) { client.apps().statefulSets().load(it).get() } } diff --git a/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt b/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt index c0be6f25ab18e62fd90fccdb75396da012da2223..9f3754c54f4b1eeb018b55787974179647f726b6 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt +++ b/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt @@ -42,7 +42,7 @@ class ResourceByLabelHandler(private val client: NamespacedKubernetesClient) { * @param [labelName] the label name * @param [labelValue] the value of this label */ - fun removeDeployments(labelName: String, labelValue: String){ + fun removeDeployments(labelName: String, labelValue: String) { this.client .apps() .deployments() @@ -69,7 +69,7 @@ class ResourceByLabelHandler(private val client: NamespacedKubernetesClient) { * @param [labelName] the label name * @param [labelValue] the value of this label */ - fun removeConfigMaps(labelName: String, labelValue: String){ + fun removeConfigMaps(labelName: String, labelValue: String) { this.client .configMaps() .withLabel("$labelName=$labelValue") @@ -106,7 +106,8 @@ class ResourceByLabelHandler(private val client: NamespacedKubernetesClient) { .withLabel("$labelName=$labelValue") .list() .items - .isNullOrEmpty()) { + .isNullOrEmpty() + ) { logger.info { "Wait for pods with label $labelName=$labelValue to be deleted." } Thread.sleep(1000) } diff --git a/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt b/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt index 3bbae82d77dc5b01a5827c7ee713bf2566be1bab..8e83883fc881db0f7e2b1b75b2fb7c7322a11a00 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt +++ b/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt @@ -4,7 +4,6 @@ import mu.KotlinLogging import org.apache.kafka.clients.admin.AdminClient import org.apache.kafka.clients.admin.CreateTopicsResult import org.apache.kafka.clients.admin.NewTopic -import org.apache.kafka.common.errors.TopicExistsException import java.lang.Thread.sleep private val logger = KotlinLogging.logger {} @@ -35,7 +34,7 @@ class TopicManager(private val kafkaConfig: Map<String, Any>) { logger.debug { e } // TODO remove due to attached exception to warn log? logger.info { "Remove existing topics." } delete(newTopics.map { topic -> topic.name() }, kafkaAdmin) - logger.info { "Will retry the topic creation in ${RETRY_TIME/1000} seconds." } + logger.info { "Will retry the topic creation in ${RETRY_TIME / 1000} seconds." } sleep(RETRY_TIME) retryCreation = true } @@ -104,7 +103,7 @@ class TopicManager(private val kafkaConfig: Map<String, Any>) { if (toDelete.isNullOrEmpty()) { deleted = true } else { - logger.info { "Deletion of Kafka topics failed, will retry in ${RETRY_TIME/1000} seconds." } + logger.info { "Deletion of Kafka topics failed, will retry in ${RETRY_TIME / 1000} seconds." } sleep(RETRY_TIME) } } diff --git a/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionStatus.kt b/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionStatus.kt index 51b76fcee8fb35c83dca407691833dbb235b29c5..252738959762aa5d0732babc5589c698d7bd4e9f 100644 --- a/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionStatus.kt +++ b/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionStatus.kt @@ -5,7 +5,7 @@ import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.api.model.Namespaced @JsonDeserialize -class ExecutionStatus(): KubernetesResource, Namespaced { +class ExecutionStatus : KubernetesResource, Namespaced { var executionState: String = "" var executionDuration: String = "-" } \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/patcher/LabelPatcher.kt b/theodolite/src/main/kotlin/theodolite/patcher/LabelPatcher.kt index 4fa7fc893cfaf864d935074ff50af8d61f7aac76..2f8c703afa9e826a79f0785abef493d2d448ac74 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/LabelPatcher.kt +++ b/theodolite/src/main/kotlin/theodolite/patcher/LabelPatcher.kt @@ -11,34 +11,34 @@ class LabelPatcher(private val k8sResource: KubernetesResource, val variableName AbstractPatcher(k8sResource) { override fun <String> patch(labelValue: String) { - if(labelValue is kotlin.String){ - when(k8sResource){ + if (labelValue is kotlin.String) { + when (k8sResource) { is Deployment -> { - if (k8sResource.metadata.labels == null){ + if (k8sResource.metadata.labels == null) { k8sResource.metadata.labels = mutableMapOf() } k8sResource.metadata.labels[this.variableName] = labelValue } is StatefulSet -> { - if (k8sResource.metadata.labels == null){ + if (k8sResource.metadata.labels == null) { k8sResource.metadata.labels = mutableMapOf() } k8sResource.metadata.labels[this.variableName] = labelValue } is Service -> { - if (k8sResource.metadata.labels == null){ + if (k8sResource.metadata.labels == null) { k8sResource.metadata.labels = mutableMapOf() } k8sResource.metadata.labels[this.variableName] = labelValue } is ConfigMap -> { - if (k8sResource.metadata.labels == null){ + if (k8sResource.metadata.labels == null) { k8sResource.metadata.labels = mutableMapOf() } k8sResource.metadata.labels[this.variableName] = labelValue } - is CustomResource<*,*> -> { - if (k8sResource.metadata.labels == null){ + is CustomResource<*, *> -> { + if (k8sResource.metadata.labels == null) { k8sResource.metadata.labels = mutableMapOf() } k8sResource.metadata.labels[this.variableName] = labelValue diff --git a/theodolite/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt b/theodolite/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt index 65489a96974ad566fe7cbd88cf6ff7fb49135e1d..c617917e6894c3a30779dd4257a96365ded35481 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt +++ b/theodolite/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt @@ -8,13 +8,14 @@ class NumNestedGroupsLoadGeneratorReplicaPatcher( private val k8sResource: KubernetesResource, private val numSensors: String, private val loadGenMaxRecords: String - ) : +) : AbstractPatcher(k8sResource) { override fun <String> patch(value: String) { if (k8sResource is Deployment) { if (value is kotlin.String) { - val approxNumSensors = numSensors.toDouble().pow(Integer.parseInt(value).toDouble()) - val loadGenInstances = (approxNumSensors + loadGenMaxRecords.toDouble() - 1) / loadGenMaxRecords.toDouble() + val approxNumSensors = numSensors.toDouble().pow(Integer.parseInt(value).toDouble()) + val loadGenInstances = + (approxNumSensors + loadGenMaxRecords.toDouble() - 1) / loadGenMaxRecords.toDouble() this.k8sResource.spec.replicas = loadGenInstances.toInt() } } diff --git a/theodolite/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt b/theodolite/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt index f6a06324e36d7942d3944a492fee263f428376c1..86bb37db3cb9fd0d3bca1690d5eb4e622329a9bc 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt +++ b/theodolite/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt @@ -12,7 +12,8 @@ class NumSensorsLoadGeneratorReplicaPatcher( override fun <String> patch(value: String) { if (k8sResource is Deployment) { if (value is kotlin.String) { - val loadGenInstances = (Integer.parseInt(value) + loadGenMaxRecords.toInt() - 1) / loadGenMaxRecords.toInt() + val loadGenInstances = + (Integer.parseInt(value) + loadGenMaxRecords.toInt() - 1) / loadGenMaxRecords.toInt() this.k8sResource.spec.replicas = loadGenInstances } } diff --git a/theodolite/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt b/theodolite/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt index d5a6f3821d2688651475625506a78efc6061ab82..6a1f993e2ac327ec242a8a5bafc3e6cc43475710 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt +++ b/theodolite/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt @@ -21,7 +21,7 @@ class PatcherDefinitionFactory { * value of the requiredType. */ fun createPatcherDefinition(requiredType: String, patcherTypes: List<TypeName>): List<PatcherDefinition> { - return patcherTypes.firstOrNull() { type -> type.typeName == requiredType } + return patcherTypes.firstOrNull { type -> type.typeName == requiredType } ?.patchers ?: throw IllegalArgumentException("typeName $requiredType not found.") } } diff --git a/theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt b/theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt index 6ba34d1507be488fb99a2ddf75aa3bc12f627bb3..29723355ce23810c709fe4537242d1fd7e195d25 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt +++ b/theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt @@ -41,48 +41,50 @@ class PatcherFactory { ) "NumNestedGroupsLoadGeneratorReplicaPatcher" -> NumNestedGroupsLoadGeneratorReplicaPatcher( k8sResource = resource, - loadGenMaxRecords = patcherDefinition.properties["loadGenMaxRecords"] !!, - numSensors = patcherDefinition.properties["numSensors"] !! + loadGenMaxRecords = patcherDefinition.properties["loadGenMaxRecords"]!!, + numSensors = patcherDefinition.properties["numSensors"]!! ) "NumSensorsLoadGeneratorReplicaPatcher" -> NumSensorsLoadGeneratorReplicaPatcher( k8sResource = resource, - loadGenMaxRecords = patcherDefinition.properties["loadGenMaxRecords"] !! + loadGenMaxRecords = patcherDefinition.properties["loadGenMaxRecords"]!! ) "EnvVarPatcher" -> EnvVarPatcher( k8sResource = resource, - container = patcherDefinition.properties["container"] !!, - variableName = patcherDefinition.properties["variableName"] !! + container = patcherDefinition.properties["container"]!!, + variableName = patcherDefinition.properties["variableName"]!! ) "NodeSelectorPatcher" -> NodeSelectorPatcher( k8sResource = resource, - variableName = patcherDefinition.properties["variableName"] !! + variableName = patcherDefinition.properties["variableName"]!! ) "ResourceLimitPatcher" -> ResourceLimitPatcher( k8sResource = resource, - container = patcherDefinition.properties["container"] !!, - limitedResource = patcherDefinition.properties["limitedResource"] !! + container = patcherDefinition.properties["container"]!!, + limitedResource = patcherDefinition.properties["limitedResource"]!! ) "ResourceRequestPatcher" -> ResourceRequestPatcher( k8sResource = resource, - container = patcherDefinition.properties["container"] !!, - requestedResource = patcherDefinition.properties["requestedResource"] !! + container = patcherDefinition.properties["container"]!!, + requestedResource = patcherDefinition.properties["requestedResource"]!! ) "SchedulerNamePatcher" -> SchedulerNamePatcher( k8sResource = resource ) "LabelPatcher" -> LabelPatcher( k8sResource = resource, - variableName = patcherDefinition.properties["variableName"] !! + variableName = patcherDefinition.properties["variableName"]!! ) "ImagePatcher" -> ImagePatcher( k8sResource = resource, - container = patcherDefinition.properties["container"] !! + container = patcherDefinition.properties["container"]!! ) else -> throw InvalidPatcherConfigurationException("Patcher type ${patcherDefinition.type} not found.") } } catch (e: Exception) { - throw InvalidPatcherConfigurationException("Could not create patcher with type ${patcherDefinition.type}" + - " Probably a required patcher argument was not specified." ) + throw InvalidPatcherConfigurationException( + "Could not create patcher with type ${patcherDefinition.type}" + + " Probably a required patcher argument was not specified." + ) } } } diff --git a/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt b/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt index 0e276d7de4e205a75eb309a71a793e70f7565ea4..639a7c86c641cbdcba361410cf5e25fa56dd795f 100644 --- a/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt +++ b/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt @@ -1,5 +1,4 @@ package theodolite.util -class DeploymentFailedException(message:String): Exception(message) { -} \ No newline at end of file +class DeploymentFailedException(message: String) : Exception(message) \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/util/IOHandler.kt b/theodolite/src/main/kotlin/theodolite/util/IOHandler.kt index 8d379fcf0543257edafd2e45383a02ba0254563d..57032189412d0937e4d77ddbf4354c78ffcc71a3 100644 --- a/theodolite/src/main/kotlin/theodolite/util/IOHandler.kt +++ b/theodolite/src/main/kotlin/theodolite/util/IOHandler.kt @@ -22,7 +22,7 @@ class IOHandler { var resultsFolder: String = System.getenv("RESULTS_FOLDER") ?: "" val createResultsFolder = System.getenv("CREATE_RESULTS_FOLDER") ?: "false" - if (resultsFolder != ""){ + if (resultsFolder != "") { logger.info { "RESULT_FOLDER: $resultsFolder" } val directory = File(resultsFolder) if (!directory.exists()) { @@ -35,7 +35,7 @@ class IOHandler { } resultsFolder += "/" } - return resultsFolder + return resultsFolder } /** @@ -70,9 +70,9 @@ class IOHandler { fun writeToCSVFile(fileURL: String, data: List<List<String>>, columns: List<String>) { val outputFile = File("$fileURL.csv") PrintWriter(outputFile).use { pw -> - pw.println(columns.joinToString(separator=",")) + pw.println(columns.joinToString(separator = ",")) data.forEach { - pw.println(it.joinToString(separator=",")) + pw.println(it.joinToString(separator = ",")) } } logger.info { "Wrote CSV file: $fileURL to ${outputFile.absolutePath}." } @@ -87,7 +87,7 @@ class IOHandler { fun writeStringToTextFile(fileURL: String, data: String) { val outputFile = File("$fileURL") outputFile.printWriter().use { - it.println(data) + it.println(data) } logger.info { "Wrote txt file: $fileURL to ${outputFile.absolutePath}." } } diff --git a/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt b/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt index c103ef1f35a1b3ffa56dad50c7cf6c1db51eb57f..e8ecd11d524f5c365149ac0b37c7b985812f8c4b 100644 --- a/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt +++ b/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt @@ -1,5 +1,4 @@ package theodolite.util -class InvalidPatcherConfigurationException(message:String): Exception(message) { -} +class InvalidPatcherConfigurationException(message: String) : Exception(message) diff --git a/theodolite/src/main/kotlin/theodolite/util/PrometheusResponse.kt b/theodolite/src/main/kotlin/theodolite/util/PrometheusResponse.kt index 846577387c425e920da1c2fca1f972c880e1540a..bf33fcf6104645727a13b92cf3a13d36e04a10c6 100644 --- a/theodolite/src/main/kotlin/theodolite/util/PrometheusResponse.kt +++ b/theodolite/src/main/kotlin/theodolite/util/PrometheusResponse.kt @@ -17,8 +17,7 @@ data class PrometheusResponse( * The data section of the query result contains the information about the resultType and the values itself. */ var data: PromData? = null -) -{ +) { /** * Return the data of the PrometheusResponse as [List] of [List]s of [String]s * The format of the returned list is: `[[ group, timestamp, value ], [ group, timestamp, value ], ... ]` diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt b/theodolite/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt index 53316422147280df7518585ffa9f3d2c375acf3d..7350f564a71e2f0cbf640b782f5dbf19cbdc7ecb 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt +++ b/theodolite/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt @@ -72,33 +72,35 @@ class ControllerTest { @Test @DisplayName("Check namespaced property of benchmarkCRDClient") - fun testBenchmarkClientNamespaced(){ + fun testBenchmarkClientNamespaced() { val method = controller .javaClass .getDeclaredMethod("getBenchmarks") method.isAccessible = true method.invoke(controller) - assert(server - .lastRequest - .toString() - .contains("namespaces") + assert( + server + .lastRequest + .toString() + .contains("namespaces") ) } @Test @DisplayName("Check namespaced property of executionCRDClient") - fun testExecutionClientNamespaced(){ + fun testExecutionClientNamespaced() { val method = controller .javaClass .getDeclaredMethod("getNextExecution") method.isAccessible = true method.invoke(controller) - assert(server - .lastRequest - .toString() - .contains("namespaces") + assert( + server + .lastRequest + .toString() + .contains("namespaces") ) } diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt b/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt index bbbb3092cd54a8f3313bb923be3682be50801f39..5598f48a2d291db4eab8563dd3325534f49b2eb6 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt +++ b/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt @@ -39,7 +39,7 @@ class ExecutionEventHandlerTest { executionStateHandler = ExecutionStateHandler(client = server.client) ) - this.factory = operator.getExecutionEventHandler(this.controller,server.client) + this.factory = operator.getExecutionEventHandler(this.controller, server.client) this.stateHandler = TheodoliteOperator().getExecutionStateHandler(client = server.client) this.executionVersion1 = K8sResourceLoader(server.client) @@ -66,10 +66,11 @@ class ExecutionEventHandlerTest { factory.startAllRegisteredInformers() server.lastRequest // the second request must be namespaced (this is the first `GET` request) - assert(server - .lastRequest - .toString() - .contains("namespaces") + assert( + server + .lastRequest + .toString() + .contains("namespaces") ) } diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt b/theodolite/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt index de74cf9ac87a8aca7db133a04ef3809c5e5087c2..24cb6c90d8ea222c90a398e12c7a50a2f6058a93 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt +++ b/theodolite/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt @@ -35,23 +35,24 @@ class StateHandlerTest { fun namespacedTest() { val handler = ExecutionStateHandler(client = server.client) handler.getExecutionState("example-execution") - assert(server - .lastRequest - .toString() - .contains("namespaces") + assert( + server + .lastRequest + .toString() + .contains("namespaces") ) } @Test @DisplayName("Test empty execution state") - fun executionWithoutExecutionStatusTest(){ + fun executionWithoutExecutionStatusTest() { val handler = ExecutionStateHandler(client = server.client) assertEquals(States.NO_STATE, handler.getExecutionState("example-execution")) } @Test @DisplayName("Test empty duration state") - fun executionWithoutDurationStatusTest(){ + fun executionWithoutDurationStatusTest() { val handler = ExecutionStateHandler(client = server.client) assertEquals("-", handler.getDurationState("example-execution")) } diff --git a/theodolite/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt b/theodolite/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt index 9df095fb62c49e8b1be5e472d2852932240ba8f8..739fadd3f02bfd1e60fd67e7afc695bf99e68d31 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt +++ b/theodolite/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt @@ -15,7 +15,6 @@ class ConfigOverrideModifierTest { private var benchmark = KubernetesBenchmark() - @BeforeEach fun setup() { val execution1 = ExecutionCRDummy(name = "matching-execution", benchmark = "Test-Benchmark") @@ -26,18 +25,19 @@ class ConfigOverrideModifierTest { } - @Test fun setAdditionalLabelsTest() { this.benchmark.appResource = listOf("test-resource.yaml") val modifier = ConfigOverrideModifier( execution = this.execution, - resources = this.benchmark.appResource ) + resources = this.benchmark.appResource + ) modifier.setAdditionalLabels( labelName = "test-name", - labelValue = "test-value") + labelValue = "test-value" + ) Assertions.assertEquals( "test-name",