P08-03: 配置の通常操作受入
This commit is contained in:
@@ -377,6 +377,8 @@ def check(project_root, evidence_dir):
|
||||
rows = []
|
||||
normal_results = {}
|
||||
inspections = {}
|
||||
bootstrap_inspection = None
|
||||
bootstrap_result = None
|
||||
for role, pid in zip(('writer', 'reader'), expected_pids):
|
||||
process = document(directory+'/'+role+'-process.json')
|
||||
require(process['pid'] == pid and process['failures'] == 0 and process['checks'] > 0, 'process attribution')
|
||||
@@ -392,7 +394,12 @@ def check(project_root, evidence_dir):
|
||||
require(path.startswith('user://') and record['absolute_path'] == str(Path(record['user_data_dir'])/path[7:]), 'save outside private user profile')
|
||||
result = decode(record['result'])
|
||||
require(isinstance(result, dict) and result.get('ok') is True, 'actual save/load failed')
|
||||
if native_os and role == "writer" and record["operation"] == "initial_inspect":
|
||||
require(result.get("read_only") is True and "snapshot" in result, "missing bootstrap inspection")
|
||||
bootstrap_inspection = typed_member(record["result"],"snapshot")
|
||||
if record['operation'] == 'runtime_operation':
|
||||
if native_os and role == "writer" and bootstrap_result is None:
|
||||
bootstrap_result = record["result"]
|
||||
operations.append(result.get('operation'))
|
||||
normal_results[role] = result
|
||||
if record['operation'] == 'formal_inspect':
|
||||
@@ -464,6 +471,30 @@ def check(project_root, evidence_dir):
|
||||
'expected_recent_count':len(decode(expected)['systems']['runtime']['domain_events']['recent_events']),
|
||||
'actual_recent_count':len(decode(typed(role+'-checkpoint'))['systems']['runtime']['domain_events']['recent_events']),
|
||||
'whole_raw_equal':True} and decode(comparison['returned_result']) == result, 'wrong operation comparison attribution')
|
||||
if native_os:
|
||||
prefix = "writer-bootstrap-"
|
||||
bootstrap_formal = typed(prefix+"formal-model")
|
||||
returned = typed(prefix+"returned-result")
|
||||
require(bootstrap_inspection is not None and not typed_differences(bootstrap_formal,bootstrap_inspection), "wrong bootstrap formal inspection")
|
||||
require(bootstrap_result is not None and not typed_differences(returned,bootstrap_result), "wrong bootstrap returned Dictionary")
|
||||
result = decode(returned)
|
||||
require(result.get("ok") is True and result.get("operation") == "recovery", "wrong bootstrap load result")
|
||||
expected = expected_operation(bootstrap_formal,result,"SAVE_RECOVERY_LOADED")
|
||||
actual = typed(prefix+"checkpoint")
|
||||
require(not typed_differences(expected,actual), "bootstrap source-defined operation drift")
|
||||
require(not typed_differences(expected,typed(prefix+"expected-operation")), "wrong bootstrap expected model")
|
||||
require(not typed_differences(actual,typed(prefix+"operation-actual")), "bootstrap inspection drift")
|
||||
for label in ("expected-operation","operation-actual"):
|
||||
require(sha(artifact(directory+"/"+prefix+label+".var")) == sha(artifact(directory+"/"+prefix+"checkpoint.var")), "wrong bootstrap raw model")
|
||||
comparison = document(directory+"/"+prefix+"operation-comparison.json")
|
||||
require(comparison == {
|
||||
"pid":expected_pids[0], "delta_kind":"source_defined_notification",
|
||||
"formal_model":prefix+"formal-model", "actual_model":prefix+"checkpoint",
|
||||
"expected_model":prefix+"expected-operation", "returned_result":returned,
|
||||
"saved_recent_count":len(decode(bootstrap_formal)["systems"]["runtime"]["domain_events"]["recent_events"]),
|
||||
"expected_recent_count":len(decode(expected)["systems"]["runtime"]["domain_events"]["recent_events"]),
|
||||
"actual_recent_count":len(decode(actual)["systems"]["runtime"]["domain_events"]["recent_events"]),
|
||||
"whole_raw_equal":True}, "wrong bootstrap comparison attribution")
|
||||
saved = document(directory+'/save.json')
|
||||
require(set(saved['members']) == set(MEMBERS) and saved['pid'] == expected_pids[0], 'missing formal members/writer')
|
||||
for member in MEMBERS:
|
||||
|
||||
@@ -61,6 +61,39 @@ class EvidenceTests(unittest.TestCase):
|
||||
self.assertEqual(1,C.main(['--verify-only','--project-root',str(self.root)]))
|
||||
self.assertIn('reason mismatch',json.loads(output.getvalue())['deficits'])
|
||||
|
||||
def bootstrap_edit(self, mutate):
|
||||
self.edit("os-pair/writer-bootstrap-checkpoint.json", mutate)
|
||||
self.reject("bootstrap source-defined operation drift")
|
||||
|
||||
def test_bootstrap_missing_notification(self):
|
||||
self.bootstrap_edit(lambda d: C.typed_member(d,"systems","runtime","domain_events","recent_events")["items"].pop())
|
||||
|
||||
def test_bootstrap_extra_notification(self):
|
||||
self.bootstrap_edit(lambda d: C.typed_member(d,"systems","runtime","domain_events","recent_events")["items"].append(
|
||||
copy.deepcopy(C.typed_member(d,"systems","runtime","domain_events","recent_events")["items"][-1])))
|
||||
|
||||
def test_bootstrap_counter_drift(self):
|
||||
self.bootstrap_edit(lambda d: C.typed_member(d,"systems","runtime","id_generator","counters","domain_event").update(text="999"))
|
||||
|
||||
def test_bootstrap_payload_drift(self):
|
||||
def mutate(d):
|
||||
event = C.typed_member(d,"systems","runtime","domain_events","recent_events")["items"][-1]
|
||||
C.typed_member(event,"payload","save_path").update(text='"/wrong/path"')
|
||||
self.bootstrap_edit(mutate)
|
||||
|
||||
def test_bootstrap_unknown_field_drift(self):
|
||||
self.bootstrap_edit(lambda d: d["entries"].append([F.typed("unknown"),F.typed(1)]))
|
||||
|
||||
def test_bootstrap_missing_raw(self):
|
||||
(self.out/"os-pair/writer-bootstrap-checkpoint.var").unlink()
|
||||
F.repin(self.out)
|
||||
self.reject("writer-bootstrap-checkpoint.var")
|
||||
|
||||
def test_bootstrap_overwritten_raw(self):
|
||||
shutil.copyfile(self.out/"os-pair/writer-checkpoint.var", self.out/"os-pair/writer-bootstrap-checkpoint.var")
|
||||
F.repin(self.out)
|
||||
self.reject("wrong bootstrap raw model")
|
||||
|
||||
def test_reason_mismatch(self):
|
||||
self.edit('pair/writer-actions.json', lambda d: d['actions'][0].update(status='配置可能'))
|
||||
self.reject('reason mismatch')
|
||||
|
||||
Reference in New Issue
Block a user