mirror of https://github.com/apache/kafka.git
				
				
				
			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:
		
							parent
							
								
									9df925bf9e
								
							
						
					
					
						commit
						8e522c56d1
					
				|  | @ -25,8 +25,6 @@ import org.junit.jupiter.api.Assertions.{assertEquals, assertThrows} | ||||||
| import org.junit.jupiter.api.Test | import org.junit.jupiter.api.Test | ||||||
| 
 | 
 | ||||||
| class ConsumerPerformanceTest { | class ConsumerPerformanceTest { | ||||||
| 
 |  | ||||||
|   private val outContent = new ByteArrayOutputStream() |  | ||||||
|   private val dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS") |   private val dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS") | ||||||
| 
 | 
 | ||||||
|   @Test |   @Test | ||||||
|  | @ -148,6 +146,8 @@ class ConsumerPerformanceTest { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   private def testHeaderMatchContent(detailed: Boolean, expectedOutputLineCount: Int, fun: () => Unit): Unit = { |   private def testHeaderMatchContent(detailed: Boolean, expectedOutputLineCount: Int, fun: () => Unit): Unit = { | ||||||
|  |     val outContent = new ByteArrayOutputStream | ||||||
|  |     try { | ||||||
|       Console.withOut(outContent) { |       Console.withOut(outContent) { | ||||||
|         ConsumerPerformance.printHeader(detailed) |         ConsumerPerformance.printHeader(detailed) | ||||||
|         fun() |         fun() | ||||||
|  | @ -157,7 +157,10 @@ class ConsumerPerformanceTest { | ||||||
|         val header = contents(0) |         val header = contents(0) | ||||||
|         val body = contents(1) |         val body = contents(1) | ||||||
| 
 | 
 | ||||||
|       assertEquals(header.split(",").length, body.split(",").length) |         assertEquals(header.split(",\\s").length, body.split(",\\s").length) | ||||||
|  |       } | ||||||
|  |     } finally { | ||||||
|  |       outContent.close() | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue