squah-confluent commented on code in PR #21770:
URL: https://github.com/apache/kafka/pull/21770#discussion_r2940139413
##########
coordinator-common/src/test/java/org/apache/kafka/coordinator/common/runtime/CoordinatorBackgroundThreadPoolExecutorTest.java:
##########
@@ -80,28 +81,32 @@ public void testMetrics() throws ExecutionException,
InterruptedException, Timeo
task1Unblocked.countDown();
task1.get(5, TimeUnit.SECONDS);
- // Task 3 starts.
+ // Task 3 starts after task 1's metrics are recorded.
task3Started.await();
// Task 2 takes 500 ms.
mockTime.sleep(400);
task2Unblocked.countDown();
task2.get(5, TimeUnit.SECONDS);
+ // Wait until the metrics are recorded before advancing the clock.
+ verify(metrics,
timeout(5000).times(1)).recordBackgroundProcessingTime(500L);
+ verify(metrics,
timeout(5000).times(1)).recordBackgroundThreadBusyTime(250.0);
+
// Task 3 takes 500 ms.
mockTime.sleep(100);
task3Unblocked.countDown();
task3.get(5, TimeUnit.SECONDS);
-
- verify(metrics, times(2)).recordBackgroundQueueTime(0);
- verify(metrics, times(1)).recordBackgroundQueueTime(100);
- verify(metrics, times(1)).recordBackgroundProcessingTime(100);
- verify(metrics, times(2)).recordBackgroundProcessingTime(500);
- verify(metrics, times(1)).recordBackgroundThreadBusyTime(50.0);
- verify(metrics, times(2)).recordBackgroundThreadBusyTime(250.0);
Review Comment:
I don't follow. `awaitTermination` below waits for all work on the thread
pool to complete and is sufficient to ensure that the metrics have been
recorded.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]