fix: isolate component failures and recover owned CAD resources
This commit is contained in:
1 parent
a8da30aad2
commit
4db5f05531
87 files changed
+6688
-301
No files matched your search
@@ -81,6 +81,66 @@ def test_failed_queue_receipt_does_not_claim_success(project_service):
|
||||
assert journal.finish('a' * 32, result)['status'] == 'failed'
|
||||
|
||||
|
||||
def test_inspect_accepts_frozen_workspace_checkpoint(project_service):
|
||||
service, _, data, ids, hashes = project_service
|
||||
journal = RunJournal(data)
|
||||
journal.begin('b' * 32, ids, hashes)
|
||||
path = data / 'workspace-queues' / ('b' * 32 + '.json')
|
||||
path.parent.mkdir(parents=True)
|
||||
path.write_text(json.dumps({'version': 1, 'task_ids': ids, 'plan_hashes': hashes,
|
||||
'phase': 'primary', 'entries': {key: {'state': 'pending', 'message': '',
|
||||
'released': False, 'problems_done': False, 'checkpoint_id': str(index) * 32}
|
||||
for index, key in enumerate(ids, 1)}}))
|
||||
result = journal.inspect(service, 'b' * 32)
|
||||
assert result['queue_available'] and result['resume_ready']
|
||||
assert result['remaining_task_ids'] == ids
|
||||
|
||||
|
||||
@pytest.mark.parametrize('isolated', [True, False])
|
||||
def test_released_isolated_project_does_not_block_resume_of_other_projects(project_service, isolated):
|
||||
from dx_productivity.dsh.run_journal import resume_preflight
|
||||
service, _, data, ids, hashes = project_service
|
||||
journal = RunJournal(data)
|
||||
journal.begin('d' * 32, ids, hashes)
|
||||
evidence(service, ids[0], state='batch_saved_unverified' if isolated else 'batch_failed')
|
||||
entries = {key: {'state': ('blocked' if isolated else 'failed') if index == 0 else 'pending', 'message': 'problem' if index == 0 else '',
|
||||
'released': index == 0, 'problems_done': False, 'checkpoint_id': str(index + 1) * 32}
|
||||
for index, key in enumerate(ids)}
|
||||
entries[ids[0]]['supervisor_batch_id'] = 'e' * 32
|
||||
path = data / 'workspace-queues' / ('d' * 32 + '.json')
|
||||
path.parent.mkdir(parents=True)
|
||||
path.write_text(json.dumps({'version': 1, 'task_ids': ids, 'plan_hashes': hashes,
|
||||
'phase': 'primary' if isolated else 'problems', 'entries': entries}))
|
||||
result = journal.inspect(service, 'd' * 32)
|
||||
assert result['queue_available'] and result['resume_ready'], result['blockers']
|
||||
assert result['remaining_task_ids'] == (ids[1:] if isolated else ids)
|
||||
assert result['isolated_task_ids'] == ([ids[0]] if isolated else [])
|
||||
assert result['tasks'][0]['interrupted'] == isolated
|
||||
report = resume_preflight(service, result)
|
||||
assert report['ready']
|
||||
assert report['tasks'][0]['isolated'] == isolated
|
||||
|
||||
|
||||
def test_unpaused_blocked_project_is_not_a_completed_run(project_service):
|
||||
_, _, data, ids, hashes = project_service
|
||||
journal = RunJournal(data)
|
||||
journal.begin('b' * 32, ids, hashes)
|
||||
result = TaskQueueResult('b' * 32, (TaskQueueEntry(ids[0], 'blocked'),), False)
|
||||
assert journal.finish('b' * 32, result)['status'] == 'blocked'
|
||||
|
||||
|
||||
def test_confirmed_run_reports_isolated_blocked_project_as_issue(project_service, monkeypatch):
|
||||
from threading import Event
|
||||
from dx_productivity.dsh.execution_runs import execute_confirmed_run
|
||||
from dx_productivity.dsh.task_lifecycle import preflight
|
||||
service, _, data, ids, _ = project_service
|
||||
monkeypatch.setattr('dx_productivity.dsh.execution_runs.execute_task_queue', lambda *_args, **_kwargs:
|
||||
TaskQueueResult('c' * 32, tuple(TaskQueueEntry(task_id, 'blocked' if index == 0 else 'completed')
|
||||
for index, task_id in enumerate(ids)), False))
|
||||
result = execute_confirmed_run(service, data, ids, preflight(service, ids), Event(), 'c' * 32)
|
||||
assert result['status'] == 'blocked'
|
||||
|
||||
|
||||
def test_native_confirmed_resume_marks_running_and_retains_last_receipt(project_service):
|
||||
_, _, data, ids, hashes = project_service
|
||||
journal = RunJournal(data)
|
||||
|
||||
Reference in new issue
Block a user