This is an automated email from the ASF dual-hosted git repository.
slievrly 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 8d522f0684 test: fix flaky AuthControllerWithRandomPasswordTest by
isolating context with TestPropertySource (#8181)
8d522f0684 is described below
commit 8d522f0684029f2740f8d862eaf9b97588a07a6f
Author: 徐晓伟 <[email protected]>
AuthorDate: Mon Jul 27 23:24:11 2026 +0800
test: fix flaky AuthControllerWithRandomPasswordTest by isolating context
with TestPropertySource (#8181)
---
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 1 +
.../seata/namingserver/AuthControllerWithRandomPasswordTest.java | 7 +++++++
3 files changed, 9 insertions(+)
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 5c3afb7420..2c7c7ee06a 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -43,6 +43,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#8146](https://github.com/apache/incubator-seata/pull/8146)] test: cover
rm-datasource resource id initializers
- [[#8175](https://github.com/apache/incubator-seata/pull/8175)] fix flaky
testCachedConfigurationChangeListener due to async race condition
+- [[#8181](https://github.com/apache/incubator-seata/pull/8181)] fix
AuthControllerWithRandomPasswordTest flaky failure caused by Spring Boot test
context caching
### refactor:
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index b4f0545d11..6eba484d32 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -42,6 +42,7 @@
- [[#8146](https://github.com/apache/incubator-seata/pull/8146)] test: 覆盖
rm-datasource resource id initializers
- [[#8175](https://github.com/apache/incubator-seata/pull/8175)] 修复
testCachedConfigurationChangeListener 因异步竞态条件导致的偶发失败
+- [[#8181](https://github.com/apache/incubator-seata/pull/8181)] 修复
AuthControllerWithRandomPasswordTest 因 Spring Boot 测试上下文缓存导致的偶发失败
### refactor:
diff --git
a/namingserver/src/test/java/org/apache/seata/namingserver/AuthControllerWithRandomPasswordTest.java
b/namingserver/src/test/java/org/apache/seata/namingserver/AuthControllerWithRandomPasswordTest.java
index db9446cabb..30e58dbcb2 100644
---
a/namingserver/src/test/java/org/apache/seata/namingserver/AuthControllerWithRandomPasswordTest.java
+++
b/namingserver/src/test/java/org/apache/seata/namingserver/AuthControllerWithRandomPasswordTest.java
@@ -27,6 +27,7 @@ import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType;
+import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import tools.jackson.databind.ObjectMapper;
@@ -41,6 +42,12 @@ import static
org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static
org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static
org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+/**
+ * Add a unique, namespaced test property so Spring's test context cache
treats this class as a distinct configuration.
+ * This prevents reuse of an already-started context (e.g. other
@SpringBootTest + @AutoConfigureMockMvc tests),
+ * which would omit the startup log line "Use the auto-generated password:
[...]" from {@link CapturedOutput}.
+ */
+@TestPropertySource(properties =
"seata.test.context.cache.key=AuthControllerWithRandomPasswordTest")
@SpringBootTest
@ExtendWith(OutputCaptureExtension.class)
@AutoConfigureMockMvc
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]