Test execution speed / 测试执行提速
Parallel execution changes scheduling and fixture setup, never the selected tests or the
quality thresholds. make check still runs the complete gate; scripts/ci-check.sh also
runs the README checks and every declared mutation. The existing default
-m 'not integration' is unchanged. Overall coverage remains at least 85%, and the
domain coverage checks in scripts/check_coverage.py still run after the merged report.
GitHub CI runs the same commands split across parallel jobs; see CI layout.
并行只改变调度与夹具准备,不改变用例选择和质量门槛。make check 仍执行完整门禁;
scripts/ci-check.sh 另执行 README 检查和全部变异锚。原有默认
-m 'not integration' 不变,总覆盖率仍须达到 85%,合并报告后仍执行领域覆盖率检查。
GitHub CI 把同一组命令拆到多个并行 job 上执行,见下文「CI 分片」。
Scheduling options / 调度方式比较
| Option / 方式 | Behavior / 行为 | Fit here / 本仓取舍 |
|---|---|---|
xdist load |
Dispatch pending tests to available workers. / 按空闲情况派发用例。 | Fine granularity; expensive fixtures may repeat. / 粒度细,昂贵夹具可能重复。 |
xdist loadfile |
Keep each file on one worker. / 同一文件留在同一 worker。 | Reuses file fixtures; slow files limit balance. / 便于复用夹具,慢文件可能拖尾。 |
xdist loadscope |
Group functions by module and methods by class. / 函数按模块、方法按类分组。 | Useful for costly module/class fixtures. / 适合昂贵模块或类夹具。 |
xdist loadgroup |
Keep each xdist_group together; dispatch unmarked tests as load. / 相同 xdist_group 留在同一 worker,未标记用例按 load 派发。 |
Shares a Docker fixture but allows other workers to compete for resources. / 可复用 Docker 夹具,其它 worker 仍会争用资源。 |
| Repository security scheduler / 本仓安全调度器 | Run the security group alone, then execute ordinary cases concurrently. / 安全组先独占执行,再并行执行普通用例。 | Protects container startup and cleanup; adds a serial phase. / 保护容器启动与清理,代价是增加独占阶段。 |
xdist worksteal |
Redistribute queued tests from busy workers. / 空闲 worker 从繁忙队列取任务。 | Handles variable durations; no file affinity guarantee. / 应对耗时差异,不保证文件亲和。 |
| Separate pytest shards / 多个 pytest 分片 | Manually partition node IDs and merge reports. / 自行划分节点并合并报告。 | Used across CI jobs, with a completeness check and merged coverage. / CI 跨 job 使用,配完整性检查与覆盖率合并。 |
| Python process pool / Python 进程池 | Execute picklable work in separate interpreters. / 独立解释器执行可序列化任务。 | Suitable for independent jobs; does not supply pytest scheduling or reporting. / 适合独立任务,不能直接替代 pytest 调度和报告。 |
| Python thread pool / Python 线程池 | Share an interpreter while overlapping work. / 共用解释器并发执行。 | Suitable for supervising subprocesses, unsafe for simultaneous in-process pytest sessions. / 可管理子进程,不宜在同一进程并跑 pytest 会话。 |
The xdist scheduler semantics and fixture behavior above come from its distribution guide and fixture guide. Process/thread tradeoffs follow the Python 3.12 executor documentation. The fit assessment is based on this repository's fixtures and runners.
上表调度及夹具语义以官方指南为据,进程池与线程池行为以 Python 3.12 官方文档为据; 适用性一列是结合本仓夹具和执行器的判断。xdist 的 session 夹具每个 worker 各执行一次, 不是整个分布式运行只执行一次。
Isolation and coverage / 隔离与覆盖率
- The session fixture in
tests/conftest.pycreates one migrated empty source per worker, usingtests/db_templates.py. Tests receive copies and never write to that source.DATAKEEL_HOMEremains inside each test's temporary directory. / 根 session 夹具通过tests/db_templates.py为每个 worker 创建一个迁移完成的空模板; 用例获得副本,不写模板,DATAKEEL_HOME仍位于各用例临时目录。 - SQLite uses
sqlite3.Connection.backup()to make a full database copy for eachdbfixture. Teardown disposes the engine and removes that copy plus its-waland-shmsidecars; session cleanup removes the worker's source file. / SQLite 的每个db夹具通过sqlite3.Connection.backup()获得完整数据库副本; 清理时释放 engine,删除该副本及其-wal、-shm文件,会话结束后删除 worker 模板。 - PostgreSQL creates a private
datakeel_template_<UUID>database fromtemplate0, migrates atest_<UUID>schema there, and clones the whole database into a freshdatakeel_test_<UUID>database per test. The same schema name may exist in different databases; their facts and connections remain separate. Database constraints, functions and triggers are retained with the schema objects, rather than rebuilt from table-only metadata. Connections use the copied schema's search path. / PostgreSQL 从template0创建私有datakeel_template_<UUID>数据库,在其中迁移test_<UUID>schema,再为每个用例克隆为新的datakeel_test_<UUID>完整数据库。 不同数据库中可以有相同 schema 名,其事实和连接仍独立;复制保留约束、函数和触发器等 schema 对象,不以仅含表结构的 metadata 重建,连接仍设置对应 search path。 - PostgreSQL fixtures reject hosts other than
localhostor127.0.0.1. The local test role needsCREATEDBand permission to clone the template; the fixture owns the templates it creates. Cleanup drops only UUID databases recorded as created by that template owner, after disposing their engines. The drop usesWITH (FORCE)so that, like the originalDROP SCHEMA, cleanup does not depend on the test having closed every session (for example, a test that replacesengine.dispose). FORCE only ends sessions connected to that UUID database; it never touches other databases or the container. Each copy starts with one pooled connection, matching the original fixture's state aftermigrate(), because offline tests forbid opening sockets after setup. / PostgreSQL 夹具继续拒绝localhost、127.0.0.1以外的主机。本地测试角色须有CREATEDB及克隆模板的权限,夹具拥有自己创建的模板。清理先释放 engine,只删除当前 owner 记录为自己创建的 UUID 数据库。删除使用WITH (FORCE),与原DROP SCHEMA一样 不依赖用例关闭全部会话(例如用例替换了engine.dispose);FORCE 只结束连到该 UUID 库的 会话,不影响其它库或容器。每个副本交付前先建好一条池内连接,与原夹具migrate()后的 状态一致,因为离线用例在准备阶段后禁止新建 socket。 unmigrated_dbretains the original migration-test path: each test gets an empty SQLite file or its own PostgreSQL schema in the supplied database, then executes the migrations under test. Teardown drops only that schema and disposes its engine. /unmigrated_db保留原迁移测试路径:每用例创建空 SQLite 文件,或在指定 PostgreSQL 数据库内创建独立 schema,再执行待测迁移;清理仅删除该 schema 并释放 engine。- Most child fixtures generate data in
tmp_pathand retain function scope. Environment and module monkeypatches stay within the worker process and are undone by pytest. These properties must be preserved when reducing fixture setup cost. / 大部分子夹具在tmp_path内按用例生成数据;环境和模块 monkeypatch 留在 worker 进程内,由 pytest 撤销。缩短夹具准备耗时时仍须保留这些性质。 - The real sandbox fixture owns a unique Docker image tag and its build state directory. It removes only its exact tag. Session fixture duplication must be considered when choosing worker count and scheduler; a scheduler does not make shared paths safe. / 真实沙箱夹具拥有唯一镜像 tag 和独立构建状态目录,只删除自己创建的精确 tag。 选择并行数与调度方式时须考虑 session 夹具重复,调度方式本身不能隔离共享路径。
- pytest-cov supports xdist and combines worker coverage into one data file.
make check-coveragethen writes the terminal, XML and JSON reports and applies all thresholds to that result; CI first combines the data files of all shards. This differs from coverage in ordinary child processes: pytest-cov 7 removed its own subprocess instrumentation; enabling that separately would require coverage's subprocess patch and is outside the scheduling change. / pytest-cov 原生支持 xdist,把各 worker 覆盖率合并成一个数据文件;make check-coverage再输出终端、XML、JSON 报告,门槛作用于合并结果;CI 先合并所有分片的数据文件。普通子进程覆盖率是另一件事:pytest-cov 7 已移除自己的子进程采集;如另行 启用,需要 coverage 的 subprocess patch,不应与本次调度改动混淆。
Sources: pytest-cov xdist support, pytest-cov subprocess migration. The fixture descriptions above are derived from repository code.
Repeated PostgreSQL migrations retain installed training triggers, checking both the trigger
name and the schema-resolved table OID before creating a missing trigger. Function bodies
still use CREATE OR REPLACE. This follows the existing release/lineage constraint pattern
and avoids trigger DDL blocking an active version writer. Trigger event-definition changes
need an explicit migration; ordinary startup does not repair manually altered triggers.
PostgreSQL 重复迁移会按触发器名称和当前 schema 的表 OID 判断是否已安装训练约束,
只创建缺失触发器,函数体仍通过 CREATE OR REPLACE 更新。该方式沿用发布和血缘约束的
既有模式,避免触发器 DDL 阻塞正在写版本的事务。触发事件定义变更需要显式迁移,
普通启动不负责修复被手工改动的触发器。
Copy and privilege semantics are documented by
SQLite's backup API
and PostgreSQL 17 CREATE DATABASE.
Commands and default / 入口与默认值
make check-python runs check-python-static, then check-pytest (the full pytest step through
uv run python -m scripts.run_pytest) and check-coverage.
The wrapper selects --dist loadgroup and explicitly loads scripts.pytest_groups with
-p so the plugin also runs in workers. The plugin marks only
tests/operators/custom_sandbox/test_security.py with the security xdist_group and
installs the scheduler in scripts.pytest_scheduler.
make check-python 依次执行 check-python-static、check-pytest(完整 pytest 步骤,通过
uv run python -m scripts.run_pytest 执行)和 check-coverage。
默认选择 --dist loadgroup,通过 -p 显式加载 scripts.pytest_groups,确保 worker
也执行插件。插件只给 tests/operators/custom_sandbox/test_security.py 添加安全组
xdist_group,并安装 scripts.pytest_scheduler 中的调度器。
The selected security tests run first on one worker while the other workers stay idle. Only after that phase completes do ordinary cases execute concurrently. Group affinity alone would avoid duplicate image builds but would still allow CPU and I/O contention during container startup and cleanup. The exclusive phase covers both. A security failure still fails the gate; the scheduler does not reinterpret a timeout or missing cleanup as success. A worker crash aborts the run rather than treating unfinished cases as completed. All phases belong to one pytest session with one merged coverage report. The image fixture has module scope, so its cleanup completes with the final security test protocol before ordinary work starts.
被选中的安全用例先在一个 worker 上执行,其它 worker 保持空闲;独占阶段结束后,才并行 执行普通用例。仅设置组亲和只能避免重复构建镜像,仍会在容器启动和清理时争用 CPU 与 I/O;独占阶段同时保护这些操作。安全测试失败仍使门禁失败,调度器不会把超时或缺少清理 视为成功;worker 崩溃会终止本次运行,不把未完成用例算作已完成。所有阶段属于同一个 pytest 会话,最终只合并一份覆盖率报告。 镜像夹具使用模块作用域,其清理包含在最后一个安全用例的完整协议中,在普通阶段开始前完成。
scripts.pytest_priorities holds a static list of complete node IDs for expensive cases.
After the security phase, these cases are dispatched early to reduce the final long tail.
Unlisted tests keep their relative order; no test is removed, duplicated or selected from
a timing cache. The priority list contains no measured timings or machine-specific data.
Other tests remain ungrouped and can run separately even when they share a file.
The exception is ORDERED_MODULES in scripts.pytest_groups: exact test modules whose
cases share module state and therefore depend on serial order within the module.
tests/operators/pointcloud/test_shape.py draws all generated shapes from one module-level
seeded generator, so a case's data depends on which cases of that module ran before it
in the same process. Split across workers, a threshold assertion failed in a full run
(median 0.193, required above 0.2). Each listed module runs whole on one worker in
collection order, so every case sees exactly its serial data. Add a module here when its
cases share mutable module state; do not change its data or assertions for parallelism.
scripts.pytest_priorities 保存昂贵用例的完整 node ID 静态列表。安全阶段后优先派发这些
用例,减少末尾长尾;未列出的用例保持相对顺序。不会删除、重复用例,也不根据计时缓存
筛选用例。优先级列表不包含实测耗时或机器专属数据;其它用例不分组,即使在同一文件中
也可分别执行。
例外是 scripts.pytest_groups 的 ORDERED_MODULES:其中模块的用例共享模块状态,结果依赖
模块内的串行顺序。tests/operators/pointcloud/test_shape.py 的所有生成点云都取自同一个
模块级固定种子随机数发生器,某个用例拿到的数据取决于同一进程里先跑了该模块哪些用例。
拆到多个 worker 后,一次全量运行中阈值断言失败(中位数 0.193,要求大于 0.2)。列入的
模块整体在一个 worker 上按收集顺序执行,每个用例拿到的数据与串行完全一致。今后若用例
共享可变模块状态就加入此处,不要为并行改它的数据或断言。
loadfile was considered for fixture reuse, but it also serializes every case in a heavy
CLI evaluation file. Selective grouping and explicit priorities avoid that file-wide
restriction. Scheduling marks and priorities do not change -m 'not integration', test
membership, assertions or coverage thresholds.
loadfile 有利于复用夹具,但也会让重型 CLI evaluation 文件内的所有用例串行执行。
精确分组与显式优先级避免整文件绑定。调度 marker 和优先级不改变
-m 'not integration'、用例集合、断言或覆盖率门槛。
The worker policy in scripts.test_workers.test_worker_count() is
max(1, min(16, os.cpu_count() or 1)). The cap bounds memory, process, database and temporary
disk demand. Override it with a positive integer in DATAKEEL_TEST_WORKERS.
DATAKEEL_TEST_WORKERS=1 executes serially. The same policy bounds mutation concurrency.
CI uses the same wrapper and sets the count explicitly for its four-core runner.
scripts.test_workers.test_worker_count() 的默认公式为
max(1, min(16, os.cpu_count() or 1)),上限限制内存、进程、数据库连接和临时磁盘需求。
可用环境变量 DATAKEEL_TEST_WORKERS 设为正整数覆盖;设为 1 时串行执行。
变异并发复用相同策略;CI 使用同一入口,并为四核 runner 显式设置并行数。
make check-python
DATAKEEL_TEST_WORKERS=1 make check-python
DATAKEEL_TEST_WORKERS=4 scripts/ci-check.sh
uv run pytest --collect-only -q
Direct pytest commands retain their normal semantics; collection does not need worker startup. Neither a smaller worker count nor serial execution changes test selection.
直接调用 pytest 保留原有语义,收集用例无需启动 worker;减少 worker 或串行执行不改变用例集合。
Mutation execution / 变异执行
Each mutation keeps its own TemporaryDirectory, source copy, home, SQLite database and
subprocess environment. A successful unmodified baseline is required before mutated jobs
start. A pytest mutant must still produce exactly its declared test's measured call
assertion; setup errors, skips and crashes never count as a kill. The special explanation
probe remains confined to its mutant's source copy. Concurrency must be bounded rather
than creating one worker per mutation, and results must retain catalogue order.
每个变异继续拥有独立临时目录、源码副本、home、SQLite 数据库和子进程环境;原始基线必须 先全部通过,才启动变异。pytest 变异仍须有且仅有目标用例的实际调用断言失败,准备阶段 错误、跳过和崩溃不能算 KILLED。特殊解释探针仍仅修改对应变异副本。并发必须有上限, 不能每个变异都创建一个 worker;输出顺序应与变异目录一致。
The mutation supervisor uses ThreadPoolExecutor: each task already starts a separate
interpreter, so another process pool would add an unnecessary interpreter and serialization
layer. Every pytest subprocess disables nested xdist with -n0. Each baseline job also
uses its own source copy, and all baseline jobs must pass before the mutation pool starts.
Executor map preserves catalogue order when collecting results.
变异管理器使用 ThreadPoolExecutor:每项任务本来就启动独立解释器,再套进程池会增加解释器
和序列化开销。pytest 子进程通过 -n0 禁用嵌套 xdist;每项基线也使用独立源码副本,所有
基线通过后才启动变异池。通过 executor 的 map 按目录顺序收集结果。
A subprocess timeout is not evidence either way. When a mutation or baseline exceeds its
limit (300 seconds for one pytest target, 900 seconds for a complete golden evaluation), the
whole measurement is repeated once in a fresh source copy. A second timeout is recorded under
environment_failures in the report with the target and the command; the report is still
written, the script prints one line per failure without a stack trace and exits nonzero. A
timed-out mutation is never counted as killed, and a timed-out baseline still blocks every
mutant. Other crashes still fail immediately.
子进程超时不算任何证据。某个变异或基线超过上限(单个 pytest 目标 300 秒,完整 golden
评测 900 秒)时,在新的源码副本里整体重跑一次;再次超时就在报告的
environment_failures 里记下目标和命令,报告照常写出,每条失败打印一行、不打印 Python
堆栈,脚本以非零退出。超时的变异不算 KILLED,超时的基线照样拦住所有变异;其它崩溃仍
直接失败。
CI layout / CI 分片
.github/workflows/ci.yml runs on pull requests, on pushes to main and by hand
(workflow_dispatch). A pull request produces one run; a tag push produces none, because the
tagged commit was already verified. A newer commit on the same pull request cancels its older
run. Both stacks (SQLite and the PostgreSQL service) run the same jobs with fail-fast: false,
so a failure on one stack never cancels the other:
Only gates enables the shared setup action's license-wheels input. After uv sync --locked,
the CI-only supplier fetches the compatible certifi/orjson archives from their exact
files.pythonhosted.org URLs in uv.lock into a dedicated $RUNNER_TEMP directory. It rejects
all redirects and verifies filename, length, SHA-256 and wheel structure before exporting
DATAKEEL_LICENSE_WHEEL_DIR through $GITHUB_ENV. Failure stops setup before audit; the audit
itself stays offline. The pytest, mutation and report jobs do not enable these extra downloads.
仅两栈 gates 启用原始 wheel 证据供给;全部验证通过后才导出目录,许可审计始终离线。 pytest 分片超时仍独立失败,不通过许可供给、超时调整或检查豁免掩盖。
| Job / job | Commands / 命令 |
|---|---|
gates (<stack>) |
sandbox security tests; npm run check:source; make check-public; make check-rust; make collect-tests; make check-python-static; make check-scale; make check-web check-licenses; npm run check:source; scripts/check_readme.py |
pytest K/4 (<stack>) |
make install-accel; make check-pytest PYTEST_SHARD=K/4 |
mutation K/2 (<stack>) |
make install-accel; scripts/mutate.py --shard K/2 --output … |
report (<stack>) |
make check-test-shards; make combine-coverage check-coverage; scripts/merge_mutation_reports.py |
scripts.pytest_shards keeps whole test files together, so module fixtures, the sandbox
security group and ORDERED_MODULES stay on one shard. Files are packed longest first by
the seconds in scripts/pytest_durations.json; a file without a measurement weighs its test
count times the measured mean. Refresh the table from downloaded pytest-* artifacts with
uv run python -m scripts.pytest_durations <artifact directories>; the slower stack's time
is kept per file. The weights only affect balance, never selection. The report job checks
that every shard ran once, each saw the same collection as an unsharded
pytest --collect-only, their selections are disjoint and together equal that collection,
no file was split, and every selected test passed or skipped. It then combines coverage and
applies the 85% total line and scripts/check_coverage.py, and merges the mutation shard
reports with the unsharded rules: green baselines, every catalogue mutation measured once and
killed, no environment failures. Mutation shards deal golden and pytest mutations
round-robin separately, keeping catalogue order inside each shard.
Each shard job builds and installs the Rust extension itself (about 15 seconds with the shared
Rust cache): test files import datakeel_accel at module level. Locally nothing changes:
make check runs all of this unsharded in one command, and scripts/ci-check.sh adds the
README checks and the whole mutation catalogue.
工作流在 PR、推送 main 以及手动触发(workflow_dispatch)时运行。一个 PR 只产生一次
运行;推 tag 不再运行,因为 tag 指向的提交已经在 PR 上验过;同一 PR 的新提交会取消旧
运行。两个栈(SQLite 与 PostgreSQL 服务容器)跑同样的 job,关掉 fail-fast,一个栈失败不
取消另一个。job 与命令见上表。
scripts.pytest_shards 以整个测试文件为单位分片,模块夹具、沙箱安全组和
ORDERED_MODULES 都留在同一片。按 scripts/pytest_durations.json 的秒数从长到短装进当前
最轻的片;表里没有的文件按「条数 × 实测平均每条秒数」估算。用下载的 pytest-* 工件执行
uv run python -m scripts.pytest_durations <工件目录> 刷新耗时表,每个文件取较慢栈的耗时。
耗时只影响均衡,不影响选择哪些测试。report job 检查:每片恰好运行一次、每片看到的收集结果
与不分片的 pytest --collect-only 相同、各片选择互不重叠且并集等于完整收集、没有文件被拆开、
每条选中的测试都通过或跳过;再合并覆盖率,按 85% 总线和 scripts/check_coverage.py 判定;
最后合并变异分片报告,按不分片时的规则判定:基线全绿、目录里每个变异恰好测一次且全部
KILLED、没有环境失败。变异分片把 golden 型和 pytest 型变异各自轮流发到各片,片内保持目录
顺序。
每个分片 job 自己构建并安装 Rust 扩展(共享 Rust 缓存后约 15 秒),因为测试文件在模块顶层
导入 datakeel_accel。本机用法不变:make check 一条命令不分片跑完以上全部,
scripts/ci-check.sh 另跑 README 检查和完整变异目录。
Measurement protocol / 测量方法
Measure SQLite and PostgreSQL separately, with at most one complete gate running at a
time. Record commit, worker count, test count, wall time, exit status and uptime before
and after every measurement. Run the serial baseline and parallel comparison consecutively
under comparable machine load. Preserve the slowest 50 tests with --durations=50 and
record step times for the complete gate. A failed or interrupted run is not a completed
performance result. Sandbox restrictions are failures to report, never a reason to add
skip, xfail or deselection.
Treat the original baseline snapshot as read-only: optimized fixtures and scheduling belong only in the comparison checkout. Preserve baseline logs even if the run cannot finish within the task time limit.
SQLite 与 PostgreSQL 分别计时,同一时间最多执行一条完整门禁。每次记录提交、worker 数、
用例数、耗时、退出码及运行前后的 uptime。串行基线和并行对照应在相近负载下连续执行;
用 --durations=50 保留最慢 50 个用例,并记录完整门禁各步耗时。失败或中断不能算完成的
性能结果;沙箱限制只如实报告,不能据此新增 skip、xfail 或排除用例。
原始基线快照只读使用,优化后的夹具和调度只写入对照工作区。即使基线无法在任务时限内 完成,也保留原始日志。
Changed-test selection: deferred / 改动影响选择:暂缓
No check-changed shortcut is implemented in this change. Full test and mutation execution
remain the required gate. The following comparison records options for a separately
validated future shortcut.
本次不实现 check-changed,完整测试和变异仍是必需门禁。下表保留后续实现快速门禁时的
选型依据;任何方案都须独立验证可信度。
| Method / 方法 | Strength / 优点 | Conservative fallback needed / 须保守兜底 |
|---|---|---|
| pytest-testmon | Records executed dependencies and detects changed code using its own database. / 记录实际执行依赖,以自身数据库判断代码变化。 | Requires a complete initial run and valid state for each backend/environment; non-Python resources need extra rules. / 每个后端和环境均需完整初始记录及有效状态,非 Python 资源需补充规则。 |
| Static import graph / 静态 import 图 | No historical coverage database; reverse transitive imports give an explainable file set. / 无需历史覆盖库,可解释地反向遍历传递 import。 | Dynamic imports, fixtures, configuration and data dependencies need explicit edges or full execution. / 动态导入、夹具、配置和数据依赖须显式补边,否则全跑。 |
| Coverage test contexts / 覆盖率用例上下文 | Maps measured lines to test IDs, using the existing coverage tooling. / 复用现有覆盖工具,把执行行映射到用例节点。 | An unexecuted/new path has no historical edge; stale, incomplete or mismatched data must trigger full execution. / 新路径或未执行路径缺乏历史边,数据过期、不完整或不匹配时须全跑。 |
testmon's initial-run requirement and dependency model are documented by
its maintainers.
Python exposes static Import and ImportFrom nodes through
the AST API.
Coverage documents measurement contexts,
and pytest-cov supports full parameterized test IDs with
--cov-context=test.
The fallback rules are repository design requirements, not guarantees from these tools.
testmon 的初始全跑要求及依赖模型、Python AST 的 import 节点、coverage 的上下文数据能力 均见上述官方来源;保守兜底规则是本仓必须另行实现的约束,并非工具自动保证。
A future implementation must always run repository-wide static checks, select mutations whose target source files changed, and rerun everything for uncertain impact. Validation must replay three historical fixes with their source changes removed and demonstrate that the shortcut reports failure in each case. Full coverage gates remain separate because coverage from a selected subset cannot establish whole-suite coverage.
后续实现须始终运行全仓静态检查,执行目标源码文件被改动的变异锚,影响无法确定时全跑。 验收须选取三个历史修复提交,分别撤掉源码修复并证明快速门禁报红。子集测试覆盖率不能 证明完整覆盖率,因此仍须保留独立的全量覆盖率门禁。
PostgreSQL advisory lock evidence / PG 锁实证
tests/storage/test_evidence_locks_pg.py and
tests/evidence/test_vector_publication_pg.py belong to the ordinary pytest collection,
without the optional integration marker. SQLite explicitly skips them. The PostgreSQL CI
stack executes them through the existing whole-file shards and completeness gate; no extra
opt-in or lock substitution is used.
上述用例在 SQLite 明确 skip,在 PG CI 的常规分片中必须执行。它们只用隔离本地 PG
fixture,以独立连接的 PID、限定数据库/schema/key 的 pg_locks、pg_blocking_pids
与线程完成标志证明阻塞;deadline 只限制失败耗时,不以等待时长推断锁状态。
After an isolated local PG container has been explicitly authorized and provisioned by the maintainer, retain JUnit properties for the actual SQL and completion order:
维护者明确授权并准备好隔离本地 PG 容器后,保留 JUnit 属性中的实际 SQL 和完成顺序:
: "${DATAKEEL_TEST_DATABASE_URL:?Set the authorized local PG fixture URL}"
: "${PG_EVIDENCE_DIR:?Set an evidence output directory}"
.venv/bin/python -m pytest \
tests/storage/test_evidence_locks_pg.py \
tests/evidence/test_vector_publication_pg.py \
tests/storage/test_evidence_batching.py \
-q -o junit_family=legacy --junitxml="$PG_EVIDENCE_DIR/pg-lock.xml"
pg_lock_trace contains ordered SQL dispatch/completion, transaction markers and server
observations; pg_lock_stack, pg_lock_pids and pg_lock_observer_sql identify the stack,
connections and observation query. pg_lock_sources binds the actual source SHA-256 values
to each runtime trace. Ordinary batching cases emit pg_batch_sql,
pg_batch_selects and pg_batch_inserts. Keep the worktree source hashes with the report;
a SQLite skip report is collection evidence only and does not validate PostgreSQL behavior.
发布交错仅在 A 的首条真实 advisory SQL 发送前用 Event 调度 B/C 的真实提交;随后真实 持锁者使 A 在 PG 上等待,A 获锁后的查询、predecessor 和最终 producer 都须通过断言。 重建用例只把本地 fixture 的 Session 工厂接到工作线程独占的真实 PG Session,生产锁、 查询、diff 和 rebuild 实现均原样执行。提交返回标志可能晚于等待者收到锁授予;顺序断言 以提交调用、服务端锁等待和锁 SQL 完成为证据,不假定两个线程的返回先后。