deploy(agent): verify 增加「账号级负载字段」换新证据
1.0.14 起单 auth 的旧记录也会合成 accounts[],投影带 load; 旧镜像 items 里没有 accounts 键 —— 可干净区分新旧镜像。 三态判定(ok / noupstream / old)避免线上无上游时假失败。 已用 6 组输入干跑验证(含 data 为数组的兼容分支)。
This commit is contained in:
1 parent
51c473bdd7
commit
f4adb5685c
1 file changed
+22
@@ -167,6 +167,28 @@ print(len(d.get("labels") or []))' 2>/dev/null || echo '')"
|
||||
echo " ✗ 趋势接口异常(labels=${labels:-空})—— 镜像可能没真正换新"; rc=1
|
||||
fi
|
||||
|
||||
# 4) 上游账号级负载(1.0.14 新增):投影里出现 accounts[].load = 新代码在跑。
|
||||
# 1.0.14 起**单 auth 的旧记录也会被合成为一条 account**,所以只要有任一上游记录,
|
||||
# 新镜像必定返回该字段;旧镜像返回的 items 里根本没有 accounts 键 —— 新旧可分。
|
||||
# 只验「字段在不在」不验数值(线上未必有流量)。三态避免「空库」时假失败。
|
||||
local acct
|
||||
acct="$(live_curl -b "$jar" "https://$LIVE_HOST:$LIVE_PORT/api/admin/upstreams" \
|
||||
| "$PY" -c 'import json,sys
|
||||
d = json.load(sys.stdin).get("data") or {}
|
||||
items = d.get("items") or [] if isinstance(d, dict) else (d if isinstance(d, list) else [])
|
||||
if not items:
|
||||
print("noupstream"); sys.exit(0)
|
||||
for u in items:
|
||||
for a in (u.get("accounts") or []):
|
||||
if isinstance(a.get("load"), dict) and "requests" in a["load"]:
|
||||
print("ok"); sys.exit(0)
|
||||
print("old")' 2>/dev/null || echo '')"
|
||||
case "$acct" in
|
||||
ok) echo " ✓ 上游带账号级负载字段(accounts[].load)" ;;
|
||||
noupstream) echo " · 线上没有任何上游,跳过账号负载证据(不判失败)" ;;
|
||||
*) echo " ✗ 上游接口缺 accounts[].load —— 镜像可能没真正换新"; rc=1 ;;
|
||||
esac
|
||||
|
||||
rm -f "$jar"
|
||||
if [ "$rc" = "0" ]; then echo "✔ 正式环境验收通过"; else echo "✗ 正式环境验收未通过"; fi
|
||||
return $rc
|
||||
|
||||
Reference in new issue
Block a user