test(grpc-data): A4 part 2 — A03 gap via pause+stop, origin watcher + re-assert mirror check, latest-EventId positive control; duplicate-transition checks (A03/A06/A07); docs: folder-first event item still refused BadNotSupported (workaround: i=2253 first)

This commit is contained in:
Joseph Doherty
2026-11-25 02:04:30 -05:00
parent 9ea50c11b2
commit 42e3800f2c
2 changed files with 53 additions and 7 deletions
+8 -2
View File
@@ -829,8 +829,14 @@ This section is what an OPC UA client of the **consumer** sees. Code: `OpcUaServ
- Each placement's folder is wired as a notifier when it is materialised: a projected folder, or the mapping anchor.
Wiring is lazy, in both directions, and also adds a root notifier. It is unwired at every projected-removal site.
Projected folders of a condition-bearing mapping have `SubscribeToEvents` from materialisation. A client can therefore
subscribe at a folder before any condition is wired there, and that subscription opens demand.
Projected folders of a condition-bearing mapping are meant to have `SubscribeToEvents` from materialisation, so that a
client can subscribe at a folder before any condition is wired there and open demand.
- ⚠️ **Live behaviour (A4 gate, runs `a4s-1` and `a4s-3`): that does not hold.** On a consumer node where no `i=2253` event
item has opened demand yet (including a freshly restarted node), an event item on a mapping's branch folder (e.g.
`remote-opc`) is refused `BadNotSupported` and the CLI `alarms -n <folder>` exits. Once demand is open and the
conditions are wired, the same folder accepts items and delivers every event.
- **Workaround:** open demand with a Server-object (`i=2253`) event item first (ScadaBridge's DCL already does), then
subscribe at folders. A folder-only client never receives imported conditions. Tracked as an A4 finding.
- **One event per origin transition.** It is delivered to every wired folder item and to the Server object (`i=2253`),
however many placements the condition has (one `ReportEvent`, through the shared report walk).
- A folder holding an admitted event item is pinned: projection eviction and paging skip it. Removing the mapping still
@@ -474,6 +474,22 @@ class ConditionScenarios:
ids = [b["EventId"] for b in blocks if b.get("EventId")]
return len(ids) == len(set(ids))
@staticmethod
def duplicate_transitions(watcher, names):
"""Live events (after the watcher's RefreshEnd) that repeat a condition's (Time, State, Severity, Message): one origin
transition delivered twice under different consumer EventIds — the EventId-uniqueness check cannot see that."""
blocks = watcher.blocks()
end = next((i for i, b in enumerate(blocks) if "RefreshEnd" in (b.get("EventType") or "")), -1)
seen, dupes = set(), []
for b in blocks[end + 1:]:
if b.get("Condition") not in names:
continue
key = (b.get("Condition"), b.get("Time"), b.get("State"), b.get("Severity"), b.get("Message"))
if key in seen:
dupes.append(key)
seen.add(key)
return dupes
def partner(self, pair, node):
return next(n for n in self.r.manifest["nodes"] if n.startswith(pair + "-") and n != node)
@@ -507,6 +523,7 @@ class ConditionScenarios:
partner = self.partner("source", source)
self.report["nodes"] = {"source_primary": source, "source_partner": partner, "consumer": consumer}
imported = self.watch(consumer, "consumer")
origin = self.watch(source, "origin")
time.sleep(6)
self.raise_scripted()
active = wait_for(lambda: self.latest(imported, name, lambda b: b.get("State") == "Active, Unacknowledged"), 120)
@@ -518,22 +535,31 @@ class ConditionScenarios:
# Phase 1 — stream reset against the same origin incarnation.
since = self.utc(-2)
time.sleep(3)
e1 = self.latest(imported, name)["EventId"]
mark = len(imported.blocks(name))
mark, origin_mark = len(imported.blocks(name)), len(origin.blocks(name))
self.r.mutate(bump_mapping_revision=self.fixture["conditions"]["native"]["mappings"]["pumpb"])
self.r.manifest = self.r.rig.load()
opened = wait_for(lambda: self.stream_opened(consumer, since), 120)
barrier = wait_for(lambda: self.barriers(consumer, since), 120)
time.sleep(8)
reset_events = imported.blocks(name)[mark:]
self.report["phase1"] = {"stream_opened": opened[-2:], "barrier": barrier[-2:], "events_during_reset": [(b.get("State"), b.get("EventType")) for b in reset_events],
"watcher_alive": imported.process.poll() is None}
origin_events = origin.blocks(name)[origin_mark:]
self.report["phase1"] = {"stream_opened": opened[-2:], "barrier": barrier[-2:], "events_during_reset": [(b.get("State"), b.get("Time")) for b in reset_events],
"origin_events_during_reset": [(b.get("State"), b.get("Time")) for b in origin_events],
"origin_reassert_log": self.log_lines(source, since, "re-asserted")[-2:], "watcher_alive": imported.process.poll() is None}
self.check("p1_stream_reopened_same_origin", opened and all(source in line for line in opened))
self.check("p1_barrier_after_reset", barrier)
self.check("p1_no_event_for_unchanged_state", not [b for b in reset_events if b.get("State")])
# A deploy is the rig's only stream-reset trigger, and it also makes the origin re-assert its scripted alarms (a new
# record time, same activation marker): the consumer must mirror exactly the origin's events — no resync extras.
self.check("p1_consumer_events_mirror_origin", len(reset_events) == len(origin_events) and self.unique_event_ids(imported.blocks(name)))
comment = self.ack(consumer, condition, e1, "comment-old-eventid-same-incarnation", command="comment")
self.report["phase1"]["comment_with_pre_reset_eventid"] = comment
self.check("p1_pre_reset_eventid_still_accepted", comment["good"])
latest_comment = self.ack(consumer, condition, self.latest(imported, name)["EventId"], "comment-latest-eventid-after-reset", command="comment")
self.report["phase1"]["comment_with_latest_eventid"] = latest_comment
self.check("p1_latest_eventid_accepted_positive_control", latest_comment["good"])
origin.stop()
time.sleep(6)
# Phase 2 — origin failover with a clear-and-re-raise in the gap.
@@ -543,11 +569,16 @@ class ConditionScenarios:
mark_all, mark_named, mark_native = len(imported.blocks()), len(imported.blocks(name)), len(imported.blocks(native))
since = self.utc(-1)
phase2 = self.report["phase2"] = {"pre_eventid": pre["EventId"], "pre_time": pre.get("Time"), "native_pre": native_pre}
with self.r.stopped(source):
# The gap: freeze the old Primary (docker pause), clear and re-raise at the device, unfreeze and stop it at once — so
# the consumer's stream never carries the clear, and the new Primary's record has a new time with the same state.
with self.r.paused(source) as resume:
self.r.device("set", address=20, value=0)
time.sleep(4)
self.raise_scripted()
time.sleep(2)
phase2["gap_clear_reraise_at"] = self.utc()
phase2["pause"] = resume()
with self.r.stopped(source):
phase2["new_source_primary"] = self.r.wait_primary("source", exclude=source)
reopened = wait_for(lambda: self.stream_opened(consumer, since, partner), 240)
barrier = wait_for(lambda: self.barriers(consumer, since), 120)
@@ -586,6 +617,9 @@ class ConditionScenarios:
self.check("p2_no_duplicate_eventids", self.unique_event_ids(imported.blocks(name)[mark_named:])
and self.unique_event_ids(imported.blocks(native)[mark_native:]))
self.check("p2_watcher_alive_throughout", imported.process.poll() is None)
dupes = self.duplicate_transitions(imported, (name, native))
self.report["duplicate_transitions"] = dupes
self.check("no_duplicate_transitions_whole_scenario", not dupes)
phase2["source_restarted"] = source
def scenario_A06(self):
@@ -665,6 +699,9 @@ class ConditionScenarios:
self.report["converged_clear_counts"] = counts
self.check("converged_clear_exactly_once_both_nodes", all(v == 1 for v in counts.values()))
self.check("converged_no_duplicate_eventids", all(self.unique_event_ids(w.blocks(name)) for w in converge.values()))
dupes = {k: self.duplicate_transitions(w, (name, native)) for k, w in {**watches, **converge}.items()}
self.report["duplicate_transitions"] = dupes
self.check("no_duplicate_transitions_any_client", not any(dupes.values()))
def scenario_A07(self):
"""Consumer node restart (the non-Primary member, so no Primary change): a client that subscribes + ConditionRefreshes
@@ -721,6 +758,9 @@ class ConditionScenarios:
self.report["clear_counts"] = counts
self.check("positive_control_clear_exactly_once", all(v == 1 for v in counts.values()))
self.check("no_duplicate_eventids", self.unique_event_ids(early.blocks(name)) and self.unique_event_ids(late.blocks(name)))
dupes = {k: self.duplicate_transitions(w, (name, native)) for k, w in (("early", early), ("late", late))}
self.report["duplicate_transitions"] = dupes
self.check("no_duplicate_transitions", not any(dupes.values()))
# ---- helpers ----------------------------------------------------------------------------------------------------
@staticmethod