Files
cms-SiteForge/scripts/write_v818_acceptance.py
T

75 lines
7.2 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
"""Creates a durable V8.18 evidence index from the tests already executed."""
from __future__ import annotations
import json,html,datetime
from pathlib import Path
root=Path(__file__).resolve().parents[1]
rep=root/'reports'
r=json.loads((rep/'v818-regression-2rounds.json').read_text(encoding='utf-8'))
a=json.loads((rep/'v818-readonly.json').read_text(encoding='utf-8'))
http=(rep/'v818-http-e2e.log').read_text(encoding='utf-8')
assert r['status']=='PASS' and r['repeats']==2 and not r['failures']
assert (rep/'v818_two_rounds_exitcode').read_text().strip()=='0'
assert 'PASS' in http
runs=[x for x in r['runs'] if x['label'].startswith('round')]
total=sum(x['passed'] for x in runs)
result={
'platform':'SiteForge Enterprise', 'version':'8.18.0-dev.1',
'generated_at':datetime.datetime.now(datetime.timezone.utc).isoformat(),
'delivery':'developer integration build',
'source':'V8.17 complete source + V8.18 improvements',
'local_validation':{
'pytest_status':r['status'], 'modules':r['modules'], 'rounds':r['repeats'],
'passed_per_round':r['tests_last_complete_round'], 'passed_across_rounds':total,
'failures':r['counts']['FAIL'], 'timeouts':r['counts']['TIMEOUT'],
'http_worker_e2e':'PASS', 'python_compile':'PASS', 'node_syntax':'PASS',
'static_audit':'PASS (12 checks, 2 skipped)',
'ci_yaml':'parsed locally; not executed on GitHub Actions'},
'not_tested_in_this_environment':[
'real PostgreSQL data migration and dump/restore (CI entry supplied)',
'real Redis wake-up (CI entry supplied)',
'Docker engine / multi-container multi-worker network fault tests',
'Playwright/Chromium interactive browser smoke',
'SFTP/S3/HTTPS remote public deployment and rollback',
'production backup RPO/RTO and offsite restore'],
'changed_modules':[
'app/backup.py','app/pg_disaster_recovery.py','app/sqlite_pg_transfer.py',
'app/jobs.py','app/worker.py','scripts/pg_disaster_recovery.py',
'scripts/migrate_sqlite_to_postgres.py','scripts/verify_pg_bootstrap.py',
'scripts/verify_sqlite_pg_transfer.py','scripts/verify_pg_backup_restore.py',
'scripts/verify_redis_signal.py','.github/workflows/ci.yml'],
'limitations': 'NOT production-approved; real PG/Redis/Docker tests require external CI/ops environment'}
(rep/'V8_18_RELEASE_EVIDENCE.json').write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf-8')
lines=['# SiteForge Enterprise V8.18.0-dev.1 — 集成验收总览','',
'**结论:本地开发集成回归通过,正式生产环境验收未完成。**','',
f"- 自动化:{r['modules']} 个模块,{r['repeats']} 轮 × {r['tests_last_complete_round']} 项 = {total} 项通过;0 失败 / 0 超时。",
'- HTTP + Worker 真实端到端:通过(登录 → 建站 → 入队 → Worker 构建 → ZIP → 预览)。',
'- Python 编译、JavaScript 语法、项目静态检查:通过。',
'- 项目只读审计:12 项通过,2 项跳过。',
'', '## 核心新增', '',
'- Postgres 模式禁用不正确的 SQLite 备份;Postgres 离线 ZIP 灾备、校验与恢复到全新数据库/目录。',
'- SQLite → PostgreSQL 离线迁移、依赖排序、事务提交和逐表哈希/行数核验。',
'- 发布/回滚任务租约过期、网络故障、取消后标记待核对,禁止不安全自动重试。',
'- CI PostgreSQL、Redis 和实际 pg_dump → 恢复的集成烟测入口。',
'', '## 仍未通过生产门禁', '']
lines.extend('- '+x for x in result['not_tested_in_this_environment'])
lines+=['','## 文件','',
'- `reports/v818-regression-2rounds.html`:两轮测试明细',
'- `reports/v818-readonly.html`:只读审计报告',
'- `reports/v818-http-e2e.log`:HTTP/Worker E2E 输出',
'- `docs/V8_18_ENTERPRISE_HARDENING.md`:运维、迁移与灾备说明',
'', '注:成功通过本地自动化不代表 Docker 和真实 PostgreSQL 性能/容灾验收通过。']
(rep/'V8_18_集成验收总览.md').write_text('\n'.join(lines)+'\n',encoding='utf-8')
rows=''.join(f"<tr><td>{html.escape(x['label'])}</td><td class=ok>{x['status']}</td><td>{x['passed']}</td><td>{x['seconds']}s</td></tr>" for x in runs)
risks=''.join('<li>'+html.escape(x)+'</li>' for x in result['not_tested_in_this_environment'])
page=f'''<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>SiteForge V8.18 · 企业集成验收</title><style>
:root{{font-family:system-ui,-apple-system,"Microsoft YaHei",sans-serif;color:#1d2939;background:#f5f7fb}}*{{box-sizing:border-box}}body{{margin:0}}header{{background:#152338;color:white;padding:44px max(24px,calc((100vw - 1120px)/2))}}header p{{color:#b0c5df}}main{{max-width:1120px;margin:28px auto;padding:0 18px}}.cards{{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}}.card,section{{border:1px solid #e5e9ef;background:#fff;border-radius:12px;padding:20px}}.card small{{color:#758398}}.big{{font-size:31px;font-weight:750;margin:6px 0}}.ok{{color:#13795b;font-weight:700}}section{{margin-top:14px}}h2{{margin:0 0 15px;font-size:20px}}table{{width:100%;border-collapse:collapse}}th,td{{padding:10px;border-bottom:1px solid #eef0f4;text-align:left}}.warning{{font-weight:600;color:#99580c}}li{{margin:8px 0}}@media(max-width:650px){{.cards{{grid-template-columns:repeat(2,1fr)}}section{{overflow-x:auto}}}}</style></head><body>
<header><div style="font-size:13px;letter-spacing:2px;color:#b0c5df">SITEFORGE ENTERPRISE</div><h1>V8.18 · 集成验收总览</h1><p>开发集成版 · 本地验证通过 · 生产环境门禁未关闭</p></header><main><div class=cards>
<div class=card><small>每轮自动化测试</small><div class=big>299</div><span class=ok>PASS</span></div><div class=card><small>重复回归</small><div class=big>2</div><span>共 {total} 次通过</span></div><div class=card><small>测试模块</small><div class=big>{r['modules']}</div><span>历史模块 + 新模块</span></div><div class=card><small>失败 / 超时</small><div class=big>0 / 0</div><span class=ok>PASS</span></div></div>
<section><h2>完整回归批次</h2><table><tr><th>批次</th><th>状态</th><th>测试通过</th><th>耗时</th></tr>{rows}</table></section>
<section><h2>业务链路</h2><p class=ok>PASS · 登录/CSRF → 创建网站和页面 → 异步 Worker 构建 → ZIP 下载 → 页面预览</p><p>Python 编译、JavaScript 语法检查及源码只读审计均通过;只读审计 2 项因环境/人工证据缺失跳过。</p></section>
<section><h2>尚未关闭的生产验收</h2><p class=warning>下列内容已准备 CI/运维入口,当前环境尚无真实完成证据:</p><ul>{risks}</ul></section>
<section><h2>运维与版本说明</h2><p>交付包含 V8.17 原有完整业务模块、V8.18 新增备份/迁移/防重复发布代码、自动化测试、CI 工作流、README、完整原始测试日志与验收报告。</p><p>真实上线前必须独立执行 PostgreSQL 迁移、灾备恢复、多 Worker、真实浏览器、部署回滚与故障演练。所有数据库写操作均应只在隔离测试库或经批准的维护窗口执行。</p></section></main></body></html>'''
(rep/'V8_18_集成验收总览.html').write_text(page,encoding='utf-8')
print('WROTE',total,'passed across two rounds')