[ 
https://issues.apache.org/jira/browse/BEAM-4553?focusedWorklogId=152704&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-152704
 ]

ASF GitHub Bot logged work on BEAM-4553:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Oct/18 15:10
            Start Date: 09/Oct/18 15:10
    Worklog Time Spent: 10m 
      Work Description: echauchot commented on a change in pull request #6569: 
[BEAM-4553] Implement graphite sink for MetricsPusher and refactor 
MetricsHttpSink test
URL: https://github.com/apache/beam/pull/6569#discussion_r223743972
 
 

 ##########
 File path: 
runners/extensions-java/metrics/src/test/java/org/apache/beam/runners/extensions/metrics/MetricsGraphiteSinkTest.java
 ##########
 @@ -0,0 +1,108 @@
+/*
+ * 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.beam.runners.extensions.metrics;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import org.apache.beam.sdk.metrics.MetricQueryResults;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.sdk.options.PipelineOptionsFactory;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Test class for MetricsGraphiteSink. */
+public class MetricsGraphiteSinkTest {
+  private static NetworkMockServer graphiteServer;
+  private static int port;
+
+  @BeforeClass
+  public static void beforeClass() throws IOException, InterruptedException {
+    // get free local port
+    ServerSocket serverSocket = new ServerSocket(0);
+    port = serverSocket.getLocalPort();
+    serverSocket.close();
+    graphiteServer = new NetworkMockServer(port);
+    Thread.sleep(200);
+    graphiteServer.clear();
+    graphiteServer.start();
+  }
+
+  @Before
+  public void before() {
+    graphiteServer.clear();
+  }
+
+  @AfterClass
+  public static void afterClass() throws IOException {
+    graphiteServer.stop();
+  }
+
+  @Test
+  public void testWriteMetricsWithCommittedSupported() throws Exception {
+    MetricQueryResults metricQueryResults = new CustomMetricQueryResults(true);
+    PipelineOptions pipelineOptions = PipelineOptionsFactory.create();
+    pipelineOptions.setMetricsGraphitePort(port);
+    pipelineOptions.setMetricsGraphiteHost("127.0.0.1");
+    MetricsGraphiteSink metricsGraphiteSink = new 
MetricsGraphiteSink(pipelineOptions);
+    metricsGraphiteSink.writeMetrics(metricQueryResults);
+    Thread.sleep(2000L);
 
 Review comment:
   Yes because, when we write messages to the socket, then on a different 
thread `NetworkMockServer` reads the socket and adds messages to an arrayList 
so that they could be read in the assert. On heavy load jenkins server, the 
test might fail because the `NetworkMockServer` does not have enough time to 
add the messages to the arraylist

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 152704)
    Time Spent: 2h 10m  (was: 2h)

> Implement a Graphite sink for the metrics pusher
> ------------------------------------------------
>
>                 Key: BEAM-4553
>                 URL: https://issues.apache.org/jira/browse/BEAM-4553
>             Project: Beam
>          Issue Type: Sub-task
>          Components: runner-extensions-metrics
>            Reporter: Etienne Chauchot
>            Assignee: Etienne Chauchot
>            Priority: Major
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> Today only a REST Http sink that sends raw json metrics using POST request to 
> a http server is available. It is more a POC sink. It would be good to code 
> the first real metrics sink. Some of the most popular is Graphite.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to