zentol commented on a change in pull request #11195: [FLINK-16222][runtime] Use 
plugins mechanism for initializing MetricReporters
URL: https://github.com/apache/flink/pull/11195#discussion_r394239114
 
 

 ##########
 File path: 
flink-end-to-end-tests/flink-metrics-reporter-prometheus-test/src/test/java/org/apache/flink/metrics/prometheus/tests/PrometheusReporterEndToEndITCase.java
 ##########
 @@ -120,24 +122,51 @@ public static void checkOS() {
        public final DownloadCache downloadCache = DownloadCache.get();
 
        @Test
-       public void testReporter() throws Exception {
-               dist.copyOptJarsToLib("flink-metrics-prometheus");
+       public void reporterWorksWhenFoundInLibsViaReflection() throws 
Exception {
+               dist.copyOptJarsToLib(PROMETHEUS_JAR_PREFIX);
+               testReporter(false);
+       }
+
+       @Test
+       public void reporterWorksWhenFoundInPluginsViaReflection() throws 
Exception {
+               dist.copyOptJarsToPlugins(PROMETHEUS_JAR_PREFIX);
+               testReporter(false);
+       }
+
+       @Test
+       public void reporterWorksWhenFoundInPluginsViaFactories() throws 
Exception {
+               dist.copyOptJarsToPlugins(PROMETHEUS_JAR_PREFIX);
+               testReporter(true);
+       }
 
+       @Test
+       public void reporterWorksWhenFoundBothInPluginsAndLibsViaFactories() 
throws Exception {
+               dist.copyOptJarsToPlugins(PROMETHEUS_JAR_PREFIX);
+               dist.copyOptJarsToLib(PROMETHEUS_JAR_PREFIX);
+               testReporter(true);
+       }
+
+       private void testReporter(boolean useFactory) throws Exception {
                final Configuration config = new Configuration();
-               config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + 
"prom." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, 
PrometheusReporter.class.getCanonicalName());
+
+               if (useFactory) {
+                       
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "prom." + 
ConfigConstants.METRICS_REPORTER_FACTORY_CLASS_SUFFIX, 
PrometheusReporterFactory.class.getName());
+               } else {
+                       
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);
 
-               downloadCache.getOrDownload(
-                       
"https://github.com/prometheus/prometheus/releases/download/v"; + 
PROMETHEUS_VERSION + '/' + prometheusArchive.getFileName(),
+               final Path prometheusArchive = downloadCache.getOrDownload(
 
 Review comment:
   this belongs into a separate commit since it is fixing a bug in the test 
that can occur independently from this PR.

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


With regards,
Apache Git Services

Reply via email to