pnowojski commented on a change in pull request #4801: [FLINK-7812] Log system 
resources metrics
URL: https://github.com/apache/flink/pull/4801#discussion_r207506533
 
 

 ##########
 File path: 
flink-tests/src/test/java/org/apache/flink/runtime/taskexecutor/SystemResourcesMetricsITCase.java
 ##########
 @@ -0,0 +1,123 @@
+/*
+ * 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.taskexecutor;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.metrics.Gauge;
+import org.apache.flink.metrics.MetricConfig;
+import org.apache.flink.metrics.reporter.AbstractReporter;
+import org.apache.flink.test.util.MiniClusterResource;
+import org.apache.flink.test.util.MiniClusterResourceConfiguration;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static 
org.apache.flink.configuration.CoreOptions.SYSTEM_RESOURCE_METRICS;
+import static org.apache.flink.configuration.MetricOptions.REPORTERS_LIST;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Integration tests for proper initialization of the system resource metrics.
+ */
+public class SystemResourcesMetricsITCase {
+
+       @ClassRule
+       public static final MiniClusterResource MINI_CLUSTER_RESOURCE = new 
MiniClusterResource(
+               new MiniClusterResourceConfiguration.Builder()
+                       .setConfiguration(getConfiguration())
+                       .setNumberTaskManagers(1)
+                       .setNumberSlotsPerTaskManager(1)
+                       .build());
+
+       private static Configuration getConfiguration() {
+               Configuration configuration = new Configuration();
+               configuration.setBoolean(SYSTEM_RESOURCE_METRICS, true);
+               configuration.setString(REPORTERS_LIST, "test_reporter");
+               configuration.setString("metrics.reporter.test_reporter.class", 
TestReporter.class.getName());
+               return configuration;
+       }
+
+       @Test
+       public void startTaskManagerAndCheckForRegisteredSystemMetrics() throws 
Exception {
+               assertEquals(1, TestReporter.OPENED_REPORTERS.size());
 
 Review comment:
   There should be one. `MiniCluster` is starting up both job manager and task 
manager reusing the same reporter. Their metrics are only prefixed with 
`localhost.jobmanager.` and `localhost.taskamanger.TASKMANAGER_ID.` 
   
   Added test coverage to look for both jobmanager and taskmanager metrics.

----------------------------------------------------------------
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


With regards,
Apache Git Services

Reply via email to