KAFKA-17911: Fix handling of env variables in KafkaDockerWrapper (#17655)

Reviewers: Luke Chen <showuon@gmail.com>
This commit is contained in:
Mickael Maison 2024-11-06 10:47:51 +01:00 committed by GitHub
parent 688c2c0913
commit c40cb07984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -173,7 +173,7 @@ object KafkaDockerWrapper extends Logging {
env.map {
case (key, value) =>
if (key.startsWith("KAFKA_") && !ExcludeServerPropsEnv.contains(key)) {
val final_key = key.replace("KAFKA_", "").toLowerCase()
val final_key = key.replaceFirst("KAFKA_", "").toLowerCase()
.replace("_", ".")
.replace("...", "-")
.replace("..", "_")

View File

@ -28,8 +28,9 @@ class KafkaDockerWrapperTest {
val envVars = Map("KAFKA_TOOLS_LOG4J_LOGLEVEL" -> "TRACE",
"KAFKA_VALID_PROPERTY" -> "Value",
"SOME_VARIABLE" -> "Some Value",
"KAFKA_VALID___PROPERTY__ALL_CASES" -> "All Cases Value")
val expected = List("valid.property=Value", "valid-property_all.cases=All Cases Value")
"KAFKA_VALID___PROPERTY__ALL_CASES" -> "All Cases Value",
"KAFKA_KAFKA_VALID_PROPERTY" -> "Value")
val expected = List("valid.property=Value", "valid-property_all.cases=All Cases Value", "kafka.valid.property=Value")
val actual = KafkaDockerWrapper.getServerConfigsFromEnv(envVars)
assertEquals(expected, actual)
}