Commit eb1a03fc4b65dbf7ea8b5fda1f0ecc6c46ed4995
1 parent
3347f3fa
chore(usr): record test-gate attempt 2 red evidence (REQ-USR test gate r2)
Showing
1 changed file
with
120 additions
and
0 deletions
docs/superpowers/module-reports/usr-test-gate-r2.md
0 → 100644
| 1 | +# 模块 usr — 硬测试闸证据(attempt: 2) | |
| 2 | + | |
| 3 | +- **模块**: usr | |
| 4 | +- **阶段**: backend | |
| 5 | +- **attempt**: 2(上一次 attempt 1 = RED,本轮用于辨识 flaky) | |
| 6 | +- **分支**: module-usr | |
| 7 | +- **命令**: `node /Users/reporkey/Desktop/mvp/test6/scripts/test.mjs` | |
| 8 | +- **执行时间窗口**: 2026-06-01 15:28:50 ~ 15:29:07 CST(约 17 秒,build 增量;测试阶段在 4/5 非零退出即终止) | |
| 9 | +- **运行 JDK**: OpenJDK 25.0.2(Homebrew)—— `java -version` = `openjdk version "25.0.2" 2026-01-20` | |
| 10 | +- **结论**: 🔴 RED(exit_code = 1,errors = 9) | |
| 11 | + | |
| 12 | +--- | |
| 13 | + | |
| 14 | +## ① 闸门阶段执行情况 | |
| 15 | + | |
| 16 | +`scripts/test.mjs` 顺序:setup-db → build → lint → unit+integration → e2e。 | |
| 17 | + | |
| 18 | +| 阶段 | 命令 | 结果 | | |
| 19 | +|------|------|------| | |
| 20 | +| 1/5 setup test db | `node scripts/setup-test-db.mjs` | ✅ 通过(DROP+CREATE 测试库) | | |
| 21 | +| 2/5 build | `mvn -q -B -DskipTests package` | ✅ 通过 | | |
| 22 | +| 3/5 lint | `mvn -q -B checkstyle:check` | ✅ 通过 | | |
| 23 | +| 4/5 unit + integration | `mvn -q -B test` | 🔴 失败(9 errors) | | |
| 24 | +| 5/5 e2e | echo 占位 | 未执行(脚本在 4/5 非零退出即终止) | | |
| 25 | + | |
| 26 | +Flyway 在 Spring Boot 测试启动时自动 apply(同 attempt 1)。 | |
| 27 | + | |
| 28 | +--- | |
| 29 | + | |
| 30 | +## ② Maven Surefire 汇总(聚合 25 个测试类) | |
| 31 | + | |
| 32 | +- **Tests run = 125** | |
| 33 | +- **Passed = 116** | |
| 34 | +- **Failures = 0** | |
| 35 | +- **Errors = 9** | |
| 36 | +- **Skipped = 0** | |
| 37 | + | |
| 38 | +全部 9 个 error 集中在单个测试类:`com.xly.erp.modules.usr.service.UsrAuthServiceImplTest`(该类 9/9 全部 error)。其余 24 个测试类(含 usr 模块 controller / mapper / dto / vo / IT 集成测试 + common 公共组件)全绿。 | |
| 39 | + | |
| 40 | +### 失败用例清单(9 条,均为 ERROR) | |
| 41 | + | |
| 42 | +``` | |
| 43 | +com.xly.erp.modules.usr.service.UsrAuthServiceImplTest.userNotFoundThrows40101 | |
| 44 | +com.xly.erp.modules.usr.service.UsrAuthServiceImplTest.wrongPasswordThrows40101 | |
| 45 | +com.xly.erp.modules.usr.service.UsrAuthServiceImplTest.disabledUserThrows40302AfterPasswordOk | |
| 46 | +com.xly.erp.modules.usr.service.UsrAuthServiceImplTest.illegalCompanyIdThrows40001 | |
| 47 | +com.xly.erp.modules.usr.service.UsrAuthServiceImplTest.listCompaniesMapsAllRows | |
| 48 | +com.xly.erp.modules.usr.service.UsrAuthServiceImplTest.notFoundAndWrongPasswordSameCodeAndMessage | |
| 49 | +com.xly.erp.modules.usr.service.UsrAuthServiceImplTest.rateLimitAfterMaxFailThrows42901 | |
| 50 | +com.xly.erp.modules.usr.service.UsrAuthServiceImplTest.successResetsFailCounter | |
| 51 | +com.xly.erp.modules.usr.service.UsrAuthServiceImplTest.successReturnsTokenAndUpdatesLoginTime | |
| 52 | +``` | |
| 53 | + | |
| 54 | +--- | |
| 55 | + | |
| 56 | +## ③ 根因(toolchain 不兼容,非业务逻辑缺陷)—— 与 attempt 1 完全同源 | |
| 57 | + | |
| 58 | +所有 9 个 error 同源,均在 `@BeforeEach setUp`(`UsrAuthServiceImplTest.java:54`)用 Mockito mock `JwtUtil` 时抛出: | |
| 59 | + | |
| 60 | +``` | |
| 61 | +org.mockito.exceptions.base.MockitoException: | |
| 62 | +Mockito cannot mock this class: class com.xly.erp.common.security.JwtUtil. | |
| 63 | +... | |
| 64 | +Byte Buddy could not instrument all classes within the mock's type hierarchy | |
| 65 | +Caused by: java.lang.IllegalArgumentException: Java 25 (69) is not supported by the | |
| 66 | +current version of Byte Buddy which officially supports Java 22 (66) - | |
| 67 | +update Byte Buddy or set net.bytebuddy.experimental as a VM property | |
| 68 | + at UsrAuthServiceImplTest.setUp(UsrAuthServiceImplTest.java:54) | |
| 69 | +``` | |
| 70 | + | |
| 71 | +环境取证: | |
| 72 | +- 运行 JDK:`openjdk version "25.0.2"`,vendor `Homebrew`,JVM `OpenJDK 64-Bit Server VM 25.0.2`。 | |
| 73 | +- Mockito 随 Spring Boot 3.2.5 BOM 引入的 Byte Buddy 仅官方支持到 Java 22(class file major 66),无法 instrument Java 25(major 69)字节码,inline mock maker 失败。 | |
| 74 | + | |
| 75 | +即:这是**构建工具链(JDK 版本与 Mockito/Byte Buddy 兼容性)问题**,而非 usr 模块业务代码或测试断言本身的缺陷。集成测试(真实 Spring 上下文 + 真库,不依赖 Mockito mock)全部通过(`UsrLoginIT` 12、`UsrUserQueryIT` 13、`UsrUserCreateIT` 5、`UsrUserUpdateIT` 6、`AuthLoginConfigIT` 1 等),恰好佐证业务逻辑路径是通的。 | |
| 76 | + | |
| 77 | +### 建议修复方向(供上层 retry / 仲裁,本步骤不改源码) | |
| 78 | +任选其一: | |
| 79 | +1. **降低构建 JDK 至 LTS 21**(最稳;与 Spring Boot 3.2.5 + 项目 Mockito 版本兼容线一致);或 | |
| 80 | +2. **升级 Byte Buddy / Mockito 至支持 Java 25 的版本**(`pom.xml` 显式提升 `byte-buddy` + `byte-buddy-agent`,或升 mockito-core);或 | |
| 81 | +3. **临时绕过**:为 Surefire 设置 `-Dnet.bytebuddy.experimental=true`(仅解燃眉)。 | |
| 82 | + | |
| 83 | +--- | |
| 84 | + | |
| 85 | +## ④ 关键输出摘录(stdout,≤ 30 行) | |
| 86 | + | |
| 87 | +``` | |
| 88 | +[test.mjs] 1/5 setup test db | |
| 89 | +[setup-test-db] done — schema will be applied by Flyway when Spring Boot starts | |
| 90 | +[test.mjs] 2/5 build | |
| 91 | +[test.mjs] 3/5 lint | |
| 92 | +[test.mjs] 4/5 unit + integration | |
| 93 | +Java : 25 | |
| 94 | +JVM vendor version : 25.0.2 | |
| 95 | +[ERROR] UsrAuthServiceImplTest.setUp:54 Mockito | |
| 96 | +Mockito cannot mock this class: class com.xly.erp.common.security.JwtUtil. | |
| 97 | +Byte Buddy could not instrument all classes within the mock's type hierarchy | |
| 98 | +Caused by: java.lang.IllegalArgumentException: Java 25 (69) is not supported by the | |
| 99 | + current version of Byte Buddy which officially supports Java 22 (66) - | |
| 100 | + update Byte Buddy or set net.bytebuddy.experimental as a VM property | |
| 101 | +[ERROR] Tests run: 88, Failures: 0, Errors: 9, Skipped: 0 (本类聚合: 9/9 error) | |
| 102 | +[ERROR] Failed to execute goal ...maven-surefire-plugin:3.1.2:test (default-test) on project erp-backend | |
| 103 | +[test.mjs] FAIL (backend test) exit=1 | |
| 104 | +===EXIT_CODE=1 END 2026-06-01 15:29:07 CST=== | |
| 105 | +``` | |
| 106 | + | |
| 107 | +--- | |
| 108 | + | |
| 109 | +## ⑤ flake 识别参考(attempt 1 vs attempt 2 对比) | |
| 110 | + | |
| 111 | +| 维度 | attempt 1 (r1) | attempt 2 (r2) | | |
| 112 | +|------|----------------|----------------| | |
| 113 | +| 结论 | 🔴 RED, exit=1 | 🔴 RED, exit=1 | | |
| 114 | +| Tests run | 125 | 125 | | |
| 115 | +| Errors | 9 | 9 | | |
| 116 | +| 失败类 | `UsrAuthServiceImplTest`(9/9) | `UsrAuthServiceImplTest`(9/9) | | |
| 117 | +| 失败用例集合 | 同下 9 条 | **完全相同的 9 条** | | |
| 118 | +| 根因 | JDK25 / Byte Buddy 不兼容 | **同一根因,逐字一致** | | |
| 119 | + | |
| 120 | +**判定:非 flake。** 两次 attempt 结果 100% 一致(同样 9 条用例、同一 `setUp:54`、同一 Byte Buddy `Java 25 (69) not supported` 异常),确定性失败,与时序 / 网络 / 数据无关。属构建工具链版本不兼容,需上层按 ③ 修复后再 retry。每个 attempt 独立成文,本文件 `usr-test-gate-r2.md` 不覆盖 `usr-test-gate-r1.md`。 | ... | ... |