Skip to content

Commit

Permalink
Re-add missing TCKs
Browse files Browse the repository at this point in the history
Removes outdated extension
Adjust example to metrics 5
  • Loading branch information
rzo1 committed Apr 23, 2024
1 parent d9f345b commit 1706146
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 142 deletions.
9 changes: 3 additions & 6 deletions examples/mp-metrics-timed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@
<name>TomEE :: Examples :: Microprofile Metrics Timed</name>
<properties>
<version.jakartaee-api>10.0-M2</version.jakartaee-api>
<version.microprofile.metrics>4.0.1</version.microprofile.metrics>
<version.microprofile.metrics>5.0.2</version.microprofile.metrics>
<version.arquillian.bom>1.7.0.Final</version.arquillian.bom>
<version.jakartaee-api>9.1-M2</version.jakartaee-api>
<microprofile.metrics.version>5.0.0-SNAPSHOT</microprofile.metrics.version>
<version.arquillian.bom>1.7.0.Alpha10</version.arquillian.bom>
<junit.version>4.13.2</junit.version>
<tomee.version>10.0.0-M2-SNAPSHOT</tomee.version>
</properties>
Expand Down Expand Up @@ -94,8 +91,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>

Expand Down
94 changes: 1 addition & 93 deletions examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ public void testTimedMetric() {
.path("/weather/day/status")
.request().buildGet().invoke();

// final String metricPath = "/metrics/application/weather_day_status";
final String metricPath = "/metrics";
assertPrometheusFormat(metricPath);

//assertJsonFormat(metricPath); // TODO: fix JSON export
// assertJsonFormat(metricPath);
}

private void assertPrometheusFormat(final String metricPath) {
Expand All @@ -93,8 +92,6 @@ private void assertPrometheusFormat(final String metricPath) {
.invoke()
.readEntity(String.class);

System.out.println("Received: " + metric);

String[] expected = {
"# TYPE weather_day_status_seconds summary",
"# HELP weather_day_status_seconds This metric shows the weather status of the day.",
Expand All @@ -115,93 +112,4 @@ private void assertPrometheusFormat(final String metricPath) {
.forEach(text -> assertTrue("Expected: " + text + " to be present in " + metric, metric.contains(text)));
}

private void assertJsonFormat(final String metricPath) {
WebTarget webTarget = client.target(base.toExternalForm());

String metric = webTarget
.path(metricPath)
.request()
.accept(MediaType.APPLICATION_JSON)
.buildGet()
.invoke()
.readEntity(String.class);

JsonObject expectedJson = Json.createReader(new StringReader(metric)).readObject();

String[] expected = {
"count",
"meanRate",
"fifteenMinRate",
"fiveMinRate",
"oneMinRate",
"min",
"max",
"mean",
"stddev",
"p50",
"p75",
"p95",
"p98",
"p99",
"p999"
};

Stream.of(expected)
.forEach(text ->
assertTrue(
"Expected: " + text + " to be present in " + metric,
expectedJson.getJsonObject("weather_day_status").get(text) != null));
}

@Test
@Ignore
// TODO: fix JSON export
public void testTimedMetricMetadata() {

WebTarget webTarget = client.target(base.toExternalForm());

// Response response = webTarget.path("/metrics/application/weather_day_status")
Response response = webTarget.path("/metrics")
.request()
.accept(MediaType.APPLICATION_JSON)
.build("OPTIONS")
.invoke();

final String metaData = response.readEntity(String.class);

System.out.println("Received: " + metaData);

JsonObject metadataJson = Json.createReader(new StringReader(metaData)).readObject();

final String expected = "{\n" +
" \"weather_day_status\": {\n" +
" \"description\": \"This metric shows the weather status of the day.\",\n" +
" \"name\": \"weather_day_status\",\n" +
" \"reusable\": false,\n" +
" \"tags\": \"\",\n" +
" \"type\": \"timer\",\n" +
" \"typeRaw\": \"TIMER\",\n" +
" \"unit\": \"nanoseconds\"\n" +
" }\n" +
"}";

JsonObject expectedJson = Json.createReader(new StringReader(expected)).readObject();
assertEquals(expectedJson.keySet().size(), metadataJson.keySet().size());

String[] expectedKeys = {
"description",
"name",
"reusable",
"tags",
"type",
"typeRaw",
"unit",
};

Stream.of(expectedKeys)
.forEach(text ->
assertTrue(
"Expected: " + text + " to be present in " + expected,
expectedJson.getJsonObject("weather_day_status").get(text) != null));
}
}
4 changes: 2 additions & 2 deletions tck/microprofile-tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

<modules>
<module>config</module>
<!--<module>jwt</module>-->
<module>jwt</module>
<module>health</module>
<module>metrics</module>
<!--<module>rest-client</module>-->
<module>rest-client</module>
<module>openapi</module>
<module>fault-tolerance</module>
<module>opentracing</module>
Expand Down

This file was deleted.

0 comments on commit 1706146

Please sign in to comment.