flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-10633) End-to-end test: Prometheus reporter
Date Fri, 02 Nov 2018 11:03:00 GMT

    [ https://issues.apache.org/jira/browse/FLINK-10633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16672935#comment-16672935
] 

ASF GitHub Bot commented on FLINK-10633:
----------------------------------------

zentol commented on a change in pull request #7003: [FLINK-10633][prometheus] Add E2E test
URL: https://github.com/apache/flink/pull/7003#discussion_r230337516
 
 

 ##########
 File path: flink-end-to-end-tests/flink-metrics-reporter-prometheus-test/src/test/java/org/apache/flink/metrics/prometheus/tests/PrometheusReporterEndToEndITCase.java
 ##########
 @@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.metrics.prometheus.tests;
+
+import org.apache.flink.configuration.ConfigConstants;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.metrics.prometheus.PrometheusReporter;
+import org.apache.flink.tests.util.AutoClosableProcess;
+import org.apache.flink.tests.util.CommandLineWrapper;
+import org.apache.flink.tests.util.FlinkDistribution;
+import org.apache.flink.util.ExceptionUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.time.Duration;
+import java.util.List;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.tests.util.AutoClosableProcess.runBlocking;
+import static org.apache.flink.tests.util.AutoClosableProcess.runNonBlocking;
+
+/**
+ * End-to-end test for the PrometheusReporter.
+ */
+public class PrometheusReporterEndToEndITCase extends TestLogger {
+
+	private static final Logger LOG = LoggerFactory.getLogger(PrometheusReporterEndToEndITCase.class);
+
+	private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+	private static final String PROMETHEUS_FILE_NAME = "prometheus-2.4.3.linux-amd64";
+
+	private static final Pattern LOG_REPORTER_PORT_PATTERN = Pattern.compile(".*Started PrometheusReporter
HTTP server on port ([0-9]+).*");
+
+	@Rule
+	public final FlinkDistribution dist = new FlinkDistribution();
+
+	@Rule
+	public final TemporaryFolder tmp = new TemporaryFolder();
+
+	@Test
+	public void testReporter() throws Exception {
+		LOG.info("starting test");
+		dist.copyOptJarsToLib("flink-metrics-prometheus");
+
+		final Configuration config = new Configuration();
+		config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "prom." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX,
PrometheusReporter.class.getCanonicalName());
+		config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "prom.port", "9000-9100");
+
+		dist.appendConfiguration(config);
+
+		final Path tmpPrometheusDir = tmp.newFolder().toPath().resolve("prometheus");
+		final Path prometheusArchive = tmpPrometheusDir.resolve(PROMETHEUS_FILE_NAME + ".tar.gz");
+		final Path prometheusBinDir = tmpPrometheusDir.resolve(PROMETHEUS_FILE_NAME);
+		final Path prometheusConfig = prometheusBinDir.resolve("prometheus.yml");
+		final Path prometheusBinary = prometheusBinDir.resolve("prometheus");
+		Files.createDirectory(tmpPrometheusDir);
+
+		runBlocking(
+			"Download of Prometheus",
+			Duration.ofMinutes(5),
+			CommandLineWrapper
+				.wget("https://github.com/prometheus/prometheus/releases/download/v2.4.3/" + prometheusArchive.getFileName())
+				.targetDir(tmpPrometheusDir)
+				.build());
+
+		runBlocking("Extraction of Prometheus archive",
+			CommandLineWrapper
+				.tar(prometheusArchive)
+				.extract()
+				.zipped()
+				.targetDir(tmpPrometheusDir)
+				.build());
+
+		runBlocking("Set Prometheus scrape interval",
+			CommandLineWrapper
+				.sed("s/\\(scrape_interval:\\).*/\\1 1s/", prometheusConfig)
 
 Review comment:
   I had already implemented the sed logic in bash (actually the entire test was already written
in bash), so I opted for re-using some stuff.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> End-to-end test: Prometheus reporter
> ------------------------------------
>
>                 Key: FLINK-10633
>                 URL: https://issues.apache.org/jira/browse/FLINK-10633
>             Project: Flink
>          Issue Type: Sub-task
>          Components: E2E Tests
>    Affects Versions: 1.7.0
>            Reporter: Till Rohrmann
>            Assignee: Chesnay Schepler
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.7.0
>
>
> Add an end-to-end test using the {{PrometheusReporter}} to verify that all metrics are
properly reported. Additionally verify that the newly introduce RocksDB metrics are accessible
(see FLINK-10423).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message