feat(auth): add Redis authorization caching

This commit is contained in:
2026-08-01 12:20:31 +08:00
parent 84c2b0b21d
commit 46abf4d62f
36 changed files with 21757 additions and 35 deletions

View File

@@ -11,7 +11,7 @@
| `ready` | `GET /api/health/ready` | 每次检查 PostgreSQL、Redis 以及消息/outbox 就绪状态 |
| `mixed` | 70% hot、20% cold、10% ready | 默认的读多型业务流量 |
`setup()` 会强制校验 readiness 响应中的 `database=true``redis.configured=true``redis.ready=true`,所以 Redis 没接上时测试会直接失败,不会给出误导性的容量数字
运行器会先分别执行 PostgreSQL 查询和 Redis `PING`,再要求 API readiness 返回 `status=ready`;任一依赖未接通时测试会直接失败,不会给出误导性的容量数字。公开 readiness 响应不暴露内部依赖明细
## 一键本机测试

View File

@@ -82,12 +82,8 @@ if [[ -z "${ready_body}" ]]; then
exit 1
fi
printf '%s\n' "${ready_body}" >"${result_dir}/readiness.json"
if ! printf '%s' "${ready_body}" | grep -q '"database":true'; then
echo "PostgreSQL is not ready: ${ready_body}" >&2
exit 1
fi
if ! printf '%s' "${ready_body}" | grep -q '"redis":{"configured":true,"ready":true}'; then
echo "Redis is not configured and ready: ${ready_body}" >&2
if ! printf '%s' "${ready_body}" | grep -q '"status":"ready"'; then
echo "PostgreSQL or Redis is not ready: ${ready_body}" >&2
exit 1
fi

View File

@@ -61,8 +61,8 @@ export function setup() {
} catch (error) {
fail(`Readiness endpoint did not return JSON: ${error}`);
}
if (!readiness.database || !readiness.redis?.configured || !readiness.redis?.ready) {
fail(`PostgreSQL and Redis must both be configured and ready: ${JSON.stringify(readiness)}`);
if (readiness.status !== 'ready') {
fail(`PostgreSQL and Redis must both be ready: ${JSON.stringify(readiness)}`);
}
const catalog = http.get(`${baseUrl}/api/catalog/regions`, {