diff --git a/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml b/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml index ebc2fe9e44fe303e342cabee301cb63664867cfb..cdc2122d9e6b568f1a75b0d55eff8a0af6450983 100644 --- a/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml +++ b/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml @@ -22,7 +22,7 @@ loadTypes: - type: "NumSensorsLoadGeneratorReplicaPatcher" resource: "uc1-load-generator-deployment.yaml" kafkaConfig: - bootstrapServer: "theodolite-cp-kafka:9092" + bootstrapServer: "localhost:31290" topics: - name: "input" numPartitions: 40 diff --git a/theodolite-quarkus/config/example-execution-yaml-resource.yaml b/theodolite-quarkus/config/example-execution-yaml-resource.yaml index 23c1587ec1e5c2a88fcf69d7127edbcc1ffdb00f..e0b327a022099410fea8028fb5d37fee5672a857 100644 --- a/theodolite-quarkus/config/example-execution-yaml-resource.yaml +++ b/theodolite-quarkus/config/example-execution-yaml-resource.yaml @@ -17,6 +17,7 @@ execution: strategy: "LinearSearch" duration: 300 # in seconds repetitions: 1 + loadGenerationDelay: 30 # in seconds, optional field, default is 0 seconds restrictions: - "LowerBound" configOverrides: [] diff --git a/theodolite-quarkus/config/example-operator-execution.yaml b/theodolite-quarkus/config/example-operator-execution.yaml index 3df1a723dd771453ab1b267335176e4ae74c3ed5..882c38a97c882ac180a2416e0b5046fa6d467efd 100644 --- a/theodolite-quarkus/config/example-operator-execution.yaml +++ b/theodolite-quarkus/config/example-operator-execution.yaml @@ -21,6 +21,7 @@ execution: strategy: "LinearSearch" duration: 300 # in seconds repetitions: 1 + delay: 30 # in seconds restrictions: - "LowerBound" configOverrides: [] diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt index db7999b205c61d94fa17791a5d549a2620601b6b..95af36d1b14eb4d664ffd0d3d463df17fd8fb534 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/Benchmark.kt @@ -21,6 +21,7 @@ interface Benchmark { fun buildDeployment( load: LoadDimension, res: Resource, - configurationOverrides: List<ConfigurationOverride?> + configurationOverrides: List<ConfigurationOverride?>, + delay: Long ): BenchmarkDeployment } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt index 2d5d15b3389cf723be3a8ceb0fff8b27bd700419..40ab663e179735be61356947df7c37e9edd0a2ea 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt @@ -47,6 +47,7 @@ class BenchmarkExecution : CustomResource(), Namespaced { var duration by Delegates.notNull<Long>() var repetitions by Delegates.notNull<Int>() lateinit var restrictions: List<String> + var loadGenerationDelay = 0L } /** diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index 53fcb57934c50a1b5f5715395b3db74daf819b31..b5316a3df78e7291569ec1d36e561a5445b6f86d 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -70,31 +70,36 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced { override fun buildDeployment( load: LoadDimension, res: Resource, - configurationOverrides: List<ConfigurationOverride?> + configurationOverrides: List<ConfigurationOverride?>, + loadGenerationDelay: Long ): BenchmarkDeployment { logger.info { "Using $namespace as namespace." } logger.info { "Using $path as resource path." } - val resources = loadKubernetesResources(this.appResource + this.loadGenResource) + val appResources = loadKubernetesResources(this.appResource) + val loadGenResources = loadKubernetesResources(this.loadGenResource) + val patcherFactory = PatcherFactory() // patch the load dimension the resources load.getType().forEach { patcherDefinition -> - patcherFactory.createPatcher(patcherDefinition, resources).patch(load.get().toString()) + patcherFactory.createPatcher(patcherDefinition, loadGenResources).patch(load.get().toString()) } res.getType().forEach { patcherDefinition -> - patcherFactory.createPatcher(patcherDefinition, resources).patch(res.get().toString()) + patcherFactory.createPatcher(patcherDefinition, appResources).patch(res.get().toString()) } // Patch the given overrides configurationOverrides.forEach { override -> override?.let { - patcherFactory.createPatcher(it.patcher, resources).patch(override.value) + patcherFactory.createPatcher(it.patcher, appResources + loadGenResources).patch(override.value) } } return KubernetesBenchmarkDeployment( namespace = namespace, - resources = resources.map { r -> r.second }, + appResources = appResources.map { it.second }, + loadGenResources = loadGenResources.map { it.second }, + loadGenerationDelay = loadGenerationDelay, kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer), topics = kafkaConfig.topics, client = DefaultKubernetesClient().inNamespace(namespace) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt index 49662d4bf99546016e5a9c0d1811ed69f71cbe12..7d1c3f4ba727b8c149e3c5678ad406fa293c8f5b 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt @@ -8,6 +8,7 @@ import org.apache.kafka.clients.admin.NewTopic import theodolite.k8s.K8sManager import theodolite.k8s.TopicManager import theodolite.util.KafkaConfig +import java.time.Duration private val logger = KotlinLogging.logger {} @@ -22,7 +23,9 @@ private val logger = KotlinLogging.logger {} @RegisterForReflection class KubernetesBenchmarkDeployment( val namespace: String, - val resources: List<KubernetesResource>, + val appResources: List<KubernetesResource>, + val loadGenResources: List<KubernetesResource>, + private val loadGenerationDelay: Long, private val kafkaConfig: HashMap<String, Any>, private val topics: List<KafkaConfig.TopicWrapper>, private val client: NamespacedKubernetesClient @@ -41,7 +44,10 @@ class KubernetesBenchmarkDeployment( val kafkaTopics = this.topics.filter { !it.removeOnly } .map { NewTopic(it.name, it.numPartitions, it.replicationFactor) } kafkaController.createTopics(kafkaTopics) - resources.forEach { kubernetesManager.deploy(it) } + appResources.forEach { kubernetesManager.deploy(it) } + logger.info { "Wait ${this.loadGenerationDelay} seconds before starting the load generator." } + Thread.sleep(Duration.ofSeconds(this.loadGenerationDelay).toMillis()) + loadGenResources.forEach { kubernetesManager.deploy(it) } } /** @@ -51,9 +57,8 @@ class KubernetesBenchmarkDeployment( * - Remove the [KubernetesResource]s. */ override fun teardown() { - resources.forEach { - kubernetesManager.remove(it) - } + loadGenResources.forEach { kubernetesManager.remove(it) } + appResources.forEach { kubernetesManager.remove(it) } kafkaController.removeTopics(this.topics.map { topic -> topic.name }) KafkaLagExporterRemover(client).remove(LAG_EXPORTER_POD_LABEL) logger.info { "Teardown complete. Wait $SLEEP_AFTER_TEARDOWN ms to let everything come down." } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt index 4fb99fb727cb1fc1774924f5fc22f6cf0646238d..909ae77a95dfef7dfc1dafd7bd0a326a72ef1424 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -24,9 +24,10 @@ abstract class BenchmarkExecutor( val benchmark: Benchmark, val results: Results, val executionDuration: Duration, - configurationOverrides: List<ConfigurationOverride?>, + val configurationOverrides: List<ConfigurationOverride?>, val slo: BenchmarkExecution.Slo, - val executionId: Int + val executionId: Int, + val loadGenerationDelay: Long ) { var run: AtomicBoolean = AtomicBoolean(true) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index cd85c143e3c416f115a4d301629caf4d46b7459f..22db5076bee51e03318aa9ac95e66c2d61d27f28 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -18,13 +18,14 @@ class BenchmarkExecutorImpl( benchmark: Benchmark, results: Results, executionDuration: Duration, - private val configurationOverrides: List<ConfigurationOverride?>, + configurationOverrides: List<ConfigurationOverride?>, slo: BenchmarkExecution.Slo, - executionId: Int -) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo, executionId) { + executionId: Int, + loadGenerationDelay: Long +) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo, executionId, loadGenerationDelay) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { var result = false - val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) + val benchmarkDeployment = benchmark.buildDeployment(load, res, configurationOverrides, loadGenerationDelay) try { benchmarkDeployment.setup() diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt index a50a38e79b52a72fa68eb9eda70cf1072f80df74..80e1ac2341d9f8608d70b39a0d99f7b88dd7f108 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt @@ -30,7 +30,8 @@ class Shutdown(private val benchmarkExecution: BenchmarkExecution, private val b benchmark.buildDeployment( load = LoadDimension(0, emptyList()), res = Resource(0, emptyList()), - configurationOverrides = benchmarkExecution.configOverrides + configurationOverrides = benchmarkExecution.configOverrides, + loadGenerationDelay = 0L ) deployment.teardown() } catch (e: Exception) { diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index 01b25e110bbeb59ab308fb5b0a94a3fb249a1a48..c297251e30c17e5824c2541365164d9824718073 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -71,7 +71,8 @@ class TheodoliteExecutor( executionDuration = executionDuration, configurationOverrides = config.configOverrides, slo = config.slos[0], - executionId = config.executionId + executionId = config.executionId, + loadGenerationDelay = config.execution.loadGenerationDelay ) return Config( diff --git a/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml b/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml index ef625dfe6ec78c2cc0ed099dfee0f767d57263bb..7f76b1bca0db77df08861e0611487642e19bbc1a 100644 --- a/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml +++ b/theodolite-quarkus/src/main/resources/operator/example-execution-k8s-resource.yaml @@ -22,6 +22,7 @@ execution: strategy: "LinearSearch" duration: 60 repetitions: 1 + delay: 30 # in seconds restrictions: - "LowerBound" configOverrides: diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt index 7802529bfda309131cafc0ab3f39fda43285c32f..726d4490b053b5c56f0a0387f54ad557d4c1865c 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt @@ -31,7 +31,7 @@ class CompositeStrategyTest { val results = Results() val benchmark = TestBenchmark() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0) + val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0, 0) val linearSearch = LinearSearch(benchmarkExecutor) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = @@ -65,7 +65,7 @@ class CompositeStrategyTest { val benchmark = TestBenchmark() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() val benchmarkExecutorImpl = - TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0) + TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0, 0) val binarySearch = BinarySearch(benchmarkExecutorImpl) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = @@ -98,7 +98,7 @@ class CompositeStrategyTest { val results = Results() val benchmark = TestBenchmark() val sloChecker: BenchmarkExecution.Slo = BenchmarkExecution.Slo() - val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0) + val benchmarkExecutor = TestBenchmarkExecutorImpl(mockResults, benchmark, results, sloChecker, 0, 0) val binarySearch = BinarySearch(benchmarkExecutor) val lowerBoundRestriction = LowerBoundRestriction(results) val strategy = diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt index 6f476278d08eacfc9857c1e5431636e5a219f26c..71e3cbcc78208cc4227e369d59d841e39adb87ed 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmark.kt @@ -11,7 +11,8 @@ class TestBenchmark : Benchmark { override fun buildDeployment( load: LoadDimension, res: Resource, - configurationOverrides: List<ConfigurationOverride?> + configurationOverrides: List<ConfigurationOverride?>, + loadGenerationDelay: Long ): BenchmarkDeployment { return TestBenchmarkDeployment() } diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt index 2bafcb76dfc3463d9aa350b88c9f73d52cea6629..294727d6a252a29e312ff532937e7fdf9f079ac7 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt @@ -13,7 +13,8 @@ class TestBenchmarkExecutorImpl( benchmark: Benchmark, results: Results, slo: BenchmarkExecution.Slo, - executionId: Int + executionId: Int, + loadGenerationDelay: Long ) : BenchmarkExecutor( benchmark, @@ -21,7 +22,8 @@ class TestBenchmarkExecutorImpl( executionDuration = Duration.ofSeconds(1), configurationOverrides = emptyList(), slo = slo, - executionId = executionId + executionId = executionId, + loadGenerationDelay = loadGenerationDelay ) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean {