diff --git a/theodolite/src/main/kotlin/theodolite/util/Config.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/Config.kt similarity index 68% rename from theodolite/src/main/kotlin/theodolite/util/Config.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/Config.kt index 675caea5fbd3b8e8c699019e10f43c36b9fbaebe..c429d6b3f456c345c7ab2adb1ccd95635603ef4f 100644 --- a/theodolite/src/main/kotlin/theodolite/util/Config.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/Config.kt @@ -1,8 +1,8 @@ -package theodolite.util +package rocks.theodolite.core import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.strategies.Metric -import theodolite.strategies.searchstrategy.SearchStrategy +import rocks.theodolite.core.strategies.Metric +import rocks.theodolite.core.strategies.searchstrategy.SearchStrategy /** * Config class that represents a configuration of a theodolite run. @@ -15,9 +15,7 @@ import theodolite.strategies.searchstrategy.SearchStrategy @RegisterForReflection data class Config( val loads: List<Int>, - val loadPatcherDefinitions : List<PatcherDefinition>, val resources: List<Int>, - val resourcePatcherDefinitions : List<PatcherDefinition>, val searchStrategy: SearchStrategy, val metric: Metric ) diff --git a/theodolite/src/main/kotlin/rocks/theodolite/core/ExecutionRunner.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/ExecutionRunner.kt new file mode 100644 index 0000000000000000000000000000000000000000..a63269bb8ebb009ecd858be145523c4029814888 --- /dev/null +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/ExecutionRunner.kt @@ -0,0 +1,50 @@ +package rocks.theodolite.core + +import rocks.theodolite.core.strategies.Metric +import rocks.theodolite.core.strategies.searchstrategy.SearchStrategy + + +class ExecutionRunner (private val searchStrategy: SearchStrategy, + private val resources: List<Int>, private val loads: List<Int>, + private val metric: Metric, private val executionId: Int) { + + /** + * Run all experiments for given loads and resources. + * Called by [rocks.theodolite.kubernetes.execution.TheodoliteExecutor] to run an Execution. + */ + fun run() { + + val ioHandler = IOHandler() + val resultsFolder = ioHandler.getResultFolderURL() + + //execute benchmarks for each load for the demand metric, or for each resource amount for capacity metric + try { + searchStrategy.applySearchStrategyByMetric(loads, resources, metric) + + } finally { + ioHandler.writeToJSONFile( + searchStrategy.experimentRunner.results, + "${resultsFolder}exp${executionId}-result" + ) + // Create expXYZ_demand.csv file or expXYZ_capacity.csv depending on metric + when(metric) { + Metric.DEMAND -> + ioHandler.writeToCSVFile( + "${resultsFolder}exp${executionId}_demand", + calculateMetric(loads, searchStrategy.experimentRunner.results), + listOf("load","resources") + ) + Metric.CAPACITY -> + ioHandler.writeToCSVFile( + "${resultsFolder}exp${executionId}_capacity", + calculateMetric(resources, searchStrategy.experimentRunner.results), + listOf("resource", "loads") + ) + } + } + } + + private fun calculateMetric(xValues: List<Int>, results: Results): List<List<String>> { + return xValues.map { listOf(it.toString(), results.getOptYDimensionValue(it).toString()) } + } +} \ No newline at end of file diff --git a/theodolite/src/main/kotlin/rocks/theodolite/core/ExperimentRunner.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/ExperimentRunner.kt new file mode 100644 index 0000000000000000000000000000000000000000..830469320d98cf66cd9395e3cdf74b2443758c3c --- /dev/null +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/ExperimentRunner.kt @@ -0,0 +1,29 @@ +package rocks.theodolite.core + +import java.util.concurrent.atomic.AtomicBoolean + + +/** + * Abstract class acts as an interface for the theodolite core to run experiments. + * The results of the experiments are stored in [results]. + * + * @property results + */ +abstract class ExperimentRunner(val results: Results) { + + var run: AtomicBoolean = AtomicBoolean(true) + + /** + * Run an experiment for the given parametrization, evaluate the + * experiment and save the result. + * + * @param load to be tested. + * @param resource to be tested. + * @return True, if the number of resources are suitable for the + * given load, false otherwise (demand metric), or + * True, if there is a load suitable for the + * given resource, false otherwise. + */ + abstract fun runExperiment(load: Int, resource: Int): Boolean + +} diff --git a/theodolite/src/main/kotlin/theodolite/util/IOHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/IOHandler.kt similarity index 99% rename from theodolite/src/main/kotlin/theodolite/util/IOHandler.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/IOHandler.kt index 8b580c733ab7ae527d99c676223f4b09b392c6fd..4d2cab0da938b18950def8cfb5cc6f104e110125 100644 --- a/theodolite/src/main/kotlin/theodolite/util/IOHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/IOHandler.kt @@ -1,4 +1,4 @@ -package theodolite.util +package rocks.theodolite.core import com.google.gson.GsonBuilder import mu.KotlinLogging diff --git a/theodolite/src/main/kotlin/theodolite/util/Results.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/Results.kt similarity index 98% rename from theodolite/src/main/kotlin/theodolite/util/Results.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/Results.kt index 418ac50f285996affd7db1c15fc44a22f1677d29..16e6b517e1f570fd17a1b9688aff4f41ec8c9884 100644 --- a/theodolite/src/main/kotlin/theodolite/util/Results.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/Results.kt @@ -1,7 +1,7 @@ -package theodolite.util +package rocks.theodolite.core import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.strategies.Metric +import rocks.theodolite.core.strategies.Metric /** * Central class that saves the state of an execution of Theodolite. For an execution, it is used to save the result of diff --git a/theodolite/src/main/kotlin/theodolite/strategies/Metric.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/Metric.kt similarity index 87% rename from theodolite/src/main/kotlin/theodolite/strategies/Metric.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/Metric.kt index 05383ca913a460641a6e632211787a2aec17e9d0..db161d10c61fae512e28ba059e604835d22aeb96 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/Metric.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/Metric.kt @@ -1,4 +1,4 @@ -package theodolite.strategies +package rocks.theodolite.core.strategies enum class Metric(val value: String) { DEMAND("demand"), diff --git a/theodolite/src/main/kotlin/theodolite/strategies/StrategyFactory.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/StrategyFactory.kt similarity index 67% rename from theodolite/src/main/kotlin/theodolite/strategies/StrategyFactory.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/StrategyFactory.kt index 505681716966016548416bf40cefc2c9ad15d805..d2925c798e29705f3333130e8c9f09e32d7ec31c 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/StrategyFactory.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/StrategyFactory.kt @@ -1,11 +1,11 @@ -package theodolite.strategies +package rocks.theodolite.core.strategies -import theodolite.benchmark.BenchmarkExecution -import theodolite.execution.BenchmarkExecutor -import theodolite.strategies.restriction.LowerBoundRestriction -import theodolite.strategies.restriction.RestrictionStrategy -import theodolite.strategies.searchstrategy.* -import theodolite.util.Results +import rocks.theodolite.core.strategies.guessstrategy.PrevInstanceOptGuess +import rocks.theodolite.core.strategies.restrictionstrategy.LowerBoundRestriction +import rocks.theodolite.core.strategies.restrictionstrategy.RestrictionStrategy +import rocks.theodolite.core.strategies.searchstrategy.* +import rocks.theodolite.core.ExperimentRunner +import rocks.theodolite.core.Results /** * Factory for creating [SearchStrategy] and [RestrictionStrategy] strategies. @@ -22,28 +22,24 @@ class StrategyFactory { * * @throws IllegalArgumentException if the [SearchStrategy] was not one of the allowed options. */ - fun createSearchStrategy(executor: BenchmarkExecutor, searchStrategyObject: BenchmarkExecution.Strategy, - results: Results): SearchStrategy { + fun createSearchStrategy(executor: ExperimentRunner, name: String, searchStrategy: String, restrictions: List<String>, + guessStrategy: String, results: Results): SearchStrategy { - var strategy : SearchStrategy = when (searchStrategyObject.name) { + var strategy : SearchStrategy = when (name) { "FullSearch" -> FullSearch(executor) "LinearSearch" -> LinearSearch(executor) "BinarySearch" -> BinarySearch(executor) - "RestrictionSearch" -> when (searchStrategyObject.searchStrategy){ - "FullSearch" -> composeSearchRestrictionStrategy(executor, FullSearch(executor), results, - searchStrategyObject.restrictions) - "LinearSearch" -> composeSearchRestrictionStrategy(executor, LinearSearch(executor), results, - searchStrategyObject.restrictions) - "BinarySearch" -> composeSearchRestrictionStrategy(executor, BinarySearch(executor), results, - searchStrategyObject.restrictions) - else -> throw IllegalArgumentException( - "Search Strategy ${searchStrategyObject.searchStrategy} for RestrictionSearch not found") + "RestrictionSearch" -> when (searchStrategy){ + "FullSearch" -> composeSearchRestrictionStrategy(executor, FullSearch(executor), results, restrictions) + "LinearSearch" -> composeSearchRestrictionStrategy(executor, LinearSearch(executor), results, restrictions) + "BinarySearch" -> composeSearchRestrictionStrategy(executor, BinarySearch(executor), results, restrictions) + else -> throw IllegalArgumentException("Search Strategy $searchStrategy for RestrictionSearch not found") } - "InitialGuessSearch" -> when (searchStrategyObject.guessStrategy){ - "PrevResourceMinGuess" -> InitialGuessSearchStrategy(executor,PrevInstanceOptGuess(), results) - else -> throw IllegalArgumentException("Guess Strategy ${searchStrategyObject.guessStrategy} not found") + "InitialGuessSearch" -> when (guessStrategy){ + "PrevResourceMinGuess" -> InitialGuessSearchStrategy(executor, PrevInstanceOptGuess(), results) + else -> throw IllegalArgumentException("Guess Strategy $guessStrategy not found") } - else -> throw IllegalArgumentException("Search Strategy $searchStrategyObject not found") + else -> throw IllegalArgumentException("Search Strategy not found") } return strategy @@ -78,7 +74,7 @@ class StrategyFactory { * @param results The [Results] saves the state of the Theodolite benchmark run. * @param restrictions The [RestrictionStrategy]'s to use. */ - private fun composeSearchRestrictionStrategy(executor: BenchmarkExecutor, searchStrategy: SearchStrategy, + private fun composeSearchRestrictionStrategy(executor: ExperimentRunner, searchStrategy: SearchStrategy, results: Results, restrictions: List<String>): SearchStrategy { if(restrictions.isNotEmpty()){ return RestrictionSearch(executor,searchStrategy,createRestrictionStrategy(results, restrictions)) diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/GuessStrategy.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/guessstrategy/GuessStrategy.kt similarity index 93% rename from theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/GuessStrategy.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/guessstrategy/GuessStrategy.kt index f243b8e4076d0cf0d2ef23bdd6b02b5da2d34152..6ab5c1b6d10da318c4b5b3f24d6cc521ff247e79 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/GuessStrategy.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/guessstrategy/GuessStrategy.kt @@ -1,4 +1,4 @@ -package theodolite.strategies.searchstrategy +package rocks.theodolite.core.strategies.guessstrategy import io.quarkus.runtime.annotations.RegisterForReflection diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/PrevInstanceOptGuess.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/guessstrategy/PrevInstanceOptGuess.kt similarity index 94% rename from theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/PrevInstanceOptGuess.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/guessstrategy/PrevInstanceOptGuess.kt index c919b475995a6a5366371336041d9633f0aa1993..3b2d7b1b0e6c4133b939742a83afc55fabb7b101 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/PrevInstanceOptGuess.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/guessstrategy/PrevInstanceOptGuess.kt @@ -1,4 +1,4 @@ -package theodolite.strategies.searchstrategy +package rocks.theodolite.core.strategies.guessstrategy /** diff --git a/theodolite/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestriction.kt similarity index 90% rename from theodolite/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestriction.kt index 1203d7293e3790aac2af653c9ceccd0c2ef544bd..2e5a51018fd742abbb18edb1d788a6644e94d2f1 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestriction.kt @@ -1,6 +1,6 @@ -package theodolite.strategies.restriction +package rocks.theodolite.core.strategies.restrictionstrategy -import theodolite.util.Results +import rocks.theodolite.core.Results /** * The [LowerBoundRestriction] sets the lower bound of the resources to be examined in the experiment to the value diff --git a/theodolite/src/main/kotlin/theodolite/strategies/restriction/RestrictionStrategy.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/RestrictionStrategy.kt similarity index 91% rename from theodolite/src/main/kotlin/theodolite/strategies/restriction/RestrictionStrategy.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/RestrictionStrategy.kt index 1ac9d201c734c84db4ec8837c8a242f2be8531b9..16532c32e2c9c64ac69d1c5ed32f6ec0d3345747 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/restriction/RestrictionStrategy.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/RestrictionStrategy.kt @@ -1,7 +1,7 @@ -package theodolite.strategies.restriction +package rocks.theodolite.core.strategies.restrictionstrategy import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.util.Results +import rocks.theodolite.core.Results /** * A 'Restriction Strategy' restricts a list of resources or loads depending on the metric based on the current diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/BinarySearch.kt similarity index 86% rename from theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/BinarySearch.kt index 6e56c3b36c6e2889e4714c890a424e4f6765386e..7c339c449e85a0fa73484d60a455016931cee473 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/BinarySearch.kt @@ -1,16 +1,16 @@ -package theodolite.strategies.searchstrategy +package rocks.theodolite.core.strategies.searchstrategy import mu.KotlinLogging -import theodolite.execution.BenchmarkExecutor +import rocks.theodolite.core.ExperimentRunner private val logger = KotlinLogging.logger {} /** * Binary-search-like implementation for determining the smallest suitable number of instances. * - * @param benchmarkExecutor Benchmark executor which runs the individual benchmarks. + * @param experimentRunner Benchmark executor which runs the individual benchmarks. */ -class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchmarkExecutor) { +class BinarySearch(experimentRunner: ExperimentRunner) : SearchStrategy(experimentRunner) { override fun findSuitableResource(load: Int, resources: List<Int>): Int? { val result = binarySearchDemand(load, resources, 0, resources.size - 1) if (result == -1) { @@ -43,7 +43,7 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm if (lower == upper) { val res = resources[lower] logger.info { "Running experiment with load '$load' and resource '$res'" } - if (this.benchmarkExecutor.runExperiment(load, res)) return lower + if (this.experimentRunner.runExperiment(load, res)) return lower else { if (lower + 1 == resources.size) return -1 return lower + 1 @@ -54,7 +54,7 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm val mid = (upper + lower) / 2 val res = resources[mid] logger.info { "Running experiment with load '$load' and resource '$res'" } - if (this.benchmarkExecutor.runExperiment(load, res)) { + if (this.experimentRunner.runExperiment(load, res)) { // case length = 2 if (mid == lower) { return lower @@ -83,7 +83,7 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm if (lower == upper) { val load = loads[lower] logger.info { "Running experiment with load '$load' and resource '$resource'" } - if (this.benchmarkExecutor.runExperiment(load, resource)) return lower + if (this.experimentRunner.runExperiment(load, resource)) return lower else { if (lower + 1 == loads.size) return -1 return lower - 1 @@ -94,7 +94,7 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm val mid = (upper + lower + 1) / 2 //round to next int val load = loads[mid] logger.info { "Running experiment with load '$load' and resource '$resource'" } - if (this.benchmarkExecutor.runExperiment(load, resource)) { + if (this.experimentRunner.runExperiment(load, resource)) { // length = 2, so since we round down mid is equal to lower if (mid == upper) { return upper diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/FullSearch.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/FullSearch.kt similarity index 73% rename from theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/FullSearch.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/FullSearch.kt index 6af6aa1602d18a089b9450f6e1eb84bca8edafa3..7cd1dfe08cfef7ea42f0a663bbc80eb63f8ca9fe 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/FullSearch.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/FullSearch.kt @@ -1,7 +1,7 @@ -package theodolite.strategies.searchstrategy +package rocks.theodolite.core.strategies.searchstrategy import mu.KotlinLogging -import theodolite.execution.BenchmarkExecutor +import rocks.theodolite.core.ExperimentRunner private val logger = KotlinLogging.logger {} @@ -12,15 +12,15 @@ private val logger = KotlinLogging.logger {} * * @see LinearSearch for a SearchStrategy that stops once the desired resource (demand) or load (capacity) is found. * - * @param benchmarkExecutor Benchmark executor which runs the individual benchmarks. + * @param experimentRunner Benchmark executor which runs the individual benchmarks. */ -class FullSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchmarkExecutor) { +class FullSearch(experimentRunner: ExperimentRunner) : SearchStrategy(experimentRunner) { override fun findSuitableResource(load: Int, resources: List<Int>): Int? { var minimalSuitableResources: Int? = null for (res in resources) { logger.info { "Running experiment with load '$load' and resources '$res'" } - val result = this.benchmarkExecutor.runExperiment(load, res) + val result = this.experimentRunner.runExperiment(load, res) if (result && minimalSuitableResources == null) { minimalSuitableResources = res } @@ -32,7 +32,7 @@ class FullSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchmar var maxSuitableLoad: Int? = null for (load in loads) { logger.info { "Running experiment with resources '$resource' and load '$load'" } - if (this.benchmarkExecutor.runExperiment(load, resource)) maxSuitableLoad = load + if (this.experimentRunner.runExperiment(load, resource)) maxSuitableLoad = load } return maxSuitableLoad } diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/InitialGuessSearchStrategy.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategy.kt similarity index 83% rename from theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/InitialGuessSearchStrategy.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategy.kt index 447d810942be74f0cdbee865e3f0bb5d58e61603..8d257bb329729cab033e10195e7a9df3260aeeb3 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/InitialGuessSearchStrategy.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategy.kt @@ -1,8 +1,9 @@ -package theodolite.strategies.searchstrategy +package rocks.theodolite.core.strategies.searchstrategy import mu.KotlinLogging -import theodolite.execution.BenchmarkExecutor -import theodolite.util.Results +import rocks.theodolite.core.strategies.guessstrategy.GuessStrategy +import rocks.theodolite.core.ExperimentRunner +import rocks.theodolite.core.Results private val logger = KotlinLogging.logger {} @@ -10,15 +11,15 @@ private val logger = KotlinLogging.logger {} * Search strategy implementation for determining the smallest suitable resource demand. * Starting with a resource amount provided by a guess strategy. * - * @param benchmarkExecutor Benchmark executor which runs the individual benchmarks. + * @param experimentRunner Benchmark executor which runs the individual benchmarks. * @param guessStrategy Strategy that provides us with a guess for the first resource amount. * @param results current results of all previously performed benchmarks. */ class InitialGuessSearchStrategy( - benchmarkExecutor: BenchmarkExecutor, + experimentRunner: ExperimentRunner, private val guessStrategy: GuessStrategy, private var results: Results -) : SearchStrategy(benchmarkExecutor) { +) : SearchStrategy(experimentRunner) { override fun findSuitableResource(load: Int, resources: List<Int>): Int? { @@ -39,7 +40,7 @@ class InitialGuessSearchStrategy( // If the first experiment passes, starting downward linear search // otherwise starting upward linear search - if (this.benchmarkExecutor.runExperiment(load, lastLowestResource)) { + if (this.experimentRunner.runExperiment(load, lastLowestResource)) { resourcesToCheck = resources.subList(0, startIndex).reversed() if (resourcesToCheck.isEmpty()) return lastLowestResource @@ -48,7 +49,7 @@ class InitialGuessSearchStrategy( for (res in resourcesToCheck) { logger.info { "Running experiment with load '$load' and resources '$res'" } - if (this.benchmarkExecutor.runExperiment(load, res)) { + if (this.experimentRunner.runExperiment(load, res)) { currentMin = res } } @@ -64,7 +65,7 @@ class InitialGuessSearchStrategy( for (res in resourcesToCheck) { logger.info { "Running experiment with load '$load' and resources '$res'" } - if (this.benchmarkExecutor.runExperiment(load, res)) return res + if (this.experimentRunner.runExperiment(load, res)) return res } } } @@ -93,7 +94,7 @@ class InitialGuessSearchStrategy( // If the first experiment passes, starting upwards linear search // otherwise starting downward linear search - if (!this.benchmarkExecutor.runExperiment(lastMaxLoad, resource)) { + if (!this.experimentRunner.runExperiment(lastMaxLoad, resource)) { // downward search loadsToCheck = loads.subList(0, startIndex).reversed() @@ -101,7 +102,7 @@ class InitialGuessSearchStrategy( for (load in loadsToCheck) { logger.info { "Running experiment with resource '$resource' and load '$load'" } - if (this.benchmarkExecutor.runExperiment(load, resource)) { + if (this.experimentRunner.runExperiment(load, resource)) { return load } } @@ -117,7 +118,7 @@ class InitialGuessSearchStrategy( var currentMax: Int = lastMaxLoad for (load in loadsToCheck) { logger.info { "Running experiment with resource '$resource' and load '$load'" } - if (this.benchmarkExecutor.runExperiment(load, resource)) { + if (this.experimentRunner.runExperiment(load, resource)) { currentMax = load } } diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/LinearSearch.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/LinearSearch.kt similarity index 65% rename from theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/LinearSearch.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/LinearSearch.kt index 1991431a970e44bf70eccf834a2ecb0221502a71..c3276f05e141d15652012952991a47a1fde30ad4 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/LinearSearch.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/LinearSearch.kt @@ -1,7 +1,7 @@ -package theodolite.strategies.searchstrategy +package rocks.theodolite.core.strategies.searchstrategy import mu.KotlinLogging -import theodolite.execution.BenchmarkExecutor +import rocks.theodolite.core.ExperimentRunner private val logger = KotlinLogging.logger {} @@ -9,14 +9,14 @@ private val logger = KotlinLogging.logger {} * Linear-search-like implementation for determining the smallest/biggest suitable number of resources/loads, * depending on the metric. * - * @param benchmarkExecutor Benchmark executor which runs the individual benchmarks. + * @param experimentRunner Benchmark executor which runs the individual benchmarks. */ -class LinearSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchmarkExecutor) { +class LinearSearch(experimentRunner: ExperimentRunner) : SearchStrategy(experimentRunner) { override fun findSuitableResource(load: Int, resources: List<Int>): Int? { for (res in resources) { logger.info { "Running experiment with load '$load' and resources '$res'" } - if (this.benchmarkExecutor.runExperiment(load, res)) return res + if (this.experimentRunner.runExperiment(load, res)) return res } return null } @@ -25,7 +25,7 @@ class LinearSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm var maxSuitableLoad: Int? = null for (load in loads) { logger.info { "Running experiment with resources '$resource' and load '$load'" } - if (this.benchmarkExecutor.runExperiment(load, resource)) { + if (this.experimentRunner.runExperiment(load, resource)) { maxSuitableLoad = load } else break } diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/RestrictionSearch.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearch.kt similarity index 75% rename from theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/RestrictionSearch.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearch.kt index 0a136d6ff43e6f62fc5ebe34c392816da3592bf1..703a7de8b9e084b2bb55bc9270b9d07ea6adfe83 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/RestrictionSearch.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearch.kt @@ -1,23 +1,23 @@ -package theodolite.strategies.searchstrategy +package rocks.theodolite.core.strategies.searchstrategy import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.execution.BenchmarkExecutor -import theodolite.strategies.restriction.RestrictionStrategy +import rocks.theodolite.core.strategies.restrictionstrategy.RestrictionStrategy +import rocks.theodolite.core.ExperimentRunner /** * Strategy that combines a SearchStrategy and a set of RestrictionStrategy. * - * @param benchmarkExecutor Benchmark executor which runs the individual benchmarks. + * @param experimentRunner Benchmark executor which runs the individual benchmarks. * @param searchStrategy the [SearchStrategy] that is executed as part of this [RestrictionSearch]. * @param restrictionStrategies the set of [RestrictionStrategy] that are connected conjunctive to restrict the Resource. * */ @RegisterForReflection class RestrictionSearch( - benchmarkExecutor: BenchmarkExecutor, - private val searchStrategy: SearchStrategy, - private val restrictionStrategies: Set<RestrictionStrategy> -) : SearchStrategy(benchmarkExecutor) { + experimentRunner: ExperimentRunner, + private val searchStrategy: SearchStrategy, + private val restrictionStrategies: Set<RestrictionStrategy> +) : SearchStrategy(experimentRunner) { /** * Restricting the possible resources and calling findSuitableResource of the given [SearchStrategy]. diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/SearchStrategy.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/SearchStrategy.kt similarity index 83% rename from theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/SearchStrategy.kt rename to theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/SearchStrategy.kt index 962504c7d85fa5e28d73fe0cb9d844ed2be66a99..d08581ff70c509f54a9b8e5f972bb3661cb0b8f8 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/SearchStrategy.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/searchstrategy/SearchStrategy.kt @@ -1,20 +1,19 @@ -package theodolite.strategies.searchstrategy +package rocks.theodolite.core.strategies.searchstrategy import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.execution.BenchmarkExecutor -import theodolite.strategies.Metric -import theodolite.util.Results +import rocks.theodolite.core.strategies.Metric +import rocks.theodolite.core.ExperimentRunner /** * Base class for the implementation for SearchStrategies. SearchStrategies determine the smallest suitable number * of resources/loads for a load/resource (depending on the metric). * - * @param benchmarkExecutor Benchmark executor which runs the individual benchmarks. + * @param experimentRunner Benchmark executor which runs the individual benchmarks. * @param guessStrategy Guess strategy for the initial resource amount in case the InitialGuessStrategy is selected. * @param results the [Results] object. */ @RegisterForReflection -abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor) { +abstract class SearchStrategy(val experimentRunner: ExperimentRunner) { /** @@ -29,13 +28,13 @@ abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor) { when(metric) { Metric.DEMAND -> for (load in loads) { - if (benchmarkExecutor.run.get()) { + if (experimentRunner.run.get()) { this.findSuitableResource(load, resources) } } Metric.CAPACITY -> for (resource in resources) { - if (benchmarkExecutor.run.get()) { + if (experimentRunner.run.get()) { this.findSuitableLoad(resource, loads) } } diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/Action.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Action.kt similarity index 91% rename from theodolite/src/main/kotlin/theodolite/benchmark/Action.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Action.kt index 8bd16d04d6a5e5ef3f362ff7d5611bf73e367a7e..2ecf486323f0ed1e71be1fe069d93dc81edddc65 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/Action.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Action.kt @@ -1,11 +1,10 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.util.ActionCommandFailedException -import theodolite.util.Configuration + @JsonDeserialize @RegisterForReflection diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/ActionCommand.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ActionCommand.kt similarity index 98% rename from theodolite/src/main/kotlin/theodolite/benchmark/ActionCommand.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ActionCommand.kt index 9f0578f7d1456d823a29049daae6dbe886c95e2a..eefacbea9268f44969fd88d7650d5ddc5e00fb8e 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/ActionCommand.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ActionCommand.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import io.fabric8.kubernetes.api.model.Status import io.fabric8.kubernetes.client.KubernetesClientException @@ -7,8 +7,6 @@ import io.fabric8.kubernetes.client.dsl.ExecListener import io.fabric8.kubernetes.client.dsl.ExecWatch import io.fabric8.kubernetes.client.utils.Serialization import mu.KotlinLogging -import theodolite.util.ActionCommandFailedException -import theodolite.util.Configuration import java.io.ByteArrayOutputStream import java.time.Duration import java.util.concurrent.CountDownLatch diff --git a/theodolite/src/main/kotlin/theodolite/util/ActionCommandFailedException.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ActionCommandFailedException.kt similarity index 76% rename from theodolite/src/main/kotlin/theodolite/util/ActionCommandFailedException.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ActionCommandFailedException.kt index c1a8fc401961370d2f07bfffe43f0ae4dc441d25..8472b0cc9b46a952dbeb14eb73093c821cd6ed57 100644 --- a/theodolite/src/main/kotlin/theodolite/util/ActionCommandFailedException.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ActionCommandFailedException.kt @@ -1,4 +1,4 @@ -package theodolite.util +package rocks.theodolite.kubernetes class ActionCommandFailedException(message: String, e: Exception? = null) : DeploymentFailedException(message,e) { } \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkDeployment.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/BenchmarkDeployment.kt similarity index 93% rename from theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkDeployment.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/BenchmarkDeployment.kt index fd01ecd986775ef704949743fef0d19f5492e9a6..df303b3b85175d6133e8bc9e7a2748cf8c46464c 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkDeployment.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/BenchmarkDeployment.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes /** * A BenchmarkDeployment contains the necessary infrastructure to execute a benchmark. diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/BenchmarkDeploymentBuilder.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/BenchmarkDeploymentBuilder.kt new file mode 100644 index 0000000000000000000000000000000000000000..544f8bd5ae227ca682e688dff9fc9df0efec60c3 --- /dev/null +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/BenchmarkDeploymentBuilder.kt @@ -0,0 +1,25 @@ +package rocks.theodolite.kubernetes + +import rocks.theodolite.kubernetes.patcher.PatcherDefinition +import rocks.theodolite.kubernetes.util.ConfigurationOverride + +/** + * This interface is needed for test purposes. + */ +interface BenchmarkDeploymentBuilder { + + /** + * Builds a Deployment that can be deployed. + * @return a BenchmarkDeployment. + */ + fun buildDeployment( + load: Int, + loadPatcherDefinitions: List<PatcherDefinition>, + resource: Int, + resourcePatcherDefinitions: List<PatcherDefinition>, + configurationOverrides: List<ConfigurationOverride?>, + loadGenerationDelay: Long, + afterTeardownDelay: Long, + waitForResourcesEnabled: Boolean + ): BenchmarkDeployment +} \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/ConfigMapResourceSet.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ConfigMapResourceSet.kt similarity index 96% rename from theodolite/src/main/kotlin/theodolite/benchmark/ConfigMapResourceSet.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ConfigMapResourceSet.kt index eea5b15cb1db7242328033a1bc46fb224d287bc2..43c478b983d879135b00e6208df8bb36b7978c8f 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/ConfigMapResourceSet.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ConfigMapResourceSet.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.api.model.HasMetadata @@ -6,7 +6,6 @@ import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.client.KubernetesClientException import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.util.DeploymentFailedException import java.lang.IllegalArgumentException @RegisterForReflection diff --git a/theodolite/src/main/kotlin/theodolite/util/Configuration.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Configuration.kt similarity index 90% rename from theodolite/src/main/kotlin/theodolite/util/Configuration.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Configuration.kt index 0a63cfa84de9e60fba04707372ef884d77a1543b..e28e2a2a7644222f656bdebd05d122cd853ac456 100644 --- a/theodolite/src/main/kotlin/theodolite/util/Configuration.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Configuration.kt @@ -1,6 +1,4 @@ -package theodolite.util - -import theodolite.execution.ExecutionModes +package rocks.theodolite.kubernetes // Defaults private const val DEFAULT_NAMESPACE = "default" diff --git a/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/DeploymentFailedException.kt similarity index 75% rename from theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/DeploymentFailedException.kt index 9f4caedf3db1e09dca7924bf0035c6ace0b835d7..cde0021255b471354e8513139cad0f6e083f804a 100644 --- a/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/DeploymentFailedException.kt @@ -1,4 +1,4 @@ -package theodolite.util +package rocks.theodolite.kubernetes open class DeploymentFailedException(message: String, e: Exception? = null) : TheodoliteException(message,e) diff --git a/theodolite/src/main/kotlin/theodolite/util/ExecutionFailedException.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ExecutionFailedException.kt similarity index 75% rename from theodolite/src/main/kotlin/theodolite/util/ExecutionFailedException.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ExecutionFailedException.kt index 2e181dad35786d386226f8a57dfffbc2c3966754..8924dd18199e0ff937c783873878c6f245d01ea5 100644 --- a/theodolite/src/main/kotlin/theodolite/util/ExecutionFailedException.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ExecutionFailedException.kt @@ -1,3 +1,3 @@ -package theodolite.util +package rocks.theodolite.kubernetes open class ExecutionFailedException(message: String, e: Exception? = null) : TheodoliteException(message,e) diff --git a/theodolite/src/main/kotlin/theodolite/execution/ExecutionModes.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ExecutionModes.kt similarity index 74% rename from theodolite/src/main/kotlin/theodolite/execution/ExecutionModes.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ExecutionModes.kt index 370b87e062d942a512e059ee4041dca776376ddf..e8e4b642689c455b7be6c32d0bdedad58861238c 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/ExecutionModes.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ExecutionModes.kt @@ -1,4 +1,4 @@ -package theodolite.execution +package rocks.theodolite.kubernetes enum class ExecutionModes(val value: String) { OPERATOR("operator"), diff --git a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ExperimentRunnerImpl.kt similarity index 66% rename from theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ExperimentRunnerImpl.kt index 790e796e0792acb2542a69db7c1f626aa7c0ee67..e1ce46ea24fc97bb7b0421b8e3507c8e989d654a 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ExperimentRunnerImpl.kt @@ -1,44 +1,36 @@ -package theodolite.execution +package rocks.theodolite.kubernetes import io.quarkus.runtime.annotations.RegisterForReflection import mu.KotlinLogging -import theodolite.benchmark.Benchmark -import theodolite.benchmark.Slo -import theodolite.evaluation.AnalysisExecutor -import theodolite.execution.operator.EventCreator -import theodolite.util.* +import rocks.theodolite.core.ExperimentRunner +import rocks.theodolite.core.Results +import rocks.theodolite.kubernetes.model.KubernetesBenchmark.Slo +import rocks.theodolite.kubernetes.util.ConfigurationOverride +import rocks.theodolite.kubernetes.operator.EventCreator +import rocks.theodolite.kubernetes.slo.AnalysisExecutor +import rocks.theodolite.kubernetes.patcher.PatcherDefinition import java.time.Duration import java.time.Instant private val logger = KotlinLogging.logger {} @RegisterForReflection -class BenchmarkExecutorImpl( - benchmark: Benchmark, +class ExperimentRunnerImpl( results: Results, - executionDuration: Duration, - configurationOverrides: List<ConfigurationOverride?>, - slos: List<Slo>, - repetitions: Int, - executionId: Int, - loadGenerationDelay: Long, - afterTeardownDelay: Long, - executionName: String, - loadPatcherDefinitions: List<PatcherDefinition>, - resourcePatcherDefinitions: List<PatcherDefinition> -) : BenchmarkExecutor( - benchmark, - results, - executionDuration, - configurationOverrides, - slos, - repetitions, - executionId, - loadGenerationDelay, - afterTeardownDelay, - executionName, - loadPatcherDefinitions, - resourcePatcherDefinitions + private val benchmarkDeploymentBuilder: BenchmarkDeploymentBuilder, + private val executionDuration: Duration, + private val configurationOverrides: List<ConfigurationOverride?>, + private val slos: List<Slo>, + private val repetitions: Int, + private val executionId: Int, + private val loadGenerationDelay: Long, + private val afterTeardownDelay: Long, + private val executionName: String, + private val loadPatcherDefinitions: List<PatcherDefinition>, + private val resourcePatcherDefinitions: List<PatcherDefinition>, + private val waitForResourcesEnabled: Boolean +) : ExperimentRunner( + results ) { private val eventCreator = EventCreator() private val mode = Configuration.EXECUTION_MODE @@ -79,14 +71,15 @@ class BenchmarkExecutorImpl( } private fun runSingleExperiment(load: Int, resource: Int): Pair<Instant, Instant> { - val benchmarkDeployment = benchmark.buildDeployment( + val benchmarkDeployment = benchmarkDeploymentBuilder.buildDeployment( load, this.loadPatcherDefinitions, resource, this.resourcePatcherDefinitions, this.configurationOverrides, this.loadGenerationDelay, - this.afterTeardownDelay + this.afterTeardownDelay, + this.waitForResourcesEnabled ) val from: Instant @@ -136,4 +129,25 @@ class BenchmarkExecutorImpl( } return Pair(from, to) } + + /** + * Wait while the benchmark is running and log the number of minutes executed every 1 minute. + */ + fun waitAndLog() { + logger.info { "Execution of a new experiment started." } + + var secondsRunning = 0L + + while (run.get() && secondsRunning < executionDuration.toSeconds()) { + secondsRunning++ + Thread.sleep(Duration.ofSeconds(1).toMillis()) + + if ((secondsRunning % 60) == 0L) { + logger.info { "Executed: ${secondsRunning / 60} minutes." } + } + } + + logger.debug { "Executor shutdown gracefully." } + + } } \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/FileSystemResourceSet.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/FileSystemResourceSet.kt similarity index 96% rename from theodolite/src/main/kotlin/theodolite/benchmark/FileSystemResourceSet.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/FileSystemResourceSet.kt index e95a637ab88f11902062de73b0c34603b08aded3..44dacc044e2af477814be0399d23a5b14818bcee 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/FileSystemResourceSet.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/FileSystemResourceSet.kt @@ -1,11 +1,10 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.util.DeploymentFailedException import java.io.BufferedReader import java.io.FileInputStream import java.io.FileNotFoundException diff --git a/theodolite/src/main/kotlin/theodolite/k8s/K8sContextFactory.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/K8sContextFactory.kt similarity index 96% rename from theodolite/src/main/kotlin/theodolite/k8s/K8sContextFactory.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/K8sContextFactory.kt index 38224f26a38a241e92b38e8b92a7fa5b4e198f5e..880449d1952247bd7bf1784e083acc14ee59fea5 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/K8sContextFactory.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/K8sContextFactory.kt @@ -1,4 +1,4 @@ -package theodolite.k8s +package rocks.theodolite.kubernetes import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext diff --git a/theodolite/src/main/kotlin/theodolite/k8s/K8sManager.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/K8sManager.kt similarity index 90% rename from theodolite/src/main/kotlin/theodolite/k8s/K8sManager.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/K8sManager.kt index 5b4880b45db76d9e68e87fda0ece5b04966439c8..66bfb2572bfcb5cb53d579a8af1c94c2b39bb532 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/K8sManager.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/K8sManager.kt @@ -1,9 +1,6 @@ -package theodolite.k8s +package rocks.theodolite.kubernetes -import io.fabric8.kubernetes.api.model.ConfigMap import io.fabric8.kubernetes.api.model.HasMetadata -import io.fabric8.kubernetes.api.model.KubernetesResource -import io.fabric8.kubernetes.api.model.Service import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.StatefulSet import io.fabric8.kubernetes.client.NamespacedKubernetesClient diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/KubernetesBenchmarkDeployment.kt similarity index 94% rename from theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/KubernetesBenchmarkDeployment.kt index 1d7b22233c084625cf16ca7194c76c14601bbaad..be567ccd8ec969a4964886e20f141fa4fad17b88 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/KubernetesBenchmarkDeployment.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.KubernetesResource @@ -6,10 +6,9 @@ import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.quarkus.runtime.annotations.RegisterForReflection import mu.KotlinLogging import org.apache.kafka.clients.admin.NewTopic -import theodolite.k8s.K8sManager -import theodolite.k8s.ResourceByLabelHandler -import theodolite.k8s.TopicManager -import theodolite.util.KafkaConfig +import rocks.theodolite.kubernetes.kafka.TopicManager +import rocks.theodolite.kubernetes.model.crd.KafkaConfig +import theodolite.benchmark.RolloutManager import java.time.Duration private val logger = KotlinLogging.logger {} @@ -42,6 +41,8 @@ class KubernetesBenchmarkDeployment( private val LAG_EXPORTER_POD_LABEL_NAME = "app.kubernetes.io/name" private val LAG_EXPORTER_POD_LABEL_VALUE = "kafka-exporter" + + /** * Setup a [KubernetesBenchmark] using the [TopicManager] and the [K8sManager]: * - Create the needed topics. diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/KubernetesBenchmarkDeploymentBuilder.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/KubernetesBenchmarkDeploymentBuilder.kt new file mode 100644 index 0000000000000000000000000000000000000000..67fe92afb8aa4c9edda2474fc6307c16c21a41f6 --- /dev/null +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/KubernetesBenchmarkDeploymentBuilder.kt @@ -0,0 +1,92 @@ +package rocks.theodolite.kubernetes + +import io.fabric8.kubernetes.api.model.HasMetadata +import io.fabric8.kubernetes.client.NamespacedKubernetesClient +import mu.KotlinLogging +import rocks.theodolite.kubernetes.model.KubernetesBenchmark +import rocks.theodolite.kubernetes.patcher.PatchHandler +import rocks.theodolite.kubernetes.util.ConfigurationOverride +import rocks.theodolite.kubernetes.patcher.PatcherDefinition + +private val logger = KotlinLogging.logger {} + +class KubernetesBenchmarkDeploymentBuilder (val kubernetesBenchmark: KubernetesBenchmark, + private var client: NamespacedKubernetesClient) + : BenchmarkDeploymentBuilder { + + + /** + * Builds a deployment. + * First loads all required resources and then patches them to the concrete load and resources for the experiment for the demand metric + * or loads all loads and then patches them to the concrete load and resources for the experiment. + * Afterwards patches additional configurations(cluster depending) into the resources (or loads). + * @param load concrete load that will be benchmarked in this experiment (demand metric), or scaled (capacity metric). + * @param resource concrete resource that will be scaled for this experiment (demand metric), or benchmarked (capacity metric). + * @param configurationOverrides + * @return a [BenchmarkDeployment] + */ + override fun buildDeployment( + load: Int, + loadPatcherDefinitions: List<PatcherDefinition>, + resource: Int, + resourcePatcherDefinitions: List<PatcherDefinition>, + configurationOverrides: List<ConfigurationOverride?>, + loadGenerationDelay: Long, + afterTeardownDelay: Long, + waitForResourcesEnabled: Boolean + ): BenchmarkDeployment { + logger.info { "Using ${this.client.namespace} as namespace." } + + val appResources = loadKubernetesResources(kubernetesBenchmark.sut.resources, this.client).toResourceMap() + val loadGenResources = loadKubernetesResources(kubernetesBenchmark.loadGenerator.resources, this.client).toResourceMap() + + // patch the load dimension the resources + loadPatcherDefinitions.forEach { patcherDefinition -> + loadGenResources[patcherDefinition.resource] = + PatchHandler.patchResource(loadGenResources, patcherDefinition, load.toString()) + } + resourcePatcherDefinitions.forEach { patcherDefinition -> + appResources[patcherDefinition.resource] = + PatchHandler.patchResource(appResources, patcherDefinition, resource.toString()) + } + + // Patch the given overrides + configurationOverrides.forEach { override -> + override?.let { + if (appResources.keys.contains(it.patcher.resource)) { + appResources[it.patcher.resource] = + PatchHandler.patchResource(appResources, override.patcher, override.value) + } else { + loadGenResources[it.patcher.resource] = + PatchHandler.patchResource(loadGenResources, override.patcher, override.value) + } + } + } + + val kafkaConfig = kubernetesBenchmark.kafkaConfig + + return KubernetesBenchmarkDeployment( + sutBeforeActions = kubernetesBenchmark.sut.beforeActions, + sutAfterActions = kubernetesBenchmark.sut.afterActions, + loadGenBeforeActions = kubernetesBenchmark.loadGenerator.beforeActions, + loadGenAfterActions = kubernetesBenchmark.loadGenerator.afterActions, + appResources = appResources.toList().flatMap { it.second }, + loadGenResources = loadGenResources.toList().flatMap { it.second }, + loadGenerationDelay = loadGenerationDelay, + afterTeardownDelay = afterTeardownDelay, + kafkaConfig = if (kafkaConfig != null) mapOf("bootstrap.servers" to kafkaConfig.bootstrapServer) else mapOf(), + topics = kafkaConfig?.topics ?: listOf(), + client = this.client, + rolloutMode = waitForResourcesEnabled + ) + } + +} + +private fun Collection<Pair<String, HasMetadata>>.toResourceMap(): MutableMap<String, List<HasMetadata>> { + return this.toMap() + .toMutableMap() + .map { Pair(it.key, listOf(it.value)) } + .toMap() + .toMutableMap() +} diff --git a/theodolite/src/main/kotlin/theodolite/execution/Main.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Main.kt similarity index 57% rename from theodolite/src/main/kotlin/theodolite/execution/Main.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Main.kt index 17b3d4e7b86f9e430abfb6093e79aa7865cd5923..cbd7c3106b39c4571d559d4071cd4ac16e180bc8 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/Main.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Main.kt @@ -1,9 +1,11 @@ -package theodolite.execution +package rocks.theodolite.kubernetes +import io.fabric8.kubernetes.client.DefaultKubernetesClient +import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.quarkus.runtime.annotations.QuarkusMain import mu.KotlinLogging -import theodolite.execution.operator.TheodoliteOperator -import theodolite.util.Configuration +import rocks.theodolite.kubernetes.operator.TheodoliteOperator +import rocks.theodolite.kubernetes.standalone.TheodoliteStandalone import kotlin.system.exitProcess private val logger = KotlinLogging.logger {} @@ -17,9 +19,12 @@ object Main { val mode = Configuration.EXECUTION_MODE logger.info { "Start Theodolite with mode $mode" } + val namespace = Configuration.NAMESPACE + val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace) + when (mode.lowercase()) { - ExecutionModes.STANDALONE.value -> TheodoliteStandalone().start() - ExecutionModes.OPERATOR.value -> TheodoliteOperator().start() + ExecutionModes.STANDALONE.value -> TheodoliteStandalone(client).start() + ExecutionModes.OPERATOR.value -> TheodoliteOperator(client).start() else -> { logger.error { "MODE $mode not found" } exitProcess(1) diff --git a/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ResourceByLabelHandler.kt similarity index 99% rename from theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ResourceByLabelHandler.kt index 518b8eae211dd064e3c12b0713382bf3b12bb1ba..c65235f5fef304a7644399573380b4147704cb6c 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ResourceByLabelHandler.kt @@ -1,4 +1,4 @@ -package theodolite.k8s +package rocks.theodolite.kubernetes import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSet.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ResourceSet.kt similarity index 92% rename from theodolite/src/main/kotlin/theodolite/benchmark/ResourceSet.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ResourceSet.kt index 19fc85845ae99c7a5e4f7369db4b6cd383c3131b..9910d0ac89a9b423047f4f20f07a8015cbb24f9a 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSet.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ResourceSet.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.api.model.KubernetesResource diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ResourceSets.kt similarity index 80% rename from theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ResourceSets.kt index 2ee8d8cf5c0e8590728bc253fd452fe8aa1d9d96..f57835a1e2459b0ce8989a4f1c745cc272e5f1e9 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/ResourceSets.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.annotation.JsonProperty @@ -7,7 +7,13 @@ import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.util.DeploymentFailedException + +/** + * Loads [KubernetesResource]s. + */ +fun loadKubernetesResources(resourceSet: List<ResourceSets>, client: NamespacedKubernetesClient): Collection<Pair<String, HasMetadata>> { + return resourceSet.flatMap { it.loadResourceSet(client) } +} @JsonDeserialize @RegisterForReflection @@ -20,8 +26,8 @@ class ResourceSets : KubernetesResource { @JsonInclude(JsonInclude.Include.NON_NULL) var fileSystem: FileSystemResourceSet? = null - fun loadResourceSet(client: NamespacedKubernetesClient): Collection<Pair<String, HasMetadata>> { + fun loadResourceSet(client: NamespacedKubernetesClient): Collection<Pair<String, HasMetadata>> { return if (this.configMap != null) { configMap?.getResourceSet(client = client)!! } else if (this.fileSystem != null) { diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/RolloutManager.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/RolloutManager.kt similarity index 95% rename from theodolite/src/main/kotlin/theodolite/benchmark/RolloutManager.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/RolloutManager.kt index f282fb27971218754a0e35801342efc83837b64b..f760bb407ec2a6c4ab2ee08d3521ad72d12dd25d 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/RolloutManager.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/RolloutManager.kt @@ -1,18 +1,15 @@ package theodolite.benchmark import io.fabric8.kubernetes.api.model.HasMetadata -import io.fabric8.kubernetes.api.model.Pod import io.fabric8.kubernetes.api.model.apps.DaemonSet import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.ReplicaSet import io.fabric8.kubernetes.api.model.apps.StatefulSet import io.fabric8.kubernetes.api.model.batch.v1.Job import io.fabric8.kubernetes.client.NamespacedKubernetesClient -import theodolite.k8s.K8sManager +import rocks.theodolite.kubernetes.K8sManager private var SLEEP_TIME_MS = 500L - - class RolloutManager(private val blockUntilResourcesReady: Boolean, private val client: NamespacedKubernetesClient) { fun rollout(resources: List<HasMetadata>) { diff --git a/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Shutdown.kt similarity index 67% rename from theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Shutdown.kt index cdfe68e7a93d64f2385bded31f94f77ab7b3be0e..e970c84d345031b79f8afeedf56591e071bb154f 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/Shutdown.kt @@ -1,8 +1,9 @@ -package theodolite.execution +package rocks.theodolite.kubernetes +import io.fabric8.kubernetes.client.NamespacedKubernetesClient import mu.KotlinLogging -import theodolite.benchmark.BenchmarkExecution -import theodolite.benchmark.KubernetesBenchmark +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.model.KubernetesBenchmark private val logger = KotlinLogging.logger {} @@ -12,7 +13,9 @@ private val logger = KotlinLogging.logger {} * @property benchmarkExecution * @property benchmark */ -class Shutdown(private val benchmarkExecution: BenchmarkExecution, private val benchmark: KubernetesBenchmark) { +class Shutdown(private val benchmarkExecution: BenchmarkExecution, + private val benchmark: KubernetesBenchmark, + private val client: NamespacedKubernetesClient) { /** * Run @@ -20,17 +23,19 @@ class Shutdown(private val benchmarkExecution: BenchmarkExecution, private val b */ fun run() { // Build Configuration to teardown + val benchmarkDeploymentBuilder = KubernetesBenchmarkDeploymentBuilder(benchmark, this.client) try { logger.info { "Received shutdown signal -> Shutting down" } val deployment = - benchmark.buildDeployment( + benchmarkDeploymentBuilder.buildDeployment( load = 0, loadPatcherDefinitions = emptyList(), resource = 0, resourcePatcherDefinitions = emptyList(), configurationOverrides = benchmarkExecution.configOverrides, loadGenerationDelay = 0L, - afterTeardownDelay = 5L + afterTeardownDelay = 5L, + waitForResourcesEnabled = benchmark.waitForResourcesEnabled ) deployment.teardown() logger.info { "Finished teardown of all benchmark resources." } diff --git a/theodolite/src/main/kotlin/theodolite/util/TheodoliteException.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/TheodoliteException.kt similarity index 72% rename from theodolite/src/main/kotlin/theodolite/util/TheodoliteException.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/TheodoliteException.kt index fc7453bae6aaa4c5c526eee72c006562ea887eb5..6a4374c3e3c9435c498c8e15e8c5efaa01fd89cd 100644 --- a/theodolite/src/main/kotlin/theodolite/util/TheodoliteException.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/TheodoliteException.kt @@ -1,3 +1,3 @@ -package theodolite.util +package rocks.theodolite.kubernetes open class TheodoliteException (message: String, e: Exception? = null) : Exception(message,e) \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/TheodoliteExecutor.kt similarity index 59% rename from theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/TheodoliteExecutor.kt index 82b406264fe7a07da1759936f4f2667150a7dee1..69615522ba9bbd5ef0944528eacbf1dce318caf9 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/TheodoliteExecutor.kt @@ -1,12 +1,18 @@ -package theodolite.execution +package rocks.theodolite.kubernetes +import io.fabric8.kubernetes.client.NamespacedKubernetesClient import mu.KotlinLogging -import theodolite.benchmark.BenchmarkExecution -import theodolite.benchmark.KubernetesBenchmark -import theodolite.patcher.PatcherDefinitionFactory -import theodolite.strategies.Metric -import theodolite.strategies.StrategyFactory -import theodolite.util.* +import rocks.theodolite.core.ExecutionRunner +import rocks.theodolite.core.ExperimentRunner +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.patcher.PatcherDefinitionFactory +import rocks.theodolite.core.strategies.Metric +import rocks.theodolite.core.strategies.StrategyFactory +import rocks.theodolite.core.Config +import rocks.theodolite.core.IOHandler +import rocks.theodolite.core.Results +import rocks.theodolite.kubernetes.model.KubernetesBenchmark +import rocks.theodolite.kubernetes.slo.SloFactory import java.io.File import java.time.Duration @@ -17,25 +23,26 @@ private val logger = KotlinLogging.logger {} * The Theodolite executor runs all the experiments defined with the given execution and benchmark configuration. * * @property benchmarkExecution Configuration of a execution - * @property kubernetesBenchmark Configuration of a benchmark + * @property benchmark Configuration of a benchmark * @constructor Create empty Theodolite executor */ class TheodoliteExecutor( - private val benchmarkExecution: BenchmarkExecution, - private val kubernetesBenchmark: KubernetesBenchmark + private val benchmarkExecution: BenchmarkExecution, + private val benchmark: KubernetesBenchmark, + private val client: NamespacedKubernetesClient ) { /** * An executor object, configured with the specified benchmark, evaluation method, experiment duration * and overrides which are given in the execution. */ - lateinit var executor: BenchmarkExecutor + lateinit var experimentRunner: ExperimentRunner /** * Creates all required components to start Theodolite. * * @return a [Config], that contains a list of LoadDimension s, * a list of Resource s , and the [restrictionSearch]. - * The [searchStrategy] is configured and able to find the minimum required resource for the given load. + * The [SearchStrategy] is configured and able to find the minimum required resource for the given load. */ private fun buildConfig(): Config { val results = Results(Metric.from(benchmarkExecution.execution.metric)) @@ -46,20 +53,20 @@ class TheodoliteExecutor( val resourcePatcherDefinition = PatcherDefinitionFactory().createPatcherDefinition( benchmarkExecution.resources.resourceType, - this.kubernetesBenchmark.resourceTypes + this.benchmark.resourceTypes ) val loadDimensionPatcherDefinition = PatcherDefinitionFactory().createPatcherDefinition( benchmarkExecution.loads.loadType, - this.kubernetesBenchmark.loadTypes + this.benchmark.loadTypes ) - val slos = SloFactory().createSlos(this.benchmarkExecution, this.kubernetesBenchmark) + val slos = SloFactory().createSlos(this.benchmarkExecution, this.benchmark) - executor = - BenchmarkExecutorImpl( - benchmark = kubernetesBenchmark, + experimentRunner = + ExperimentRunnerImpl( + benchmarkDeploymentBuilder = KubernetesBenchmarkDeploymentBuilder(this.benchmark,this.client), results = results, executionDuration = executionDuration, configurationOverrides = benchmarkExecution.configOverrides, @@ -70,83 +77,76 @@ class TheodoliteExecutor( afterTeardownDelay = benchmarkExecution.execution.afterTeardownDelay, executionName = benchmarkExecution.name, loadPatcherDefinitions = loadDimensionPatcherDefinition, - resourcePatcherDefinitions = resourcePatcherDefinition + resourcePatcherDefinitions = resourcePatcherDefinition, + waitForResourcesEnabled = this.benchmark.waitForResourcesEnabled ) if (benchmarkExecution.loads.loadValues != benchmarkExecution.loads.loadValues.sorted()) { benchmarkExecution.loads.loadValues = benchmarkExecution.loads.loadValues.sorted() logger.info { - "Load values are not sorted correctly. Theodolite sorts them in ascending order." + - "New order is: ${benchmarkExecution.loads.loadValues}." + "Load values are not sorted correctly, Theodolite sorts them in ascending order." + + "New order is: ${benchmarkExecution.loads.loadValues}" } } if (benchmarkExecution.resources.resourceValues != benchmarkExecution.resources.resourceValues.sorted()) { benchmarkExecution.resources.resourceValues = benchmarkExecution.resources.resourceValues.sorted() logger.info { - "Load values are not sorted correctly. Theodolite sorts them in ascending order." + - "New order is: ${benchmarkExecution.resources.resourceValues}." + "Load values are not sorted correctly, Theodolite sorts them in ascending order." + + "New order is: ${benchmarkExecution.resources.resourceValues}" } } return Config( loads = benchmarkExecution.loads.loadValues, - loadPatcherDefinitions = loadDimensionPatcherDefinition, resources = benchmarkExecution.resources.resourceValues, - resourcePatcherDefinitions = resourcePatcherDefinition, - searchStrategy = strategyFactory.createSearchStrategy(executor, benchmarkExecution.execution.strategy, results), + searchStrategy = strategyFactory.createSearchStrategy(experimentRunner, benchmarkExecution.execution.strategy.name, + benchmarkExecution.execution.strategy.searchStrategy, benchmarkExecution.execution.strategy.restrictions, + benchmarkExecution.execution.strategy.guessStrategy, results), metric = Metric.from(benchmarkExecution.execution.metric) ) } - fun getExecution(): BenchmarkExecution { - return this.benchmarkExecution - } - /** - * Run all experiments which are specified in the corresponding - * execution and benchmark objects. + * Sets up the Infrastructure, increments the executionId, calls the [ExecutionRunner] that runs + * all experiments which are specified in the corresponding execution and benchmark objects. */ - fun run() { - kubernetesBenchmark.setupInfrastructure() + fun setupAndRunExecution() { + setupInfrastructure() val ioHandler = IOHandler() val resultsFolder = ioHandler.getResultFolderURL() this.benchmarkExecution.executionId = getAndIncrementExecutionID(resultsFolder + "expID.txt") ioHandler.writeToJSONFile(this.benchmarkExecution, "${resultsFolder}exp${this.benchmarkExecution.executionId}-execution-configuration") ioHandler.writeToJSONFile( - kubernetesBenchmark, + benchmark, "${resultsFolder}exp${this.benchmarkExecution.executionId}-benchmark-configuration" ) val config = buildConfig() - //execute benchmarks for each load for the demand metric, or for each resource amount for capacity metric - try { - config.searchStrategy.applySearchStrategyByMetric(config.loads, config.resources, config.metric) + val executionRunner = ExecutionRunner(config.searchStrategy, config.resources, config.loads,config.metric, + this.benchmarkExecution.executionId) - } finally { - ioHandler.writeToJSONFile( - config.searchStrategy.benchmarkExecutor.results, - "${resultsFolder}exp${this.benchmarkExecution.executionId}-result" - ) - // Create expXYZ_demand.csv file or expXYZ_capacity.csv depending on metric - when(config.metric) { - Metric.DEMAND -> - ioHandler.writeToCSVFile( - "${resultsFolder}exp${this.benchmarkExecution.executionId}_demand", - calculateMetric(config.loads, config.searchStrategy.benchmarkExecutor.results), - listOf("load","resources") - ) - Metric.CAPACITY -> - ioHandler.writeToCSVFile( - "${resultsFolder}exp${this.benchmarkExecution.executionId}_capacity", - calculateMetric(config.resources, config.searchStrategy.benchmarkExecutor.results), - listOf("resource", "loads") - ) - } - } - kubernetesBenchmark.teardownInfrastructure() + executionRunner.run() + + teardownInfrastructure() + } + + private fun setupInfrastructure() { + benchmark.infrastructure.beforeActions.forEach { it.exec(client = client) } + val kubernetesManager = K8sManager(this.client) + loadKubernetesResources(benchmark.infrastructure.resources, this.client) + .map { it.second } + .forEach { kubernetesManager.deploy(it) } + } + + private fun teardownInfrastructure() { + val kubernetesManager = K8sManager(this.client) + loadKubernetesResources(benchmark.infrastructure.resources, this.client) + .map { it.second } + .forEach { kubernetesManager.remove(it) } + benchmark.infrastructure.afterActions.forEach { it.exec(client = client) } } private fun getAndIncrementExecutionID(fileURL: String): Int { @@ -163,4 +163,7 @@ class TheodoliteExecutor( return xValues.map { listOf(it.toString(), results.getOptYDimensionValue(it).toString()) } } + fun getExecution(): BenchmarkExecution { + return this.benchmarkExecution + } } diff --git a/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/kafka/TopicManager.kt similarity index 98% rename from theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/kafka/TopicManager.kt index ed1e06571d20c53fc82439833c8a31800a48b602..e9a0cb4b3c0863baf54a8dda58b96c81a80af60d 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/kafka/TopicManager.kt @@ -1,4 +1,4 @@ -package theodolite.k8s +package rocks.theodolite.kubernetes.kafka import mu.KotlinLogging import org.apache.kafka.clients.admin.AdminClient diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/BenchmarkExecution.kt similarity index 97% rename from theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/BenchmarkExecution.kt index 13c98d7013fc3c6f24066419604d42c576db2c94..167423ec911cd740b0ee0246e8512dde8402f1e9 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/BenchmarkExecution.kt @@ -1,9 +1,9 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes.model import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.api.model.KubernetesResource import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.util.ConfigurationOverride +import rocks.theodolite.kubernetes.util.ConfigurationOverride import kotlin.properties.Delegates /** diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/KubernetesBenchmark.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/KubernetesBenchmark.kt new file mode 100644 index 0000000000000000000000000000000000000000..9c1412af7e6a86fbb248e8be7d1a97259a59c8d0 --- /dev/null +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/KubernetesBenchmark.kt @@ -0,0 +1,77 @@ +package rocks.theodolite.kubernetes.model + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.fabric8.kubernetes.api.model.KubernetesResource +import io.quarkus.runtime.annotations.RegisterForReflection +import rocks.theodolite.kubernetes.Action +import rocks.theodolite.kubernetes.ResourceSets +import rocks.theodolite.kubernetes.model.crd.KafkaConfig +import rocks.theodolite.kubernetes.patcher.PatcherDefinition +import kotlin.properties.Delegates + +/** + * Represents a benchmark in Kubernetes. An example for this is the BenchmarkType.yaml + * Contains a of: + * - [name] of the benchmark, + * - [appResource] list of the resources that have to be deployed for the benchmark, + * - [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 [theodolite.k8s.TopicManager], + * - [namespace] for the client, + * - [path] under which the resource yamls can be found. + * + * This class is used for the parsing(in the [theodolite.execution.TheodoliteStandalone]) and + * for the deserializing in the [theodolite.execution.operator.TheodoliteOperator]. + * @constructor construct an empty Benchmark. + */ +@JsonDeserialize +@RegisterForReflection +class KubernetesBenchmark : KubernetesResource { + lateinit var name: String + var waitForResourcesEnabled = false + lateinit var resourceTypes: List<TypeName> + lateinit var loadTypes: List<TypeName> + lateinit var slos: MutableList<Slo> + var kafkaConfig: KafkaConfig? = null + lateinit var infrastructure: Resources + lateinit var sut: Resources + lateinit var loadGenerator: Resources + + /** + * The TypeName encapsulates a list of [PatcherDefinition] along with a typeName that specifies for what the [PatcherDefinition] should be used. + */ + @RegisterForReflection + @JsonDeserialize + class TypeName { + lateinit var typeName: String + lateinit var patchers: List<PatcherDefinition> + } + + /** + * Measurable metric. + * [sloType] determines the type of the metric. + * It is evaluated using the [theodolite.evaluation.ExternalSloChecker] by data measured by Prometheus. + * The evaluation checks if a [threshold] is reached or not. + * [offset] determines the shift in hours by which the start and end timestamps should be shifted. + * The [warmup] determines after which time the metric should be evaluated to avoid starting interferences. + * The [warmup] time unit depends on the Slo: for the lag trend it is in seconds. + */ + @JsonDeserialize + @RegisterForReflection + class Slo : KubernetesResource { + lateinit var name: String + lateinit var sloType: String + lateinit var prometheusUrl: String + var offset by Delegates.notNull<Int>() + lateinit var properties: MutableMap<String, String> + } + + @JsonDeserialize + @RegisterForReflection + class Resources { + lateinit var resources: List<ResourceSets> + lateinit var beforeActions: List<Action> + lateinit var afterActions: List<Action> + } +} diff --git a/theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkCRD.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkCRD.kt similarity index 86% rename from theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkCRD.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkCRD.kt index 0ec6decbdea5e192721a4f9b6d0d85ea65665a5a..f480177e4482ab48df01593fdc10ea459a87ca43 100644 --- a/theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkCRD.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkCRD.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.api.model.Namespaced @@ -6,7 +6,7 @@ import io.fabric8.kubernetes.client.CustomResource import io.fabric8.kubernetes.model.annotation.Group import io.fabric8.kubernetes.model.annotation.Kind import io.fabric8.kubernetes.model.annotation.Version -import theodolite.benchmark.KubernetesBenchmark +import rocks.theodolite.kubernetes.model.KubernetesBenchmark @JsonDeserialize @Version("v1") diff --git a/theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkExecutionList.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkExecutionList.kt similarity index 72% rename from theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkExecutionList.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkExecutionList.kt index 2b2dcc07f9c37f1712109e3d092f2db0c139e1c8..768cd7c4f7edf2f254905539214177638ad5283c 100644 --- a/theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkExecutionList.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkExecutionList.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import io.fabric8.kubernetes.client.CustomResourceList diff --git a/theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkState.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkState.kt similarity index 77% rename from theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkState.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkState.kt index dc2c6f9ba971367c0bb142a54745629eb29c07d5..928a411725f5eaf71839f4b7109b69ff40eb8807 100644 --- a/theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkState.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkState.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import com.fasterxml.jackson.annotation.JsonValue diff --git a/theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkStatus.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkStatus.kt similarity index 87% rename from theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkStatus.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkStatus.kt index d4a17dbefb6cf3a53d545c32cb18e1d9acd7067f..691e5e1a83da5ccb3897f0b6342ee78ce437ba6b 100644 --- a/theodolite/src/main/kotlin/theodolite/model/crd/BenchmarkStatus.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkStatus.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.api.model.KubernetesResource diff --git a/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionCRD.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionCRD.kt similarity index 86% rename from theodolite/src/main/kotlin/theodolite/model/crd/ExecutionCRD.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionCRD.kt index 3be0aaf2a30cd4ef279edd34854eb936cc6e7e7c..df7b0f0c1ca326db21885beb1c714060aa56b251 100644 --- a/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionCRD.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionCRD.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.api.model.Namespaced @@ -6,7 +6,7 @@ import io.fabric8.kubernetes.client.CustomResource import io.fabric8.kubernetes.model.annotation.Group import io.fabric8.kubernetes.model.annotation.Kind import io.fabric8.kubernetes.model.annotation.Version -import theodolite.benchmark.BenchmarkExecution +import rocks.theodolite.kubernetes.model.BenchmarkExecution @JsonDeserialize @Version("v1") diff --git a/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionState.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionState.kt similarity index 86% rename from theodolite/src/main/kotlin/theodolite/model/crd/ExecutionState.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionState.kt index 9ce38d9f56a968ccc408966e56609ee4f70570a4..d74d70eb8e91246946923532967534aa46b958f7 100644 --- a/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionState.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionState.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import com.fasterxml.jackson.annotation.JsonValue diff --git a/theodolite/src/main/kotlin/theodolite/util/ExecutionStateComparator.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStateComparator.kt similarity index 74% rename from theodolite/src/main/kotlin/theodolite/util/ExecutionStateComparator.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStateComparator.kt index 81bf350b58901bc10535f143d5ccdb295b5fe85f..9e859c3e943df4c72a2265941f14ea218b35ab12 100644 --- a/theodolite/src/main/kotlin/theodolite/util/ExecutionStateComparator.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStateComparator.kt @@ -1,7 +1,7 @@ -package theodolite.util +package rocks.theodolite.kubernetes.model.crd -import theodolite.model.crd.ExecutionCRD -import theodolite.model.crd.ExecutionState +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD +import rocks.theodolite.kubernetes.model.crd.ExecutionState class ExecutionStateComparator(private val preferredState: ExecutionState): Comparator<ExecutionCRD> { diff --git a/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionStatus.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStatus.kt similarity index 97% rename from theodolite/src/main/kotlin/theodolite/model/crd/ExecutionStatus.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStatus.kt index 1f843ccf9152676e778bc4ed359776e37205e998..6bec7197ddde61185ca37b3e0e96f471a910a0aa 100644 --- a/theodolite/src/main/kotlin/theodolite/model/crd/ExecutionStatus.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStatus.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.core.JsonGenerator diff --git a/theodolite/src/main/kotlin/theodolite/util/KafkaConfig.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/KafkaConfig.kt similarity index 92% rename from theodolite/src/main/kotlin/theodolite/util/KafkaConfig.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/KafkaConfig.kt index 4e72ccb0d86749a6538c26556241ac114ef8d9a4..adde94c5126e370816966e6991670b6d400ba79a 100644 --- a/theodolite/src/main/kotlin/theodolite/util/KafkaConfig.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/KafkaConfig.kt @@ -1,8 +1,8 @@ -package theodolite.util +package rocks.theodolite.kubernetes.model.crd import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.util.KafkaConfig.TopicWrapper +import rocks.theodolite.kubernetes.model.crd.KafkaConfig.TopicWrapper import kotlin.properties.Delegates import kotlin.reflect.KProperty diff --git a/theodolite/src/main/kotlin/theodolite/model/crd/KubernetesBenchmarkList.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/KubernetesBenchmarkList.kt similarity index 72% rename from theodolite/src/main/kotlin/theodolite/model/crd/KubernetesBenchmarkList.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/KubernetesBenchmarkList.kt index 8ad0a493d948bf5f78741052100766dcf6e316ec..be34662bd63b39808099a968ec4b89b5499ef34b 100644 --- a/theodolite/src/main/kotlin/theodolite/model/crd/KubernetesBenchmarkList.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/model/crd/KubernetesBenchmarkList.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import io.fabric8.kubernetes.client.CustomResourceList diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/AbstractStateHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/AbstractStateHandler.kt similarity index 98% rename from theodolite/src/main/kotlin/theodolite/execution/operator/AbstractStateHandler.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/AbstractStateHandler.kt index 84343ea7e8d7d420bcf320f36be02c39c41a1945..96593914cf07c427c924a1631a00f76dc3649ed3 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/AbstractStateHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/AbstractStateHandler.kt @@ -1,4 +1,4 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.KubernetesResourceList diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateChecker.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateChecker.kt similarity index 86% rename from theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateChecker.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateChecker.kt index c20b2ba87e386dc7c0a14245e03bedfb067720e6..90229d9533ea69116a460162b8b4046eb0b3aea6 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateChecker.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateChecker.kt @@ -1,22 +1,23 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator 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.dsl.MixedOperation import io.fabric8.kubernetes.client.dsl.Resource -import theodolite.benchmark.Action -import theodolite.benchmark.ActionSelector -import theodolite.benchmark.KubernetesBenchmark -import theodolite.benchmark.ResourceSets -import theodolite.model.crd.BenchmarkCRD -import theodolite.model.crd.BenchmarkState -import theodolite.model.crd.KubernetesBenchmarkList +import rocks.theodolite.kubernetes.Action +import rocks.theodolite.kubernetes.ActionSelector +import rocks.theodolite.kubernetes.model.KubernetesBenchmark +import rocks.theodolite.kubernetes.ResourceSets +import rocks.theodolite.kubernetes.model.crd.BenchmarkCRD +import rocks.theodolite.kubernetes.model.crd.BenchmarkState +import rocks.theodolite.kubernetes.model.crd.KubernetesBenchmarkList +import rocks.theodolite.kubernetes.loadKubernetesResources class BenchmarkStateChecker( - private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>, - private val benchmarkStateHandler: BenchmarkStateHandler, - private val client: NamespacedKubernetesClient + private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>, + private val benchmarkStateHandler: BenchmarkStateHandler, + private val client: NamespacedKubernetesClient, ) { @@ -129,7 +130,7 @@ class BenchmarkStateChecker( * @return true if the required resources are found, else false */ fun checkIfResourceIsInfrastructure(resourcesSets: List<ResourceSets>, selector: ActionSelector): Boolean { - val resources = resourcesSets.flatMap { it.loadResourceSet(this.client) } + val resources = loadKubernetesResources(resourcesSets, this.client) if (resources.isEmpty()) { return false } @@ -176,9 +177,9 @@ class BenchmarkStateChecker( fun checkResources(benchmark: KubernetesBenchmark): BenchmarkState { return try { val appResources = - benchmark.loadKubernetesResources(resourceSet = benchmark.sut.resources) + loadKubernetesResources(resourceSet = benchmark.sut.resources, this.client) val loadGenResources = - benchmark.loadKubernetesResources(resourceSet = benchmark.loadGenerator.resources) + loadKubernetesResources(resourceSet = benchmark.loadGenerator.resources, this.client) if (appResources.isNotEmpty() && loadGenResources.isNotEmpty()) { BenchmarkState.READY } else { @@ -188,6 +189,8 @@ class BenchmarkStateChecker( BenchmarkState.PENDING } } + + } private fun <K, V> Map<K, V>.containsMatchLabels(matchLabels: Map<V, V>): Boolean { diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateHandler.kt similarity index 80% rename from theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateHandler.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateHandler.kt index 3b46859737d86a34b58a5514c0ae31ae215b9c7d..9a272b43f911bf523adf7c64c5ab34793b7a7dc5 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateHandler.kt @@ -1,7 +1,9 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.client.NamespacedKubernetesClient -import theodolite.model.crd.* +import rocks.theodolite.kubernetes.model.crd.BenchmarkCRD +import rocks.theodolite.kubernetes.model.crd.BenchmarkState +import rocks.theodolite.kubernetes.model.crd.ExecutionState class BenchmarkStateHandler(val client: NamespacedKubernetesClient) : AbstractStateHandler<BenchmarkCRD>( diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ClusterSetup.kt similarity index 84% rename from theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ClusterSetup.kt index e67be01ea80178b6d6bfb01b32bfd28c111addb9..a84bacb8296d62b8d6863046561dc797443e6084 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ClusterSetup.kt @@ -1,21 +1,21 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.client.KubernetesClientException import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.dsl.MixedOperation import io.fabric8.kubernetes.client.dsl.Resource import mu.KotlinLogging -import theodolite.execution.Shutdown -import theodolite.k8s.K8sContextFactory -import theodolite.k8s.ResourceByLabelHandler -import theodolite.model.crd.* +import rocks.theodolite.kubernetes.K8sContextFactory +import rocks.theodolite.kubernetes.ResourceByLabelHandler +import rocks.theodolite.kubernetes.model.crd.* +import rocks.theodolite.kubernetes.Shutdown private val logger = KotlinLogging.logger {} class ClusterSetup( - private val executionCRDClient: MixedOperation<ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>>, - private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>, - private val client: NamespacedKubernetesClient + private val executionCRDClient: MixedOperation<ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>>, + private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>, + private val client: NamespacedKubernetesClient ) { private val serviceMonitorContext = K8sContextFactory().create( @@ -53,7 +53,7 @@ class ClusterSetup( if (benchmark != null) { execution.spec.name = execution.metadata.name benchmark.spec.name = benchmark.metadata.name - Shutdown(execution.spec, benchmark.spec).run() + Shutdown(execution.spec, benchmark.spec, client).run() } else { throw IllegalStateException("Execution with state ${ExecutionState.RUNNING.value} was found, but no corresponding benchmark. " + "Could not initialize cluster.") diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/EventCreator.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/EventCreator.kt similarity index 83% rename from theodolite/src/main/kotlin/theodolite/execution/operator/EventCreator.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/EventCreator.kt index fab098ebd5fe765a455d787ddb7fcbfbb6c9ffc7..6803da62f045efcaf1b5504a33b42b2200d16baa 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/EventCreator.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/EventCreator.kt @@ -1,4 +1,4 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.api.model.EventBuilder import io.fabric8.kubernetes.api.model.EventSource @@ -6,14 +6,14 @@ import io.fabric8.kubernetes.api.model.ObjectReference import io.fabric8.kubernetes.client.DefaultKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient import mu.KotlinLogging -import theodolite.util.Configuration +import rocks.theodolite.kubernetes.Configuration import java.time.Instant import java.util.* import kotlin.NoSuchElementException private val logger = KotlinLogging.logger {} class EventCreator { - val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(Configuration.NAMESPACE) + private val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(Configuration.NAMESPACE) fun createEvent(executionName: String, type: String, message: String, reason: String) { val uuid = UUID.randomUUID().toString() @@ -34,15 +34,15 @@ class EventCreator { event.source = source event.involvedObject = objectRef - client.v1().events().inNamespace(Configuration.NAMESPACE).createOrReplace(event) + this.client.v1().events().inNamespace(Configuration.NAMESPACE).createOrReplace(event) } catch (e: NoSuchElementException) { logger.warn {"Could not create event: type: $type, message: $message, reason: $reason, no corresponding execution found."} } } private fun buildObjectReference(executionName: String): ObjectReference { - val exec = TheodoliteOperator() - .getExecutionClient(client = client) + val exec = TheodoliteOperator(this.client) + .getExecutionClient() .list() .items .first{it.metadata.name == executionName} diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandler.kt similarity index 91% rename from theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandler.kt index 25c627a350e3939530c4b453ec6db846b546cc08..58120d25d7e26daab015c01fece85cf72344bffa 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionEventHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandler.kt @@ -1,11 +1,12 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import com.google.gson.Gson import com.google.gson.GsonBuilder import io.fabric8.kubernetes.client.informers.ResourceEventHandler import mu.KotlinLogging -import theodolite.benchmark.BenchmarkExecution -import theodolite.model.crd.* +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD +import rocks.theodolite.kubernetes.model.crd.ExecutionState private val logger = KotlinLogging.logger {} @@ -18,8 +19,8 @@ private val logger = KotlinLogging.logger {} * @see BenchmarkExecution */ class ExecutionEventHandler( - private val controller: TheodoliteController, - private val stateHandler: ExecutionStateHandler + private val controller: TheodoliteController, + private val stateHandler: ExecutionStateHandler ) : ResourceEventHandler<ExecutionCRD> { private val gson: Gson = GsonBuilder().enableComplexMapKeySerialization().create() diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionStateHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionStateHandler.kt similarity index 92% rename from theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionStateHandler.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionStateHandler.kt index 340044e5be954d4d7673120e5bf2cba5aed02d92..6264b574d2be297865fab3b2a4d020bc57c56678 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/ExecutionStateHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/ExecutionStateHandler.kt @@ -1,9 +1,9 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.api.model.MicroTime import io.fabric8.kubernetes.client.NamespacedKubernetesClient -import theodolite.model.crd.ExecutionCRD -import theodolite.model.crd.ExecutionState +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD +import rocks.theodolite.kubernetes.model.crd.ExecutionState import java.lang.Thread.sleep import java.time.Instant import java.util.concurrent.atomic.AtomicBoolean diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/LeaderElector.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/LeaderElector.kt similarity index 97% rename from theodolite/src/main/kotlin/theodolite/execution/operator/LeaderElector.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/LeaderElector.kt index 558d06ce03074c38741b6c0a72c6ffa6eff96019..8a713d040e931a0e60266059c4faa44fdf5bddbc 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/LeaderElector.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/LeaderElector.kt @@ -1,4 +1,4 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.client.DefaultKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/StateHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/StateHandler.kt similarity index 90% rename from theodolite/src/main/kotlin/theodolite/execution/operator/StateHandler.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/StateHandler.kt index 28563ac5a640d0226224b812a8e0691cde83942a..eaa3b39ec1391cb1e27573dfc85345add4c32330 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/StateHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/StateHandler.kt @@ -1,4 +1,4 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator private const val MAX_RETRIES: Int = 5 diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteController.kt similarity index 69% rename from theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteController.kt index d9cb33b189da02b807301dde8550f2ae532d7e5a..9fdc409e159791f30b62f899e0f4d7aa7bcab319 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteController.kt @@ -1,21 +1,26 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator +import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.dsl.MixedOperation import io.fabric8.kubernetes.client.dsl.Resource import mu.KotlinLogging -import theodolite.benchmark.BenchmarkExecution -import theodolite.benchmark.KubernetesBenchmark -import theodolite.execution.TheodoliteExecutor -import theodolite.model.crd.* -import theodolite.patcher.ConfigOverrideModifier -import theodolite.util.ExecutionStateComparator +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.model.crd.BenchmarkCRD +import rocks.theodolite.kubernetes.model.crd.ExecutionState +import rocks.theodolite.kubernetes.model.crd.KubernetesBenchmarkList +import rocks.theodolite.kubernetes.model.KubernetesBenchmark +import rocks.theodolite.kubernetes.TheodoliteExecutor +import rocks.theodolite.kubernetes.model.crd.* +import rocks.theodolite.kubernetes.patcher.ConfigOverrideModifier +import rocks.theodolite.kubernetes.model.crd.ExecutionStateComparator +import rocks.theodolite.kubernetes.loadKubernetesResources import java.lang.Thread.sleep private val logger = KotlinLogging.logger {} const val DEPLOYED_FOR_EXECUTION_LABEL_NAME = "deployed-for-execution" const val DEPLOYED_FOR_BENCHMARK_LABEL_NAME = "deployed-for-benchmark" const val CREATED_BY_LABEL_NAME = "app.kubernetes.io/created-by" -const val CREATED_BY_LABEL_VALUE = "theodolite" +const val CREATED_BY_LABEL_VALUE = "rocks/theodolite" /** * The controller implementation for Theodolite. @@ -25,10 +30,12 @@ const val CREATED_BY_LABEL_VALUE = "theodolite" */ class TheodoliteController( - private val executionCRDClient: MixedOperation<ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>>, - private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>, - private val executionStateHandler: ExecutionStateHandler, - private val benchmarkStateChecker: BenchmarkStateChecker + private val client: NamespacedKubernetesClient, + private val executionCRDClient: MixedOperation<ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>>, + private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>, + private val executionStateHandler: ExecutionStateHandler, + private val benchmarkStateChecker: BenchmarkStateChecker, + ) { lateinit var executor: TheodoliteExecutor @@ -68,28 +75,28 @@ class TheodoliteController( private fun runExecution(execution: BenchmarkExecution, benchmark: KubernetesBenchmark) { try { val modifier = ConfigOverrideModifier( - execution = execution, - resources = benchmark.loadKubernetesResources(benchmark.sut.resources).map { it.first } - + benchmark.loadKubernetesResources(benchmark.loadGenerator.resources).map { it.first } - ) - modifier.setAdditionalLabels( - labelValue = execution.name, - labelName = DEPLOYED_FOR_EXECUTION_LABEL_NAME - ) - modifier.setAdditionalLabels( - labelValue = benchmark.name, - labelName = DEPLOYED_FOR_BENCHMARK_LABEL_NAME - ) - modifier.setAdditionalLabels( - labelValue = CREATED_BY_LABEL_VALUE, - labelName = CREATED_BY_LABEL_NAME - ) + execution = execution, + resources = loadKubernetesResources(benchmark.sut.resources, this.client).map { it.first } + + loadKubernetesResources(benchmark.loadGenerator.resources, this.client).map { it.first } + ) + modifier.setAdditionalLabels( + labelValue = execution.name, + labelName = DEPLOYED_FOR_EXECUTION_LABEL_NAME + ) + modifier.setAdditionalLabels( + labelValue = benchmark.name, + labelName = DEPLOYED_FOR_BENCHMARK_LABEL_NAME + ) + modifier.setAdditionalLabels( + labelValue = CREATED_BY_LABEL_VALUE, + labelName = CREATED_BY_LABEL_NAME + ) - executionStateHandler.setExecutionState(execution.name, ExecutionState.RUNNING) - executionStateHandler.startDurationStateTimer(execution.name) + executionStateHandler.setExecutionState(execution.name, ExecutionState.RUNNING) + executionStateHandler.startDurationStateTimer(execution.name) - executor = TheodoliteExecutor(execution, benchmark) - executor.run() + executor = TheodoliteExecutor(execution, benchmark, this.client) + executor.setupAndRunExecution() when (executionStateHandler.getExecutionState(execution.name)) { ExecutionState.RESTART -> runExecution(execution, benchmark) ExecutionState.RUNNING -> { @@ -119,7 +126,7 @@ class TheodoliteController( if (restart) { executionStateHandler.setExecutionState(this.executor.getExecution().name, ExecutionState.RESTART) } - this.executor.executor.run.set(false) + this.executor.experimentRunner.run.set(false) } /** diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteOperator.kt similarity index 62% rename from theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteOperator.kt index ada30ec945dd602dabe3ddb5f0e635a4eeea7b5f..bdaa2692d374b4002a1f890f706e2c1ec0d8733c 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/operator/TheodoliteOperator.kt @@ -1,20 +1,18 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator -import io.fabric8.kubernetes.client.DefaultKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.dsl.MixedOperation import io.fabric8.kubernetes.client.dsl.Resource import io.fabric8.kubernetes.client.informers.SharedInformerFactory import io.fabric8.kubernetes.internal.KubernetesDeserializer import mu.KotlinLogging -import theodolite.model.crd.BenchmarkCRD -import theodolite.model.crd.BenchmarkExecutionList -import theodolite.model.crd.ExecutionCRD -import theodolite.model.crd.KubernetesBenchmarkList -import theodolite.util.Configuration +import rocks.theodolite.kubernetes.Configuration +import rocks.theodolite.kubernetes.model.crd.BenchmarkCRD +import rocks.theodolite.kubernetes.model.crd.BenchmarkExecutionList +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD +import rocks.theodolite.kubernetes.model.crd.KubernetesBenchmarkList -private const val DEFAULT_NAMESPACE = "default" private const val EXECUTION_SINGULAR = "execution" private const val BENCHMARK_SINGULAR = "benchmark" private const val API_VERSION = "v1" @@ -27,10 +25,7 @@ private val logger = KotlinLogging.logger {} * * **See Also:** [Kubernetes Operator Pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) */ -class TheodoliteOperator { - private val namespace = Configuration.NAMESPACE - - private val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace) +class TheodoliteOperator(private val client: NamespacedKubernetesClient) { private lateinit var controller: TheodoliteController private lateinit var executionStateHandler: ExecutionStateHandler private lateinit var benchmarkStateHandler: BenchmarkStateHandler @@ -39,7 +34,7 @@ class TheodoliteOperator { fun start() { LeaderElector( - client = client, + client = this.client, name = Configuration.COMPONENT_NAME ).getLeadership(::startOperator) } @@ -48,7 +43,7 @@ class TheodoliteOperator { * Start the operator. */ private fun startOperator() { - logger.info { "Becoming the leading operator. Use namespace '$namespace'." } + logger.info { "Becoming the leading operator. Use namespace '${this.client.namespace}'." } client.use { KubernetesDeserializer.registerCustomKind( "$GROUP/$API_VERSION", @@ -63,28 +58,26 @@ class TheodoliteOperator { ) ClusterSetup( - executionCRDClient = getExecutionClient(client), - benchmarkCRDClient = getBenchmarkClient(client), - client = client + executionCRDClient = getExecutionClient(), + benchmarkCRDClient = getBenchmarkClient(), + client = this.client ).clearClusterState() controller = getController( - client = client, - executionStateHandler = getExecutionStateHandler(client = client), - benchmarkStateChecker = getBenchmarkStateChecker(client = client) + executionStateHandler = getExecutionStateHandler(), + benchmarkStateChecker = getBenchmarkStateChecker() ) - getExecutionEventHandler(controller, client).startAllRegisteredInformers() + getExecutionEventHandler(controller).startAllRegisteredInformers() controller.run() } } - fun getExecutionEventHandler( - controller: TheodoliteController, - client: NamespacedKubernetesClient + private fun getExecutionEventHandler( + controller: TheodoliteController, ): SharedInformerFactory { - val factory = client.informers() - .inNamespace(client.namespace) + val factory = this.client.informers() + .inNamespace(this.client.namespace) factory.sharedIndexInformerForCustomResource( ExecutionCRD::class.java, @@ -92,46 +85,46 @@ class TheodoliteOperator { ).addEventHandler( ExecutionEventHandler( controller = controller, - stateHandler = ExecutionStateHandler(client) + stateHandler = ExecutionStateHandler(this.client) ) ) return factory } - fun getExecutionStateHandler(client: NamespacedKubernetesClient): ExecutionStateHandler { + fun getExecutionStateHandler(): ExecutionStateHandler { if (!::executionStateHandler.isInitialized) { - this.executionStateHandler = ExecutionStateHandler(client = client) + this.executionStateHandler = ExecutionStateHandler(client = this.client) } return executionStateHandler } - fun getBenchmarkStateHandler(client: NamespacedKubernetesClient) : BenchmarkStateHandler { + fun getBenchmarkStateHandler() : BenchmarkStateHandler { if (!::benchmarkStateHandler.isInitialized) { - this.benchmarkStateHandler = BenchmarkStateHandler(client = client) + this.benchmarkStateHandler = BenchmarkStateHandler(client = this.client) } return benchmarkStateHandler } - fun getBenchmarkStateChecker(client: NamespacedKubernetesClient) : BenchmarkStateChecker { + fun getBenchmarkStateChecker() : BenchmarkStateChecker { if (!::benchmarkStateChecker.isInitialized) { this.benchmarkStateChecker = BenchmarkStateChecker( - client = client, - benchmarkStateHandler = getBenchmarkStateHandler(client = client), - benchmarkCRDClient = getBenchmarkClient(client = client)) + client = this.client, + benchmarkStateHandler = getBenchmarkStateHandler(), + benchmarkCRDClient = getBenchmarkClient()) } return benchmarkStateChecker } fun getController( - client: NamespacedKubernetesClient, - executionStateHandler: ExecutionStateHandler, - benchmarkStateChecker: BenchmarkStateChecker + executionStateHandler: ExecutionStateHandler, + benchmarkStateChecker: BenchmarkStateChecker ): TheodoliteController { if (!::controller.isInitialized) { this.controller = TheodoliteController( - benchmarkCRDClient = getBenchmarkClient(client), - executionCRDClient = getExecutionClient(client), + client = this.client, + benchmarkCRDClient = getBenchmarkClient(), + executionCRDClient = getExecutionClient(), executionStateHandler = executionStateHandler, benchmarkStateChecker = benchmarkStateChecker ) @@ -139,21 +132,21 @@ class TheodoliteOperator { return this.controller } - fun getExecutionClient(client: NamespacedKubernetesClient): MixedOperation< + fun getExecutionClient(): MixedOperation< ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>> { - return client.customResources( + return this.client.customResources( ExecutionCRD::class.java, BenchmarkExecutionList::class.java ) } - fun getBenchmarkClient(client: NamespacedKubernetesClient): MixedOperation< + fun getBenchmarkClient(): MixedOperation< BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>> { - return client.customResources( + return this.client.customResources( BenchmarkCRD::class.java, KubernetesBenchmarkList::class.java ) diff --git a/theodolite/src/main/kotlin/theodolite/patcher/AbstractPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcher.kt similarity index 95% rename from theodolite/src/main/kotlin/theodolite/patcher/AbstractPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcher.kt index fbbb7fa1d2ea9fd67732ea5b84f29012c5708136..a20a26b351e730de60497ac014b3aba855ac01f5 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/AbstractPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.client.utils.Serialization diff --git a/theodolite/src/main/kotlin/theodolite/patcher/ConfigOverrideModifier.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ConfigOverrideModifier.kt similarity index 89% rename from theodolite/src/main/kotlin/theodolite/patcher/ConfigOverrideModifier.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ConfigOverrideModifier.kt index 8f77b1b95f3bf5cc9422cda55cb261048cebaeb6..c45808b5a81e5ffdfa5fd09b263ae49312a8d7fa 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/ConfigOverrideModifier.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ConfigOverrideModifier.kt @@ -1,8 +1,7 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher -import theodolite.benchmark.BenchmarkExecution -import theodolite.util.ConfigurationOverride -import theodolite.util.PatcherDefinition +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.util.ConfigurationOverride /** * The ConfigOverrideModifier makes it possible to update the configuration overrides of an execution. diff --git a/theodolite/src/main/kotlin/theodolite/patcher/DataVolumeLoadGeneratorReplicaPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/DataVolumeLoadGeneratorReplicaPatcher.kt similarity index 97% rename from theodolite/src/main/kotlin/theodolite/patcher/DataVolumeLoadGeneratorReplicaPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/DataVolumeLoadGeneratorReplicaPatcher.kt index db019282fd14c8a7aaa6eba7cd3969ba42da8023..d884c9ee1b6925bc985ad1da69a46f6589917b01 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/DataVolumeLoadGeneratorReplicaPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/DataVolumeLoadGeneratorReplicaPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata diff --git a/theodolite/src/main/kotlin/theodolite/patcher/EnvVarPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/EnvVarPatcher.kt similarity index 97% rename from theodolite/src/main/kotlin/theodolite/patcher/EnvVarPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/EnvVarPatcher.kt index ee95871211145e740a64e711996b85af98ee2151..33d6c8d9b6f5f82a49e7cd414e4b273708c0e68a 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/EnvVarPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/EnvVarPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.Container import io.fabric8.kubernetes.api.model.EnvVar diff --git a/theodolite/src/main/kotlin/theodolite/patcher/ImagePatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcher.kt similarity index 96% rename from theodolite/src/main/kotlin/theodolite/patcher/ImagePatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcher.kt index 2918c825931eb0bb4ca8ad176224e79815272b67..7f54416501bc742499a958566a179b7fad320318 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/ImagePatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/InvalidPatcherConfigurationException.kt similarity index 53% rename from theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/InvalidPatcherConfigurationException.kt index d02948ad341207051c4653ba9400ac0ffe5b03aa..88ad707ec48b0c2c2b3a62cc46f004ced64dbb69 100644 --- a/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/InvalidPatcherConfigurationException.kt @@ -1,3 +1,5 @@ -package theodolite.util +package rocks.theodolite.kubernetes.patcher + +import rocks.theodolite.kubernetes.DeploymentFailedException class InvalidPatcherConfigurationException(message: String, e: Exception? = null) : DeploymentFailedException(message,e) diff --git a/theodolite/src/main/kotlin/theodolite/patcher/LabelPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/LabelPatcher.kt similarity index 97% rename from theodolite/src/main/kotlin/theodolite/patcher/LabelPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/LabelPatcher.kt index 9a98f9689e28d77d3e7eea5974eff29ab4bbe0f8..8bb5be97e780479884e6cb8e551c03340b04f8e6 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/LabelPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/LabelPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.ConfigMap import io.fabric8.kubernetes.api.model.GenericKubernetesResource diff --git a/theodolite/src/main/kotlin/theodolite/patcher/MatchLabelPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/MatchLabelPatcher.kt similarity index 96% rename from theodolite/src/main/kotlin/theodolite/patcher/MatchLabelPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/MatchLabelPatcher.kt index 693d751f275d3666b5e360766eb449b8f6b639c3..725c9cf8a6a87c23119812c0a5d5ad3280a42e3c 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/MatchLabelPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/MatchLabelPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/main/kotlin/theodolite/patcher/NamePatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NamePatcher.kt similarity index 96% rename from theodolite/src/main/kotlin/theodolite/patcher/NamePatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NamePatcher.kt index 74fae390145a10d487b9c39628e67965999593e4..a6416a7e77841fa869de7ce2c248882fb486572c 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/NamePatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NamePatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.ConfigMap import io.fabric8.kubernetes.api.model.GenericKubernetesResource diff --git a/theodolite/src/main/kotlin/theodolite/patcher/NodeSelectorPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NodeSelectorPatcher.kt similarity index 93% rename from theodolite/src/main/kotlin/theodolite/patcher/NodeSelectorPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NodeSelectorPatcher.kt index b608d3b10440a19998f81776642562d337a4642a..c3b5ba1a07afa41dd604f2335baf6b58e362f293 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/NodeSelectorPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NodeSelectorPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt similarity index 94% rename from theodolite/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt index deee1b6efebe98f52e2d19c5cbe2e4c68174ed8f..e3b0105768ec339758fd89233a09da233145d641 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt similarity index 93% rename from theodolite/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt index 8463d672687aa9594e2ef168d53e6d7551bc0d4a..6bb2750bb1ca923aa05022884ef7054772a987c6 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/main/kotlin/theodolite/patcher/PatchHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatchHandler.kt similarity index 86% rename from theodolite/src/main/kotlin/theodolite/patcher/PatchHandler.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatchHandler.kt index 73f2f2435b42c59a1b0a294c67bbd0c726ffc209..6873d9ec84cd02b85b2342bbd37d429c706a47ab 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/PatchHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatchHandler.kt @@ -1,19 +1,13 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata -import theodolite.util.InvalidPatcherConfigurationException -import theodolite.util.PatcherDefinition - class PatchHandler { - companion object { - private fun getResourcesToPatch(resources: MutableMap<String, List<HasMetadata>>, patcherDefinition: PatcherDefinition): List<HasMetadata> { return resources[patcherDefinition.resource] ?: throw InvalidPatcherConfigurationException("Could not find resource ${patcherDefinition.resource}") } - fun patchResource( resources: MutableMap<String, List<HasMetadata>>, patcherDefinition: PatcherDefinition, diff --git a/theodolite/src/main/kotlin/theodolite/patcher/Patcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/Patcher.kt similarity index 92% rename from theodolite/src/main/kotlin/theodolite/patcher/Patcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/Patcher.kt index 72fe6a1f02e7f1767176fd965740c80f1437f6c1..310b370b97d065fc1ea0c3f7edd81577816ff69c 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/Patcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/Patcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.quarkus.runtime.annotations.RegisterForReflection diff --git a/theodolite/src/main/kotlin/theodolite/util/PatcherDefinition.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherDefinition.kt similarity index 93% rename from theodolite/src/main/kotlin/theodolite/util/PatcherDefinition.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherDefinition.kt index fd2ac209a52e0d516ffa9ec07e465fa076ae665a..653ed9e03caf86c661e6a52ed59501b478eea7b5 100644 --- a/theodolite/src/main/kotlin/theodolite/util/PatcherDefinition.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherDefinition.kt @@ -1,4 +1,4 @@ -package theodolite.util +package rocks.theodolite.kubernetes.patcher import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize diff --git a/theodolite/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherDefinitionFactory.kt similarity index 83% rename from theodolite/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherDefinitionFactory.kt index 6a1f993e2ac327ec242a8a5bafc3e6cc43475710..be9dcd11b08edf58462f0a1e71c7c3ab548fa66a 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherDefinitionFactory.kt @@ -1,7 +1,6 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher -import theodolite.util.PatcherDefinition -import theodolite.util.TypeName +import rocks.theodolite.kubernetes.model.KubernetesBenchmark /** * The PatcherDefinition Factory creates a [PatcherDefinition]s. @@ -20,7 +19,7 @@ class PatcherDefinitionFactory { * @return A list of PatcherDefinitions which corresponds to the * value of the requiredType. */ - fun createPatcherDefinition(requiredType: String, patcherTypes: List<TypeName>): List<PatcherDefinition> { + fun createPatcherDefinition(requiredType: String, patcherTypes: List<KubernetesBenchmark.TypeName>): List<PatcherDefinition> { 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/rocks/theodolite/kubernetes/patcher/PatcherFactory.kt similarity index 95% rename from theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherFactory.kt index 85848a48450637863363a366a1a1767c2c5af565..a4dcf68d2b4ec12facb26755e9f63e298725e195 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherFactory.kt @@ -1,7 +1,4 @@ -package theodolite.patcher - -import theodolite.util.InvalidPatcherConfigurationException -import theodolite.util.PatcherDefinition +package rocks.theodolite.kubernetes.patcher /** * The Patcher factory creates [Patcher]s @@ -76,7 +73,7 @@ class PatcherFactory { "ServiceSelectorPatcher" -> ServiceSelectorPatcher( variableName = patcherDefinition.properties["label"]!! ) - "theodolite.patcher.VolumesConfigMapPatcher" -> VolumesConfigMapPatcher( + "rocks.theodolite.kubernetes.patcher.VolumesConfigMapPatcher" -> VolumesConfigMapPatcher( volumeName = patcherDefinition.properties["volumeName"]!! ) else -> throw InvalidPatcherConfigurationException("Patcher type ${patcherDefinition.type} not found.") diff --git a/theodolite/src/main/kotlin/theodolite/patcher/ReplicaPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ReplicaPatcher.kt similarity index 91% rename from theodolite/src/main/kotlin/theodolite/patcher/ReplicaPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ReplicaPatcher.kt index 837bebf9da968d9afd7da6846575c9f1f457a3e3..8637b1299e878c4424e7fcaf4eac3bc901428541 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/ReplicaPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ReplicaPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ResourceLimitPatcher.kt similarity index 95% rename from theodolite/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ResourceLimitPatcher.kt index 8b75d43bfc5b589c8c65a1016058a5b850ac9063..7450e2edfa20f570742fe0336d0d27c76ec83aa2 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ResourceLimitPatcher.kt @@ -1,9 +1,8 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.* import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.StatefulSet -import theodolite.util.InvalidPatcherConfigurationException /** * The Resource limit [Patcher] set resource limits for deployments and statefulSets. diff --git a/theodolite/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ResourceRequestPatcher.kt similarity index 95% rename from theodolite/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ResourceRequestPatcher.kt index f63386e5565d053bf276ccada628c3a1676c7c68..bdcdc9527e8fa4dad9f85917be7d5c1c2fe67c2e 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ResourceRequestPatcher.kt @@ -1,9 +1,8 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.* import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.StatefulSet -import theodolite.util.InvalidPatcherConfigurationException /** * The Resource request [Patcher] set resource limits for deployments and statefulSets. diff --git a/theodolite/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/SchedulerNamePatcher.kt similarity index 92% rename from theodolite/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/SchedulerNamePatcher.kt index fc6a2864b1cc9495336a2e4756da97b2bd498dc3..c5ac16cdfe25f6b2fd2e4d0a2fb27000f885ffe7 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/SchedulerNamePatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/main/kotlin/theodolite/patcher/ServiceSelectorPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ServiceSelectorPatcher.kt similarity index 92% rename from theodolite/src/main/kotlin/theodolite/patcher/ServiceSelectorPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ServiceSelectorPatcher.kt index 3d94e283902b9879225ca4b8730730697ebe02a7..b38ae4108748f85e7ac60f3ee3aa8c5d28281432 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/ServiceSelectorPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ServiceSelectorPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.Service diff --git a/theodolite/src/main/kotlin/theodolite/patcher/TemplateLabelPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/TemplateLabelPatcher.kt similarity index 96% rename from theodolite/src/main/kotlin/theodolite/patcher/TemplateLabelPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/TemplateLabelPatcher.kt index 2707d98e046ce9aef01285d9febc7ab3b6d4c45d..534809cf8c36fb2065cbe3c0823294b346ac05f6 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/TemplateLabelPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/TemplateLabelPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/main/kotlin/theodolite/patcher/VolumesConfigMapPatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/VolumesConfigMapPatcher.kt similarity index 97% rename from theodolite/src/main/kotlin/theodolite/patcher/VolumesConfigMapPatcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/VolumesConfigMapPatcher.kt index 17068c7e7f206b1bbed4530c2008b60d3aaf593e..54a459a19b35e74839de647761e8ac22f839ca2d 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/VolumesConfigMapPatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/VolumesConfigMapPatcher.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/AnalysisExecutor.kt similarity index 93% rename from theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/AnalysisExecutor.kt index 7948058f0716a29712c360b5f90362dcedce2d7f..de57254167fc0a4b6c8ad707e647cad956daa7d2 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/AnalysisExecutor.kt @@ -1,9 +1,8 @@ -package theodolite.evaluation +package rocks.theodolite.kubernetes.slo -import theodolite.benchmark.Slo -import theodolite.strategies.Metric -import theodolite.util.EvaluationFailedException -import theodolite.util.IOHandler +import rocks.theodolite.core.strategies.Metric +import rocks.theodolite.core.IOHandler +import rocks.theodolite.kubernetes.model.KubernetesBenchmark.Slo import java.text.Normalizer import java.time.Duration import java.time.Instant diff --git a/theodolite/src/main/kotlin/theodolite/util/EvaluationFailedException.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/EvaluationFailedException.kt similarity index 52% rename from theodolite/src/main/kotlin/theodolite/util/EvaluationFailedException.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/EvaluationFailedException.kt index ebdf5a37b4e82c8d4b1870d065f5e77133154735..564ec926aeba501c55675ba3d25cfa8ebf50b68b 100644 --- a/theodolite/src/main/kotlin/theodolite/util/EvaluationFailedException.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/EvaluationFailedException.kt @@ -1,3 +1,5 @@ -package theodolite.util +package rocks.theodolite.kubernetes.slo + +import rocks.theodolite.kubernetes.ExecutionFailedException class EvaluationFailedException(message: String, e: Exception? = null) : ExecutionFailedException(message,e) diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/ExternalSloChecker.kt similarity index 94% rename from theodolite/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/ExternalSloChecker.kt index 7587e8326df98f3c45c016bfd3b2d7db8077e6d1..01b21c845a614ba42581c182d975da5ad645b474 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/ExternalSloChecker.kt @@ -1,8 +1,8 @@ -package theodolite.evaluation +package rocks.theodolite.kubernetes.slo import khttp.post import mu.KotlinLogging -import theodolite.util.PrometheusResponse +import rocks.theodolite.kubernetes.util.PrometheusResponse import java.net.ConnectException /** diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/MetricFetcher.kt similarity index 96% rename from theodolite/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/MetricFetcher.kt index b6a1857cba513f663876f88d7a7d69ad02c0bc40..962564475d0ad0b56bad8cf99daf12329950eaf3 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/MetricFetcher.kt @@ -1,10 +1,10 @@ -package theodolite.evaluation +package rocks.theodolite.kubernetes.slo import com.google.gson.Gson import khttp.get import khttp.responses.Response import mu.KotlinLogging -import theodolite.util.PrometheusResponse +import rocks.theodolite.kubernetes.util.PrometheusResponse import java.net.ConnectException import java.time.Duration import java.time.Instant diff --git a/theodolite/src/main/kotlin/theodolite/util/PrometheusResponse.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/PrometheusResponse.kt similarity index 98% rename from theodolite/src/main/kotlin/theodolite/util/PrometheusResponse.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/PrometheusResponse.kt index 9b0b0dd4e0a5a48072ca576e874cb850c5f8df3b..5222a78bde342fea4a94c69bf1e42e132d0bc706 100644 --- a/theodolite/src/main/kotlin/theodolite/util/PrometheusResponse.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/PrometheusResponse.kt @@ -1,4 +1,4 @@ -package theodolite.util +package rocks.theodolite.kubernetes.util import io.quarkus.runtime.annotations.RegisterForReflection import java.util.* diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/SloChecker.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloChecker.kt similarity index 81% rename from theodolite/src/main/kotlin/theodolite/evaluation/SloChecker.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloChecker.kt index 82f903f5be868731d58ebefd6279d5d438bd5eab..f4ac163547421d5f0f07d2511c2e3eeeebdb35b0 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/SloChecker.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloChecker.kt @@ -1,6 +1,6 @@ -package theodolite.evaluation +package rocks.theodolite.kubernetes.slo -import theodolite.util.PrometheusResponse +import rocks.theodolite.kubernetes.util.PrometheusResponse /** * A SloChecker can be used to evaluate data from Prometheus. diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/SloCheckerFactory.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloCheckerFactory.kt similarity index 97% rename from theodolite/src/main/kotlin/theodolite/evaluation/SloCheckerFactory.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloCheckerFactory.kt index 7ab6a0255f6c078f0f365289baa1eb0300a3244a..810675f159169f31314289d08a59fcc15bf8a243 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/SloCheckerFactory.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloCheckerFactory.kt @@ -1,6 +1,6 @@ -package theodolite.evaluation +package rocks.theodolite.kubernetes.slo -import theodolite.strategies.Metric +import rocks.theodolite.core.strategies.Metric /** diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/SloConfigHandler.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloConfigHandler.kt similarity index 89% rename from theodolite/src/main/kotlin/theodolite/evaluation/SloConfigHandler.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloConfigHandler.kt index ee892109dc1fc03a9c270151944c6d90fbacf45e..ed18e4a0b4027ce4284cc83ff4c9520738ec2ba7 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/SloConfigHandler.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloConfigHandler.kt @@ -1,7 +1,7 @@ -package theodolite.evaluation +package rocks.theodolite.kubernetes.slo -import theodolite.benchmark.Slo -import theodolite.util.InvalidPatcherConfigurationException +import rocks.theodolite.kubernetes.model.KubernetesBenchmark.Slo +import rocks.theodolite.kubernetes.patcher.InvalidPatcherConfigurationException import javax.enterprise.context.ApplicationScoped private const val DEFAULT_CONSUMER_LAG_METRIC_BASE = "kafka_consumergroup_lag" diff --git a/theodolite/src/main/kotlin/theodolite/execution/SloFactory.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloFactory.kt similarity index 74% rename from theodolite/src/main/kotlin/theodolite/execution/SloFactory.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloFactory.kt index b990828fa1db09532767b9f9255aa53e9c9e894a..047f8a657de8aba6f032d36e8b84d7046d5e0209 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/SloFactory.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloFactory.kt @@ -1,8 +1,8 @@ -package theodolite.execution +package rocks.theodolite.kubernetes.slo -import theodolite.benchmark.BenchmarkExecution -import theodolite.benchmark.KubernetesBenchmark -import theodolite.benchmark.Slo +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.model.KubernetesBenchmark +import rocks.theodolite.kubernetes.model.KubernetesBenchmark.Slo class SloFactory { diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/SloJson.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloJson.kt similarity index 78% rename from theodolite/src/main/kotlin/theodolite/evaluation/SloJson.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloJson.kt index 205389276f2c1adef6cba6c745baf99744c8d2dd..653ad6b5f998014a0f5b9e8b7397bcd3ce51f729 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/SloJson.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloJson.kt @@ -1,7 +1,7 @@ -package theodolite.evaluation +package rocks.theodolite.kubernetes.slo import com.google.gson.Gson -import theodolite.util.PromResult +import rocks.theodolite.kubernetes.util.PromResult class SloJson constructor( val results: List<List<PromResult>>, diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/SloTypes.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloTypes.kt similarity index 91% rename from theodolite/src/main/kotlin/theodolite/evaluation/SloTypes.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloTypes.kt index 812b50de779d2f3abfd5788b8aee145edc959e6c..07cbcd634ec7b46bd0e66a52f62989660575765f 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/SloTypes.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/slo/SloTypes.kt @@ -1,4 +1,4 @@ -package theodolite.evaluation +package rocks.theodolite.kubernetes.slo enum class SloTypes(val value: String) { GENERIC("generic"), diff --git a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteStandalone.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/standalone/TheodoliteStandalone.kt similarity index 73% rename from theodolite/src/main/kotlin/theodolite/execution/TheodoliteStandalone.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/standalone/TheodoliteStandalone.kt index 1bbf3e01f461a19dbe588aedd41be63b84c86162..8cf3959b95374183a989a0217d754aea7eab716a 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteStandalone.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/standalone/TheodoliteStandalone.kt @@ -1,14 +1,18 @@ -package theodolite.execution +package rocks.theodolite.kubernetes.standalone +import io.fabric8.kubernetes.client.NamespacedKubernetesClient import mu.KotlinLogging -import theodolite.benchmark.BenchmarkExecution -import theodolite.benchmark.KubernetesBenchmark -import theodolite.util.YamlParserFromFile -import theodolite.util.EvaluationFailedException -import theodolite.util.ExecutionFailedException +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.model.KubernetesBenchmark +import rocks.theodolite.kubernetes.TheodoliteExecutor +import rocks.theodolite.kubernetes.util.YamlParserFromFile +import rocks.theodolite.kubernetes.slo.EvaluationFailedException +import rocks.theodolite.kubernetes.ExecutionFailedException +import rocks.theodolite.kubernetes.Shutdown import kotlin.concurrent.thread import kotlin.system.exitProcess + private val logger = KotlinLogging.logger {} @@ -27,7 +31,7 @@ private val logger = KotlinLogging.logger {} * * @constructor Create empty Theodolite yaml executor */ -class TheodoliteStandalone { +class TheodoliteStandalone (private val client: NamespacedKubernetesClient) { private val parser = YamlParserFromFile() fun start() { @@ -48,11 +52,11 @@ class TheodoliteStandalone { // Add shutdown hook // Use thread{} with start = false, else the thread will start right away - val shutdown = thread(start = false) { Shutdown(benchmarkExecution, benchmark).run() } + val shutdown = thread(start = false) { Shutdown(benchmarkExecution, benchmark, client).run() } Runtime.getRuntime().addShutdownHook(shutdown) try { - TheodoliteExecutor(benchmarkExecution, benchmark).run() + TheodoliteExecutor(benchmarkExecution, benchmark, client).setupAndRunExecution() } catch (e: EvaluationFailedException) { logger.error { "Evaluation failed with error: ${e.message}" } }catch (e: ExecutionFailedException) { diff --git a/theodolite/src/main/kotlin/theodolite/util/ConfigurationOverride.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/ConfigurationOverride.kt similarity index 81% rename from theodolite/src/main/kotlin/theodolite/util/ConfigurationOverride.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/ConfigurationOverride.kt index 537b44721bb344c2cd7af71d29dc4fa3da5a7a33..4b054d61c15c13b2058fd4848dd69fc4633610c8 100644 --- a/theodolite/src/main/kotlin/theodolite/util/ConfigurationOverride.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/ConfigurationOverride.kt @@ -1,7 +1,8 @@ -package theodolite.util +package rocks.theodolite.kubernetes.util import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.quarkus.runtime.annotations.RegisterForReflection +import rocks.theodolite.kubernetes.patcher.PatcherDefinition /** * Representation of a configuration override. diff --git a/theodolite/src/main/kotlin/theodolite/util/Parser.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/Parser.kt similarity index 89% rename from theodolite/src/main/kotlin/theodolite/util/Parser.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/Parser.kt index e435b1cbbf18b9f860ceda69f5f7ec66e64c9375..65cd6a39303d3f0f0814c7197bbe15b4919be5d7 100644 --- a/theodolite/src/main/kotlin/theodolite/util/Parser.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/Parser.kt @@ -1,4 +1,4 @@ -package theodolite.util +package rocks.theodolite.kubernetes.util /** * Interface for parsers. diff --git a/theodolite/src/main/kotlin/theodolite/util/YamlParserFromFile.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/YamlParserFromFile.kt similarity index 92% rename from theodolite/src/main/kotlin/theodolite/util/YamlParserFromFile.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/YamlParserFromFile.kt index 58ca925e6aeeaca4f2f35c97c027ee2d24188e50..f6a1179a880631dea7471b68b34c0823400aaadc 100644 --- a/theodolite/src/main/kotlin/theodolite/util/YamlParserFromFile.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/YamlParserFromFile.kt @@ -1,4 +1,4 @@ -package theodolite.util +package rocks.theodolite.kubernetes.util import org.yaml.snakeyaml.Yaml import org.yaml.snakeyaml.constructor.Constructor diff --git a/theodolite/src/main/kotlin/theodolite/util/YamlParserFromString.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/YamlParserFromString.kt similarity index 90% rename from theodolite/src/main/kotlin/theodolite/util/YamlParserFromString.kt rename to theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/YamlParserFromString.kt index 99c81f1ed674b2aa21f6aec7b3e0dff1b8c86840..288414422963ad3de8f6b853b949b4af7939bf6a 100644 --- a/theodolite/src/main/kotlin/theodolite/util/YamlParserFromString.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/util/YamlParserFromString.kt @@ -1,4 +1,4 @@ -package theodolite.util +package rocks.theodolite.kubernetes.util import org.yaml.snakeyaml.Yaml import org.yaml.snakeyaml.constructor.Constructor diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt deleted file mode 100644 index f2b587cba90151af199da4b76a9cb8ad407f80ef..0000000000000000000000000000000000000000 --- a/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt +++ /dev/null @@ -1,32 +0,0 @@ -package theodolite.benchmark - -import io.quarkus.runtime.annotations.RegisterForReflection -import theodolite.util.ConfigurationOverride -import theodolite.util.PatcherDefinition - -/** - * A Benchmark contains: - * - The Resource that can be scaled for the benchmark. - * - The Load that can be scaled the benchmark. - * - additional [ConfigurationOverride]s. - */ -@RegisterForReflection -interface Benchmark { - - fun setupInfrastructure() - fun teardownInfrastructure() - - /** - * Builds a Deployment that can be deployed. - * @return a BenchmarkDeployment. - */ - fun buildDeployment( - load: Int, - loadPatcherDefinitions: List<PatcherDefinition>, - resource: Int, - resourcePatcherDefinitions: List<PatcherDefinition>, - configurationOverrides: List<ConfigurationOverride?>, - loadGenerationDelay: Long, - afterTeardownDelay: Long - ): BenchmarkDeployment -} diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt deleted file mode 100644 index d40d91961266098702171c7c3d040db87b2c6f9f..0000000000000000000000000000000000000000 --- a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ /dev/null @@ -1,166 +0,0 @@ -package theodolite.benchmark - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.fabric8.kubernetes.api.model.HasMetadata -import io.fabric8.kubernetes.api.model.KubernetesResource -import io.fabric8.kubernetes.client.DefaultKubernetesClient -import io.fabric8.kubernetes.client.NamespacedKubernetesClient -import io.quarkus.runtime.annotations.RegisterForReflection -import mu.KotlinLogging -import theodolite.k8s.K8sManager -import theodolite.patcher.PatchHandler -import theodolite.patcher.PatcherFactory -import theodolite.util.* -import kotlin.properties.Delegates - - -private val logger = KotlinLogging.logger {} - -private var DEFAULT_NAMESPACE = "default" -private var DEFAULT_THEODOLITE_APP_RESOURCES = "./benchmark-resources" - -/** - * Represents a benchmark in Kubernetes. An example for this is the BenchmarkType.yaml - * Contains a of: - * - [name] of the benchmark, - * - [infrastructure] resources that have to be deployed for the benchmark infrastructure - * - [sut] list of the resources that have to be deployed for the benchmark, - * - [loadGenerator] resource that generates the load, - * - [resourceTypes] types of scaling resources, - * - [loadTypes] types of loads that can be scaled for the benchmark, - * - [kafkaConfig] for the [theodolite.k8s.TopicManager], - * - [namespace] for the client, - * - * This class is used for the parsing(in the [theodolite.execution.TheodoliteStandalone]) and - * for the deserializing in the [theodolite.execution.operator.TheodoliteOperator]. - * @constructor construct an empty Benchmark. - */ -@JsonDeserialize -@RegisterForReflection -class KubernetesBenchmark : KubernetesResource, Benchmark { - lateinit var name: String - var waitForResourcesEnabled = false - lateinit var resourceTypes: List<TypeName> - lateinit var loadTypes: List<TypeName> - lateinit var slos: MutableList<Slo> - var kafkaConfig: KafkaConfig? = null - lateinit var infrastructure: Resources - lateinit var sut: Resources - lateinit var loadGenerator: Resources - private var namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE - - @Transient - private var client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace) - - /** - * Loads [KubernetesResource]s. - * It first loads them via the [YamlParserFromFile] to check for their concrete type and afterwards initializes them using - * the [K8sResourceLoader] - */ - @Deprecated("Use `loadResourceSet` from `ResourceSets`") - fun loadKubernetesResources(resourceSet: List<ResourceSets>): Collection<Pair<String, HasMetadata>> { - return loadResources(resourceSet) - } - - private fun loadResources(resourceSet: List<ResourceSets>): Collection<Pair<String, HasMetadata>> { - return resourceSet.flatMap { it.loadResourceSet(this.client) } - } - - override fun setupInfrastructure() { - this.infrastructure.beforeActions.forEach { it.exec(client = client) } - RolloutManager(waitForResourcesEnabled, this.client) - .rollout(loadResources(this.infrastructure.resources).map { it.second }) - } - - override fun teardownInfrastructure() { - val kubernetesManager = K8sManager(this.client) - - loadResources(this.infrastructure.resources) - .map { it.second } - .forEach { kubernetesManager.remove(it) } - this.infrastructure.afterActions.forEach { it.exec(client = client) } - } - - /** - * Builds a deployment. - * First loads all required resources and then patches them to the concrete load and resources for the experiment for the demand metric - * or loads all loads and then patches them to the concrete load and resources for the experiment. - * Afterwards patches additional configurations(cluster depending) into the resources (or loads). - * @param load concrete load that will be benchmarked in this experiment (demand metric), or scaled (capacity metric). - * @param resource concrete resource that will be scaled for this experiment (demand metric), or benchmarked (capacity metric). - * @param configurationOverrides - * @return a [BenchmarkDeployment] - */ - override fun buildDeployment( - load: Int, - loadPatcherDefinitions: List<PatcherDefinition>, - resource: Int, - resourcePatcherDefinitions: List<PatcherDefinition>, - configurationOverrides: List<ConfigurationOverride?>, - loadGenerationDelay: Long, - afterTeardownDelay: Long - ): BenchmarkDeployment { - logger.info { "Using $namespace as namespace." } - - - val appResources = loadResources(this.sut.resources).toResourceMap() - val loadGenResources = loadResources(this.loadGenerator.resources).toResourceMap() - - // patch the load dimension the resources - loadPatcherDefinitions.forEach { patcherDefinition -> - loadGenResources[patcherDefinition.resource] = - PatchHandler.patchResource(loadGenResources, patcherDefinition, load.toString()) - } - resourcePatcherDefinitions.forEach { patcherDefinition -> - appResources[patcherDefinition.resource] = - PatchHandler.patchResource(appResources, patcherDefinition, resource.toString()) - } - - configurationOverrides.forEach { override -> - override?.let { - if (appResources.keys.contains(it.patcher.resource)) { - appResources[it.patcher.resource] = - PatchHandler.patchResource(appResources, override.patcher, override.value) - } else { - loadGenResources[it.patcher.resource] = - PatchHandler.patchResource(loadGenResources, override.patcher, override.value) - } - } - } - - val kafkaConfig = this.kafkaConfig - - return KubernetesBenchmarkDeployment( - sutBeforeActions = sut.beforeActions, - sutAfterActions = sut.afterActions, - loadGenBeforeActions = loadGenerator.beforeActions, - loadGenAfterActions = loadGenerator.afterActions, - appResources = appResources.toList().flatMap { it.second }, - loadGenResources = loadGenResources.toList().flatMap { it.second }, - loadGenerationDelay = loadGenerationDelay, - afterTeardownDelay = afterTeardownDelay, - kafkaConfig = if (kafkaConfig != null) mapOf("bootstrap.servers" to kafkaConfig.bootstrapServer) else mapOf(), - topics = kafkaConfig?.topics ?: listOf(), - client = this.client, - rolloutMode = waitForResourcesEnabled - - ) - } - - /** - * This function can be used to set the Kubernetes client manually. This is for example necessary for testing. - * - * @param client - */ - fun setClient(client: NamespacedKubernetesClient) { - this.client = client - } -} - -private fun Collection<Pair<String, HasMetadata>>.toResourceMap(): MutableMap<String, List<HasMetadata>> { - return this.toMap() - .toMutableMap() - .map { Pair(it.key, listOf(it.value)) } - .toMap() - .toMutableMap() -} diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/Resources.kt b/theodolite/src/main/kotlin/theodolite/benchmark/Resources.kt deleted file mode 100644 index fccbd2c41a646a2ef85ef77c65763e7f793d1e91..0000000000000000000000000000000000000000 --- a/theodolite/src/main/kotlin/theodolite/benchmark/Resources.kt +++ /dev/null @@ -1,14 +0,0 @@ -package theodolite.benchmark - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.quarkus.runtime.annotations.RegisterForReflection - -@JsonDeserialize -@RegisterForReflection -class Resources { - - lateinit var resources: List<ResourceSets> - lateinit var beforeActions: List<Action> - lateinit var afterActions: List<Action> - -} \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/Slo.kt b/theodolite/src/main/kotlin/theodolite/benchmark/Slo.kt deleted file mode 100644 index c9aac4a1b68692669f0db577003856b964ade4ec..0000000000000000000000000000000000000000 --- a/theodolite/src/main/kotlin/theodolite/benchmark/Slo.kt +++ /dev/null @@ -1,25 +0,0 @@ -package theodolite.benchmark - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.fabric8.kubernetes.api.model.KubernetesResource -import io.quarkus.runtime.annotations.RegisterForReflection -import kotlin.properties.Delegates - -/** - * Measurable metric. - * [sloType] determines the type of the metric. - * It is evaluated using the [theodolite.evaluation.ExternalSloChecker] by data measured by Prometheus. - * The evaluation checks if a [threshold] is reached or not. - * [offset] determines the shift in hours by which the start and end timestamps should be shifted. - * The [warmup] determines after which time the metric should be evaluated to avoid starting interferences. - * The [warmup] time unit depends on the Slo: for the lag trend it is in seconds. - */ -@JsonDeserialize -@RegisterForReflection -class Slo : KubernetesResource { - lateinit var name: String - lateinit var sloType: String - lateinit var prometheusUrl: String - var offset by Delegates.notNull<Int>() - lateinit var properties: MutableMap<String, String> -} \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt deleted file mode 100644 index 9ae267f42ca3f8420dbd507b0b92e92bf49a31f5..0000000000000000000000000000000000000000 --- a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ /dev/null @@ -1,73 +0,0 @@ -package theodolite.execution - -import mu.KotlinLogging -import theodolite.benchmark.Benchmark -import theodolite.benchmark.Slo -import theodolite.util.ConfigurationOverride -import theodolite.util.PatcherDefinition -import theodolite.util.Results -import java.time.Duration -import java.util.concurrent.atomic.AtomicBoolean - -private val logger = KotlinLogging.logger {} - -/** - * The Benchmark Executor runs a single experiment. - * - * @property benchmark - * @property results - * @property executionDuration - * @constructor Create empty Benchmark executor - */ -abstract class BenchmarkExecutor( - val benchmark: Benchmark, - val results: Results, - val executionDuration: Duration, - val configurationOverrides: List<ConfigurationOverride?>, - val slos: List<Slo>, - val repetitions: Int, - val executionId: Int, - val loadGenerationDelay: Long, - val afterTeardownDelay: Long, - val executionName: String, - val loadPatcherDefinitions: List<PatcherDefinition>, - val resourcePatcherDefinitions: List<PatcherDefinition> -) { - - var run: AtomicBoolean = AtomicBoolean(true) - - /** - * Run a experiment for the given parametrization, evaluate the - * experiment and save the result. - * - * @param load to be tested. - * @param resource to be tested. - * @return True, if the number of resources are suitable for the - * given load, false otherwise (demand metric), or - * True, if there is a load suitable for the - * given resource, false otherwise. - */ - abstract fun runExperiment(load: Int, resource: Int): Boolean - - /** - * Wait while the benchmark is running and log the number of minutes executed every 1 minute. - * - */ - fun waitAndLog() { - logger.info { "Execution of a new experiment started." } - - var secondsRunning = 0L - - while (run.get() && secondsRunning < executionDuration.toSeconds()) { - secondsRunning++ - Thread.sleep(Duration.ofSeconds(1).toMillis()) - - if ((secondsRunning % 60) == 0L) { - logger.info { "Executed: ${secondsRunning / 60} minutes." } - } - } - - logger.debug { "Executor shutdown gracefully." } - - } -} diff --git a/theodolite/src/main/kotlin/theodolite/util/TypeName.kt b/theodolite/src/main/kotlin/theodolite/util/TypeName.kt deleted file mode 100644 index f20fc7c9ce6757be75d9317e76c23a68b09914bd..0000000000000000000000000000000000000000 --- a/theodolite/src/main/kotlin/theodolite/util/TypeName.kt +++ /dev/null @@ -1,14 +0,0 @@ -package theodolite.util - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.quarkus.runtime.annotations.RegisterForReflection - -/** - * The TypeName encapsulates a list of [PatcherDefinition] along with a typeName that specifies for what the [PatcherDefinition] should be used. - */ -@RegisterForReflection -@JsonDeserialize -class TypeName { - lateinit var typeName: String - lateinit var patchers: List<PatcherDefinition> -} diff --git a/theodolite/src/test/kotlin/theodolite/util/IOHandlerTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/core/IOHandlerTest.kt similarity index 99% rename from theodolite/src/test/kotlin/theodolite/util/IOHandlerTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/core/IOHandlerTest.kt index cec18832ad99a01dc7977b64a19111f57f49d7f4..65e84d7dd37eb5b68f77bc2d47d212db2f720a90 100644 --- a/theodolite/src/test/kotlin/theodolite/util/IOHandlerTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/core/IOHandlerTest.kt @@ -1,4 +1,4 @@ -package theodolite.util +package rocks.theodolite.core import com.google.gson.GsonBuilder import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/util/ResultsTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/core/ResultsTest.kt similarity index 97% rename from theodolite/src/test/kotlin/theodolite/util/ResultsTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/core/ResultsTest.kt index d453587a9aeeee1ad48cf750a614009ef6be9aff..2dbeb44b90f780975af884028335a7e398c7cfdc 100644 --- a/theodolite/src/test/kotlin/theodolite/util/ResultsTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/core/ResultsTest.kt @@ -1,10 +1,10 @@ -package theodolite.util +package rocks.theodolite.core import io.quarkus.test.junit.QuarkusTest import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test -import theodolite.strategies.Metric +import rocks.theodolite.core.strategies.Metric @QuarkusTest internal class ResultsTest { diff --git a/theodolite/src/test/kotlin/theodolite/strategies/restriction/LowerBoundRestrictionTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestrictionTest.kt similarity index 92% rename from theodolite/src/test/kotlin/theodolite/strategies/restriction/LowerBoundRestrictionTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestrictionTest.kt index e659d5f542910611af96d7eb6a68140ebd43065b..79fadb4867a155ee7b4dc86e4bb165947a4f15a4 100644 --- a/theodolite/src/test/kotlin/theodolite/strategies/restriction/LowerBoundRestrictionTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestrictionTest.kt @@ -1,11 +1,12 @@ -package theodolite.strategies.restriction +package rocks.theodolite.core.strategies.restrictionstrategy 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.strategies.Metric -import theodolite.util.Results +import rocks.theodolite.core.strategies.Metric +import rocks.theodolite.core.strategies.restrictionstrategy.LowerBoundRestriction +import rocks.theodolite.core.Results internal class LowerBoundRestrictionTest { diff --git a/theodolite/src/test/kotlin/theodolite/InitialGuessSearchStrategyTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategyTest.kt similarity index 82% rename from theodolite/src/test/kotlin/theodolite/InitialGuessSearchStrategyTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategyTest.kt index dbe55ff36f591a45df3fd9898419befe5a5fdeb7..820dc7564aac2497a2884ca004f15110bc5465f7 100644 --- a/theodolite/src/test/kotlin/theodolite/InitialGuessSearchStrategyTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategyTest.kt @@ -1,14 +1,15 @@ -package theodolite +package rocks.theodolite.core.strategies.searchstrategy import io.quarkus.test.junit.QuarkusTest import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test -import theodolite.strategies.searchstrategy.InitialGuessSearchStrategy -import theodolite.strategies.Metric -import theodolite.util.Results +import rocks.theodolite.core.strategies.Metric import mu.KotlinLogging -import theodolite.benchmark.Slo -import theodolite.strategies.searchstrategy.PrevInstanceOptGuess +import rocks.theodolite.kubernetes.TestBenchmarkDeploymentBuilder +import rocks.theodolite.kubernetes.TestExperimentRunnerImpl +import rocks.theodolite.core.strategies.guessstrategy.PrevInstanceOptGuess +import rocks.theodolite.core.Results +import rocks.theodolite.kubernetes.model.KubernetesBenchmark.Slo private val logger = KotlinLogging.logger {} @@ -29,10 +30,10 @@ class InitialGuessSearchStrategyTest { val mockLoads: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList() val results = Results(Metric.from("demand")) - val benchmark = TestBenchmark() + val benchmarkDeploymentBuilder = TestBenchmarkDeploymentBuilder() val guessStrategy = PrevInstanceOptGuess() val sloChecker = Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 5) + val benchmarkExecutor = TestExperimentRunnerImpl(results, mockResults, benchmarkDeploymentBuilder, listOf(sloChecker), 0, 0, 5) val strategy = InitialGuessSearchStrategy(benchmarkExecutor,guessStrategy, results) val actual: ArrayList<Int?> = ArrayList() @@ -67,10 +68,10 @@ class InitialGuessSearchStrategyTest { val mockLoads: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList() val results = Results(Metric.from("demand")) - val benchmark = TestBenchmark() + val benchmarkDeploymentBuilder = TestBenchmarkDeploymentBuilder() val guessStrategy = PrevInstanceOptGuess() val sloChecker = Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 5) + val benchmarkExecutor = TestExperimentRunnerImpl(results, mockResults, benchmarkDeploymentBuilder, listOf(sloChecker), 0, 0, 5) val strategy = InitialGuessSearchStrategy(benchmarkExecutor,guessStrategy, results) val actual: ArrayList<Int?> = ArrayList() @@ -105,10 +106,10 @@ class InitialGuessSearchStrategyTest { val mockLoads: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList() val results = Results(Metric.from("demand")) - val benchmark = TestBenchmark() + val benchmarkDeploymentBuilder = TestBenchmarkDeploymentBuilder() val guessStrategy = PrevInstanceOptGuess() val sloChecker = Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 5) + val benchmarkExecutor = TestExperimentRunnerImpl(results, mockResults, benchmarkDeploymentBuilder, listOf(sloChecker), 0, 0, 5) val strategy = InitialGuessSearchStrategy(benchmarkExecutor, guessStrategy, results) val actual: ArrayList<Int?> = ArrayList() diff --git a/theodolite/src/test/kotlin/theodolite/RestrictionSearchTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearchTest.kt similarity index 81% rename from theodolite/src/test/kotlin/theodolite/RestrictionSearchTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearchTest.kt index 23fa99c6d1775f291949a9068399f5bcf6e5179a..bae944801fcacf40431559a0e7ddeb78923d2173 100644 --- a/theodolite/src/test/kotlin/theodolite/RestrictionSearchTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearchTest.kt @@ -1,16 +1,14 @@ -package theodolite +package rocks.theodolite.core.strategies.searchstrategy import io.quarkus.test.junit.QuarkusTest import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test -import theodolite.benchmark.Slo -import theodolite.strategies.Metric -import theodolite.strategies.restriction.LowerBoundRestriction -import theodolite.strategies.searchstrategy.BinarySearch -import theodolite.strategies.searchstrategy.FullSearch -import theodolite.strategies.searchstrategy.RestrictionSearch -import theodolite.strategies.searchstrategy.LinearSearch -import theodolite.util.Results +import rocks.theodolite.kubernetes.TestBenchmarkDeploymentBuilder +import rocks.theodolite.kubernetes.TestExperimentRunnerImpl +import rocks.theodolite.core.strategies.Metric +import rocks.theodolite.core.strategies.restrictionstrategy.LowerBoundRestriction +import rocks.theodolite.core.Results +import rocks.theodolite.kubernetes.model.KubernetesBenchmark.Slo @QuarkusTest class RestrictionSearchTest { @@ -30,9 +28,9 @@ class RestrictionSearchTest { val mockLoads: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList() val results = Results(Metric.from("demand")) - val benchmark = TestBenchmark() + val benchmarkDeploymentBuilder = TestBenchmarkDeploymentBuilder() val sloChecker = Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 5) + val benchmarkExecutor = TestExperimentRunnerImpl(results, mockResults, benchmarkDeploymentBuilder, listOf(sloChecker), 0, 0, 5) val linearSearch = LinearSearch(benchmarkExecutor) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = @@ -63,9 +61,9 @@ class RestrictionSearchTest { val mockLoads: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList() val results = Results(Metric.from("demand")) - val benchmark = TestBenchmark() + val benchmarkDeploymentBuilder = TestBenchmarkDeploymentBuilder() val sloChecker = Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 5) + val benchmarkExecutor = TestExperimentRunnerImpl(results, mockResults, benchmarkDeploymentBuilder, listOf(sloChecker), 0, 0, 5) val fullSearch = FullSearch(benchmarkExecutor) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = @@ -96,10 +94,10 @@ class RestrictionSearchTest { val mockLoads: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..6).toList() val results = Results(Metric.from("demand")) - val benchmark = TestBenchmark() + val benchmarkDeploymentBuilder = TestBenchmarkDeploymentBuilder() val sloChecker = Slo() val benchmarkExecutorImpl = - TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 0) + TestExperimentRunnerImpl(results, mockResults, benchmarkDeploymentBuilder, listOf(sloChecker), 0, 0, 0) val binarySearch = BinarySearch(benchmarkExecutorImpl) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = RestrictionSearch(benchmarkExecutorImpl, binarySearch, setOf(lowerBoundRestriction)) @@ -129,9 +127,9 @@ class RestrictionSearchTest { val mockLoads: List<Int> = (0..6).toList() val mockResources: List<Int> = (0..7).toList() val results = Results(Metric.from("demand")) - val benchmark = TestBenchmark() + val benchmarkDeploymentBuilder = TestBenchmarkDeploymentBuilder() val sloChecker = Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, listOf(sloChecker), 0, 0, 0) + val benchmarkExecutor = TestExperimentRunnerImpl(results, mockResults, benchmarkDeploymentBuilder, listOf(sloChecker), 0, 0, 0) val binarySearch = BinarySearch(benchmarkExecutor) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = diff --git a/theodolite/src/test/kotlin/theodolite/benchmark/ActionCommandTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ActionCommandTest.kt similarity index 91% rename from theodolite/src/test/kotlin/theodolite/benchmark/ActionCommandTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ActionCommandTest.kt index 47f0e52f45e46e3cda093ff1b9722071f22ef7e8..afc86fc2663d07ab3711533f0d01797bd7311363 100644 --- a/theodolite/src/test/kotlin/theodolite/benchmark/ActionCommandTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ActionCommandTest.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import io.fabric8.kubernetes.api.model.Pod import io.fabric8.kubernetes.api.model.PodBuilder @@ -8,9 +8,9 @@ import io.fabric8.kubernetes.client.utils.Utils import io.quarkus.test.junit.QuarkusTest import org.junit.jupiter.api.* import org.junit.jupiter.api.Assertions.assertEquals -import theodolite.execution.operator.TheodoliteController -import theodolite.execution.operator.TheodoliteOperator -import theodolite.util.ActionCommandFailedException +import rocks.theodolite.kubernetes.operator.TheodoliteController +import rocks.theodolite.kubernetes.operator.TheodoliteOperator + @QuarkusTest class ActionCommandTest { @@ -20,11 +20,10 @@ class ActionCommandTest { @BeforeEach fun setUp() { server.before() - val operator = TheodoliteOperator() + val operator = TheodoliteOperator(server.client) this.controller = operator.getController( - client = server.client, - executionStateHandler = operator.getExecutionStateHandler(client = server.client), - benchmarkStateChecker = operator.getBenchmarkStateChecker(client = server.client) + executionStateHandler = operator.getExecutionStateHandler(), + benchmarkStateChecker = operator.getBenchmarkStateChecker() ) val pod: Pod = PodBuilder().withNewMetadata() diff --git a/theodolite/src/test/kotlin/theodolite/benchmark/ConfigMapResourceSetTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ConfigMapResourceSetTest.kt similarity index 95% rename from theodolite/src/test/kotlin/theodolite/benchmark/ConfigMapResourceSetTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ConfigMapResourceSetTest.kt index 33a4572e368655744185312ff2352b1294d7bef6..87058706c1a315c98ba098e6c5835f3a57343112 100644 --- a/theodolite/src/test/kotlin/theodolite/benchmark/ConfigMapResourceSetTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ConfigMapResourceSetTest.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import com.fasterxml.jackson.databind.ObjectMapper import io.fabric8.kubernetes.api.model.* @@ -19,16 +19,11 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows -import org.mockito.kotlin.mock import registerResource -import theodolite.TestBenchmark -import theodolite.execution.operator.BenchmarkCRDummy -import theodolite.execution.operator.ExecutionClient -import theodolite.execution.operator.ExecutionEventHandler -import theodolite.execution.operator.ExecutionStateHandler -import theodolite.model.crd.BenchmarkCRD -import theodolite.model.crd.ExecutionCRD -import theodolite.util.DeploymentFailedException +import rocks.theodolite.kubernetes.model.crd.BenchmarkCRDummy +import rocks.theodolite.kubernetes.operator.ExecutionClient +import rocks.theodolite.kubernetes.model.crd.BenchmarkCRD +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD import java.io.FileInputStream // TODO move somewhere else diff --git a/theodolite/src/test/kotlin/theodolite/benchmark/ErrorChannelMessage.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ErrorChannelMessage.kt similarity index 94% rename from theodolite/src/test/kotlin/theodolite/benchmark/ErrorChannelMessage.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ErrorChannelMessage.kt index df57a2529653a39ccbde14b4a91d30352224457e..4181b7cbb90fd0c6bd2db78753560092d7ea60ca 100644 --- a/theodolite/src/test/kotlin/theodolite/benchmark/ErrorChannelMessage.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ErrorChannelMessage.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import io.fabric8.mockwebserver.internal.WebSocketMessage import java.nio.charset.StandardCharsets diff --git a/theodolite/src/test/kotlin/theodolite/benchmark/FileSystemResourceSetTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/FileSystemResourceSetTest.kt similarity index 97% rename from theodolite/src/test/kotlin/theodolite/benchmark/FileSystemResourceSetTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/FileSystemResourceSetTest.kt index 6a31875d00c8f578dcc475c3de21e130c595f673..1c5f32159713e7ace6857caf0f97b43c90cb36e0 100644 --- a/theodolite/src/test/kotlin/theodolite/benchmark/FileSystemResourceSetTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/FileSystemResourceSetTest.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import io.fabric8.kubernetes.api.model.* import io.fabric8.kubernetes.api.model.apps.Deployment @@ -13,9 +13,8 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.io.TempDir import registerResource -import theodolite.model.crd.BenchmarkCRD -import theodolite.model.crd.ExecutionCRD -import theodolite.util.DeploymentFailedException +import rocks.theodolite.kubernetes.model.crd.BenchmarkCRD +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD import java.io.FileInputStream import java.nio.file.Files import java.nio.file.Path diff --git a/theodolite/src/test/kotlin/theodolite/k8s/K8sManagerTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/K8sManagerTest.kt similarity index 99% rename from theodolite/src/test/kotlin/theodolite/k8s/K8sManagerTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/K8sManagerTest.kt index ee80d55caf995642f6fff04cfeeb66bc08ab93d3..90dd01626a7c18e0b6f8d6018aae54297e758464 100644 --- a/theodolite/src/test/kotlin/theodolite/k8s/K8sManagerTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/K8sManagerTest.kt @@ -1,4 +1,4 @@ -package theodolite.k8s +package rocks.theodolite.kubernetes import io.fabric8.kubernetes.api.model.* import io.fabric8.kubernetes.api.model.apps.Deployment diff --git a/theodolite/src/test/kotlin/theodolite/benchmark/ResourceSetsTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ResourceSetsTest.kt similarity index 98% rename from theodolite/src/test/kotlin/theodolite/benchmark/ResourceSetsTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ResourceSetsTest.kt index b2ce9d73447961c56b121542a4c91822e3703e95..f0a6c120ca6c3397e8d41cd9f42b536b3e053caf 100644 --- a/theodolite/src/test/kotlin/theodolite/benchmark/ResourceSetsTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/ResourceSetsTest.kt @@ -1,4 +1,4 @@ -package theodolite.benchmark +package rocks.theodolite.kubernetes import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.dataformat.yaml.YAMLFactory @@ -16,7 +16,6 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.io.TempDir -import theodolite.util.DeploymentFailedException import java.nio.file.Files import java.nio.file.Path diff --git a/theodolite/src/test/kotlin/theodolite/TestBenchmarkDeployment.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/TestBenchmarkDeployment.kt similarity index 56% rename from theodolite/src/test/kotlin/theodolite/TestBenchmarkDeployment.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/TestBenchmarkDeployment.kt index 68b08c294128368ee1b65549aa85c877bd4bf313..92bc2fd26a8c5e9d77b0729731b3e65833b3dd08 100644 --- a/theodolite/src/test/kotlin/theodolite/TestBenchmarkDeployment.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/TestBenchmarkDeployment.kt @@ -1,6 +1,6 @@ -package theodolite +package rocks.theodolite.kubernetes -import theodolite.benchmark.BenchmarkDeployment +import rocks.theodolite.kubernetes.BenchmarkDeployment class TestBenchmarkDeployment : BenchmarkDeployment { override fun setup() {} diff --git a/theodolite/src/test/kotlin/theodolite/TestBenchmark.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/TestBenchmarkDeploymentBuilder.kt similarity index 52% rename from theodolite/src/test/kotlin/theodolite/TestBenchmark.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/TestBenchmarkDeploymentBuilder.kt index 335b0f8c59ac7642c30a12e494890e8f2c52ccda..cc7c9d6ae9a5fe158f7ba9243f23442acde001ee 100644 --- a/theodolite/src/test/kotlin/theodolite/TestBenchmark.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/TestBenchmarkDeploymentBuilder.kt @@ -1,17 +1,10 @@ -package theodolite +package rocks.theodolite.kubernetes -import theodolite.benchmark.Benchmark -import theodolite.benchmark.BenchmarkDeployment -import theodolite.util.ConfigurationOverride -import theodolite.util.PatcherDefinition -class TestBenchmark : Benchmark { +import rocks.theodolite.kubernetes.util.ConfigurationOverride +import rocks.theodolite.kubernetes.patcher.PatcherDefinition - override fun setupInfrastructure() { - } - - override fun teardownInfrastructure() { - } +class TestBenchmarkDeploymentBuilder(): BenchmarkDeploymentBuilder { override fun buildDeployment( load: Int, @@ -20,7 +13,8 @@ class TestBenchmark : Benchmark { resourcePatcherDefinitions: List<PatcherDefinition>, configurationOverrides: List<ConfigurationOverride?>, loadGenerationDelay: Long, - afterTeardownDelay: Long + afterTeardownDelay: Long, + waitForResourcesEnabled: Boolean ): BenchmarkDeployment { return TestBenchmarkDeployment() } diff --git a/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/TestExperimentRunnerImpl.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/TestExperimentRunnerImpl.kt new file mode 100644 index 0000000000000000000000000000000000000000..896beed83e0c9436c3aadc83b1e395df06b1f5b2 --- /dev/null +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/TestExperimentRunnerImpl.kt @@ -0,0 +1,24 @@ +package rocks.theodolite.kubernetes + +import rocks.theodolite.core.Results +import rocks.theodolite.kubernetes.model.KubernetesBenchmark.Slo +import rocks.theodolite.core.ExperimentRunner + +class TestExperimentRunnerImpl( + results: Results, + private val mockResults: Array<Array<Boolean>>, + private val benchmarkDeploymentBuilder: TestBenchmarkDeploymentBuilder, + private val slo: List<Slo>, + private val executionId: Int, + private val loadGenerationDelay: Long, + private val afterTeardownDelay: Long +) : ExperimentRunner( + results +) { + + override fun runExperiment(load: Int, resource: Int): Boolean { + val result = this.mockResults[load][resource] + this.results.setResult(Pair(load, resource), result) + return result + } +} diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkCRDummy.kt similarity index 79% rename from theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkCRDummy.kt index 152191bc271552dfb50c022c678a023ce0eb65cd..2bd52d55bb3acd3e37d53d22a1a434d53c1fff95 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/BenchmarkCRDummy.kt @@ -1,9 +1,6 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.model.crd -import theodolite.benchmark.KubernetesBenchmark -import theodolite.benchmark.Resources -import theodolite.model.crd.BenchmarkCRD -import theodolite.util.KafkaConfig +import rocks.theodolite.kubernetes.model.KubernetesBenchmark class BenchmarkCRDummy(name: String) { @@ -27,9 +24,9 @@ class BenchmarkCRDummy(name: String) { benchmarkCR.apiVersion = "v1" benchmark.waitForResourcesEnabled = false - benchmark.infrastructure = Resources() - benchmark.sut = Resources() - benchmark.loadGenerator = Resources() + benchmark.infrastructure = KubernetesBenchmark.Resources() + benchmark.sut = KubernetesBenchmark.Resources() + benchmark.loadGenerator = KubernetesBenchmark.Resources() benchmark.infrastructure.resources = emptyList() benchmark.sut.resources = emptyList() diff --git a/theodolite/src/test/kotlin/theodolite/model/crd/CRDExecutionTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/CRDExecutionTest.kt similarity index 88% rename from theodolite/src/test/kotlin/theodolite/model/crd/CRDExecutionTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/CRDExecutionTest.kt index 1150141ecc6a7147c930375af5bc965b81647e5a..a7de76acfe7aac9b92628e87b9911599a13ab438 100644 --- a/theodolite/src/test/kotlin/theodolite/model/crd/CRDExecutionTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/CRDExecutionTest.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import io.fabric8.kubernetes.api.model.KubernetesResourceList import io.fabric8.kubernetes.client.dsl.MixedOperation @@ -11,15 +11,11 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import org.mockito.internal.matchers.apachecommons.ReflectionEquals -import org.apache.commons.lang3.builder.EqualsBuilder -import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.instanceOf -import org.mockito.kotlin.isA import org.mockito.kotlin.mock -import theodolite.benchmark.BenchmarkExecution -import theodolite.execution.operator.* -import theodolite.util.ConfigurationOverride +import rocks.theodolite.kubernetes.operator.ExecutionEventHandler +import rocks.theodolite.kubernetes.operator.ExecutionStateHandler +import rocks.theodolite.kubernetes.operator.TheodoliteController +import rocks.theodolite.kubernetes.util.ConfigurationOverride import java.io.FileInputStream diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionCRDummy.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionCRDummy.kt similarity index 88% rename from theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionCRDummy.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionCRDummy.kt index 961c813f432d13fd2b373c74adaa00df4049a334..871471ee941f5cf2d254fb2bd70556f161d8d4de 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionCRDummy.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionCRDummy.kt @@ -1,9 +1,6 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.model.crd -import theodolite.benchmark.BenchmarkExecution -import theodolite.model.crd.ExecutionCRD -import theodolite.model.crd.ExecutionStatus -import theodolite.model.crd.ExecutionState +import rocks.theodolite.kubernetes.model.BenchmarkExecution class ExecutionCRDummy(name: String, benchmark: String) { diff --git a/theodolite/src/test/kotlin/theodolite/util/ExecutionStateComparatorTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStateComparatorTest.kt similarity index 86% rename from theodolite/src/test/kotlin/theodolite/util/ExecutionStateComparatorTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStateComparatorTest.kt index ae80312afd2c128f0f542306a8ffda7f3f53876b..14186ef408acd3233ce866102497bc56af1cdfda 100644 --- a/theodolite/src/test/kotlin/theodolite/util/ExecutionStateComparatorTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStateComparatorTest.kt @@ -1,10 +1,8 @@ -package theodolite.util +package rocks.theodolite.kubernetes.model.crd import io.quarkus.test.junit.QuarkusTest import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test -import theodolite.execution.operator.ExecutionCRDummy -import theodolite.model.crd.ExecutionState @QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/model/crd/ExecutionStatusTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStatusTest.kt similarity index 99% rename from theodolite/src/test/kotlin/theodolite/model/crd/ExecutionStatusTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStatusTest.kt index 157bc1c03cc40375c928677189f549052e1e134d..4c9326ac2e99dd7dd9707d4db25cb2e9e360ddf9 100644 --- a/theodolite/src/test/kotlin/theodolite/model/crd/ExecutionStatusTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/model/crd/ExecutionStatusTest.kt @@ -1,4 +1,4 @@ -package theodolite.model.crd +package rocks.theodolite.kubernetes.model.crd import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.exc.InvalidFormatException diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkStateCheckerTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateCheckerTest.kt similarity index 85% rename from theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkStateCheckerTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateCheckerTest.kt index 528cfac8066c28bf6382fb97cddf280b3c1de622..d9009222122f99d587c5dc6522a794639a84d4e6 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkStateCheckerTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/BenchmarkStateCheckerTest.kt @@ -1,4 +1,4 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import com.google.gson.Gson import io.fabric8.kubernetes.api.model.ConfigMapBuilder @@ -13,8 +13,13 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.Assertions.* -import theodolite.benchmark.* -import theodolite.model.crd.BenchmarkState +import rocks.theodolite.kubernetes.ActionSelector +import rocks.theodolite.kubernetes.model.crd.BenchmarkState +import rocks.theodolite.kubernetes.model.KubernetesBenchmark +import rocks.theodolite.kubernetes.model.crd.BenchmarkCRDummy +import rocks.theodolite.kubernetes.ConfigMapResourceSet +import rocks.theodolite.kubernetes.PodSelector +import rocks.theodolite.kubernetes.ResourceSets internal class BenchmarkStateCheckerTest { private val server = KubernetesServer(false, false) @@ -26,17 +31,17 @@ internal class BenchmarkStateCheckerTest { fun setUp() { server.before() serverCrud.before() - val operator = TheodoliteOperator() + val operator = TheodoliteOperator(serverCrud.client) checker = BenchmarkStateChecker( client = server.client, - benchmarkCRDClient = operator.getBenchmarkClient(server.client), - benchmarkStateHandler = operator.getBenchmarkStateHandler(server.client) + benchmarkCRDClient = operator.getBenchmarkClient(), + benchmarkStateHandler = operator.getBenchmarkStateHandler() ) checkerCrud = BenchmarkStateChecker( client = serverCrud.client, - benchmarkCRDClient = operator.getBenchmarkClient(serverCrud.client), - benchmarkStateHandler = operator.getBenchmarkStateHandler(serverCrud.client) + benchmarkCRDClient = operator.getBenchmarkClient(), + benchmarkStateHandler = operator.getBenchmarkStateHandler() ) val pod: Pod = PodBuilder().withNewMetadata() @@ -162,16 +167,17 @@ internal class BenchmarkStateCheckerTest { @Test fun checkResources() { - val benchmark = BenchmarkCRDummy( + val benchmarkCR = BenchmarkCRDummy( name = "test-benchmark" ) - benchmark.getCR().spec.setClient(serverCrud.client) - val resourceSet = Resources() + val benchmark = benchmarkCR.getCR().spec + + val resourceSet = KubernetesBenchmark.Resources() resourceSet.resources = listOf(createAndDeployConfigmapResourceSet()) - benchmark.getCR().spec.infrastructure = resourceSet - benchmark.getCR().spec.loadGenerator = resourceSet - benchmark.getCR().spec.sut = resourceSet + benchmark.infrastructure = resourceSet + benchmark.loadGenerator = resourceSet + benchmark.sut = resourceSet - assertEquals(BenchmarkState.READY,checkerCrud.checkResources(benchmark.getCR().spec)) + assertEquals(BenchmarkState.READY,checkerCrud.checkResources(benchmark)) } } \ No newline at end of file diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ControllerTest.kt similarity index 91% rename from theodolite/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ControllerTest.kt index 7d40f7e45d6aa2c93206a1bad22754fe93b0c100..3120d7420065cfe254d1ed76735ddc8b35d2bc21 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/ControllerTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ControllerTest.kt @@ -1,4 +1,4 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import com.google.gson.Gson import com.google.gson.GsonBuilder @@ -10,11 +10,10 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -import theodolite.benchmark.BenchmarkExecution -import theodolite.benchmark.KubernetesBenchmark -import theodolite.model.crd.BenchmarkCRD -import theodolite.model.crd.BenchmarkState -import theodolite.model.crd.ExecutionCRD +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.model.KubernetesBenchmark +import rocks.theodolite.kubernetes.model.crd.* + @QuarkusTest class ControllerTest { @@ -32,11 +31,10 @@ class ControllerTest { @BeforeEach fun setUp() { server.before() - val operator = TheodoliteOperator() + val operator = TheodoliteOperator(server.client) this.controller = operator.getController( - client = server.client, - executionStateHandler = operator.getExecutionStateHandler(client = server.client), - benchmarkStateChecker = operator.getBenchmarkStateChecker(client = server.client) + executionStateHandler = operator.getExecutionStateHandler(), + benchmarkStateChecker = operator.getBenchmarkStateChecker() ) // benchmark diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandlerTest.kt similarity index 98% rename from theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandlerTest.kt index c08e0565375de84a228a28b6d68a0b713af97d0f..e794ae1638bd6c7f265b3b7ffb08c2494ba76a37 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandlerTest.kt @@ -1,4 +1,4 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.api.model.KubernetesResourceList import io.fabric8.kubernetes.client.dsl.MixedOperation @@ -16,8 +16,8 @@ import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import org.mockito.kotlin.* -import theodolite.model.crd.ExecutionCRD -import theodolite.model.crd.ExecutionState +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD +import rocks.theodolite.kubernetes.model.crd.ExecutionState import java.io.FileInputStream import java.util.stream.Stream diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTestWithInformer.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandlerTestWithInformer.kt similarity index 98% rename from theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTestWithInformer.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandlerTestWithInformer.kt index adddc705616935e5440c1c601615ce9a065df4c4..63a669fe67c66b644b6acbabedc5d79afff8ee31 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerTestWithInformer.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandlerTestWithInformer.kt @@ -1,4 +1,4 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.client.dsl.Resource import io.fabric8.kubernetes.client.server.mock.KubernetesServer @@ -11,8 +11,8 @@ import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import org.mockito.kotlin.* -import theodolite.model.crd.ExecutionCRD -import theodolite.model.crd.ExecutionState +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD +import rocks.theodolite.kubernetes.model.crd.ExecutionState import java.io.FileInputStream import java.util.concurrent.CountDownLatch import java.util.stream.Stream diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerWrapper.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandlerWrapper.kt similarity index 63% rename from theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerWrapper.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandlerWrapper.kt index 5dbc515a7799dd51e6395153f13d80650587d7fa..43ff721bd0f964065243188465849354bc7f8b23 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/ExecutionEventHandlerWrapper.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/ExecutionEventHandlerWrapper.kt @@ -1,13 +1,14 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.client.informers.ResourceEventHandler -import theodolite.model.crd.ExecutionCRD +import rocks.theodolite.kubernetes.operator.ExecutionEventHandler +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD class ExecutionEventHandlerWrapper( - private val executionEventHandler: ExecutionEventHandler, - private val afterOnAddCallback: () -> Unit, - private val afterOnUpdateCallback: () -> Unit, - private val afterOnDeleteCallback: () -> Unit + private val executionEventHandler: ExecutionEventHandler, + private val afterOnAddCallback: () -> Unit, + private val afterOnUpdateCallback: () -> Unit, + private val afterOnDeleteCallback: () -> Unit ) : ResourceEventHandler<ExecutionCRD> { override fun onAdd(execution: ExecutionCRD) { diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/StateHandlerTest.kt similarity index 90% rename from theodolite/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/StateHandlerTest.kt index ba65356b65b6ac23ca56c268bb003815917cf162..ebef641d1e0a699ab5e220b0846be654fbefc672 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/StateHandlerTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/operator/StateHandlerTest.kt @@ -1,4 +1,4 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.operator import io.fabric8.kubernetes.client.server.mock.KubernetesServer import io.quarkus.test.junit.QuarkusTest @@ -10,9 +10,9 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -import theodolite.k8s.K8sManager -import theodolite.model.crd.ExecutionCRD -import theodolite.model.crd.ExecutionState +import rocks.theodolite.kubernetes.K8sManager +import rocks.theodolite.kubernetes.model.crd.ExecutionCRD +import rocks.theodolite.kubernetes.model.crd.ExecutionState @QuarkusTest @WithKubernetesTestServer diff --git a/theodolite/src/test/kotlin/theodolite/patcher/AbstractPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcherTest.kt similarity index 94% rename from theodolite/src/test/kotlin/theodolite/patcher/AbstractPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcherTest.kt index 05bb9588a2de5656b9c0b39d16d2160f691bbe91..cb92423305fd3f724753225d95150d5198f1d306 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/AbstractPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/AbstractPatcherTest.kt @@ -1,13 +1,10 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.* -import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder -import io.fabric8.kubernetes.api.model.apps.StatefulSet import io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder import io.quarkus.test.junit.QuarkusTest import org.junit.jupiter.api.Test -import theodolite.util.PatcherDefinition @QuarkusTest abstract class AbstractPatcherTest { diff --git a/theodolite/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ConfigOverrideModifierTest.kt similarity index 82% rename from theodolite/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ConfigOverrideModifierTest.kt index 1db1122e1caa5a783159ecaba849b99963e3c2a9..6172454008266c987b335999b7d8bbe67bb0fc02 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ConfigOverrideModifierTest.kt @@ -1,13 +1,13 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.quarkus.test.junit.QuarkusTest import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import theodolite.benchmark.BenchmarkExecution -import theodolite.benchmark.KubernetesBenchmark -import theodolite.execution.operator.BenchmarkCRDummy -import theodolite.execution.operator.ExecutionCRDummy +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.model.KubernetesBenchmark +import rocks.theodolite.kubernetes.model.crd.BenchmarkCRDummy +import rocks.theodolite.kubernetes.model.crd.ExecutionCRDummy @QuarkusTest class ConfigOverrideModifierTest { diff --git a/theodolite/src/test/kotlin/theodolite/patcher/DataVolumeLoadGeneratorReplicaPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/DataVolumeLoadGeneratorReplicaPatcherTest.kt similarity index 84% rename from theodolite/src/test/kotlin/theodolite/patcher/DataVolumeLoadGeneratorReplicaPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/DataVolumeLoadGeneratorReplicaPatcherTest.kt index e55767ea79f1925a3825aca11eb74a8641c17a90..6c9be1b9a59f963c8996e520b55e16caf24cbf6c 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/DataVolumeLoadGeneratorReplicaPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/DataVolumeLoadGeneratorReplicaPatcherTest.kt @@ -2,11 +2,11 @@ package theodolite.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest -import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import rocks.theodolite.kubernetes.patcher.AbstractPatcherTest -import org.junit.jupiter.api.Assertions.* +import rocks.theodolite.kubernetes.patcher.VolumesConfigMapPatcher @QuarkusTest internal class DataVolumeLoadGeneratorReplicaPatcherTest: AbstractPatcherTest() { diff --git a/theodolite/src/test/kotlin/theodolite/patcher/EnvVarPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/EnvVarPatcherTest.kt similarity index 92% rename from theodolite/src/test/kotlin/theodolite/patcher/EnvVarPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/EnvVarPatcherTest.kt index cc46347acf5b005ed05170fe27a40de3ca69599d..83cd056ac1b56b13fb8f211a2d926f1272c9fb0e 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/EnvVarPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/EnvVarPatcherTest.kt @@ -1,6 +1,5 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher -import io.fabric8.kubernetes.api.model.EnvVar import io.fabric8.kubernetes.api.model.EnvVarBuilder import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/patcher/ImagePatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcherTest.kt similarity index 94% rename from theodolite/src/test/kotlin/theodolite/patcher/ImagePatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcherTest.kt index 6592f65934716bfd74d562c5a3fb52ddb40c8b86..7b3f803a4e13039b7bb40aec6259f7d9a4fdbb57 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/ImagePatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/patcher/LabelPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/LabelPatcherTest.kt similarity index 94% rename from theodolite/src/test/kotlin/theodolite/patcher/LabelPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/LabelPatcherTest.kt index 64583e4be67282543a44d09b36e657eede2f9eac..652dda47cef34a7a95e54c36cbe9af9c897b84a1 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/LabelPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/LabelPatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/patcher/MatchLabelPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/MatchLabelPatcherTest.kt similarity index 95% rename from theodolite/src/test/kotlin/theodolite/patcher/MatchLabelPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/MatchLabelPatcherTest.kt index 796f2ffeb6f4c22b9d00218b91f0fbe2ee9f6567..a5711a762ab65fc39edf731c21d085d0936a5a93 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/MatchLabelPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/MatchLabelPatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/patcher/NamePatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NamePatcherTest.kt similarity index 88% rename from theodolite/src/test/kotlin/theodolite/patcher/NamePatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NamePatcherTest.kt index 5ae75c5b0dca038b8e351683bfd0ee2a40d217eb..cb1308cb73dc127661b2c2741fdc3e0460fcfde4 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/NamePatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NamePatcherTest.kt @@ -1,6 +1,5 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher -import io.fabric8.kubernetes.api.model.KubernetesResource import io.quarkus.test.junit.QuarkusTest import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach diff --git a/theodolite/src/test/kotlin/theodolite/patcher/NodeSelectorPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NodeSelectorPatcherTest.kt similarity index 93% rename from theodolite/src/test/kotlin/theodolite/patcher/NodeSelectorPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NodeSelectorPatcherTest.kt index a042faf8484eb0ce7e1e21a6069be2beeff0b693..ca8f83518a5bcd96837de96b1879c0de2e9a5773 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/NodeSelectorPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NodeSelectorPatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest @@ -7,7 +7,6 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.Assertions.* -import org.mockito.kotlin.reset @QuarkusTest internal class NodeSelectorPatcherTest: AbstractPatcherTest() { diff --git a/theodolite/src/test/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NumNestedGroupsLoadGeneratorReplicaPatcherTest.kt similarity index 94% rename from theodolite/src/test/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NumNestedGroupsLoadGeneratorReplicaPatcherTest.kt index 6b2a639285b134c0efcaaf5b296f18779f4f8322..8940e288fae79f10e5dcd728121a2dbbf0aaa180 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NumNestedGroupsLoadGeneratorReplicaPatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NumSensorsLoadGeneratorReplicaPatcherTest.kt similarity index 94% rename from theodolite/src/test/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NumSensorsLoadGeneratorReplicaPatcherTest.kt index 50d122e60104ad0239824e5b4471ade8b3ff7bfb..e3bb6ffff4938bcaeb4a0db6487bd4741da75850 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/NumSensorsLoadGeneratorReplicaPatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/patcher/PatcherDefinitionFactoryTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/PatcherDefinitionFactoryTest.kt similarity index 88% rename from theodolite/src/test/kotlin/theodolite/patcher/PatcherDefinitionFactoryTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/PatcherDefinitionFactoryTest.kt index 4696e646726f9ed6ad3e4c5cda1631ded42930e4..010fa1e25fb89619c8954b1bafa52c5389d0a2f3 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/PatcherDefinitionFactoryTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/PatcherDefinitionFactoryTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach diff --git a/theodolite/src/test/kotlin/theodolite/patcher/ReplicaPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ReplicaPatcherTest.kt similarity index 93% rename from theodolite/src/test/kotlin/theodolite/patcher/ReplicaPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ReplicaPatcherTest.kt index 0e01dead66509e40237952e4d65ea3a377943c5b..852002a07cfb756086afbc6d0573fc548f945683 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/ReplicaPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ReplicaPatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/patcher/ResourceLimitPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ResourceLimitPatcherTest.kt similarity index 97% rename from theodolite/src/test/kotlin/theodolite/patcher/ResourceLimitPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ResourceLimitPatcherTest.kt index b794ec6ed983dba92526aff67ecb3cab915871eb..b0af74d1e207ee10fac548f27267356711943dd0 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/ResourceLimitPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ResourceLimitPatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.client.server.mock.KubernetesServer @@ -8,7 +8,6 @@ import io.quarkus.test.kubernetes.client.WithKubernetesTestServer import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import theodolite.util.PatcherDefinition /** * Resource patcher test diff --git a/theodolite/src/test/kotlin/theodolite/patcher/ResourceRequestPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ResourceRequestPatcherTest.kt similarity index 97% rename from theodolite/src/test/kotlin/theodolite/patcher/ResourceRequestPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ResourceRequestPatcherTest.kt index 300397a96abd34f17f1a4a3d2b3c76e2d9da13ea..a076e541e742e97ffa95dccff925892dd63ff17a 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/ResourceRequestPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/ResourceRequestPatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.client.server.mock.KubernetesServer import io.quarkus.test.junit.QuarkusTest @@ -6,7 +6,6 @@ import io.quarkus.test.kubernetes.client.KubernetesTestServer import io.quarkus.test.kubernetes.client.WithKubernetesTestServer import io.smallrye.common.constraint.Assert.assertTrue import org.junit.jupiter.api.Test -import theodolite.util.PatcherDefinition /** * Resource patcher test diff --git a/theodolite/src/test/kotlin/theodolite/patcher/SchedulerNamePatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/SchedulerNamePatcherTest.kt similarity index 94% rename from theodolite/src/test/kotlin/theodolite/patcher/SchedulerNamePatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/SchedulerNamePatcherTest.kt index 8b6f3e9b1371bce3e17cbbc6e399d425baffd699..2b2021ec5853af4a2ef087a21bde87fb5bdc847e 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/SchedulerNamePatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/SchedulerNamePatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/patcher/TemplateLabelPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/TemplateLabelPatcherTest.kt similarity index 87% rename from theodolite/src/test/kotlin/theodolite/patcher/TemplateLabelPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/TemplateLabelPatcherTest.kt index ebfe147e7b503defe14439fb1b954b9dd269ea3e..94073b9f34d6b76d69d82e4ea40ed047a68655ff 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/TemplateLabelPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/TemplateLabelPatcherTest.kt @@ -1,8 +1,7 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest -import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -28,7 +27,4 @@ internal class TemplateLabelPatcherTest: AbstractPatcherTest() { } } - @Test - fun getVariableName() { - } } \ No newline at end of file diff --git a/theodolite/src/test/kotlin/theodolite/patcher/VolumesConfigMapPatcherTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/VolumesConfigMapPatcherTest.kt similarity index 95% rename from theodolite/src/test/kotlin/theodolite/patcher/VolumesConfigMapPatcherTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/VolumesConfigMapPatcherTest.kt index 5628fd7c50336dc620dec79945c69fd9856a9c91..db3fc812e426c0f74cf68d35a158f32a3ec0bc3f 100644 --- a/theodolite/src/test/kotlin/theodolite/patcher/VolumesConfigMapPatcherTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/patcher/VolumesConfigMapPatcherTest.kt @@ -1,4 +1,4 @@ -package theodolite.patcher +package rocks.theodolite.kubernetes.patcher import io.fabric8.kubernetes.api.model.apps.Deployment import io.quarkus.test.junit.QuarkusTest diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/SloFactoryTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/slo/SloFactoryTest.kt similarity index 59% rename from theodolite/src/test/kotlin/theodolite/execution/operator/SloFactoryTest.kt rename to theodolite/src/test/kotlin/rocks/theodolite/kubernetes/slo/SloFactoryTest.kt index c3dcd1b9529b6f24bd5b0deda920ba3e3ebb2978..de9d4c60dbad069ccb1229bebb4a4751cf96d98d 100644 --- a/theodolite/src/test/kotlin/theodolite/execution/operator/SloFactoryTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/kubernetes/slo/SloFactoryTest.kt @@ -1,13 +1,10 @@ -package theodolite.execution.operator +package rocks.theodolite.kubernetes.slo import io.quarkus.test.junit.QuarkusTest +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import theodolite.benchmark.BenchmarkExecution -import theodolite.benchmark.BenchmarkExecution.SloConfiguration -import theodolite.benchmark.KubernetesBenchmark -import theodolite.benchmark.Slo -import theodolite.execution.SloFactory -import org.junit.jupiter.api.Assertions.* +import rocks.theodolite.kubernetes.model.BenchmarkExecution +import rocks.theodolite.kubernetes.model.KubernetesBenchmark @QuarkusTest internal class SloFactoryTest { @@ -19,7 +16,7 @@ internal class SloFactoryTest { val execution = BenchmarkExecution() // Define Benchmark SLOs - val slo = Slo() + val slo = KubernetesBenchmark.Slo() slo.name="test" slo.sloType="lag trend" slo.prometheusUrl="test.de" @@ -36,7 +33,7 @@ internal class SloFactoryTest { // Define Execution SLOs, benchmark SLO values for these properties should be overwritten - val sloConfig = SloConfiguration() + val sloConfig = BenchmarkExecution.SloConfiguration() sloConfig.name = "test" val executionSloProperties = mutableMapOf<String, String>() @@ -48,7 +45,7 @@ internal class SloFactoryTest { sloConfig.properties = executionSloProperties // SLO has 'name' that isn't defined in the benchmark, therefore it will be ignored by the SloFactory - val sloConfig2 = SloConfiguration() + val sloConfig2 = BenchmarkExecution.SloConfiguration() sloConfig2.name = "test2" sloConfig2.properties = executionSloProperties @@ -57,16 +54,16 @@ internal class SloFactoryTest { val sloFactory = SloFactory() val combinedSlos = sloFactory.createSlos(execution,benchmark) - assertEquals(1, combinedSlos.size) - assertEquals("test", combinedSlos[0].name) - assertEquals("lag trend", combinedSlos[0].sloType) - assertEquals("test.de", combinedSlos[0].prometheusUrl) - assertEquals(0, combinedSlos[0].offset) - - assertEquals(4, combinedSlos[0].properties.size) - assertEquals("3000", combinedSlos[0].properties["threshold"]) - assertEquals("http://localhost:80/evaluate-slope", combinedSlos[0].properties["externalSloUrl"]) - assertEquals("80", combinedSlos[0].properties["warmup"]) - assertEquals("extended", combinedSlos[0].properties["extensionTest"]) + Assertions.assertEquals(1, combinedSlos.size) + Assertions.assertEquals("test", combinedSlos[0].name) + Assertions.assertEquals("lag trend", combinedSlos[0].sloType) + Assertions.assertEquals("test.de", combinedSlos[0].prometheusUrl) + Assertions.assertEquals(0, combinedSlos[0].offset) + + Assertions.assertEquals(4, combinedSlos[0].properties.size) + Assertions.assertEquals("3000", combinedSlos[0].properties["threshold"]) + Assertions.assertEquals("http://localhost:80/evaluate-slope", combinedSlos[0].properties["externalSloUrl"]) + Assertions.assertEquals("80", combinedSlos[0].properties["warmup"]) + Assertions.assertEquals("extended", combinedSlos[0].properties["extensionTest"]) } } \ No newline at end of file diff --git a/theodolite/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt b/theodolite/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt deleted file mode 100644 index 97197f3bad066235634869c8c37de4bc5c570f8b..0000000000000000000000000000000000000000 --- a/theodolite/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt +++ /dev/null @@ -1,38 +0,0 @@ -package theodolite - -import theodolite.benchmark.Benchmark -import theodolite.benchmark.Slo -import theodolite.execution.BenchmarkExecutor -import theodolite.util.Results -import java.time.Duration - -class TestBenchmarkExecutorImpl( - private val mockResults: Array<Array<Boolean>>, - benchmark: Benchmark, - results: Results, - slo: List<Slo>, - executionId: Int, - loadGenerationDelay: Long, - afterTeardownDelay: Long -) : - BenchmarkExecutor( - benchmark, - results, - executionDuration = Duration.ofSeconds(1), - configurationOverrides = emptyList(), - slos = slo, - repetitions = 1, - executionId = executionId, - loadGenerationDelay = loadGenerationDelay, - afterTeardownDelay = afterTeardownDelay, - executionName = "test-execution", - loadPatcherDefinitions = emptyList(), - resourcePatcherDefinitions = emptyList() - ) { - - override fun runExperiment(load: Int, resource: Int): Boolean { - val result = this.mockResults[load][resource] - this.results.setResult(Pair(load, resource), result) - return result - } -} diff --git a/theodolite/src/test/kotlin/theodolite/patcher/PatcherFactoryTest.kt b/theodolite/src/test/kotlin/theodolite/patcher/PatcherFactoryTest.kt deleted file mode 100644 index 1c3ecffa06f91d1d6c87706bb3fb28e94c414c35..0000000000000000000000000000000000000000 --- a/theodolite/src/test/kotlin/theodolite/patcher/PatcherFactoryTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package theodolite.patcher - -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.BeforeEach - -import org.junit.jupiter.api.Assertions.* - -internal class PatcherFactoryTest { - - @BeforeEach - fun setUp() { - } - - @AfterEach - fun tearDown() { - } -} \ No newline at end of file diff --git a/theodolite/src/test/kotlin/theodolite/patcher/ServiceSelectorPatcherTest.kt b/theodolite/src/test/kotlin/theodolite/patcher/ServiceSelectorPatcherTest.kt deleted file mode 100644 index caffb7eaf37c3930dbbb8a043ccd1cb7bbfd8d74..0000000000000000000000000000000000000000 --- a/theodolite/src/test/kotlin/theodolite/patcher/ServiceSelectorPatcherTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package theodolite.patcher - -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -import org.junit.jupiter.api.Assertions.* - -internal class ServiceSelectorPatcherTest { - - @BeforeEach - fun setUp() { - } - - @AfterEach - fun tearDown() { - } - - @Test - fun patch() { - } -} \ No newline at end of file