Tests clear flow tombstones between modules with the other engine rows, and the tombstone test commits its prune before checking the count, so a wrong count no longer holds the write lock over the tests after it
This commit is contained in:
@@ -18,6 +18,7 @@ from fluksio.main import app
|
||||
from fluksio.models import (
|
||||
EngineEvent,
|
||||
FlowRun,
|
||||
FlowTombstone,
|
||||
MetricBucket,
|
||||
Run,
|
||||
RunArtifact,
|
||||
@@ -69,7 +70,8 @@ def db() -> Generator[Session, None, None]:
|
||||
|
||||
|
||||
#: Tables the engine writes to on its own, from the collector and the run
|
||||
#: service the module-scoped app starts.
|
||||
#: service the module-scoped app starts, and the tombstones a flow deleted
|
||||
#: through it leaves for that history.
|
||||
_ENGINE_TABLES = (
|
||||
RunArtifact,
|
||||
RunMetric,
|
||||
@@ -78,6 +80,7 @@ _ENGINE_TABLES = (
|
||||
FlowRun,
|
||||
EngineEvent,
|
||||
MetricBucket,
|
||||
FlowTombstone,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,11 @@ def test_a_tombstone_stays_while_history_names_its_id(db: Session) -> None:
|
||||
assert graves.recorded("wren_train") == "wren_train" # history, no tombstone
|
||||
assert graves.recorded("f_nothing") is None
|
||||
|
||||
assert tombstones.prune(db) == 1
|
||||
# Committed before it is checked, so a wrong count does not leave this
|
||||
# session holding the write lock for every test after it.
|
||||
pruned = tombstones.prune(db)
|
||||
db.commit()
|
||||
assert pruned == 1
|
||||
kept = {stone.id for stone in db.exec(select(FlowTombstone))}
|
||||
assert kept == {"f_gonegone", "f_trainee", "f_measured"}
|
||||
|
||||
@@ -45,8 +48,9 @@ def test_a_tombstone_stays_while_history_names_its_id(db: Session) -> None:
|
||||
db.exec(delete(MetricBucket)) # type: ignore[call-overload]
|
||||
db.exec(delete(EngineEvent)) # type: ignore[call-overload]
|
||||
db.commit()
|
||||
assert tombstones.prune(db) == 3
|
||||
pruned = tombstones.prune(db)
|
||||
db.commit()
|
||||
assert pruned == 3
|
||||
|
||||
|
||||
def test_a_name_comes_from_the_live_flow_then_its_tombstone_then_the_id(
|
||||
|
||||
Reference in New Issue
Block a user