You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/08/17 08:55:56 UTC

[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #3256: [KYUUBI #3251] Fix thrift http frontend connection metrics

turboFei commented on code in PR #3256:
URL: https://github.com/apache/incubator-kyuubi/pull/3256#discussion_r947638446


##########
kyuubi-server/src/test/scala/org/apache/kyuubi/operation/thrift/http/KyuubiOperationThriftHttpPerUserSuite.scala:
##########
@@ -34,5 +37,42 @@ class KyuubiOperationThriftHttpPerUserSuite extends KyuubiOperationPerUserSuite
     s"jdbc:hive2://${server.frontendServices.head.connectionUrl}/;transportMode=http;" +
       s"httpPath=cliservice;"
 
-  override protected lazy val httpMode = true;
+  override protected lazy val httpMode = true
+
+  test("test connection metric") {
+    val totalConnections =
+      MetricsSystem.counterValue(MetricsConstants.THRIFT_HTTP_CONN_TOTAL).getOrElse(0L)
+    val openConnections =
+      MetricsSystem.counterValue(MetricsConstants.THRIFT_HTTP_CONN_OPEN).getOrElse(0L)
+    val failedConnections =
+      MetricsSystem.counterValue(MetricsConstants.THRIFT_HTTP_CONN_FAIL).getOrElse(0L)
+
+    withJdbcStatement() { _ =>
+      assert(MetricsSystem.counterValue(
+        MetricsConstants.THRIFT_HTTP_CONN_TOTAL).getOrElse(0L) - totalConnections === 1)
+      assert(MetricsSystem.counterValue(
+        MetricsConstants.THRIFT_HTTP_CONN_OPEN).getOrElse(0L) - openConnections === 1)
+      assert(MetricsSystem.counterValue(
+        MetricsConstants.THRIFT_HTTP_CONN_FAIL).getOrElse(0L) - failedConnections === 0)
+
+      withJdbcStatement() { _ =>
+        assert(MetricsSystem.counterValue(
+          MetricsConstants.THRIFT_HTTP_CONN_TOTAL).getOrElse(0L) - totalConnections === 2)
+        assert(MetricsSystem.counterValue(
+          MetricsConstants.THRIFT_HTTP_CONN_OPEN).getOrElse(0L) - openConnections === 2)
+        assert(MetricsSystem.counterValue(
+          MetricsConstants.THRIFT_HTTP_CONN_FAIL).getOrElse(0L) - failedConnections === 0)
+      }
+
+    }
+
+    eventually(timeout(1.seconds), interval(200.milliseconds)) {
+      assert(MetricsSystem.counterValue(

Review Comment:
   ```
   - test connection metric *** FAILED ***
     The code passed to eventually never returned normally. Attempted 15 times over 1.0059717080000001 seconds. Last failure message: 2 did not equal 0. (KyuubiOperationThriftHttpPerUserSuite.scala:69)
   ```



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

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org