[
https://issues.apache.org/jira/browse/FLINK-4389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15426899#comment-15426899
]
ASF GitHub Bot commented on FLINK-4389:
---------------------------------------
Github user zentol commented on a diff in the pull request:
https://github.com/apache/flink/pull/2363#discussion_r75355826
--- Diff:
flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/metrics/AbstractMetricHandlerTest.java
---
@@ -0,0 +1,158 @@
+/*
+ * 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.webmonitor.metrics;
+
+import org.apache.flink.runtime.webmonitor.JobManagerRetriever;
+import org.junit.Test;
+import scala.concurrent.ExecutionContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.powermock.api.mockito.PowerMockito.mock;
+
+public class AbstractMetricHandlerTest {
+ @Test
+ public void testHandleRequest() throws Exception {
+ MetricFetcher fetcher = new
MetricFetcher(mock(JobManagerRetriever.class), mock(ExecutionContext.class));
+ MetricStore store = fetcher.getMetricStore();
+
+ JobVertexMetricsHandler handler = new
JobVertexMetricsHandler(fetcher);
+
+ store.add("0:abc.metric1", 0);
+ store.add("1:tmid:abc.metric2", 1);
+ store.add("2:jobid:abc.metric3", 2);
+ store.add("3:jobid:taskid:subindex:abc.metric4", 3);
+ store.add("4:jobid:taskid:subindex:opname:abc.metric5", 4);
+
+ Map<String, String> pathParams = new HashMap<>();
+ Map<String, String> queryParams = new HashMap<>();
+
+ pathParams.put("jobid", "jobid");
+ pathParams.put("vertexid", "taskid");
+
+ String availableList = handler.handleRequest(pathParams,
queryParams, null);
+
+ assertEquals("[" +
+ "{\"id\":\"subindex.opname.abc.metric5\"}," +
+ "{\"id\":\"subindex.abc.metric4\"}" +
+ "]",
+ availableList);
+
+ queryParams.put("get", "subindex.opname.abc.metric5");
+
+ String metricValue = handler.handleRequest(pathParams,
queryParams, null);
+
+ assertEquals("[" +
+
"{\"id\":\"subindex.opname.abc.metric5\",\"value\":\"4\"}" +
+ "]"
+ , metricValue
+ );
+
+ queryParams.put("get",
"subindex.opname.abc.metric5,subindex.abc.metric4");
+
+ String metricValues = handler.handleRequest(pathParams,
queryParams, null);
+
+ assertEquals("[" +
+
"{\"id\":\"subindex.opname.abc.metric5\",\"value\":\"4\"}," +
+
"{\"id\":\"subindex.abc.metric4\",\"value\":\"3\"}" +
+ "]",
+ metricValues
+ );
+ }
+
+ @Test
+ public void testInvalidListDoesNotFail() {
+ MetricFetcher fetcher = new
MetricFetcher(mock(JobManagerRetriever.class), mock(ExecutionContext.class));
+ MetricStore store = fetcher.getMetricStore();
+
+ JobVertexMetricsHandler handler = new
JobVertexMetricsHandler(fetcher);
+
+ store.add("0:abc.metric1", 0);
+ store.add("1:tmid:abc.metric2", 1);
+ store.add("2:jobid:abc.metric3", 2);
+ store.add("3:jobid:taskid:subindex:abc.metric4", 3);
+ store.add("4:jobid:taskid:subindex:opname:abc.metric5", 4);
+
+ Map<String, String> pathParams = new HashMap<>();
+ Map<String, String> queryParams = new HashMap<>();
+
+ pathParams.put("jobid", "jobid");
+ pathParams.put("vertexid", "taskid");
+
+ //-----invalid variable
+ pathParams.put("jobid", "nonexistant");
+
+ try {
+ handler.handleRequest(pathParams, queryParams, null);
--- End diff --
good idea
> Expose metrics to Webfrontend
> -----------------------------
>
> Key: FLINK-4389
> URL: https://issues.apache.org/jira/browse/FLINK-4389
> Project: Flink
> Issue Type: Sub-task
> Components: Metrics, Webfrontend
> Affects Versions: 1.1.0
> Reporter: Chesnay Schepler
> Assignee: Chesnay Schepler
> Fix For: pre-apache
>
>
> https://cwiki.apache.org/confluence/display/FLINK/FLIP-7%3A+Expose+metrics+to+WebInterface
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)