From a8d83fb462e88cdcfee65a34efe60ec0ad96400d Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sun, 22 Dec 2024 19:34:29 +0100 Subject: [PATCH] Drop `JUnitMethodDeclaration` suppression And disable flaky test. --- ...metheus-java-client-expected-changes.patch | 55 +++++++++++++++---- ...ometheus-java-client-expected-warnings.txt | 4 ++ .../prometheus-java-client-init.patch | 11 ---- integration-tests/prometheus-java-client.sh | 3 +- 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/integration-tests/prometheus-java-client-expected-changes.patch b/integration-tests/prometheus-java-client-expected-changes.patch index b944b2d083..f632a59aec 100644 --- a/integration-tests/prometheus-java-client-expected-changes.patch +++ b/integration-tests/prometheus-java-client-expected-changes.patch @@ -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; @@ -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); @@ -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); } } diff --git a/integration-tests/prometheus-java-client-expected-warnings.txt b/integration-tests/prometheus-java-client-expected-warnings.txt index 0ddb702520..318ed862e1 100644 --- a/integration-tests/prometheus-java-client-expected-warnings.txt +++ b/integration-tests/prometheus-java-client-expected-warnings.txt @@ -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) diff --git a/integration-tests/prometheus-java-client-init.patch b/integration-tests/prometheus-java-client-init.patch index 29f752bfe4..33e4723fb0 100644 --- a/integration-tests/prometheus-java-client-init.patch +++ b/integration-tests/prometheus-java-client-init.patch @@ -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 diff --git a/integration-tests/prometheus-java-client.sh b/integration-tests/prometheus-java-client.sh index c133cd4ff6..9bbb333950 100755 --- a/integration-tests/prometheus-java-client.sh +++ b/integration-tests/prometheus-java-client.sh @@ -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] []"