0xffff-zhiyan commented on code in PR #20356: URL: https://github.com/apache/kafka/pull/20356#discussion_r2279385349
########## core/src/test/scala/kafka/server/KafkaRequestHandlerTest.scala: ########## @@ -194,6 +248,38 @@ class KafkaRequestHandlerTest { assertEquals(1, handledCount) } + @Test + def testResizeThreadPoolUpdatesThreadPoolSize(): Unit = { + val time = Time.SYSTEM + val metrics = new RequestChannelMetrics(java.util.Set.of[ApiKeys]) + val requestChannel = new RequestChannel(10, time, metrics) + val apiHandler = mock(classOf[ApiRequestHandler]) + + // start with 3 threads + val pool = new KafkaRequestHandlerPool( + 0, + requestChannel, + apiHandler, + time, + 3, + "RequestHandlerAvgIdlePercent", + ) + try { + assertEquals(3, pool.threadPoolSize.get) + + // grow to 5 + pool.resizeThreadPool(5) + assertEquals(5, pool.threadPoolSize.get) + + // shrink to 2 + pool.resizeThreadPool(2) + assertEquals(2, pool.threadPoolSize.get) Review Comment: This only tests the pool’s resize, including expansion and shrinking, since that’s the part I modified. The previous tests didn’t specifically cover this, so this ensures the pool resizes to the correct size. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org