Skip to content

Commit 0ef71da

Browse files
committed
add test for only custom yaml
1 parent b683c3d commit 0ef71da

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.contrib.jmxscraper.target_systems;
7+
8+
import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer;
9+
import io.opentelemetry.contrib.jmxscraper.TestAppContainer;
10+
import java.nio.file.Path;
11+
import org.testcontainers.containers.GenericContainer;
12+
import org.testcontainers.containers.wait.strategy.Wait;
13+
14+
public class CustomIntegrationTest extends TargetSystemIntegrationTest {
15+
16+
@Override
17+
protected GenericContainer<?> createTargetContainer(int jmxPort) {
18+
// reusing test application for custom yaml
19+
//noinspection resource
20+
return new TestAppContainer()
21+
.withJmxPort(jmxPort)
22+
.withExposedPorts(jmxPort)
23+
.waitingFor(Wait.forListeningPorts(jmxPort));
24+
}
25+
26+
@Override
27+
protected JmxScraperContainer customizeScraperContainer(
28+
JmxScraperContainer scraper, GenericContainer<?> target, Path tempDir) {
29+
// only testing custom yaml
30+
return scraper.withCustomYaml("custom-metrics.yaml");
31+
}
32+
33+
@Override
34+
protected MetricsVerifier createMetricsVerifier() {
35+
return MetricsVerifier.create()
36+
// custom metric in custom-metrics.yaml
37+
.add(
38+
"custom.jvm.uptime",
39+
metric ->
40+
metric
41+
.hasDescription("JVM uptime in milliseconds")
42+
.hasUnit("ms")
43+
.isCounter()
44+
.hasDataPointsWithoutAttributes());
45+
}
46+
}

0 commit comments

Comments
 (0)