flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] tillrohrmann commented on a change in pull request #8002: [FLINK-11923][metrics] MetricRegistryConfiguration provides MetricReporters Suppliers
Date Wed, 10 Apr 2019 14:43:57 GMT
tillrohrmann commented on a change in pull request #8002: [FLINK-11923][metrics] MetricRegistryConfiguration
provides MetricReporters Suppliers
URL: https://github.com/apache/flink/pull/8002#discussion_r273998850
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/metrics/ReporterSetupTest.java
 ##########
 @@ -0,0 +1,213 @@
+/*
+ * 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.runtime.metrics;
+
+import org.apache.flink.configuration.ConfigConstants;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.MetricOptions;
+import org.apache.flink.metrics.MetricConfig;
+import org.apache.flink.metrics.reporter.MetricReporter;
+import org.apache.flink.runtime.metrics.util.TestReporter;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for the {@link ReporterSetup}.
+ */
+public class ReporterSetupTest extends TestLogger {
+
+	/**
+	 * TestReporter1 class only for type differentiation.
+	 */
+	static class TestReporter1 extends TestReporter {
+	}
+
+	/**
+	 * TestReporter2 class only for type differentiation.
+	 */
+	static class TestReporter2 extends TestReporter {
+	}
+
+	/**
+	 * Verifies that a reporter can be configured with all it's arguments being forwarded.
+	 */
+	@Test
+	public void testReporterArgumentForwarding() {
+		final Configuration config = new Configuration();
+
+		config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "reporter." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX,
ReporterSetupTest.TestReporter1.class.getName());
+		config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "reporter.arg1", "value1");
+		config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "reporter.arg2", "value2");
+
+		final List<ReporterSetup> reporterSetups = ReporterSetup.fromConfiguration(config);
+
+		Assert.assertEquals(1, reporterSetups.size());
+
+		final ReporterSetup reporterSetup = reporterSetups.get(0);
+		Assert.assertEquals("reporter", reporterSetup.getName());
+		Assert.assertEquals("value1", reporterSetup.getConfiguration().getString("arg1", null));
+		Assert.assertEquals("value2", reporterSetup.getConfiguration().getString("arg2", null));
+		Assert.assertEquals(ReporterSetupTest.TestReporter1.class.getName(), reporterSetup.getConfiguration().getString("class",
null));
+	}
+
+	/**
+	 * Verifies that multiple reporters can be configured with all their arguments being forwarded.
+	 */
+	@Test
+	public void testSeveralReportersWithArgumentForwarding() {
 
 Review comment:
   W/o wanting to be pedantic here, but then we are missing the `0` case. I guess it does
not hurt to keep the test but it adds a bit to our testing time.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message