Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti

### Upgrade notes

- The legacy management endpoints at `/metrics` and `/healthcheck` have been removed. Please use the
standard management endpoints at `/q/metrics` and `/q/health` instead.

### Breaking changes

### New Features
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@ExtendWith(TestEnvironmentExtension.class)
Expand Down Expand Up @@ -72,26 +71,23 @@ public void clearMetrics() {
registry.clear();
}

private Map<String, MetricFamily> fetchMetrics(String endpoint) {
private Map<String, MetricFamily> fetchMetrics() {
AtomicReference<Map<String, MetricFamily>> value = new AtomicReference<>();
Awaitility.await()
.atMost(Duration.ofMinutes(2))
.untilAsserted(
() -> {
value.set(
TestMetricsUtil.fetchMetrics(
fixture.client, testEnv.baseManagementUri(), endpoint));
value.set(TestMetricsUtil.fetchMetrics(fixture.client, testEnv.baseManagementUri()));
assertThat(value.get()).containsKey(API_METRIC_NAME);
assertThat(value.get()).containsKey(HTTP_METRIC_NAME);
});
return value.get();
}

@ParameterizedTest
@ValueSource(strings = {"%s/metrics", "%s/q/metrics"})
public void testMetricsEmittedOnSuccessfulRequest(String endpoint) {
@Test
public void testMetricsEmittedOnSuccessfulRequest() {
sendSuccessfulRequest();
Map<String, MetricFamily> allMetrics = fetchMetrics(endpoint);
Map<String, MetricFamily> allMetrics = fetchMetrics();
assertThat(allMetrics).containsKey(API_METRIC_NAME);
assertThat(allMetrics.get(API_METRIC_NAME).getMetrics())
.satisfiesOnlyOnce(
Expand Down Expand Up @@ -143,11 +139,10 @@ public void testMetricsEmittedOnSuccessfulRequest(String endpoint) {
});
}

@ParameterizedTest
@ValueSource(strings = {"%s/metrics", "%s/q/metrics"})
public void testMetricsEmittedOnFailedRequest(String endpoint) {
@Test
public void testMetricsEmittedOnFailedRequest() {
sendFailingRequest();
Map<String, MetricFamily> allMetrics = fetchMetrics(endpoint);
Map<String, MetricFamily> allMetrics = fetchMetrics();
assertThat(allMetrics).containsKey(API_METRIC_NAME);
assertThat(allMetrics.get(API_METRIC_NAME).getMetrics())
.satisfiesOnlyOnce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void testMetricsAreEmittedWhenRateLimiting() {
// polaris_principal_roles_listPrincipalRoles_seconds_count{application="Polaris",class="org.apache.polaris.service.admin.api.PolarisPrincipalRolesApi",environment="prod",exception="none",method="listPrincipalRoles"} 50.0

Map<String, MetricFamily> metrics =
TestMetricsUtil.fetchMetrics(fixture.client, testEnv.baseManagementUri(), "%s/q/metrics");
TestMetricsUtil.fetchMetrics(fixture.client, testEnv.baseManagementUri());

assertThat(metrics)
.isNotEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class DefaultTestEnvironmentResolver implements TestEnvironmentResolver {
@Override
public TestEnvironment resolveTestEnvironment(ExtensionContext extensionContext) {
return new TestEnvironment(
String.format("http://localhost:%d", localPort),
String.format("http://localhost:%d", localManagementPort));
String.format("http://localhost:%d/", localPort),
String.format("http://localhost:%d/", localManagementPort));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
/** Utils for working with metrics in tests */
public class TestMetricsUtil {

public static Map<String, MetricFamily> fetchMetrics(
Client client, URI baseManagementUri, String endpointPath) {
Response response =
client.target(String.format(endpointPath, baseManagementUri)).request().get();
public static Map<String, MetricFamily> fetchMetrics(Client client, URI baseManagementUri) {
Response response = client.target(baseManagementUri.resolve("q/metrics")).request().get();
if (response.getStatus() == Status.MOVED_PERMANENTLY.getStatusCode()) {
response = client.target(response.getLocation()).request().get();
}
Expand Down