diff --git a/metrics/metrics/pom.xml b/metrics/metrics/pom.xml index 7c8e29479b2..2dbfe56d49a 100644 --- a/metrics/metrics/pom.xml +++ b/metrics/metrics/pom.xml @@ -87,11 +87,6 @@ helidon-webclient test - - io.helidon.config - helidon-config-testing - test - org.junit.jupiter junit-jupiter-api diff --git a/metrics/metrics/src/test/java/io/helidon/metrics/TestServer.java b/metrics/metrics/src/test/java/io/helidon/metrics/TestServer.java index f7e9f7bd23f..f0c70cc5820 100644 --- a/metrics/metrics/src/test/java/io/helidon/metrics/TestServer.java +++ b/metrics/metrics/src/test/java/io/helidon/metrics/TestServer.java @@ -28,7 +28,6 @@ import io.helidon.common.http.Http; import io.helidon.common.http.MediaType; -import io.helidon.config.testing.MatcherWithRetry; import io.helidon.media.jsonp.JsonpSupport; import io.helidon.webclient.WebClient; import io.helidon.webclient.WebClientRequestBuilder; @@ -54,7 +53,6 @@ import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.not; public class TestServer { @@ -193,6 +191,9 @@ void checkMetricsForExecutorService() throws Exception { String jsonKeyForCompleteTaskCountInThreadPool = "executor-service.completed-task-count;poolIndex=0;supplierCategory=my-thread-thread-pool-1;supplierIndex=0"; + // Because ThreadPoolExecutor methods are documented as reporting approximations of task counts, etc., we should + // not depend on the values changing in a reasonable time period...or at all. So this test simply makes sure that + // an expected metric is present. WebClientRequestBuilder metricsRequestBuilder = webClientBuilder .build() .get() @@ -210,39 +211,6 @@ void checkMetricsForExecutorService() throws Exception { assertThat("JSON metrics results before accessing slow endpoint", metrics, hasKey(jsonKeyForCompleteTaskCountInThreadPool)); - - int completedTaskCount = metrics.getInt(jsonKeyForCompleteTaskCountInThreadPool); - assertThat("Completed task count before accessing slow endpoint", completedTaskCount, is(0)); - - WebClientResponse slowGreetResponse = webClientBuilder - .build() - .get() - .accept(MediaType.TEXT_PLAIN) - .path("greet/slow") - .submit() - .await(CLIENT_TIMEOUT); - - assertThat("Slow greet access response status", slowGreetResponse.status().code(), is(200)); - - MatcherWithRetry.retry(() -> { - - WebClientResponse secondMetricsResponse = metricsRequestBuilder - .submit() - .await(CLIENT_TIMEOUT); - - assertThat("Second access to metrics", secondMetricsResponse.status().code(), is(200)); - - JsonObject secondMetrics = secondMetricsResponse.content().as(JsonObject.class).await(CLIENT_TIMEOUT); - - assertThat("JSON metrics results after accessing slow endpoint", - secondMetrics, - hasKey(jsonKeyForCompleteTaskCountInThreadPool)); - - int secondCompletedTaskCount = secondMetrics.getInt(jsonKeyForCompleteTaskCountInThreadPool); - - assertThat("Completed task count after accessing slow endpoint", secondCompletedTaskCount, is(1)); - return true; - }); } @ParameterizedTest