MINOR: Fix ConsumerPerformanceTest to work with non-default locales (#12623)

ConsumerPerformanceTest fails when running on a machine with a Locale where decimal is represented by a comma. E.g. in locale of Germany, one point two is written as 1,2 and not 1.2 as with the default locale.

The test fails because it validates that each header has a corresponding value by assuming that comma is a separator between values & headers. This assumption fails for Germany Locale because comma could be part of a float number.

Reviewers: David Jacot <djacot@confluent.io>
This commit is contained in:
Divij Vaidya 2022-09-21 15:54:25 +02:00 committed by GitHub
parent 9df925bf9e
commit 8e522c56d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 10 deletions

View File

@ -25,8 +25,6 @@ import org.junit.jupiter.api.Assertions.{assertEquals, assertThrows}
import org.junit.jupiter.api.Test
class ConsumerPerformanceTest {
private val outContent = new ByteArrayOutputStream()
private val dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS")
@Test
@ -148,16 +146,21 @@ class ConsumerPerformanceTest {
}
private def testHeaderMatchContent(detailed: Boolean, expectedOutputLineCount: Int, fun: () => Unit): Unit = {
Console.withOut(outContent) {
ConsumerPerformance.printHeader(detailed)
fun()
val outContent = new ByteArrayOutputStream
try {
Console.withOut(outContent) {
ConsumerPerformance.printHeader(detailed)
fun()
val contents = outContent.toString.split("\n")
assertEquals(expectedOutputLineCount, contents.length)
val header = contents(0)
val body = contents(1)
val contents = outContent.toString.split("\n")
assertEquals(expectedOutputLineCount, contents.length)
val header = contents(0)
val body = contents(1)
assertEquals(header.split(",").length, body.split(",").length)
assertEquals(header.split(",\\s").length, body.split(",\\s").length)
}
} finally {
outContent.close()
}
}
}