fix: publish management receipt before orphan-exitable terminal state
This commit is contained in:
1 parent
74a45eb5cf
commit
a045683c8a
3 files changed
+24
-2
No files matched your search
@@ -103,7 +103,9 @@ def test_real_management_worker_parent_loss_waits_for_native_boundary(tmp_path):
|
||||
while not cancel.exists() and time.monotonic()<deadline:
|
||||
time.sleep(.02)
|
||||
assert cancel.exists() and worker.poll() is None
|
||||
assert worker.wait(5) == 2
|
||||
# Either the normal failed result or orphan exit may win after return;
|
||||
# both require the receipt to have been durably published already.
|
||||
assert worker.wait(5) in (2, 75)
|
||||
assert not continued.exists()
|
||||
assert (tmp_path/'supervisor-lost.json').is_file()
|
||||
assert json.loads((tmp_path/'result.json').read_text())['safe_to_continue'] is True
|
||||
@@ -146,3 +148,20 @@ def test_remove_timeout_keeps_worker_observing_until_native_returns(tmp_path, mo
|
||||
thread.join(3)
|
||||
assert done.is_set()
|
||||
assert json.loads((tmp_path/'result.json').read_text())['safe_to_continue'] is True
|
||||
|
||||
|
||||
def test_terminal_management_state_cannot_precede_its_result_receipt(tmp_path, monkeypatch):
|
||||
job = tmp_path/'request.json'
|
||||
job.write_text(json.dumps(dict(operation='catalog', library=str(tmp_path/'lib.lmc'),
|
||||
desktop='CbbManagement_expected', operation_id='terminal-order')))
|
||||
monkeypatch.setattr(native, '_current_desktop', lambda: (None, 'wrong_desktop'))
|
||||
from cbb_refresh_verify import session_record
|
||||
observed = []
|
||||
def terminal(job, phase, **kwargs):
|
||||
if phase == 'FINISHED':
|
||||
receipt = json.loads((tmp_path/'result.json').read_text('utf-8'))
|
||||
assert receipt['safe_to_continue'] is True and receipt['success'] is False
|
||||
observed.append(phase)
|
||||
monkeypatch.setattr(session_record, 'update_worker_state', terminal)
|
||||
assert native.management_worker_main(job) == 2
|
||||
assert observed == ['FINISHED']
|
||||
Reference in new issue
Block a user