You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2022/09/29 01:39:50 UTC

[incubator-eventmesh] branch master updated: add grpc metrics unit test

This is an automated email from the ASF dual-hosted git repository.

mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git


The following commit(s) were added to refs/heads/master by this push:
     new cd16cde7 add grpc metrics unit test
     new 20291e35 Merge pull request #1448 from horoc/add-grpc-metrics-branch
cd16cde7 is described below

commit cd16cde7ebfef0ce73190e5cd9c2a204ee2a5ea4
Author: horoc <ho...@gmail.com>
AuthorDate: Tue Sep 27 21:13:38 2022 +0800

    add grpc metrics unit test
---
 .../metrics/api/GrpcSummaryMetricsTest.java        | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/eventmesh-metrics-plugin/eventmesh-metrics-api/src/test/java/org/apache/eventmesh/metrics/api/GrpcSummaryMetricsTest.java b/eventmesh-metrics-plugin/eventmesh-metrics-api/src/test/java/org/apache/eventmesh/metrics/api/GrpcSummaryMetricsTest.java
new file mode 100644
index 00000000..b7e93dd8
--- /dev/null
+++ b/eventmesh-metrics-plugin/eventmesh-metrics-api/src/test/java/org/apache/eventmesh/metrics/api/GrpcSummaryMetricsTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.eventmesh.metrics.api;
+
+import org.apache.eventmesh.metrics.api.model.GrpcSummaryMetrics;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class GrpcSummaryMetricsTest {
+
+    @Test
+    public void testTpsCalculate() {
+        GrpcSummaryMetrics grpcSummaryMetrics = new GrpcSummaryMetrics();
+        grpcSummaryMetrics.getEventMesh2ClientMsgNum().addAndGet(128);
+        grpcSummaryMetrics.getEventMesh2MqMsgNum().addAndGet(256);
+        grpcSummaryMetrics.getMq2EventMeshMsgNum().addAndGet(512);
+        grpcSummaryMetrics.getClient2EventMeshMsgNum().addAndGet(1024);
+
+        grpcSummaryMetrics.refreshTpsMetrics(500);
+        Assert.assertEquals(256, grpcSummaryMetrics.getEventMesh2ClientTPS());
+        Assert.assertEquals(512, grpcSummaryMetrics.getEventMesh2MqTPS());
+        Assert.assertEquals(1024, grpcSummaryMetrics.getMq2EventMeshTPS());
+        Assert.assertEquals(2048, grpcSummaryMetrics.getClient2EventMeshTPS());
+
+        grpcSummaryMetrics.clearAllMessageCounter();
+        Assert.assertEquals(0, grpcSummaryMetrics.getEventMesh2ClientMsgNum().get());
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org