You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2021/09/29 10:24:46 UTC
[lucene-solr] branch branch_8x updated: SOLR-15572: Fix a test
failure caused by simplistic line parsing.
This is an automated email from the ASF dual-hosted git repository.
ab pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new 88c6cd6 SOLR-15572: Fix a test failure caused by simplistic line parsing.
88c6cd6 is described below
commit 88c6cd6f73e08b8d0460fd6f81d4bd1c121c25f9
Author: Andrzej Bialecki <ab...@apache.org>
AuthorDate: Wed Sep 29 12:23:22 2021 +0200
SOLR-15572: Fix a test failure caused by simplistic line parsing.
---
.../prometheus/exporter/SolrExporterTestBase.java | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/solr/contrib/prometheus-exporter/src/test/org/apache/solr/prometheus/exporter/SolrExporterTestBase.java b/solr/contrib/prometheus-exporter/src/test/org/apache/solr/prometheus/exporter/SolrExporterTestBase.java
index a390be1..29bd85d 100644
--- a/solr/contrib/prometheus-exporter/src/test/org/apache/solr/prometheus/exporter/SolrExporterTestBase.java
+++ b/solr/contrib/prometheus-exporter/src/test/org/apache/solr/prometheus/exporter/SolrExporterTestBase.java
@@ -25,6 +25,8 @@ import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import org.apache.commons.io.IOUtils;
@@ -45,7 +47,7 @@ public class SolrExporterTestBase extends PrometheusExporterTestBase {
private SolrExporter solrExporter;
private CloseableHttpClient httpClient;
- private int promtheusExporterPort;
+ private int prometheusExporterPort;
@Override
@After
@@ -59,11 +61,11 @@ public class SolrExporterTestBase extends PrometheusExporterTestBase {
protected void startMetricsExporterWithConfiguration(String scrapeConfiguration) throws Exception {
try (ServerSocket socket = new ServerSocket(0)) {
- promtheusExporterPort = socket.getLocalPort();
+ prometheusExporterPort = socket.getLocalPort();
}
solrExporter = new SolrExporter(
- promtheusExporterPort,
+ prometheusExporterPort,
25,
10,
SolrScrapeConfiguration.solrCloud(cluster.getZkServer().getZkAddress()),
@@ -87,8 +89,11 @@ public class SolrExporterTestBase extends PrometheusExporterTestBase {
}
}
+ // solr_metrics_jvm_memory_pools_bytes{space="Metaspace",item="max",base_url="http://127.0.0.1:64202/solr",} -1.0
+ private static final Pattern METRIC_LINE_PATTERN = Pattern.compile("(\\w+(?:\\{.*})?)\\s+(\\S+)");
+
protected Map<String, Double> getAllMetrics() throws URISyntaxException, IOException {
- URI uri = new URI("http://localhost:" + promtheusExporterPort + "/metrics");
+ URI uri = new URI("http://localhost:" + prometheusExporterPort + "/metrics");
HttpGet request = new HttpGet(uri);
@@ -105,11 +110,10 @@ public class SolrExporterTestBase extends PrometheusExporterTestBase {
continue;
}
- String[] parts = currentLine.split(" ");
-
- assertEquals("Metric must have name and value: " + currentLine, 2, parts.length);
-
- metrics.put(parts[0], Double.valueOf(parts[1]));
+ Matcher matcher = METRIC_LINE_PATTERN.matcher(currentLine);
+ assertTrue("Malformed metric line: " + currentLine, matcher.find());
+ assertEquals("Metric must have 2 parts, a name and value: " + currentLine, 2, matcher.groupCount());
+ metrics.put(matcher.group(1), Double.valueOf(matcher.group(2)));
}
}
}