From 039e7b5ebd7ddaaad7148b4e0765f00c38f5dead Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Wed, 15 Jan 2025 09:37:50 +0800 Subject: [PATCH] check existing gauge --- .../apache/kyuubi/metrics/MetricsSystemSuite.scala | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/kyuubi-metrics/src/test/scala/org/apache/kyuubi/metrics/MetricsSystemSuite.scala b/kyuubi-metrics/src/test/scala/org/apache/kyuubi/metrics/MetricsSystemSuite.scala index d895e89640b..9a7a3ecfb04 100644 --- a/kyuubi-metrics/src/test/scala/org/apache/kyuubi/metrics/MetricsSystemSuite.scala +++ b/kyuubi-metrics/src/test/scala/org/apache/kyuubi/metrics/MetricsSystemSuite.scala @@ -96,13 +96,7 @@ class MetricsSystemSuite extends KyuubiFunSuite { } test("metrics - get gauge") { - val testContextPath = "/prometheus-metrics" - - val conf = KyuubiConf() - .set(MetricsConf.METRICS_ENABLED, true) - .set(MetricsConf.METRICS_REPORTERS, Set(ReporterType.PROMETHEUS.toString)) - .set(MetricsConf.METRICS_PROMETHEUS_PORT, 0) // random port - .set(MetricsConf.METRICS_PROMETHEUS_PATH, testContextPath) + val conf = KyuubiConf().set(MetricsConf.METRICS_ENABLED, true) val metricsSystem = new MetricsSystem() metricsSystem.initialize(conf) metricsSystem.start() @@ -110,9 +104,9 @@ class MetricsSystemSuite extends KyuubiFunSuite { assert(metricsSystem.getGauge(MetricsConstants.THRIFT_SSL_CERT_EXPIRATION).isEmpty) metricsSystem.registerGauge( MetricsConstants.THRIFT_SSL_CERT_EXPIRATION, - () => System.currentTimeMillis(), + 1000, 0) - assert(metricsSystem.getGauge(MetricsConstants.THRIFT_SSL_CERT_EXPIRATION).isDefined) + assert(metricsSystem.getGauge(MetricsConstants.THRIFT_SSL_CERT_EXPIRATION).get.getValue == 1000) metricsSystem.stop() }