Skip to content
Snippets Groups Projects
Commit b45315a1 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

add patcher test

parent 9b407381
No related branches found
No related tags found
1 merge request!168Enhance Code Quality
...@@ -6,6 +6,7 @@ import io.quarkus.runtime.annotations.RegisterForReflection ...@@ -6,6 +6,7 @@ import io.quarkus.runtime.annotations.RegisterForReflection
import mu.KotlinLogging import mu.KotlinLogging
import org.apache.kafka.clients.admin.NewTopic import org.apache.kafka.clients.admin.NewTopic
import theodolite.k8s.K8sManager import theodolite.k8s.K8sManager
import theodolite.k8s.ResourceByLabelHandler
import theodolite.k8s.TopicManager import theodolite.k8s.TopicManager
import theodolite.util.KafkaConfig import theodolite.util.KafkaConfig
import java.time.Duration import java.time.Duration
...@@ -32,7 +33,8 @@ class KubernetesBenchmarkDeployment( ...@@ -32,7 +33,8 @@ class KubernetesBenchmarkDeployment(
) : BenchmarkDeployment { ) : BenchmarkDeployment {
private val kafkaController = TopicManager(this.kafkaConfig) private val kafkaController = TopicManager(this.kafkaConfig)
private val kubernetesManager = K8sManager(client) 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]: * Setup a [KubernetesBenchmark] using the [TopicManager] and the [K8sManager]:
...@@ -59,7 +61,10 @@ class KubernetesBenchmarkDeployment( ...@@ -59,7 +61,10 @@ class KubernetesBenchmarkDeployment(
loadGenResources.forEach { kubernetesManager.remove(it) } loadGenResources.forEach { kubernetesManager.remove(it) }
appResources.forEach { kubernetesManager.remove(it) } appResources.forEach { kubernetesManager.remove(it) }
kafkaController.removeTopics(this.topics.map { topic -> topic.name }) 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." } logger.info { "Teardown complete. Wait $afterTeardownDelay ms to let everything come down." }
Thread.sleep(Duration.ofSeconds(afterTeardownDelay).toMillis()) Thread.sleep(Duration.ofSeconds(afterTeardownDelay).toMillis())
} }
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment