Skip to content

Commit

Permalink
Drop JUnitMethodDeclaration suppression
Browse files Browse the repository at this point in the history
And disable flaky test.
  • Loading branch information
Stephan202 committed Dec 22, 2024
1 parent 583be93 commit a8d83fb
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
55 changes: 44 additions & 11 deletions integration-tests/prometheus-java-client-expected-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9653,7 +9653,7 @@
}
--- 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
@@ -2,13 +2,13 @@ package io.prometheus.metrics.model.snapshots;
@@ -2,14 +2,14 @@ package io.prometheus.metrics.model.snapshots;

import static io.prometheus.metrics.model.snapshots.PrometheusNaming.*;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -9662,16 +9662,21 @@

import org.junit.jupiter.api.Test;

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

@Test
public void testSanitizeMetricName() {
@@ -27,19 +27,19 @@ class PrometheusNamingTest {
- public void testSanitizeMetricName() {
+ void testSanitizeMetricName() {
assertThat(prometheusName(sanitizeMetricName("0abc.def"))).isEqualTo("_abc_def");
assertThat(prometheusName(sanitizeMetricName("___ab.:c0"))).isEqualTo("___ab__c0");
assertThat(sanitizeMetricName("my_prefix/my_metric")).isEqualTo("my_prefix_my_metric");
@@ -23,25 +23,25 @@ class PrometheusNamingTest {
}

@Test
public void testSanitizeMetricNameWithUnit() {
- public void testSanitizeMetricNameWithUnit() {
+ void sanitizeMetricNameWithUnit() {
assertThat(prometheusName(sanitizeMetricName("0abc.def", Unit.RATIO)))
- .isEqualTo("_abc_def_" + Unit.RATIO);
+ .isEqualTo("_abc_def_%s", Unit.RATIO);
Expand Down Expand Up @@ -9699,35 +9704,63 @@
}

@Test
@@ -77,25 +77,23 @@ class PrometheusNamingTest {
- public void testSanitizeLabelName() {
+ void testSanitizeLabelName() {
assertThat(prometheusName(sanitizeLabelName("0abc.def"))).isEqualTo("_abc_def");
assertThat(prometheusName(sanitizeLabelName("_abc"))).isEqualTo("_abc");
assertThat(prometheusName(sanitizeLabelName("__abc"))).isEqualTo("_abc");
@@ -52,7 +52,7 @@ class PrometheusNamingTest {
}

@Test
- public void testValidateUnitName() {
+ void testValidateUnitName() {
assertThat(validateUnitName("secondstotal")).isNotNull();
assertThat(validateUnitName("total")).isNotNull();
assertThat(validateUnitName("seconds_total")).isNotNull();
@@ -64,7 +64,7 @@ class PrometheusNamingTest {
}

@Test
- public void testSanitizeUnitName() {
+ void testSanitizeUnitName() {
assertThat(sanitizeUnitName("seconds")).isEqualTo("seconds");
assertThat(sanitizeUnitName("seconds_total")).isEqualTo("seconds");
assertThat(sanitizeUnitName("seconds_total_total")).isEqualTo("seconds");
@@ -74,26 +74,24 @@ class PrometheusNamingTest {
}

@Test
public void testInvalidUnitName1() {
- public void testInvalidUnitName1() {
- assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> sanitizeUnitName("total"));
+ void invalidUnitName1() {
+ assertThatThrownBy(() -> sanitizeUnitName("total"))
+ .isInstanceOf(IllegalArgumentException.class);
}

@Test
public void testInvalidUnitName2() {
- public void testInvalidUnitName2() {
- assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> sanitizeUnitName("_total"));
+ void invalidUnitName2() {
+ assertThatThrownBy(() -> sanitizeUnitName("_total"))
+ .isInstanceOf(IllegalArgumentException.class);
}

@Test
public void testInvalidUnitName3() {
- public void testInvalidUnitName3() {
- assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> sanitizeUnitName("%"));
+ void invalidUnitName3() {
+ assertThatThrownBy(() -> sanitizeUnitName("%")).isInstanceOf(IllegalArgumentException.class);
}

@Test
public void testEmptyUnitName() {
- public void testEmptyUnitName() {
- assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> sanitizeUnitName(""));
+ void emptyUnitName() {
+ assertThatThrownBy(() -> sanitizeUnitName("")).isInstanceOf(IllegalArgumentException.class);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/Prom
prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/LabelTest.java:[19,8] [JUnitMethodDeclaration] This method's name should not redundantly start with `test` (but note that a method named `toString` is already defined in this class or a supertype)
prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/LabelTest.java:[24,8] [JUnitMethodDeclaration] This method's name should not redundantly start with `test` (but note that a method named `equals` is already defined in this class or a supertype)
prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/LabelTest.java:[29,8] [JUnitMethodDeclaration] This method's name should not redundantly start with `test` (but note that a method named `hashCode` is already defined in this class or a supertype)
prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java:[12,8] [JUnitMethodDeclaration] This method's name should not redundantly start with `test` (but note that another method named `sanitizeMetricName` is in scope)
prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java:[44,8] [JUnitMethodDeclaration] This method's name should not redundantly start with `test` (but note that another method named `sanitizeLabelName` is in scope)
prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java:[55,8] [JUnitMethodDeclaration] This method's name should not redundantly start with `test` (but note that another method named `validateUnitName` is in scope)
prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java:[67,8] [JUnitMethodDeclaration] This method's name should not redundantly start with `test` (but note that another method named `sanitizeUnitName` is in scope)
11 changes: 0 additions & 11 deletions integration-tests/prometheus-java-client-init.patch
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,3 @@
@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
3 changes: 2 additions & 1 deletion integration-tests/prometheus-java-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ additional_source_directories=''
shared_error_prone_flags=''
patch_error_prone_flags=''
validation_error_prone_flags=''
validation_build_flags=''
# XXX: Drop these flags once prometheus/client_java#1242 is resolved.
validation_build_flags='-Dtest=!SlidingWindowTest#rotate -Dsurefire.failIfNoSpecifiedTests=false'

if [ "${#}" -gt 2 ] || ([ "${#}" = 2 ] && [ "${1:---sync}" != '--sync' ]); then
>&2 echo "Usage: ${0} [--sync] [<report_directory>]"
Expand Down

0 comments on commit a8d83fb

Please sign in to comment.