Covers add-time validation (unknown action, disallowed device, out-of-range/wrong-type params, unknown kwarg - each rejected without landing in the queue), the execution-time allow-list re-check as the real safety boundary, the tomo_queue_actions global var matching the live registry, tomo_queue_show()/the webpage generator surviving a command job, legacy kind-less jobs still running as tomograms alongside a real command-job device move, and the non-idempotent resume prompt (distinct from the executor's own start-confirmation prompt). Also fixes flomni_sim: it only snapshotted/restored whatever was already in the tomo_queue/tomo_progress global vars, so a stale entry left behind by an earlier crashed run or manual debugging session against the same shared sim Redis would contaminate every test that assumed it started from an empty queue. Now resets both to empty at setup, in addition to snapshotting/restoring around the test.
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""Fixtures for end-to-end tomo-queue tests against a running flOMNI sim.
|
|
|
|
Deliberately does NOT use the shipped ``bec_client_lib_with_demo_config`` /
|
|
``bec_ipython_client_with_demo_config`` fixtures from pytest_bec_e2e: both
|
|
call ``bec.config.load_demo_config(force=True)``, which against a running sim
|
|
session overwrites the loaded simulated-flOMNI device config with BEC's demo
|
|
devices. See TOMO_QUEUE_TESTING.md section 3.
|
|
"""
|
|
|
|
import pytest
|
|
from _bootstrap import build_flomni, shutdown
|
|
|
|
_QUEUE_VAR = "tomo_queue"
|
|
_PROGRESS_VAR = "tomo_progress"
|
|
|
|
|
|
@pytest.fixture
|
|
def flomni_sim(bec_redis_fixture, bec_services_config_file_path, bec_servers):
|
|
"""A live ``Flomni`` instance attached to the already-running sim session.
|
|
|
|
See ``_bootstrap.build_flomni()`` for what connecting/constructing this
|
|
involves and why. The ``tomo_queue`` / ``tomo_progress`` global vars are
|
|
snapshotted before the test and restored after, so tests don't leak
|
|
queue/progress state into each other or into a real operator's session
|
|
on the same sim. The queue is also reset to empty at setup: it lives in
|
|
the shared sim Redis, so a prior crashed run or manual debugging session
|
|
can leave stale entries behind that would otherwise contaminate every
|
|
test that assumes it starts from an empty queue.
|
|
"""
|
|
bec, flomni = build_flomni(bec_services_config_file_path)
|
|
|
|
queue_snapshot = bec.get_global_var(_QUEUE_VAR)
|
|
progress_snapshot = bec.get_global_var(_PROGRESS_VAR)
|
|
bec.set_global_var(_QUEUE_VAR, [])
|
|
bec.set_global_var(_PROGRESS_VAR, None)
|
|
|
|
try:
|
|
yield flomni
|
|
finally:
|
|
bec.set_global_var(_QUEUE_VAR, queue_snapshot)
|
|
bec.set_global_var(_PROGRESS_VAR, progress_snapshot)
|
|
shutdown(bec)
|