test: close packaged stop recovery and real saved handoff workflows
This commit is contained in:
1 parent
d9bfc57900
commit
b038951cc4
8 files changed
+359
-15
No files matched your search
@@ -4,6 +4,7 @@ import json
|
||||
from pathlib import Path
|
||||
|
||||
from dx_productivity.trial_task_center.native_netlist import _hash
|
||||
from dx_productivity.trial_task_center.verification.contracts import digest
|
||||
|
||||
|
||||
def require(condition, message):
|
||||
@@ -11,6 +12,12 @@ def require(condition, message):
|
||||
raise ValueError(message)
|
||||
|
||||
|
||||
def journal_digest(service):
|
||||
with service.repo.store.transaction():
|
||||
return digest([dict(row) for row in service.repo.connection.execute(
|
||||
'SELECT * FROM execution_operations ORDER BY task_id,round_id,operation_key')])
|
||||
|
||||
|
||||
def records(service, task_id):
|
||||
result, cursor = [], None
|
||||
while True:
|
||||
@@ -21,7 +28,7 @@ def records(service, task_id):
|
||||
return result
|
||||
|
||||
|
||||
def freeze_inputs(service, task_id, *, expected_count):
|
||||
def freeze_inputs(service, task_id, *, expected_count, historical_before=False):
|
||||
rows = records(service, task_id)
|
||||
require(type(expected_count) is int and expected_count>0 and len(rows)==expected_count,
|
||||
'验收必须事先指定非空、准确的工程数量。')
|
||||
@@ -29,8 +36,13 @@ def freeze_inputs(service, task_id, *, expected_count):
|
||||
for row in rows:
|
||||
require(row['input_state']=='ready', '开始前输入尚未就绪。')
|
||||
payload = row['payload']
|
||||
if historical_before:
|
||||
require(payload['expectation_ref'] is not None, '交接验收需要冻结预期清单。')
|
||||
for name in ('before_ref', 'after_ref'):
|
||||
capture = service.artifacts.read(payload[name], 'snapshot')
|
||||
if historical_before and name=='before_ref':
|
||||
# Historical before is proven by its immutable capture, not today's live bytes.
|
||||
continue
|
||||
for path, sha in capture['source_hashes'].items():
|
||||
require(path not in sources or sources[path]==sha, '同一源文件出现不同摘要。')
|
||||
require(_hash(Path(path))==sha, '源文件已偏离导入时的版本。')
|
||||
@@ -40,7 +52,8 @@ def freeze_inputs(service, task_id, *, expected_count):
|
||||
'after_ref': payload['after_ref'], 'policy': payload['check_plan'], 'display_name': row['display_name']})
|
||||
operations = service.repo.connection.execute('SELECT COUNT(*) FROM execution_operations').fetchone()[0]
|
||||
return {'standard': 'verification-closed-loop-v1', 'task_id': task_id, 'items': items,
|
||||
'source_hashes': sources, 'replacement_operations_before': operations}
|
||||
'source_hashes': sources, 'replacement_operations_before': operations,
|
||||
'replacement_journal_digest':journal_digest(service), 'historical_before':historical_before}
|
||||
|
||||
|
||||
class _ReportHTML(HTMLParser):
|
||||
@@ -138,6 +151,8 @@ def verify_closed_loop(service, task_id, scope, run, report, *, expected_verdict
|
||||
count = service.repo.connection.execute('SELECT COUNT(*) FROM execution_operations').fetchone()[0]
|
||||
# Early v1 standalone fixtures recorded an implicit zero baseline.
|
||||
require(count==scope.get('replacement_operations_before', 0), '校验期间出现了新的换料操作或历史记录变化。')
|
||||
if 'replacement_journal_digest' in scope:
|
||||
require(journal_digest(service)==scope['replacement_journal_digest'], '已有换料回执或执行代次发生变化。')
|
||||
check('C05:read_only', unchanged)
|
||||
return {'standard': scope['standard'], 'task_id': task_id, 'run_id': run['run_id'],
|
||||
'validation_scope': 'single-run:C01-C05', 'not_run': ['C06', 'C07', 'C08'],
|
||||
|
||||
Reference in new issue
Block a user