mirror of
https://git.openapi.site/https://github.com/desirecore/config-center.git
synced 2026-09-05 17:33:40 +08:00
fix: validate smart routing tier completeness (#76)
This commit is contained in:
@@ -110,6 +110,20 @@ describe('真实数据全量校验', () => {
|
||||
assert.equal(routed.every((spec) => Array.isArray(spec.spec.capabilities)), true)
|
||||
})
|
||||
|
||||
it('智能路由三档必须完整唯一,且每档从自身开始回退', () => {
|
||||
const indexPath = join(ROOT, 'compute', 'model-specs', '_index.json')
|
||||
const index = JSON.parse(readFileSync(indexPath, 'utf8'))
|
||||
const validate = compile('model-specs-index')
|
||||
|
||||
const duplicateTier = structuredClone(index)
|
||||
duplicateTier.routingTiers[1] = structuredClone(duplicateTier.routingTiers[0])
|
||||
assert.equal(validate(duplicateTier), false)
|
||||
|
||||
const wrongFirstFallback = structuredClone(index)
|
||||
wrongFirstFallback.routingTiers[0].fallbackOrder = ['balanced', 'flagship', 'lightweight']
|
||||
assert.equal(validate(wrongFirstFallback), false)
|
||||
})
|
||||
|
||||
it('Provider 与 coding plan 的 _index.json 应通过 providers-index schema', () => {
|
||||
const r1 = validateFile(join(ROOT, 'compute', 'providers', '_index.json'), validators)
|
||||
const r2 = validateFile(join(ROOT, 'compute', 'coding-plans', '_index.json'), validators)
|
||||
|
||||
@@ -42,10 +42,47 @@
|
||||
"description": "该档位缺少可用候选时的量级降级/升级顺序,首项必须等于 id。"
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": { "properties": { "id": { "const": "flagship" } }, "required": ["id"] },
|
||||
"then": { "properties": { "fallbackOrder": { "items": [{ "const": "flagship" }] } } }
|
||||
},
|
||||
{
|
||||
"if": { "properties": { "id": { "const": "balanced" } }, "required": ["id"] },
|
||||
"then": { "properties": { "fallbackOrder": { "items": [{ "const": "balanced" }] } } }
|
||||
},
|
||||
{
|
||||
"if": { "properties": { "id": { "const": "lightweight" } }, "required": ["id"] },
|
||||
"then": { "properties": { "fallbackOrder": { "items": [{ "const": "lightweight" }] } } }
|
||||
}
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"description": "智能路由量级定义与回退策略。"
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"properties": {
|
||||
"routingTiers": {
|
||||
"contains": { "type": "object", "properties": { "id": { "const": "flagship" } }, "required": ["id"] }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"routingTiers": {
|
||||
"contains": { "type": "object", "properties": { "id": { "const": "balanced" } }, "required": ["id"] }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"routingTiers": {
|
||||
"contains": { "type": "object", "properties": { "id": { "const": "lightweight" } }, "required": ["id"] }
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user