This is an automated email from the ASF dual-hosted git repository.
xingfudeshi pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push:
new 54462fda4a test: fix flaky testIsRaftMode and testToString in
MetadataTest (#7859)
54462fda4a is described below
commit 54462fda4a998288457ea9c62b9da6be834a8481
Author: Xiaoyang Cai <[email protected]>
AuthorDate: Tue Dec 16 19:26:24 2025 -0600
test: fix flaky testIsRaftMode and testToString in MetadataTest (#7859)
---
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 1 +
.../org/apache/seata/common/metadata/MetadataTest.java | 14 +++++++++++---
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index adab1edbab..4394345d8f 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -143,6 +143,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7808](https://github.com/apache/incubator-seata/pull/7808)] Deflake
multiple Insert Executor tests by fixing order-dependent primary key (PK) value
comparison
- [[#7815](https://github.com/apache/incubator-seata/pull/7815)] test: fix
combine test to avoid failure due to ordering
- [[#7827](https://github.com/apache/incubator-seata/pull/7827)] Fix
non-deteriministic in TableMetaTest#testGetPrimaryKeyOnlyName
+- [[#7859](https://github.com/apache/incubator-seata/pull/7859)] Fix flaky
tests in MetadataTest caused by shared state and brittle toString assertions
- [[#7858](https://github.com/apache/incubator-seata/pull/7858)] Fix flakiness
in HttpTest.convertParamOfJsonStringTest caused by non-deterministic Map
iteration order
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index eb12b12194..a5f175544e 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -142,6 +142,7 @@
- [[#7808](https://github.com/apache/incubator-seata/pull/7808)] 修复多个 Insert
Executor 单测中因主键值比较顺序导致的间歇性失败问题
- [[#7815](https://github.com/apache/incubator-seata/pull/7815)]
通过合并测试来修复,避免因执行顺序导致的失败
- [[#7827](https://github.com/apache/incubator-seata/pull/7827)] 修复
TableMetaTest 中因主键名称列表顺序不稳定导致的单测间歇性失败问题
+- [[#7859](https://github.com/apache/incubator-seata/pull/7859)] 修复
`MetadataTest` 因共享状态与依赖 `toString()` 输出不稳定导致的测试用例间歇性失败问题
- [[#7858](https://github.com/apache/incubator-seata/pull/7858)] 修复
`HttpTest.convertParamOfJsonStringTest` 因 Map 遍历顺序不确定导致的测试用例间歇性失败问题
diff --git
a/common/src/test/java/org/apache/seata/common/metadata/MetadataTest.java
b/common/src/test/java/org/apache/seata/common/metadata/MetadataTest.java
index 2771f94989..1dc7e70a55 100644
--- a/common/src/test/java/org/apache/seata/common/metadata/MetadataTest.java
+++ b/common/src/test/java/org/apache/seata/common/metadata/MetadataTest.java
@@ -72,6 +72,7 @@ public class MetadataTest {
@Test
void testIsRaftMode() {
+ metadata.setStoreMode(StoreMode.RAFT);
Assertions.assertTrue(metadata.isRaftMode());
}
@@ -106,9 +107,16 @@ public class MetadataTest {
@Test
public void testToString() {
- Assertions.assertEquals(
- "Metadata(leaders={}, clusterTerm={},
clusterNodes={\"cluster\"->{}}, storeMode=StoreMode.RAFT)",
- metadata.toString());
+ metadata.setStoreMode(StoreMode.RAFT);
+
+ String s = metadata.toString();
+
+ Assertions.assertTrue(s.startsWith("Metadata("), "toString should
start with Metadata(");
+ Assertions.assertTrue(s.contains("leaders="), "toString should contain
leaders");
+ Assertions.assertTrue(s.contains("clusterTerm="), "toString should
contain clusterTerm");
+ Assertions.assertTrue(s.contains("clusterNodes="), "toString should
contain clusterNodes");
+ Assertions.assertTrue(
+ s.contains("storeMode=StoreMode.RAFT"), "toString should
contain storeMode=StoreMode.RAFT");
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]