Commit 3347f3fa7d0c474894b7ee20b1e1de87bb9d2f54

Authored by zichun
1 parent 0dadb833

chore(usr): 记录 usr 硬测试闸 attempt1 红色证据 (Byte Buddy 不支持 Java 25)

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