提交 9b464802 authored 作者: 陈泽健's avatar 陈泽健

chore(scripts): 新增终验脚本 check_exec_report_0902 + 解除 check_* ignore 例外

- 新增 backend/scripts/check_exec_report_0902.py:验证 5.44/5.202 定时任务执行状态、报告文件与 next_run_at 推进
- .gitignore 中 backend/scripts/check_*.py 增加例外,允许 check_exec_report_0902.py 纳入版本控制
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
上级 03ee164c
......@@ -64,6 +64,7 @@ Thumbs.db
backend/scripts/batch_*.py
backend/scripts/capture_*.py
backend/scripts/check_*.py
!backend/scripts/check_exec_report_0902.py
backend/scripts/cleanup_*.py
backend/scripts/create_*.py
backend/scripts/deploy_*.py
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""终验:5.44/5.202 指定执行是否完成并生成报告 + 定时任务 next_run_at 推进"""
import sys
sys.stdout.reconfigure(encoding="utf-8")
import paramiko
TASKS = [
{"host": "192.168.5.44", "user": "root", "pwd": "Ubains@123",
"exec_id": "exec_5d426a49d79e4cbb988d9c25e1d359e0"},
{"host": "192.168.5.202", "user": "root", "pwd": "Ubains@123",
"exec_id": "exec_bf1c7db4d6c4448097a44cc9b1e39ae8"},
]
CONTAINER = "plat-auto-test-app"
MYSQL = "plat-auto-test-mysql"
for t in TASKS:
print(f"\n===== {t['host']} exec={t['exec_id']} =====")
try:
cli = paramiko.SSHClient()
cli.set_missing_host_key_policy(paramiko.AutoAddPolicy())
cli.connect(t["host"], username=t["user"], password=t["pwd"], timeout=20)
except Exception as e:
print(f" SSH 连接失败: {e}")
continue
def run(cmd, timeout=60):
stdin, stdout, stderr = cli.exec_command(cmd, timeout=timeout)
return stdout.read().decode("utf-8", errors="replace").strip(), \
stderr.read().decode("utf-8", errors="replace").strip()
# 1) 执行状态 + 报告字段(通过容器内 python 直查,避免 mysql 客户端依赖)
sql_exec = (
f"SELECT status, started_at, finished_at, report_path, total_cases, passed, failed "
f"FROM executions WHERE id='{t['exec_id']}';"
)
out, err = run(
f"docker exec {MYSQL} mysql -uroot -p'Ubains@2025' plat_auto_test -e \"{sql_exec}\" 2>/dev/null"
)
print(f" [1] 执行记录:\n{out if out else '(空)'}"
+ (f"\n err: {err[:200]}" if err and not out else ""))
# 2) 今日报告文件
out, _ = run(
f"docker exec {CONTAINER} sh -c \"ls -lt /app/data/reports/ | head -8\""
)
print(f" [2] reports 目录最新文件:\n{out}")
# 3) scheduled_tasks next_run_at 推进情况
sql_sched = (
"SELECT id, name, status, last_run_at, next_run_at FROM scheduled_tasks "
"ORDER BY next_run_at DESC LIMIT 5;"
)
out, err = run(
f"docker exec {MYSQL} mysql -uroot -p'Ubains@2025' plat_auto_test -e \"{sql_sched}\" 2>/dev/null"
)
print(f" [3] scheduled_tasks:\n{out if out else '(空)'}"
+ (f"\n err: {err[:200]}" if err and not out else ""))
# 4) 该执行最近的 MissingGreenlet / 报告生成日志
out, _ = run(
f"docker logs -t {CONTAINER} --since 24h 2>&1 | grep -E '{t['exec_id'][:24]}|生成报告|MissingGreenlet' | tail -10"
)
print(f" [4] 相关日志尾部:\n{out if out else '(无匹配)'}")
cli.close()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论