test(grpc-data): H3 gate — Float32 legs in H01/H03, H06 origin refusal over the wire
Seed profile historizes a Float32 (registers 30..31) driven through two values; H01/H03 compare its projected rows/types with the origin (Good Singles). H06(a) also reads the denied and the unhistorized node through the consumer's deployed connection (node probe) so the origin's per-item refusal itself is compared, not only the metadata that drops the access bit.
This commit is contained in:
@@ -60,8 +60,11 @@ class HistoryGate:
|
||||
|
||||
def accumulate(self, seconds=40):
|
||||
started = datetime.now(timezone.utc)
|
||||
for _ in range(seconds):
|
||||
self.runner.device("set", address=30, value=16480) # flt = 3.5f (0x40600000, big-endian words)
|
||||
for second in range(seconds):
|
||||
self.runner.device("advance", steps=1)
|
||||
if second == seconds // 2:
|
||||
self.runner.device("set", address=30, value=16616) # flt = 7.25f (0x40E80000)
|
||||
time.sleep(1)
|
||||
finished = datetime.now(timezone.utc)
|
||||
time.sleep(4)
|
||||
@@ -87,11 +90,11 @@ class HistoryGate:
|
||||
node_id = match[4]
|
||||
index = int(re.match(r"ns=(\d+);", node_id)[1]) if node_id.startswith("ns=") else -1
|
||||
realm = "raw" if index == ns["mapped_raw"] else "uns" if index == ns["mapped_uns"] else None
|
||||
if realm and "remote-source" in stack[:-1] and match[3] in {"counter", "scalar", "text"}:
|
||||
if realm and "remote-source" in stack[:-1] and match[3] in {"counter", "scalar", "text", "flt"}:
|
||||
self.runner.check((realm, match[3]) not in found, "one projected leaf per realm and name")
|
||||
found[(realm, match[3])] = node_id
|
||||
for realm in ("raw", "uns"):
|
||||
for name in ("counter", "scalar", "text"):
|
||||
for name in ("counter", "scalar", "text", "flt"):
|
||||
self.runner.check((realm, name) in found, f"projected {realm}/{name} found by browse from the mapping anchor")
|
||||
self.runner.check(found[(realm, name)].split(";s=", 1)[1].startswith("p1."), "projected ids are opaque p1. ids")
|
||||
self.projected = found
|
||||
@@ -196,6 +199,14 @@ class HistoryGate:
|
||||
whole = self.cli(consumer, ["-n", self.projected[(realm, "counter")], *self.window_args(), "--max", "1000"], f"whole-{realm}")
|
||||
self.runner.check(history_smoke._cli_rows(whole.stdout) == origin_rows, f"{realm}: single read equals the origin")
|
||||
report[realm] = {"pages": len(pages), "rows": len(rows), "first": str(rows[0]), "last": str(rows[-1]), "page_lines": pages}
|
||||
# H3 review: a Float32 node whose backend stores Double reads the same Good rows through the projection.
|
||||
source, origin = self.origin_node("raw", "flt")
|
||||
reference = self.cli(source, ["-n", origin, *self.window_args(), "--max", "1000"], "origin-flt")
|
||||
floats = self.cli(consumer, ["-n", self.projected[("raw", "flt")], *self.window_args(), "--max", "1000"], "flt")
|
||||
origin_rows, rows = history_smoke._cli_rows(reference.stdout), history_smoke._cli_rows(floats.stdout)
|
||||
self.runner.check(reference.returncode == 0 and floats.returncode == 0 and len(rows) >= 1, "Float32 history served on both")
|
||||
self.runner.check(rows == origin_rows and all(q == "Good" for _, _, q in rows), "Float32 rows Good and equal to the origin")
|
||||
report["float32"] = {"rows": [str(r) for r in rows]}
|
||||
report["tie_cluster"] = ("not representable on the " + self.backend + " backend: SqlServer hist.Sample PK (TagId, SourceTimeUtc), "
|
||||
"QuestDB DEDUP UPSERT KEYS(ts, tag) — one stored sample per timestamp; tie paging is proven by the H1 port fuzz")
|
||||
return report
|
||||
@@ -233,7 +244,17 @@ class HistoryGate:
|
||||
origin_types = [line for line in reference.stdout.splitlines() if line.startswith("Type:")]
|
||||
self.runner.check(len(rows) == 3 and rows == origin_rows, "projected AtTime equals the origin row-for-row")
|
||||
self.runner.check(types == origin_types and all(t == "Type: UInt16" for t in types), "integer values stay UInt16 end to end")
|
||||
return {"rows": [str(r) for r in rows], "types": types}
|
||||
source, origin = self.origin_node("raw", "flt")
|
||||
float_times = ",".join(_iso(start + timedelta(seconds=sec)) for sec in (2, 20))
|
||||
reference_f = self.cli(source, ["-n", origin, "--at-time", float_times], "origin-attime-flt")
|
||||
projected_f = self.cli(consumer, ["-n", self.projected[("raw", "flt")], "--at-time", float_times], "attime-flt")
|
||||
rows_f, origin_rows_f = history_smoke._cli_rows(projected_f.stdout), history_smoke._cli_rows(reference_f.stdout)
|
||||
types_f = [line for line in projected_f.stdout.splitlines() if line.startswith("Type:")]
|
||||
origin_types_f = [line for line in reference_f.stdout.splitlines() if line.startswith("Type:")]
|
||||
self.runner.check(projected_f.returncode == 0 and rows_f == origin_rows_f and all(q == "Good" for _, _, q in rows_f),
|
||||
"Float32 AtTime equals the origin, Good")
|
||||
self.runner.check(types_f == origin_types_f and all(t == "Type: Single" for t in types_f), "Float32 values stay Single end to end")
|
||||
return {"rows": [str(r) for r in rows], "types": types, "float32": {"rows": [str(r) for r in rows_f], "types": types_f}}
|
||||
|
||||
def scenario_H04(self):
|
||||
"""A continuation across an origin failover is BadContinuationPointInvalid; a fresh read moves and succeeds."""
|
||||
@@ -316,6 +337,21 @@ class HistoryGate:
|
||||
normalise = lambda text: re.sub(r"ns=\d+;s=\S+", "<node>", "\n".join(l for l in (text.stdout + text.stderr).splitlines() if "Bad" in l))
|
||||
self.runner.check(denied == "BadHistoryOperationUnsupported", "origin ACL denial ⇒ BadHistoryOperationUnsupported")
|
||||
self.runner.check(normalise(unh) == normalise(den), "denied and unhistorized are indistinguishable")
|
||||
# H3 review: the per-item refusal itself, OVER THE WIRE (the consumer's deployed connection → the origin's ingress),
|
||||
# not only the metadata that drops the access bit: both answers identical 0x80720000, and the origin counted the calls.
|
||||
paths = self.runner.manifest["fixture"]["history"]
|
||||
primary = self.runner.primary("source")
|
||||
before = self.runner.probe(primary, "topology", timeout=30).get("inboundDataRequests")
|
||||
wire_denied = self.runner.probe(consumer, "history", "raw", path=paths["historized"]["raw"], historyNumValues=5,
|
||||
expected_state="Unsupported", timeout=60)
|
||||
wire_unhistorized = self.runner.probe(consumer, "history", "raw", path=paths["unhistorized"]["raw"], historyNumValues=5,
|
||||
expected_state="Unsupported", timeout=60)
|
||||
after = self.runner.probe(primary, "topology", timeout=30).get("inboundDataRequests")
|
||||
strip = lambda pages: [{k: v for k, v in page.items()} for page in pages]
|
||||
self.runner.check(strip(wire_denied["pages"]) == strip(wire_unhistorized["pages"]),
|
||||
"origin-ACL-denied and unhistorized answers are identical over the wire")
|
||||
report["wire"] = {"denied": wire_denied["pages"], "unhistorized": wire_unhistorized["pages"],
|
||||
"origin_inbound_requests": {"before": before, "after": after}}
|
||||
report["indistinguishable"] = {"unhistorized": normalise(unh), "denied": normalise(den), "attempts": attempts}
|
||||
self.restore()
|
||||
# (b) the LOCAL mapping-scope grant: without it, BadUserAccessDenied (a local decision); the other mapping keeps its grant.
|
||||
|
||||
@@ -359,12 +359,18 @@ try
|
||||
TagConfig = history
|
||||
? """{"region":"HoldingRegisters","address":40,"dataType":"String","stringLength":16,"writable":true,"isHistorized":true}"""
|
||||
: """{"region":"HoldingRegisters","address":40,"dataType":"String","stringLength":16,"writable":true}""" });
|
||||
if (history)
|
||||
// H3 review: a historized Float32 (two registers 30..31, big-endian), so the gate proves a backend that stores Double
|
||||
// still reads Good Singles through the projection.
|
||||
db.Tags.Add(new() { TagRowId = Guid.NewGuid(), TagId = "source-flt", DeviceId = "source-device", Name = "flt", DataType = "Float",
|
||||
AccessLevel = TagAccessLevel.ReadWrite, WriteIdempotent = false, PollGroupId = "source-fast",
|
||||
TagConfig = """{"region":"HoldingRegisters","address":30,"dataType":"Float32","writable":true,"isHistorized":true}""" });
|
||||
db.UnsAreas.Add(new() { UnsAreaRowId = Guid.NewGuid(), UnsAreaId = "source-area", ClusterId = "SOURCE", Name = "area" });
|
||||
db.UnsLines.Add(new() { UnsLineRowId = Guid.NewGuid(), UnsLineId = "source-line", UnsAreaId = "source-area", Name = "line" });
|
||||
var uuid = Guid.NewGuid();
|
||||
var equipment = DraftValidator.DeriveEquipmentId(uuid);
|
||||
db.Equipment.Add(new() { EquipmentRowId = Guid.NewGuid(), EquipmentId = equipment, EquipmentUuid = uuid, UnsLineId = "source-line", Name = "plc", MachineCode = "fixture-plc" });
|
||||
foreach (var name in new[] { "counter", "scalar", "array0", "array1", "array2", "vector", "text" })
|
||||
foreach (var name in new[] { "counter", "scalar", "array0", "array1", "array2", "vector", "text" }.Concat(history ? ["flt"] : []))
|
||||
db.UnsTagReferences.Add(new() { UnsTagReferenceRowId = Guid.NewGuid(), UnsTagReferenceId = "ref-" + name, EquipmentId = equipment, TagId = "source-" + name });
|
||||
db.NodeAcls.Add(new() { NodeAclRowId = Guid.NewGuid(), NodeAclId = "source-peer", ClusterId = "SOURCE", Principal = "fixture-consumer",
|
||||
ScopeKind = NodeAclScopeKind.Cluster, PermissionFlags = NodePermissions.Admin });
|
||||
|
||||
Reference in New Issue
Block a user