You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2024/08/03 19:04:23 UTC
(solr) branch main updated: SOLR-17368: Fix TestPrometheusResponseWriter by clearing registries (#2613)
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 14375b621fe SOLR-17368: Fix TestPrometheusResponseWriter by clearing registries (#2613)
14375b621fe is described below
commit 14375b621fe3c33c20f7a1a0e1ad6f4caffd8f21
Author: Matthew Biscocho <54...@users.noreply.github.com>
AuthorDate: Sat Aug 3 15:04:17 2024 -0400
SOLR-17368: Fix TestPrometheusResponseWriter by clearing registries (#2613)
SharedMetricRegistries.clear()
Parse numeric value based on if tags exist
Co-authored-by: Matthew Biscocho <mb...@bloomberg.net>
Co-authored-by: David Smiley <ds...@salesforce.com>
---
.../solr/response/TestPrometheusResponseWriter.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java b/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java
index 8cf651e3928..0e25201cce0 100644
--- a/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java
+++ b/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java
@@ -20,6 +20,7 @@ import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Meter;
import com.codahale.metrics.SettableGauge;
+import com.codahale.metrics.SharedMetricRegistries;
import java.lang.invoke.MethodHandles;
import java.util.Arrays;
import java.util.List;
@@ -34,6 +35,7 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.metrics.SolrMetricManager;
import org.apache.solr.util.ExternalPaths;
import org.apache.solr.util.SolrJettyTestRule;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
@@ -47,6 +49,8 @@ public class TestPrometheusResponseWriter extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
+ SharedMetricRegistries.clear();
+
solrClientTestRule.startSolr(LuceneTestCase.createTempDir());
solrClientTestRule.newCollection().withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();
var cc = solrClientTestRule.getCoreContainer();
@@ -62,6 +66,11 @@ public class TestPrometheusResponseWriter extends SolrTestCaseJ4 {
registerGauge(manager, "solr.jvm", "gc.dummyMetrics.count");
}
+ @AfterClass
+ public static void clearMetricsRegistries() {
+ SharedMetricRegistries.clear();
+ }
+
@Test
public void testPrometheusStructureOutput() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
@@ -78,7 +87,12 @@ public class TestPrometheusResponseWriter extends SolrTestCaseJ4 {
output.lines().filter(line -> !line.startsWith("#")).collect(Collectors.toList());
filteredResponse.forEach(
(actualMetric) -> {
- String actualValue = actualMetric.substring(actualMetric.lastIndexOf("} ") + 1);
+ String actualValue;
+ if (actualMetric.contains("}")) {
+ actualValue = actualMetric.substring(actualMetric.lastIndexOf("} ") + 1);
+ } else {
+ actualValue = actualMetric.split(" ")[1];
+ }
assertTrue(
"All metrics should start with 'solr_metrics_'",
actualMetric.startsWith("solr_metrics_"));