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

lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 716695a66 fix(studio): quote metric snapshot value column (#5132)
716695a66 is described below

commit 716695a661d55147cee40aabdf762e050d648f47
Author: Yexi Xiang <[email protected]>
AuthorDate: Fri Nov 27 12:12:13 2026 +0800

    fix(studio): quote metric snapshot value column (#5132)
---
 .../persistence/entity/RmqMetricSnapshot.java      |  2 +
 .../MetricSnapshotPersistenceIntegrationTest.java  | 55 ++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/persistence/entity/RmqMetricSnapshot.java
 
b/server/src/main/java/org/apache/rocketmq/studio/persistence/entity/RmqMetricSnapshot.java
index 99acfdace..6d5c8ea75 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/persistence/entity/RmqMetricSnapshot.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/persistence/entity/RmqMetricSnapshot.java
@@ -17,6 +17,7 @@
 package org.apache.rocketmq.studio.persistence.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -34,6 +35,7 @@ public class RmqMetricSnapshot {
     private String clusterId;
     private String labelsHash;
     private String labelsJson;
+    @TableField("`value`")
     private Double value;
     private String availability;
     private LocalDateTime collectedAt;
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/cluster/metrics/MetricSnapshotPersistenceIntegrationTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/metrics/MetricSnapshotPersistenceIntegrationTest.java
new file mode 100644
index 000000000..460370b63
--- /dev/null
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/cluster/metrics/MetricSnapshotPersistenceIntegrationTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.rocketmq.studio.cluster.metrics;
+
+import org.apache.rocketmq.studio.ops.alert.AlertDomain;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Verifies metric snapshot persistence against the documented H2 development 
profile. */
+@SpringBootTest
+@ActiveProfiles("dev")
+class MetricSnapshotPersistenceIntegrationTest {
+
+    @Autowired
+    private MetricSnapshotRepository repository;
+
+    @Test
+    void shouldPersistAndReadMetricSnapshotBatchThroughTheDevSchemaTest() {
+        Instant collectedAt = Instant.parse("2026-01-01T00:00:00Z");
+        MetricSample availability = new MetricSample(
+                "broker.availability", AlertDomain.CLUSTER, "runtime", null, 
Map.of(), 1D,
+                MetricAvailability.AVAILABLE, collectedAt);
+        MetricSample tps = new MetricSample(
+                "broker.tps", AlertDomain.CLUSTER, "runtime", null, Map.of(), 
2D,
+                MetricAvailability.AVAILABLE, collectedAt.plusMillis(1));
+
+        repository.saveAll(List.of(availability, tps));
+
+        List<MetricSample> persisted = repository.findRecent(availability, 
collectedAt.minusSeconds(1));
+        assertThat(persisted).hasSize(1);
+        assertThat(persisted.get(0).value()).isEqualTo(1D);
+    }
+}

Reply via email to