diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt index d5a4df074fd220dc8b62d5ecc8430b298735e0cf..e086f7f885c62c55747f9de798bc5e5bf77573d5 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt @@ -6,6 +6,7 @@ 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 java.time.Duration @@ -32,7 +33,8 @@ class KubernetesBenchmarkDeployment( ) : BenchmarkDeployment { private val kafkaController = TopicManager(this.kafkaConfig) private val kubernetesManager = K8sManager(client) - private val LAG_EXPORTER_POD_LABEL = "app.kubernetes.io/name=kafka-lag-exporter" + private val LAG_EXPORTER_POD_LABEL_NAME= "app.kubernetes.io/name" + private val LAG_EXPORTER_POD_LABEL_VALUE= "kafka-lag-exporter" /** * Setup a [KubernetesBenchmark] using the [TopicManager] and the [K8sManager]: @@ -59,7 +61,10 @@ class KubernetesBenchmarkDeployment( loadGenResources.forEach { kubernetesManager.remove(it) } appResources.forEach { kubernetesManager.remove(it) } kafkaController.removeTopics(this.topics.map { topic -> topic.name }) - ResourceByLabelRemover(client).removePod(LAG_EXPORTER_POD_LABEL) + ResourceByLabelHandler(client).removePods( + labelName = LAG_EXPORTER_POD_LABEL_NAME, + labelValue = LAG_EXPORTER_POD_LABEL_VALUE + ) logger.info { "Teardown complete. Wait $afterTeardownDelay ms to let everything come down." } Thread.sleep(Duration.ofSeconds(afterTeardownDelay).toMillis()) } diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..9df095fb62c49e8b1be5e472d2852932240ba8f8 --- /dev/null +++ b/theodolite-quarkus/src/test/kotlin/theodolite/patcher/ConfigOverrideModifierTest.kt @@ -0,0 +1,57 @@ +package theodolite.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 + +@QuarkusTest +class ConfigOverrideModifierTest { + private var execution = BenchmarkExecution() + private var benchmark = KubernetesBenchmark() + + + + @BeforeEach + fun setup() { + val execution1 = ExecutionCRDummy(name = "matching-execution", benchmark = "Test-Benchmark") + val benchmark1 = BenchmarkCRDummy(name = "Test-Benchmark") + + this.execution = execution1.getCR().spec + this.benchmark = benchmark1.getCR().spec + } + + + + @Test + fun setAdditionalLabelsTest() { + this.benchmark.appResource = listOf("test-resource.yaml") + + val modifier = ConfigOverrideModifier( + execution = this.execution, + resources = this.benchmark.appResource ) + + modifier.setAdditionalLabels( + labelName = "test-name", + labelValue = "test-value") + + Assertions.assertEquals( + "test-name", + this.execution + .configOverrides.firstOrNull() + ?.patcher + ?.properties + ?.get("variableName") + ) + Assertions.assertEquals( + "test-value", + this.execution + .configOverrides.firstOrNull() + ?.value + ) + } +} \ No newline at end of file