test(grpc-data): pinned pre-H2 SOURCE option (rig.py up --source-revision), wire tap, H05 v1-origin gate (#921); A09 driver-failure ack revert scenario (#927)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
Part 1 implemented A01, A02, A04, A05 and A08; part 2 adds A03 (origin failover + EventId re-binding), A06 (consumer
|
||||
Primary change, both consumer nodes, two principals) and A07 (consumer node restart, ConditionRefresh vs the first
|
||||
snapshot barrier). Everything else (watchers, browse-resolved ids, per-scenario restore + JSON/markdown result) is shared.
|
||||
snapshot barrier). A09 (lmxopcua#927) is the driver-failure ack revert through DriverHostActor for a remote native ack. Everything else (watchers, browse-resolved ids, per-scenario restore + JSON/markdown result) is shared.
|
||||
|
||||
Rules every scenario follows:
|
||||
- ids are RESOLVED, never constructed: projected folders by browsing the consumer's address space, imported ConditionIds
|
||||
@@ -30,8 +30,9 @@ from pathlib import Path
|
||||
import rig
|
||||
import scenarios
|
||||
|
||||
SCENARIOS = ("A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08")
|
||||
TIMEOUTS = {"A01": 420, "A02": 360, "A03": 1200, "A04": 480, "A05": 720, "A06": 1200, "A07": 900, "A08": 720}
|
||||
SCENARIOS = ("A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09")
|
||||
TIMEOUTS = {"A01": 420, "A02": 360, "A03": 1200, "A04": 480, "A05": 720, "A06": 1200, "A07": 900, "A08": 720, "A09": 600}
|
||||
REVERT_LOG = "did not reach the alarm system"
|
||||
REFRESH_REQUIRED = "RefreshRequiredEventType"
|
||||
_LOG_TIME = re.compile(r"(\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?)")
|
||||
NO_ACK = int(0b111111111111) & ~(1 << 8) # NodePermissions.Admin (4095) without AlarmAcknowledge (1 << 8)
|
||||
@@ -510,6 +511,88 @@ class ConditionScenarios:
|
||||
return {"code": code, "output": text[-300:], "good": code == 0 and ("successful" in text or "Comment added" in text),
|
||||
"event_id_unknown": "BadEventIdUnknown" in text}
|
||||
|
||||
# ---- lmxopcua#927 -------------------------------------------------------------------------------------------------
|
||||
def scenario_A09(self):
|
||||
"""A remote (A2b CallConditionMethod) ack of the NATIVE EastTankYellow, under the connection's service principal, that
|
||||
the OpcUaClient driver genuinely fails: the run-owned opc-plc is `docker pause`d just before the ack, so the driver's
|
||||
upstream Acknowledge call gets no reply and times out (no test seam). Asserts: the caller gets Good (plan §5.6 step 5:
|
||||
native ⇒ Good, `AcceptedUnconfirmed`; the failure reaches it as the revert); the origin applies the ack then REVERTS it
|
||||
(DriverHostActor `RevertNativeAlarmAck` ⇒ `EstablishesState: false`, logged "did not reach the alarm system … reverting");
|
||||
the consumer sees the reverted delta; the origin audit records the call on behalf of the end user. The upstream is frozen,
|
||||
so no driver transition can explain the Unacknowledged that follows the ack (control: no upstream event while paused).
|
||||
After unpausing, a second ack of the then-current EventId is not reverted (positive control for the failure)."""
|
||||
source, consumer = self.r.primary("source"), self.r.primary("consumer")
|
||||
name = self.fixture["conditions"]["native"]["condition"]
|
||||
since = self.utc(-2)
|
||||
origin = self.watch(source, "origin")
|
||||
imported = self.watch(consumer, "consumer")
|
||||
unacked = lambda b: b.get("State", "").endswith("Unacknowledged")
|
||||
event = wait_for(lambda: self.latest(imported, name, unacked), 300)
|
||||
origin_event = wait_for(lambda: self.latest(origin, name, unacked), 30)
|
||||
if not self.check("consumer_has_unacknowledged_native_condition", event) or not self.check("origin_has_it_too", origin_event):
|
||||
return
|
||||
condition = event["ConditionNodeId"]
|
||||
self.report["condition_id"] = condition
|
||||
self.report["before"] = {"consumer": event, "origin": origin_event}
|
||||
paused = False
|
||||
try:
|
||||
self.r.rig.compose("pause", "opcplc", timeout=60)
|
||||
paused = True
|
||||
self.report["paused_utc"] = self.utc()
|
||||
origin_mark, consumer_mark = len(origin.blocks(name)), len(imported.blocks(name))
|
||||
result = self.ack(consumer, condition, event["EventId"], "ack-driver-fails")
|
||||
self.report["ack"] = result
|
||||
self.check("caller_gets_good_accepted_unconfirmed", result["good"])
|
||||
|
||||
def reverted(watcher, mark):
|
||||
tail = states(watcher.blocks(name)[mark:])
|
||||
acked = next((i for i, state in enumerate(tail) if state and state.endswith(", Acknowledged")), None)
|
||||
return tail if acked is not None and any(state and state.endswith("Unacknowledged") for state in tail[acked + 1:]) else None
|
||||
|
||||
origin_tail = wait_for(lambda: reverted(origin, origin_mark), 60)
|
||||
consumer_tail = wait_for(lambda: reverted(imported, consumer_mark), 30)
|
||||
self.report["origin_after_ack"] = states(origin.blocks(name)[origin_mark:])
|
||||
self.report["consumer_after_ack"] = states(imported.blocks(name)[consumer_mark:])
|
||||
self.check("origin_applied_then_reverted", origin_tail)
|
||||
self.check("consumer_saw_the_reverted_delta", consumer_tail)
|
||||
latest = self.latest(imported, name)
|
||||
self.check("consumer_reverted_event_is_a_new_event_id", latest and latest.get("EventId") != event["EventId"])
|
||||
self.check("consumer_reverted_condition_id_unchanged", latest and latest.get("ConditionNodeId") == condition)
|
||||
reverts = self.log_lines(source, since, REVERT_LOG)
|
||||
failures = self.log_lines(source, since, "native-alarm acknowledge of")
|
||||
self.report["origin_revert_log"] = reverts[-5:]
|
||||
self.report["origin_driver_failure_log"] = failures[-5:]
|
||||
self.check("origin_logged_the_driver_failure_and_revert",
|
||||
any("reverting the condition to unacknowledged" in line for line in reverts))
|
||||
self.check("driver_instance_logged_the_failed_upstream_ack", any("failed" in line or "refused" in line for line in failures))
|
||||
audit = self.audit(source, since)
|
||||
self.report["origin_audit"] = audit[-10:]
|
||||
self.check("origin_audited_the_remote_ack",
|
||||
any(re.search(r"condition method \W?Acknowledge\b", line) and "AcceptedUnconfirmed" in line and "fixture-cli" in line
|
||||
for line in audit))
|
||||
# Control: the upstream is frozen, so the Unacknowledged after the ack cannot be an upstream transition. Every
|
||||
# origin event after the ack is either the ack itself or the revert (plus comms-loss quality, which has no state).
|
||||
self.report["origin_tail_states"] = sorted(set(filter(None, self.report["origin_after_ack"])))
|
||||
finally:
|
||||
if paused:
|
||||
self.r.rig.compose("unpause", "opcplc", timeout=60)
|
||||
self.report["unpaused_utc"] = self.utc()
|
||||
# Positive control: once opc-plc answers again, an ack of the current EventId is not reverted. (The paused call may
|
||||
# still be applied upstream when the container resumes; then the condition is already acknowledged, also recorded.)
|
||||
time.sleep(30)
|
||||
current = self.latest(imported, name)
|
||||
self.report["after_unpause"] = current
|
||||
if current and current.get("State", "").endswith("Unacknowledged"):
|
||||
mark = len(self.log_lines(source, since, REVERT_LOG))
|
||||
result = self.ack(consumer, condition, current["EventId"], "ack-after-unpause")
|
||||
self.report["control_ack"] = result
|
||||
self.check("control_ack_good", result["good"])
|
||||
time.sleep(15)
|
||||
self.check("control_ack_not_reverted", len(self.log_lines(source, since, REVERT_LOG)) == mark)
|
||||
else:
|
||||
self.report["control_note"] = "the upstream applied the paused acknowledge after unpause (condition already acknowledged)"
|
||||
self.check("control_upstream_acknowledged_after_unpause", current and current.get("State", "").endswith(", Acknowledged"))
|
||||
|
||||
# ---- part 2 scenarios -------------------------------------------------------------------------------------------
|
||||
def scenario_A03(self):
|
||||
"""Origin failover mid-stream with standing active alarms. Phase 1: a consumer stream reset against the SAME origin
|
||||
@@ -800,6 +883,9 @@ class ConditionScenarios:
|
||||
finally:
|
||||
self.stop_watchers()
|
||||
try:
|
||||
# A09 unpauses in its own finally; this covers a failure between its pause and that block.
|
||||
if scenario == "A09" and "paused" in self.r.rig.compose("ps", "--all", "--format", "{{.State}}", "opcplc", timeout=30):
|
||||
self.r.rig.compose("unpause", "opcplc", timeout=60)
|
||||
self.r.device("set", address=20, value=0)
|
||||
if scenario in ("A03", "A08"):
|
||||
self.r.deadline = time.monotonic() + 600
|
||||
|
||||
Reference in New Issue
Block a user