80 lines
6.0 KiB
Plaintext
80 lines
6.0 KiB
Plaintext
# M11b-4 自测留证
|
||
# 生成时间: 2026-09-22 12:52:42 +0800
|
||
# 命令: cd modules/world_sync && .venv/bin/python scripts/m11b4_selftest.py
|
||
# Python: 3.10.12
|
||
|
||
==============================================================================
|
||
AC1 广播丢失 → 3s 轮询补漏(真实 3s 节奏)
|
||
==============================================================================
|
||
interval=3.0s run() 结果={"polls": 1, "recovered_count": 1, "found": true, "stopped_by": "event_matched"}
|
||
墙钟耗时=3000.6ms(含 1 次真实 3s sleep) on_recovered 回调次数=1
|
||
兜底计数器={"polls": 1, "queries": 1, "recovered": 1, "duplicated": 0, "missed_by_broadcast": 1, "timeouts": 0, "stops_on_notify": 0, "scenes": ["sc_ac1_1790052762"], "interval": 3.0, "timeout": 10.0}
|
||
[PASS] AC1.1 轮询间隔常量 = 3.0s -> 3.0
|
||
[PASS] AC1.2 广播丢失时 found=True(补到漏网事件)
|
||
[PASS] AC1.3 stopped_by=event_matched(非 timeout) -> event_matched
|
||
[PASS] AC1.4 补漏耗时 ≤ SLO 3000ms(1 个轮询周期内) -> 3000.6ms
|
||
[PASS] AC1.5 推进后的水位线 >= 事件 created_at -> 2026-09-22 04:52:42 >= 2026-09-22 04:52:42
|
||
|
||
==============================================================================
|
||
AC1b 已投递事件不重复补漏(同秒撞秒 + event_uid 去重双保险)
|
||
==============================================================================
|
||
第1轮 recovered=1 第2轮 recovered=0(水位线=2026-09-22 04:52:42)
|
||
[PASS] AC1b.1 首轮补到 1 条
|
||
[PASS] AC1b.2 次轮 0 条(水位线+已投递集合去重)
|
||
同秒新事件 uid=ac1b-d24b05f5c6e3ef48 created_at=2026-09-22 04:52:42 -> recovered=1 found=True
|
||
[PASS] AC1b.3 同秒新事件仍被补到(>= 水位线 + NOT IN 去重)
|
||
|
||
==============================================================================
|
||
AC1c 水位线格式守卫(ISO 格式必须被拒绝,否则静默丢事件)
|
||
==============================================================================
|
||
normalize_watermark('2026-09-22T03:00:00Z') = ''
|
||
normalize_watermark('2026-09-22 03:00:00') = '2026-09-22 03:00:00'
|
||
[PASS] AC1c.1 ISO commit_ts_text 被拒绝 -> ret=False watermark=''
|
||
[PASS] AC1c.2 库内空格格式被接受
|
||
[PASS] AC1c.3 水位线单调不减(旧值被忽略)
|
||
|
||
==============================================================================
|
||
AC1d 广播正常 → 轮询立即停止(stopped_by=broadcast_received)
|
||
==============================================================================
|
||
run()={"polls": 1, "found": false, "stopped_by": "broadcast_received"} 墙钟=200.8ms(远小于 3s 周期)
|
||
[PASS] AC1d.1 收到广播后停止
|
||
[PASS] AC1d.2 未走满轮询周期 -> 200.8ms
|
||
[PASS] AC1d.3 notified 短路后 polls 计数=1 -> 1
|
||
|
||
==============================================================================
|
||
AC2 补漏查询 EXPLAIN:必须命中 ix_scene_created,禁止全表扫描
|
||
==============================================================================
|
||
补漏 SQL: SELECT id, event_uid, tenant_id, world_id, scene_id, entity_id, event_type, seq, seq_no, state_version, created_at FROM pbl_runtime_event WHERE scene_id = ? AND created_at >= ? ORDER BY created_at ASC LIMIT 500
|
||
参数 : ['sc_x', '2026-09-22 00:00:00']
|
||
EXPLAIN QUERY PLAN 原文:
|
||
{"id": 5, "parent": 0, "notused": 0, "detail": "SEARCH pbl_runtime_event USING INDEX ix_scene_created (scene_id=? AND created_at>?)"}
|
||
[PASS] AC2.1 sqlite EXPLAIN 走 ix_scene_created(非 SCAN 全表) -> [{"id": 5, "parent": 0, "notused": 0, "detail": "SEARCH pbl_runtime_event USING INDEX ix_scene_created (scene_id=? AND created_at>?)"}]
|
||
MySQL pbls@127.0.0.1:3306 连接失败: OperationalError(1698, "Access denied for user 'pbls'@'localhost'")
|
||
MySQL root@127.0.0.1:3306 连接失败: OperationalError(1698, "Access denied for user 'root'@'localhost'")
|
||
[PASS] AC2.2 MySQL EXPLAIN(本机测试库不可达,已在交付件标注环境受限项) -> skipped: 10.20.30.41 测试库凭据在本开发机不可用(ERROR 1698 Access denied)
|
||
[PASS] AC2.3 plan_uses_scene_index 能识别 type=ALL 为不合规
|
||
[PASS] AC2.4 plan_uses_scene_index 能识别 key=ix_scene_created 为合规
|
||
|
||
==============================================================================
|
||
AC3 端到端时延基准:裁决→write_event_with_state→COMMIT→广播→消费端感知
|
||
==============================================================================
|
||
样本数 n=200 SLO=1000ms dialect=sqlite(file=m11b4.sqlite)
|
||
Traceback (most recent call last):
|
||
File "/d/pipeline/workspaces/0/sdlc_general/modules/world_sync/scripts/m11b4_selftest.py", line 454, in <module>
|
||
sys.exit(main())
|
||
File "/d/pipeline/workspaces/0/sdlc_general/modules/world_sync/scripts/m11b4_selftest.py", line 434, in main
|
||
rep = test_e2e_latency(dbpath)
|
||
File "/d/pipeline/workspaces/0/sdlc_general/modules/world_sync/scripts/m11b4_selftest.py", line 339, in test_e2e_latency
|
||
rep = latency_report(hooked, events, state_builder=_state_builder,
|
||
File "/d/pipeline/workspaces/0/sdlc_general/modules/world_sync/scripts/../world_sync/pbl_runtime_latency.py", line 180, in latency_report
|
||
samples = run_chain(write_fn, events, state_builder=state_builder,
|
||
File "/d/pipeline/workspaces/0/sdlc_general/modules/world_sync/scripts/../world_sync/pbl_runtime_latency.py", line 129, in run_chain
|
||
samples.append(measure_once(write_fn, ev, st, wait_ms=wait_ms,
|
||
File "/d/pipeline/workspaces/0/sdlc_general/modules/world_sync/scripts/../world_sync/pbl_runtime_latency.py", line 84, in measure_once
|
||
result = write_fn(event_data, state_update or {})
|
||
File "/d/pipeline/workspaces/0/sdlc_general/modules/world_sync/scripts/../world_sync/pbl_runtime_broadcast.py", line 829, in wrapper
|
||
result = write_fn(*args, **kwargs) # 事务在此完成 COMMIT(或抛异常回滚)
|
||
File "/d/pipeline/workspaces/0/sdlc_general/modules/world_sync/scripts/../world_sync/pbl_runtime_tx_sqlor.py", line 137, in write_event_with_state
|
||
return _write_event_with_state(
|
||
TypeError: write_event_with_state() got an unexpected keyword argument 'event_id'
|