History is kept by flow id: runs, cascades, rollups and events file the id in their flow column and nodes as <flow id>.<node>, the API answers flow plus flow_name and shows and takes nodes as <key>.<node>; events carry flow_id from the moment they are published; run queue items, the stage cache and cached curves keep ids and keys apart; endpoints, the brain graph, device bindings and search name the id to open
This commit is contained in:
@@ -93,7 +93,9 @@ def test_events_become_rollups_failures_runs_and_audit(db: Session) -> None:
|
||||
asyncio.run(collector.flush())
|
||||
|
||||
bucket = db.exec(
|
||||
select(MetricBucket).where(MetricBucket.flow == FLOW, MetricBucket.node == NODE)
|
||||
select(MetricBucket).where(
|
||||
MetricBucket.flow_id == FLOW, MetricBucket.node == NODE
|
||||
)
|
||||
).one()
|
||||
assert (bucket.executions, bucket.errors, bucket.messages) == (1, 1, 2)
|
||||
assert bucket.duration_max_ms == 5.0
|
||||
@@ -101,19 +103,21 @@ def test_events_become_rollups_failures_runs_and_audit(db: Session) -> None:
|
||||
|
||||
failure = db.exec(
|
||||
select(EngineEvent).where(
|
||||
EngineEvent.flow == FLOW, EngineEvent.type == "node_error"
|
||||
EngineEvent.flow_id == FLOW, EngineEvent.type == "node_error"
|
||||
)
|
||||
).one()
|
||||
assert "ValueError: bad input" in failure.detail
|
||||
assert "line 3, in run" in failure.detail
|
||||
|
||||
audit = db.exec(
|
||||
select(EngineEvent).where(EngineEvent.flow == FLOW, EngineEvent.type == "audit")
|
||||
select(EngineEvent).where(
|
||||
EngineEvent.flow_id == FLOW, EngineEvent.type == "audit"
|
||||
)
|
||||
).one()
|
||||
assert (audit.actor, audit.detail) == ("someone@example.com", "published")
|
||||
|
||||
run = db.exec(select(FlowRun).where(FlowRun.id == "1-0")).one()
|
||||
assert (run.status, run.flow, run.source) == ("error", FLOW, "external")
|
||||
assert (run.status, run.flow_id, run.source) == ("error", FLOW, "external")
|
||||
assert (run.nodes, run.errors) == (1, 1)
|
||||
assert run.duration_ms > 0
|
||||
|
||||
@@ -122,7 +126,9 @@ def test_events_become_rollups_failures_runs_and_audit(db: Session) -> None:
|
||||
asyncio.run(collector.flush())
|
||||
db.expire_all()
|
||||
bucket = db.exec(
|
||||
select(MetricBucket).where(MetricBucket.flow == FLOW, MetricBucket.node == NODE)
|
||||
select(MetricBucket).where(
|
||||
MetricBucket.flow_id == FLOW, MetricBucket.node == NODE
|
||||
)
|
||||
).one()
|
||||
assert (bucket.executions, bucket.errors) == (2, 2)
|
||||
|
||||
@@ -196,7 +202,7 @@ def test_batched_rollups_add_and_redelivery_clears_a_finished_run(db: Session) -
|
||||
bucket["duration_max_ms"] = 4.0
|
||||
collector._write(collector._buckets, [], list(collector._runs.values()), False)
|
||||
|
||||
buckets = db.exec(select(MetricBucket).where(MetricBucket.flow == "bulk")).all()
|
||||
buckets = db.exec(select(MetricBucket).where(MetricBucket.flow_id == "bulk")).all()
|
||||
assert len(buckets) == 2
|
||||
assert all(
|
||||
(b.executions, b.messages, b.duration_sum_ms, b.duration_max_ms)
|
||||
@@ -400,4 +406,4 @@ def test_a_rate_limit_flush_is_a_run_that_names_its_parent(db: Session) -> None:
|
||||
assert (flush.status, flush.parent) == ("ok", held_in)
|
||||
parent = db.get(FlowRun, held_in)
|
||||
assert parent is not None
|
||||
assert (parent.flow, parent.source) == ("metrics-flush", "external")
|
||||
assert (parent.flow_id, parent.source) == ("metrics-flush", "external")
|
||||
|
||||
Reference in New Issue
Block a user