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

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

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

 ##########
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/FlinkDistribution.java
 ##########
 @@ -0,0 +1,219 @@
+/*
+ * 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.tests.util;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.GlobalConfiguration;
+import org.apache.flink.configuration.UnmodifiableConfiguration;
+import org.apache.flink.util.ExceptionUtils;
+
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.junit.Assert;
+import org.junit.rules.ExternalResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * A wrapper around a Flink distribution.
+ */
+public final class FlinkDistribution extends ExternalResource {
+
+       private static final Logger LOG = 
LoggerFactory.getLogger(FlinkDistribution.class);
+
+       private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+       private final List<AutoClosablePath> filesToDelete = new ArrayList<>(4);
+
+       private static final Path FLINK_CONF_YAML = 
Paths.get("flink-conf.yaml");
+       private static final Path FLINK_CONF_YAML_BACKUP = 
Paths.get("flink-conf.yaml.bak");
+
+       private final Path opt;
+       private final Path lib;
+       private final Path conf;
+       private final Path log;
+       private final Path bin;
+
+       private Configuration defaultConfig;
+
+       public FlinkDistribution() {
+               final String distDirProperty = System.getProperty("distDir");
+               if (distDirProperty == null) {
+                       Assert.fail("The distDir property was not set. You can 
set it when running maven via -DdistDir=<path> .");
+               }
+               final Path flinkDir = Paths.get(distDirProperty);
+               bin = flinkDir.resolve("bin");
+               opt = flinkDir.resolve("opt");
+               lib = flinkDir.resolve("lib");
+               conf = flinkDir.resolve("conf");
+               log = flinkDir.resolve("log");
+       }
+
+       @Override
+       protected void before() throws IOException {
+               defaultConfig = new 
UnmodifiableConfiguration(GlobalConfiguration.loadConfiguration(conf.toAbsolutePath().toString()));
+               final Path originalConfig = conf.resolve(FLINK_CONF_YAML);
+               final Path backupConfig = conf.resolve(FLINK_CONF_YAML_BACKUP);
+               Files.copy(originalConfig, backupConfig);
+               filesToDelete.add(new AutoClosablePath(backupConfig));
+       }
+
+       @Override
+       protected void after() {
+               try {
 
 Review comment:
   I find it a bit counter-intuitive that we stop the cluster in the `after`, 
although we have not started it in the `before`. I do not know the best 
solution, maybe setting a flag on `startCluster` and checking it in the `after` 
and if `true` then stopping the cluster. This is not the best solution but feel 
free to ignore this comment if you do not agree.

----------------------------------------------------------------
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:
us...@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)

Reply via email to