feat(config): 配置值非法无条件拒启,登记启动必需配置清单(ACM2-97)

- 新增 PipelineConfigCheck(@Context):退避档位/播种取值校验不再等 autostart(CLM-7、OPS-1)
- OperationDayZoneCheck 扩展 cutoff-hour 0-23 校验
- reference.md 新增「启动必需配置与显式开关」:必需清单、缺值路径、显式开关与运行时故障的边界
- PipelinePropsBindingTest 补一致退避档位;补非法值/范围用例
This commit is contained in:
windyboy
2026-09-21 12:46:47 +08:00
parent 9bf879ff76
commit 477f038cc1
7 changed files with 89 additions and 7 deletions
@@ -28,4 +28,13 @@ class OperationDayPropsTest {
assertTrue(failure.message!!.contains("msgx.operation-day.zone"))
}
@Test
fun `cutoff hour outside 0-23 is rejected at startup check`() {
val props = OperationDayProps().apply { cutoffHour = 24 }
val failure = assertThrows(IllegalArgumentException::class.java) { OperationDayZoneCheck(props) }
assertTrue(failure.message!!.contains("msgx.operation-day.cutoff-hour"))
}
}
@@ -0,0 +1,35 @@
package com.gzzn.omms.msgexchange.config
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
/**
* `CLM-7`/`OPS-1`:管道参数值非法必须在启动自检(无条件 `@Context`)时失败,
* 与 `msgx.pipeline.autostart` 是否开启无关。
*/
class PipelineConfigCheckTest {
@Test
fun `valid pipeline props pass the unconditional check`() {
PipelineConfigCheck(PipelineProps())
}
@Test
fun `backoff slot count mismatch rejects startup even without autostart`() {
val props = PipelineProps().apply {
pipeline.maxAttempts = 5
pipeline.backoffMs = listOf(1000L, 2000L) // 期望 4 档
}
assertThrows(IllegalArgumentException::class.java) { PipelineConfigCheck(props) }
}
@Test
fun `illegal cutover watermark rejects startup even without autostart`() {
val props = PipelineProps().apply {
pipeline.cutoverWatermark = "yesterday"
}
assertThrows(IllegalArgumentException::class.java) { PipelineConfigCheck(props) }
}
}
@@ -24,6 +24,8 @@ class PipelinePropsBindingTest : TestPropertyProvider {
override fun getProperties(): Map<String, String> = mapOf(
"msgx.pipeline.poll-interval" to "PT7S",
"msgx.pipeline.max-attempts" to "9",
// 档位数必须与 max-attempts-1 一致(PipelineConfigCheck 无条件校验,CLM-7
"msgx.pipeline.backoff-ms" to "1000,2000,3000,4000,5000,6000,7000,8000",
"msgx.schd.flush-limit" to "321",
"msgx.identity.include-day-boundary" to "true",
)
@@ -35,6 +37,7 @@ class PipelinePropsBindingTest : TestPropertyProvider {
fun `nested msgx keys bind from test properties`() {
assertEquals(Duration.ofSeconds(7), props.pipeline.pollInterval)
assertEquals(9, props.pipeline.maxAttempts)
assertEquals((1..8).map { it * 1000L }, props.pipeline.backoffMs)
assertEquals(321, props.schd.flushLimit)
assertTrue(props.identity.includeDayBoundary)
}