File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
server/src/test/java/org/elasticsearch/threadpool Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -528,10 +528,12 @@ public void testDetailedUtilizationMetric() throws Exception {
528528 });
529529 safeAwait (barrier );
530530 safeGet (future );
531- final long maxDurationNanos = System .nanoTime () - beforeStartNanos ;
532-
533531 // Wait for TaskExecutionTimeTrackingEsThreadPoolExecutor#afterExecute to run
534532 assertBusy (() -> assertThat (executor .getTotalTaskExecutionTime (), greaterThan (0L )));
533+ // When you call submit, the TimedRunnable wraps the FutureTask, so safeGet can return before the duration of
534+ // the task is calculated. Waiting for totalTaskExecutionTime to be updated ensures maxDurationNanos is greater
535+ // than the actual duration.
536+ final long maxDurationNanos = System .nanoTime () - beforeStartNanos ;
535537
536538 final long beforeMetricsCollectedNanos = System .nanoTime ();
537539 meterRegistry .getRecorder ().collect ();
You can’t perform that action at this time.
0 commit comments