Skip to content

Commit f3b0c20

Browse files
committed
plugin management
Signed-off-by: Gregor Zeitlinger <[email protected]>
1 parent 85e66d6 commit f3b0c20

File tree

42 files changed

+342
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+342
-99
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
PROTO_GENERATION: true
2626
REQUIRE_PROTO_UP_TO_DATE: true
2727
run: |
28-
echo "Java version: $(java -version) in $(which java), Maven version: $(mvn -v)"
29-
echo "JAVA_HOME: $JAVA_HOME"
28+
mvn -v
3029
./mvnw clean install
3130
./mvnw javadoc:javadoc -P javadoc # just to check if javadoc is generated

.github/workflows/native-tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: GraalVM Native Tests
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
native-tests:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up JDK
15+
uses: actions/setup-java@v4
16+
with:
17+
java-version: 17
18+
distribution: graalvm
19+
cache: 'maven'
20+
- name: Run the Maven verify phase
21+
run: ./scripts/run-native-tests.sh

integration-tests/it-common/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
Common utilities for integration tests
1717
</description>
1818

19+
<dependencies>
20+
<dependency>
21+
<groupId>io.prometheus</groupId>
22+
<artifactId>prometheus-metrics-exposition-formats</artifactId>
23+
<version>${project.version}</version>
24+
</dependency>
25+
</dependencies>
26+
1927
<build>
2028
<testResources>
2129
<testResource>

integration-tests/it-common/src/test/java/io/prometheus/client/it/common/ExporterTest.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import static org.assertj.core.api.Assertions.assertThat;
55
import static org.assertj.core.api.Assertions.fail;
66

7+
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_28_3.Metrics;
78
import java.io.ByteArrayInputStream;
89
import java.io.IOException;
10+
import java.io.InputStream;
911
import java.net.HttpURLConnection;
1012
import java.net.URISyntaxException;
1113
import java.net.URL;
14+
import java.util.ArrayList;
1215
import java.util.HashMap;
1316
import java.util.List;
1417
import java.util.Locale;
@@ -55,21 +58,27 @@ public void tearDown() throws IOException {
5558
sampleAppVolume.remove();
5659
}
5760

58-
protected void assertContentType(String expected, String actual) {
61+
public static void assertContentType(String expected, String actual) {
5962
if (!expected.replace(" ", "").equals(actual)) {
6063
assertThat(actual).isEqualTo(expected);
6164
}
6265
}
6366

6467
protected Response scrape(String method, String queryString, String... requestHeaders)
6568
throws IOException {
66-
long timeoutMillis = TimeUnit.SECONDS.toMillis(5);
67-
URL url =
69+
return scrape(
70+
method,
6871
new URL(
6972
"http://localhost:"
7073
+ sampleAppContainer.getMappedPort(9400)
7174
+ "/metrics?"
72-
+ queryString);
75+
+ queryString),
76+
requestHeaders);
77+
}
78+
79+
public static Response scrape(String method, URL url, String... requestHeaders)
80+
throws IOException {
81+
long timeoutMillis = TimeUnit.SECONDS.toMillis(5);
7382
HttpURLConnection con = (HttpURLConnection) url.openConnection();
7483
con.setRequestMethod(method);
7584
for (int i = 0; i < requestHeaders.length; i += 2) {
@@ -106,7 +115,7 @@ protected Response scrape(String method, String queryString, String... requestHe
106115
return null; // will not happen
107116
}
108117

109-
protected static class Response {
118+
public static class Response {
110119
public final int status;
111120
private final Map<String, String> headers;
112121
public final byte[] body;
@@ -136,5 +145,14 @@ public String gzipBody() throws IOException {
136145
return new String(
137146
IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(body))), UTF_8);
138147
}
148+
149+
public List<Metrics.MetricFamily> protoBody() throws IOException {
150+
List<Metrics.MetricFamily> metrics = new ArrayList<>();
151+
InputStream in = new ByteArrayInputStream(body);
152+
while (in.available() > 0) {
153+
metrics.add(Metrics.MetricFamily.parseDelimitedFrom(in));
154+
}
155+
return metrics;
156+
}
139157
}
140158
}

integration-tests/it-exporter/it-exporter-no-protobuf/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.prometheus</groupId>
88
<artifactId>it-exporter</artifactId>
9-
<version>1.3.2</version>
9+
<version>1.3.3</version>
1010
</parent>
1111

1212
<artifactId>it-exporter-no-protobuf</artifactId>

integration-tests/it-exporter/it-exporter-test/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
</description>
1818

1919
<dependencies>
20-
<dependency>
21-
<groupId>io.prometheus</groupId>
22-
<artifactId>prometheus-metrics-exposition-formats</artifactId>
23-
<version>${project.version}</version>
24-
</dependency>
2520
<dependency>
2621
<groupId>io.prometheus</groupId>
2722
<artifactId>it-common</artifactId>

integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/ExporterIT.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66
import com.google.common.io.Resources;
77
import io.prometheus.client.it.common.ExporterTest;
88
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_28_3.Metrics;
9-
import java.io.ByteArrayInputStream;
109
import java.io.IOException;
11-
import java.io.InputStream;
1210
import java.net.URISyntaxException;
1311
import java.net.URLEncoder;
14-
import java.util.ArrayList;
1512
import java.util.List;
1613
import org.junit.jupiter.api.Test;
1714
import org.junit.jupiter.params.ParameterizedTest;
@@ -82,11 +79,7 @@ public void testPrometheusProtobufFormat() throws IOException {
8279
assertThat(response.getHeader("Transfer-Encoding")).isNull();
8380
assertThat(response.getHeader("Content-Length"))
8481
.isEqualTo(Integer.toString(response.body.length));
85-
List<Metrics.MetricFamily> metrics = new ArrayList<>();
86-
InputStream in = new ByteArrayInputStream(response.body);
87-
while (in.available() > 0) {
88-
metrics.add(Metrics.MetricFamily.parseDelimitedFrom(in));
89-
}
82+
List<Metrics.MetricFamily> metrics = response.protoBody();
9083
assertThat(metrics).hasSize(3);
9184
// metrics are sorted by name
9285
assertThat(metrics.get(0).getName()).isEqualTo("integration_test_info");

integration-tests/it-exporter/it-no-protobuf/pom.xml renamed to integration-tests/it-exporter/it-no-protobuf-test/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<parent>
66
<groupId>io.prometheus</groupId>
77
<artifactId>it-exporter</artifactId>
8-
<version>1.3.2</version>
8+
<version>1.3.3</version>
99
</parent>
1010

11-
<artifactId>it-no-protobuf</artifactId>
11+
<artifactId>it-no-protobuf-test</artifactId>
1212

1313
<name>Integration Test - No Protobuf</name>
1414
<description>

integration-tests/it-exporter/it-no-protobuf/src/test/java/io/prometheus/metrics/it/noprotobuf/NoProtobufIT.java renamed to integration-tests/it-exporter/it-no-protobuf-test/src/test/java/io/prometheus/metrics/it/noprotobuf/NoProtobufIT.java

File renamed without changes.

integration-tests/it-exporter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
<module>it-exporter-httpserver-sample</module>
2323
<module>it-exporter-no-protobuf</module>
2424
<module>it-exporter-test</module>
25-
<module>it-no-protobuf</module>
25+
<module>it-no-protobuf-test</module>
2626
</modules>
2727
</project>

0 commit comments

Comments
 (0)