fix: bind UI jobs and recovery actions to captured scope
This commit is contained in:
1 parent
601dd7b6b2
commit
cd7a5e0ca1
20 files changed
+1570
-297
No files matched your search
@@ -0,0 +1,38 @@
|
||||
from threading import Event
|
||||
import pytest
|
||||
from cbb_refresh_verify.operation_queue import BatchTaskContext, TaskHandoff, native_phase
|
||||
|
||||
|
||||
def test_metadata_can_refresh_while_abandoned_native_scope_stays_protected():
|
||||
entered, release = Event(), Event()
|
||||
old = BatchTaskContext('a.lmc')
|
||||
def stalled():
|
||||
entered.set(); release.wait(3)
|
||||
try:
|
||||
with pytest.raises(TaskHandoff): old.run(stalled, timeout_seconds=.01)
|
||||
assert entered.is_set()
|
||||
new = BatchTaskContext('a.lmc')
|
||||
assert new.run(lambda: 'metadata', metadata_only=True) == 'metadata'
|
||||
with pytest.raises(TaskHandoff): new.run(lambda: 'native')
|
||||
finally:
|
||||
release.set(); old.close(timeout_seconds=1)
|
||||
|
||||
|
||||
def test_metadata_cannot_escalate_into_native_phase():
|
||||
context = BatchTaskContext('a.lmc')
|
||||
def escalate():
|
||||
with native_phase():
|
||||
pytest.fail('metadata admitted native action')
|
||||
with pytest.raises(RuntimeError, match='metadata'):
|
||||
context.run(escalate, metadata_only=True)
|
||||
|
||||
|
||||
def test_abandoned_metadata_does_not_block_next_native_admission():
|
||||
release = Event()
|
||||
old = BatchTaskContext('a.lmc')
|
||||
try:
|
||||
with pytest.raises(TaskHandoff):
|
||||
old.run(lambda: release.wait(3), timeout_seconds=.01, metadata_only=True)
|
||||
assert BatchTaskContext('a.lmc').run(lambda: 'admitted') == 'admitted'
|
||||
finally:
|
||||
release.set(); old.close(timeout_seconds=1)
|
||||
Reference in new issue
Block a user