Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Prometheus Java Client integration test #1468

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

rickie
Copy link
Member

@rickie rickie commented Dec 18, 2024

There are some XXX's left to resolve, but apart from those, I think the PR is ready to be reviewed!

For those XXX's I'll still work on creating a PR for them.

@rickie rickie force-pushed the rossendrijver/prometheus_integration_tests branch from 3cfe7b9 to 90a8bdd Compare December 18, 2024 13:31
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

2 similar comments
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie added this to the 0.20.0 milestone Dec 19, 2024
@rickie rickie added the chore A task not related to code (build, formatting, process, ...) label Dec 19, 2024
@rickie
Copy link
Member Author

rickie commented Dec 19, 2024

The IT is successful!

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.


class PrometheusInstrumentationScopeTest {

+ // XXX: Introduce support for rewriting `assertThatThrownBy#havingRootCause()`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed: #1471

@rickie rickie force-pushed the rossendrijver/prometheus_integration_tests branch from 3421c71 to b4c5bed Compare December 20, 2024 13:43
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie marked this pull request as ready for review December 20, 2024 13:45
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202 Stephan202 force-pushed the rossendrijver/prometheus_integration_tests branch from b4c5bed to 75534db Compare December 21, 2024 12:15
Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and added a commit. One point of attention: there appears to be a flaky test:

[ERROR] io.prometheus.metrics.core.metrics.SlidingWindowTest.rotate -- Time elapsed: 0.023 s <<< FAILURE!
org.opentest4j.AssertionFailedError:
[Start time: 1734782202868, current time: 1734782232878, elapsed time: 30010]
expected: [1.0, 1.0, 1.0, 1.0, 1.0]
 but was: [1.0, 1.0, 1.0, 1.0]
    at io.prometheus.metrics.core.metrics.SlidingWindowTest$Observer.assertValues(SlidingWindowTest.java:30)
    at io.prometheus.metrics.core.metrics.SlidingWindowTest.rotate(SlidingWindowTest.java:57)
    at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

@mohamedsamehsalah if you review #1471 then we can strike one precondition off the list :)

Comment on lines 11 to 14
# XXX: Minimize the diff by including
# `-XepOpt:Slf4jLoggerDeclaration:CanonicalStaticLoggerName=logger` once such
# flags are supported in patch mode. See
# https://github.com/google/error-prone/pull/4699.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't apply here 👀

<junit-jupiter.version>5.11.3</junit-jupiter.version>
<otel.instrumentation.version>2.10.0-alpha</otel.instrumentation.version>
- <java.version>8</java.version>
+ <java.version>11</java.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can specify this using additional_build_flags='-Djava.version=11' instead, keeping the patch minimal.

<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint:all,-serial,-processing,-options</arg>
- <arg>${warnings}</arg>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can instead set -Dwarnings=, keeping the patch minimal.

Comment on lines 65 to 58
--- a/prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/MetricNameFilter.java
+++ b/prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/MetricNameFilter.java
@@ -8,6 +8,8 @@ import java.util.Collection;
import java.util.function.Predicate;

/** Filter samples (i.e. time series) by name. */
+// XXX: Don't suggest changes when there are local methods with the same name.
+@SuppressWarnings("ExplicitArgumentEnumeration")
public class MetricNameFilter implements Predicate<String> {

/** For convenience, a filter that allows all names. */
--- a/prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Quantiles.java
+++ b/prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Quantiles.java
@@ -41,6 +41,8 @@ public class Quantiles implements Iterable<Quantile> {
* Create a new Quantiles instance. You can either create Quantiles with one of the static {@code
* Quantiles.of(...)} methods, or you can use the {@link Quantiles#builder()}.
*/
+ // XXX: Don't suggest changes when there are local methods with the same name.
+ @SuppressWarnings("ExplicitArgumentEnumeration")
public static Quantiles of(Quantile... quantiles) {
return of(Arrays.asList(quantiles));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, we should try to fix ExplicitArgumentEnumeration so that thee suppressions aren't necessary. (I may have time for this ~tomorrow.)

Copy link
Member Author

@rickie rickie Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have time for this ~tomorrow

If not, I'll try to make time for it on Monday! Today won't work for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed #1475 and rebased this PR to exclude these suppressions from the patch file.

Comment on lines 87 to 80
--- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotTest.java
+++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotTest.java
@@ -7,6 +7,8 @@ import org.junit.jupiter.api.Test;

class MetricSnapshotTest {

+ // XXX: Investigate the `satisfies` and how to rewrite this.
+ @SuppressWarnings("AssertThatThrownBy")
@Test
public void testDuplicateLabels() {
assertThatExceptionOfType(DuplicateLabelsException.class)
--- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java
+++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java
@@ -6,6 +6,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import org.junit.jupiter.api.Test;

+// XXX: Fix this edge case in the `JUnitMethodDeclaration` check.
+@SuppressWarnings("JUnitMethodDeclaration")
class PrometheusNamingTest {

@Test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should either fix these cases or formulate better XXX comments. (Can have a look ~tomorrow.)

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie force-pushed the rossendrijver/prometheus_integration_tests branch from 75534db to e8ff396 Compare December 22, 2024 12:39
@rickie
Copy link
Member Author

rickie commented Dec 22, 2024

Found a few flaky test issues on their GitHub about the same class as what you noticed: prometheus/client_java#956, prometheus/client_java#946.

I also experienced the issue on my local machine. Maybe for now we should report and exclude the specific case via -Dtest?

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

1 similar comment
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202
Copy link
Member

I also experienced the issue on my local machine. Maybe for now we should report and exclude the specific case via -Dtest?

Yeah, agree. I filed prometheus/client_java#1242 and will reference that issue in an accompanying comment.

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202
Copy link
Member

Rebased and added a commit. The PR now requires #1475 and #1476 to be merged first. Open points (not today):

  • Cleanup of .github/workflows/run-integration-tests.yml.
  • A closer look at the generated changes.
  • A closer look at the @SuppressWarnings("AssertThatThrownBy") in the initial patch file.

@Stephan202 Stephan202 force-pushed the rossendrijver/prometheus_integration_tests branch from 77ddee5 to 758bf21 Compare December 23, 2024 16:56
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202
Copy link
Member

Added a commit to document some possible follow-up work. Open points:

  • Fixing the build. Somehow pulling Docker images keeps failing:
    [main] INFO tc.testcontainers/ryuk:0.11.0 - Pulling docker image: testcontainers/ryuk:0.11.0. Please be patient; this may take some time but only needs to be done once.
    [docker-java-stream--1295187651] ERROR com.github.dockerjava.api.async.ResultCallbackTemplate - Error during callback
    com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"message":"Head \"[https://registry-1.docker.io/v2/testcontainers/ryuk/manifests/0.11.0\](https://registry-1.docker.io/v2/testcontainers/ryuk/manifests/0.11.0/)": Get \"https://auth.docker.io/token?account=githubactions&scope=repository%3Atestcontainers%2Fryuk%3Apull&service=registry.docker.io\": dial tcp 54.185.253.63:443: connect: connection refused"}
    
  • Cleanup of .github/workflows/run-integration-tests.yml

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore A task not related to code (build, formatting, process, ...)
Development

Successfully merging this pull request may close these issues.

3 participants