Merge #923: gRPC data H4 Gateway-backend remote history live leg vs the real AVEVA Historian (read-only gateway), H01–H08 pass; rig --history-backend gateway; drop the #922 H01 re-browse workaround now that #922 is fixed
v2-ci / unit-tests (push) Has been cancelled
v2-ci / unit-tests (push) Has been cancelled
This commit is contained in:
+1
-1
@@ -277,7 +277,7 @@ ids are stable across deploys, but a deploy retires a projected node the client
|
||||
(and after the node has been idle past its metadata lease, #922), or the read answers `BadNodeIdUnknown` / `BadUserAccessDenied`.
|
||||
History is served by the ORIGIN's historian, verbatim (values, statuses, timestamps, its paging); `--aggregate` is limited to what
|
||||
the origin's backend serves (otherwise `BadAggregateNotSupported`), and `--modified` / `--events` are refused
|
||||
`BadHistoryOperationUnsupported`. Verified with SqlServer and QuestDB origins; a Gateway (AVEVA) origin is unverified (#923).
|
||||
`BadHistoryOperationUnsupported`. Verified with SqlServer, QuestDB and Gateway (AVEVA) origins (#923).
|
||||
The consumer's **Data connections** page shows the projected history counts and open continuations a read leaves behind
|
||||
(`DataConnections.md` §"Remote history diagnostics and metrics").
|
||||
|
||||
|
||||
@@ -236,10 +236,10 @@ G0, the v1 deploy and soak (#915), is still open; see the plan's §1.1.
|
||||
|
||||
## Remote history (runtime consumers)
|
||||
|
||||
**Status: supported** (H4). Verified end to end (live gate H01–H06) with the origin on the **SqlServer** and **QuestDB**
|
||||
historian backends. The **Gateway** backend (AVEVA Historian via HistorianGateway) is **unverified** pending its live leg,
|
||||
#923 (blocked on the VPN to the historian) — the code path is the same origin history port, but no live read against it
|
||||
has been run.
|
||||
**Status: supported** (H4). Verified end to end (live gate H01–H06) with the origin on the **SqlServer**, **QuestDB** and
|
||||
**Gateway** historian backends — the Gateway leg (#923, 2026-11-28) read the real AVEVA Historian through a read-only
|
||||
HistorianGateway and also covered reverse and end-only raw reads (H07) and a strict gateway row ceiling (H08:
|
||||
ceiling-sized pages with continuations, equal to the unconstrained answers); `docs/plans/evidence/grpc-data-ext/H4.md`.
|
||||
|
||||
Since H2 a consumer can read the origin's history (HistoryRead Raw, Processed, AtTime) over a data connection. The origin
|
||||
serves it from its own historian backend (`ServerHistorian:Backend`) through the same pipeline its OPC UA clients use, so
|
||||
|
||||
+6
-4
@@ -2647,10 +2647,12 @@ from a peer.
|
||||
connections page — `docs/DataConnections.md` §"Remote history diagnostics and metrics".
|
||||
|
||||
**Verified backends.** Remote history is verified end to end (live gate H01–H06, `scripts/validation/grpc-data/history_gate.py`)
|
||||
with the origin on **`SqlServer`** and **`QuestDb`**. The **`Gateway`** backend (AVEVA Historian via HistorianGateway) is
|
||||
**unverified** remotely, pending its live leg (#923, blocked on the VPN to the historian). Nothing in the remote path is
|
||||
backend-specific, but the Gateway's own differences (the four-plus-raw-evaluated aggregate set, the strict row ceiling, the
|
||||
reverse-read walk-back) have not been observed through a data connection.
|
||||
with the origin on **`SqlServer`**, **`QuestDb`** and **`Gateway`** (AVEVA Historian via HistorianGateway, #923, 2026-11-28).
|
||||
The Gateway leg also observed the Gateway's own differences through a data connection: the raw-evaluated Average, the
|
||||
reverse/end-only walk-back (#686, `H07`) and a strict row ceiling (`MaxValuesCeiling=40`, `AllowStreamingBeyondCeiling=false`,
|
||||
`H08` — ceiling-sized pages with continuations, the raw-evaluated Average over more rows than the ceiling refused
|
||||
`BadTooManyOperations` identically on origin and consumer). Recipe: `scripts/validation/grpc-data/README.md`; evidence
|
||||
`docs/plans/evidence/grpc-data-ext/H4.md`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -88,13 +88,63 @@ Fresh run `h4a-sqlserver` (OrbStack, macOS, normal build-hash checks, 2026-11-24
|
||||
after the gate it read `Ready` with features `History`.
|
||||
- `down` ⇒ 0 run containers, 0 run volumes.
|
||||
|
||||
## Gateway leg — BLOCKED (#923), substituted by doc scoping
|
||||
## Gateway leg (#923) — PASSED 2026-11-28
|
||||
|
||||
The plan's required Gateway leg (origin `ServerHistorian:Backend=Gateway` against a local read-only HistorianGateway reading the
|
||||
real AVEVA Historian over VPN; H01–H04 with reverse/end-only and ceiling-bounded cases) was **not attempted**: the VPN to the
|
||||
historian is down. Per the plan's fallback, **#923** (`type:deploy-gate`, `blocked`) tracks it, and the docs say remote history is
|
||||
verified on the **SqlServer and QuestDB** origin backends only, with the **Gateway backend unverified pending #923**
|
||||
(`DataConnections.md`, `Historian.md`, `Client.CLI.md`).
|
||||
First run 2026-11-24 was blocked (VPN down; the docs were scoped to SqlServer/QuestDB pending #923). Run 2026-11-28 with the VPN
|
||||
up (`wonder-sql-vd03` :32565 and :1433 reachable).
|
||||
|
||||
**Posture — read-only end to end.**
|
||||
- **Gateway:** a separate, local HistorianGateway instance (`historiangw` `main` at `6a74f1e`, freshly published), compose project
|
||||
`zb-historiangw-923`, ports bound to the host **loopback only** (`127.0.0.1:5231` gRPC h2c, `:5230` health), its own fresh volume.
|
||||
`ApiKeys:Mode=Disabled` (the issue's posture — no key minted, no key store touched), `Historian:LiveWritesEnabled=false`,
|
||||
`RuntimeDb:Enabled=false` / `EventReadsEnabled=false` (no SQL write or event path), Redundancy/StoreForward off. Historian
|
||||
credentials from the existing gitignored `histgw.secrets.env`; the long-running `zb-historiangw` container was left untouched, and
|
||||
nothing in the HistorianGateway repo changed (published into a scratch build context).
|
||||
- **Origin (SOURCE pair):** `ServerHistorian:Backend=Gateway` → `http://host.docker.internal:5231` (`UseTls=false`),
|
||||
`ProvisionTags=Off`, `ContinuousHistorization:Enabled=false`, a placeholder key (the client refuses an empty one; a Disabled
|
||||
gateway never checks it). The fixture's historized tags are bound **`historianReadOnly`** (#899) to existing AVEVA system tags:
|
||||
`counter` (UInt16) → `SysTimeSec` (UInt2, 1 Hz), `flt` (Float32) → `SysDataAcqOverallItemsPerSec` (Float, 10 s), `text` (String)
|
||||
→ `SysString`.
|
||||
- **Evidence it stayed read-only:** the strict-ceiling gateway's log (it logs each RPC) shows only `HistorianRead/ReadRaw` (180) and
|
||||
`HistorianStatus/Probe` (16) — no `WriteLiveValues`, `EnsureTags`, `SendEvent(s)` or `AddHistoricalValues`; the SOURCE logs carry
|
||||
no provisioning or recorder line. (The first gateway container's log was dropped when it was recreated for the ceiling leg.)
|
||||
|
||||
**Rig support** (commits `a6ae08146`, `6ab7050c3`, `7d9818cf1`): `rig.py up --history --history-backend gateway` layers the new
|
||||
`compose.history.gateway.yml`; the endpoint allowlist admits `http://host.docker.internal:<port>` **only** under
|
||||
`ServerHistorian__Endpoint` on a gateway run (`HostGatewayEndpointTests`, with a positive control); `up` fails before any build when
|
||||
nothing listens on the loopback port; the seeder takes `GRPC_DATA_HISTORY_GATEWAY_TAGS` (`name=historianTag,…`). `history_gate.py`
|
||||
on the gateway uses a fixed past window (120 s ending 15 s ago — nothing is accumulated), adds **H07** (reverse + end-only,
|
||||
gateway-only) and **H08** (strict ceiling, run alone with `--gateway-ceiling C`), and stores the unconstrained answers in
|
||||
`H-gateway-baseline.json` for H08 to compare with.
|
||||
|
||||
**Run `h923b-gateway`** (OrbStack, normal build-hash checks, window `16:38:04Z–16:40:04Z`):
|
||||
|
||||
| ID | Result |
|
||||
|---|---|
|
||||
| H01 Raw paging, Raw + UNS | PASS (75): page size 3 ⇒ 40 pages, **120 rows per realm** (SysTimeSec 4…3), last page no CP, row-for-row = origin; single read = origin; Float32 12 Good Singles (42.527664, 64.76546, …) = origin |
|
||||
| H02 Processed | PASS (34): Average on String `text` ⇒ `BadAggregateNotSupported` both sides (refused unsent, #897); Average 10 s on `counter` 12 intervals = origin (raw-evaluated on the Gateway, #681) |
|
||||
| H03 AtTime | PASS (35): `counter` 7/11/15 `UInt16` = origin; Float32 at +2 s / +20 s 42.527664 / 59.027344 (interpolated) Good `Single` = origin |
|
||||
| H04 failover | PASS (71): page 1 held, `source-1` stopped ⇒ `source-2` primary, resumed page `BadContinuationPointInvalid`, fresh read Good |
|
||||
| H05 not advertised | PASS (58) |
|
||||
| H06 | PASS (238): unhistorized vs origin-denied identical `0x80720000`; local deny `BadUserAccessDenied`; origin continuations 1 held ⇒ 0 after session close; rebuild mid-page ⇒ invalid, fresh Good |
|
||||
| H07 reverse / end-only | PASS (43): reverse (`start = W1 > end = W0`) paged by 7 (18 pages) and whole: 120 rows **(W0, W1]** newest first (16:40:04 … 16:38:05) = origin = an independent forward read reversed; end-only (`StartTime` unspecified, `EndTime = W1`, page 5, max 20): 4 Good pages, the latest 20 rows at/before W1 (16:40:04 … 16:39:45) = origin = the forward reference |
|
||||
| H08 strict ceiling | PASS (41), gateway recreated with `MaxValuesCeiling=40`, `AllowStreamingBeyondCeiling=false` (⇒ page limit L = 24): one read capped at 1000 returns all 120 baseline rows on the origin and through the projection; 100-row pages come back **23, 22, 22, …** (6 pages, = L − 1 then L − k − 1, #694) and equal the baseline; reverse 100-row pages likewise ceiling-sized and = baseline; end-only = baseline; AtTime = baseline; raw-evaluated Average over the 120-row window ⇒ `BadTooManyOperations` on **both** origin and projection (the documented #691.3 rule: a ceiling-bounded stream not provably complete is refused, never truncated) |
|
||||
|
||||
Teardown: `rig.py down`, `docker compose down -v` for the gateway; 0 run containers / volumes left; lock released.
|
||||
|
||||
**Gate corrections found by the run (harness, not product):**
|
||||
- The first H07 draft compared a reverse read with the forward `[W0, W1)` rows reversed. Part 11: a reverse read's StartTime (the
|
||||
later bound) is inclusive and EndTime exclusive, so the answer is `(W0, W1]` — the projection and the origin agreed; the reference
|
||||
was wrong. Now built from an independent forward read past W1.
|
||||
- H01's UNS leg was refused `BadUserAccessDenied` on one run: the UNS node sat idle past its 15 s metadata lease during the longer
|
||||
(40-page) raw leg — **#922** exactly. The gate now renews before the UNS leg (deploy + re-browse, the documented workaround).
|
||||
|
||||
**Seen once, not reproduced (control plane, backend-independent — reported, not fixed here):** in one full run H06's rebuild deploy
|
||||
got HTTP 500 from CONTROL's `/api/deployments` — `AskTimeoutException` after 10 s in `AdminOperationsClient.StartDeploymentAsync`.
|
||||
The deployment WAS composed (row `CreatedAtUtc` 16:35:49.954, request at 16:35:39.48, applied and sealed right after), i.e. the
|
||||
compose itself (Serializable transaction + snapshot + `DraftValidator`) took ~10.5 s where the other ~30 deploys of the run took
|
||||
60–630 ms. No SQL autogrow in the default trace and nothing in `system_health`; the cause is not established. The caller sees a
|
||||
500 for a deployment that then goes ahead. Proposed follow-up below (coordinator to file).
|
||||
|
||||
## Review (Fable, approve-with-changes) — fixes
|
||||
|
||||
@@ -135,7 +185,9 @@ manager; a new DI-built provisional origin state), so the SqlServer leg was re-r
|
||||
|
||||
## Not verified / notes
|
||||
|
||||
- **Gateway backend** remotely (#923, above).
|
||||
- **Gateway backend** remotely: verified 2026-11-28 (#923, above). Not covered there: tie clusters (the bound AVEVA tags store one
|
||||
value per timestamp and the leg cannot write one), Gateway events history (never served remotely), the native TimeAverage/Total
|
||||
modes through a projection (H02 reads Average only).
|
||||
- **QuestDB** was not re-run for H4: the H4 change is backend-independent (counting around the same port), and the H3 rounds
|
||||
passed H01–H06 on QuestDB at `713cbfb21`. The brief asked for one SqlServer leg.
|
||||
- **Browser-rendered** page not driven (no Chrome session used); verified from the server-prerendered HTML, which runs the same
|
||||
|
||||
@@ -174,6 +174,31 @@ reaches the origin. Controls: the origin's own `counter` is historizing and its
|
||||
are in the same tap window; the probe's `--scenario history-v1-origin` sends new-shape calls (capabilities with the header are
|
||||
byte-identical to without; HistoryRead ⇒ `PERMISSION_DENIED`: a pre-H2 data listener admits only its six v1 methods) and the tap records them.
|
||||
|
||||
### Gateway origin backend (#923, needs the VPN to the AVEVA historian)
|
||||
|
||||
`--history-backend gateway` points SOURCE at a **host-run, read-only** HistorianGateway (not run-owned; start it first) through
|
||||
`http://host.docker.internal:<port>` — the only non-run-owned endpoint the allowlist admits, and only under
|
||||
`ServerHistorian__Endpoint`. The gateway must run with `ApiKeys:Mode=Disabled`, `Historian:LiveWritesEnabled=false`,
|
||||
`RuntimeDb:Enabled=false`, ports bound to `127.0.0.1` (the 2026-11-28 run used a scratch compose project `zb-historiangw-923` from a
|
||||
fresh `dotnet publish` of `historiangw` main, gRPC on `127.0.0.1:5231`). The seeder binds the historized tags `historianReadOnly`
|
||||
to existing historian tags (`GRPC_DATA_HISTORY_GATEWAY_TAGS`, default `counter=SysTimeSec,flt=SysDataAcqOverallItemsPerSec,text=SysString`);
|
||||
provisioning and continuous historization are off. `GRPC_DATA_HISTORY_GATEWAY_ENDPOINT` overrides the default
|
||||
`http://host.docker.internal:5231`.
|
||||
|
||||
```bash
|
||||
python3 scripts/validation/grpc-data/rig.py up --run-id h923-gw --history --history-backend gateway --timeout 900
|
||||
python3 scripts/validation/grpc-data/rig.py seed --run-id h923-gw
|
||||
sleep 75
|
||||
python3 scripts/validation/grpc-data/rig.py deploy --run-id h923-gw --timeout 300
|
||||
python3 scripts/validation/grpc-data/history_gate.py --run-id h923-gw # H01..H07 (H07 = reverse + end-only, gateway only)
|
||||
# restart the gateway with Historian__ReadLimits__MaxValuesCeiling=40 and __AllowStreamingBeyondCeiling=false, then:
|
||||
python3 scripts/validation/grpc-data/history_gate.py --run-id h923-gw --scenario H08 --gateway-ceiling 40
|
||||
python3 scripts/validation/grpc-data/rig.py down --run-id h923-gw
|
||||
```
|
||||
|
||||
On the gateway the window is a fixed 120 s of the recent past (nothing is accumulated). H08 re-reads the window and answers the
|
||||
previous full run stored in `evidence/H-gateway-baseline.json`, so run it after a full run on the same run id.
|
||||
|
||||
## Scenario authoring and node probes
|
||||
|
||||
The seeder is available through `LocalRig.seed_helper(action, *arguments)`. Its
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# #923 Gateway origin backend (opt-in: `rig.py up --history --history-backend gateway`), layered AFTER compose.history.yml:
|
||||
# the SOURCE pair reads history from a HOST-RUN, READ-ONLY HistorianGateway (`ServerHistorian:Backend=Gateway`) that reads
|
||||
# the real AVEVA Historian. The gateway is NOT run-owned: start it yourself before `up` (README §"Gateway origin backend")
|
||||
# with `ApiKeys:Mode=Disabled` and `Historian:LiveWritesEnabled=false`, its ports bound to the host loopback.
|
||||
#
|
||||
# Read-only on this side too: the historized fixture tags are bound `historianReadOnly` to existing historian tags
|
||||
# (GRPC_DATA_HISTORY_GATEWAY_TAGS, applied by the seeder), provisioning is Off and continuous historization is off, so
|
||||
# nothing here asks the gateway to create a tag or write a value. The API key below is a placeholder (the gateway ignores
|
||||
# keys in Disabled mode); never put a real key in this file.
|
||||
|
||||
x-source-gateway-env: &source-gateway-env
|
||||
ServerHistorian__Backend: Gateway
|
||||
ServerHistorian__Endpoint: ${GRPC_DATA_HISTORY_GATEWAY_ENDPOINT:?gateway endpoint required}
|
||||
# The gateway client refuses an empty key; a Disabled-mode gateway never verifies it. A placeholder, NOT a credential.
|
||||
ServerHistorian__ApiKey: histgw_disabledmode_placeholder
|
||||
ServerHistorian__UseTls: "false"
|
||||
ServerHistorian__AllowUntrustedServerCertificate: "true"
|
||||
ServerHistorian__ProvisionTags: "Off"
|
||||
ServerHistorian__SqlServer__ConnectionString: ""
|
||||
ContinuousHistorization__Enabled: "false"
|
||||
|
||||
services:
|
||||
seeder:
|
||||
environment:
|
||||
GRPC_DATA_HISTORY_GATEWAY_TAGS: ${GRPC_DATA_HISTORY_GATEWAY_TAGS:?gateway tag bindings required}
|
||||
source-1:
|
||||
environment: *source-gateway-env
|
||||
source-2:
|
||||
environment: *source-gateway-env
|
||||
@@ -1,4 +1,9 @@
|
||||
"""H3 live gate: scenarios H01–H06 (plan §9 "Scenarios") on a `rig.py up --history [--history-backend questdb]` run.
|
||||
"""H3 live gate: scenarios H01–H06 (plan §9 "Scenarios") on a `rig.py up --history [--history-backend questdb|gateway]` run.
|
||||
|
||||
On the gateway backend (#923) the origin reads the REAL AVEVA Historian through a host-run read-only HistorianGateway, so the
|
||||
window is a fixed stretch of the recent past of the bound historian tags (nothing is accumulated), H07 adds the reverse and
|
||||
end-only raw reads, and H08 (run on its own, after restarting the gateway with a strict row ceiling) re-reads the H01/H03/H07
|
||||
baseline through ceiling-bounded pages.
|
||||
|
||||
Every scenario is driven through the production Client CLI `historyread` against CONSUMER's OPC UA endpoint, on
|
||||
PROJECTED NodeIds resolved by browsing from the mapping anchor (never constructed `p1.` ids), and is compared with the
|
||||
@@ -26,6 +31,10 @@ NODE_PERMISSIONS_BROWSE = 1 << 0
|
||||
EXPORT_WITHOUT_HISTORY = 31 # Browse | Metadata | Read | Write | Subscribe
|
||||
# #922: longer than the rig mappings' 15 s MetadataLeaseMilliseconds, so a projected node idles past its lease.
|
||||
LEASE_LAPSE_SECONDS = 20
|
||||
GATEWAY_WINDOW_SECONDS = 120 # SysTimeSec stores one value per second ⇒ ~120 counter rows, ~12 flt rows (10 s)
|
||||
GATEWAY_WINDOW_LAG_SECONDS = 15 # stay clear of the historian's real-time storage lag
|
||||
GATEWAY_BASELINE = "H-gateway-baseline.json"
|
||||
MIN_TIME = "0001-01-01T00:00:00Z" # DateTime.MinValue ⇒ an unspecified StartTime on the wire (an end-only read)
|
||||
|
||||
|
||||
def _iso(moment):
|
||||
@@ -33,7 +42,7 @@ def _iso(moment):
|
||||
|
||||
|
||||
class HistoryGate:
|
||||
def __init__(self, run_id, *, pinned_build=False):
|
||||
def __init__(self, run_id, *, pinned_build=False, gateway_ceiling=None):
|
||||
if pinned_build:
|
||||
recorded = scenarios.restricted_json(rig.LocalRig(run_id).path)["source_tree_hash"]
|
||||
rig.source_tree_hash = lambda: recorded
|
||||
@@ -44,6 +53,8 @@ class HistoryGate:
|
||||
self.catalog = json.loads((rig.HERE / "scenarios.json").read_text())["history_scenarios"]
|
||||
self.window = None
|
||||
self.projected = {}
|
||||
self.gateway_ceiling = gateway_ceiling
|
||||
self.baseline = {}
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------- tools
|
||||
|
||||
@@ -72,6 +83,30 @@ class HistoryGate:
|
||||
time.sleep(4)
|
||||
self.window = ((started + timedelta(seconds=5)).replace(microsecond=0), (finished - timedelta(seconds=5)).replace(microsecond=0))
|
||||
|
||||
def gateway_window(self):
|
||||
"""Gateway backend: a fixed stretch of the recent past — the historian already holds it, nothing is written."""
|
||||
now = datetime.now(timezone.utc).replace(microsecond=0)
|
||||
end = now - timedelta(seconds=GATEWAY_WINDOW_LAG_SECONDS)
|
||||
self.window = (end - timedelta(seconds=GATEWAY_WINDOW_SECONDS), end)
|
||||
|
||||
def keep(self, name, value):
|
||||
"""Gateway backend: remember an answer of the unconstrained leg, for H08's ceiling-bounded re-read."""
|
||||
if self.backend == "gateway":
|
||||
self.baseline[name] = value
|
||||
self.runner.save(GATEWAY_BASELINE, {"window": [_iso(w) for w in self.window], **self.baseline})
|
||||
|
||||
@staticmethod
|
||||
def rows_text(rows):
|
||||
return [[r[0].isoformat(), r[1], r[2]] for r in rows]
|
||||
|
||||
@staticmethod
|
||||
def page_lines(stdout):
|
||||
return [line for line in stdout.splitlines() if line.startswith("Page ")]
|
||||
|
||||
@staticmethod
|
||||
def page_sizes(lines):
|
||||
return [int(re.search(r" values=(\d+) ", line)[1]) for line in lines]
|
||||
|
||||
def resolve_projected(self):
|
||||
"""Browse CONSUMER from the shared root; keep the projected leaves under the mapping anchors (`remote-source`)."""
|
||||
consumer = self.runner.primary("consumer")
|
||||
@@ -185,6 +220,8 @@ class HistoryGate:
|
||||
report = {}
|
||||
consumer = self.runner.primary("consumer")
|
||||
for realm in ("raw", "uns"):
|
||||
# No re-browse before the UNS leg: it may sit idle past its 15 s metadata lease during the raw leg, and since #922
|
||||
# a lapsed projected node renews on demand within the HistoryRead.
|
||||
source, origin = self.origin_node(realm, "counter")
|
||||
reference = self.cli(source, ["-n", origin, *self.window_args(), "--max", "1000"], f"origin-{realm}")
|
||||
self.runner.check(reference.returncode == 0, f"origin {realm} read")
|
||||
@@ -201,6 +238,7 @@ 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}
|
||||
self.keep(f"forward_{realm}", self.rows_text(origin_rows))
|
||||
# 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")
|
||||
@@ -209,8 +247,12 @@ class HistoryGate:
|
||||
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")
|
||||
self.keep("forward_flt", self.rows_text(origin_rows))
|
||||
report["tie_cluster"] = ("not representable on the " + self.backend + " backend: " + (
|
||||
"the bound AVEVA system tags store one value per timestamp and the leg is read-only (no tie can be written)"
|
||||
if self.backend == "gateway" else
|
||||
"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
|
||||
|
||||
def scenario_H02(self):
|
||||
@@ -230,6 +272,7 @@ class HistoryGate:
|
||||
self.runner.check(reference.returncode == 0 and served.returncode == 0, "Average served on both")
|
||||
rows, origin_rows = history_smoke._cli_rows(served.stdout), history_smoke._cli_rows(reference.stdout)
|
||||
self.runner.check(len(rows) > 0 and rows == origin_rows, "projected Average equals the origin row-for-row")
|
||||
self.keep("average", self.rows_text(rows))
|
||||
return {"refused": self.error_status(refused), "origin_refused": self.error_status(origin_refused), "average_rows": len(rows)}
|
||||
|
||||
def scenario_H03(self):
|
||||
@@ -256,6 +299,7 @@ class HistoryGate:
|
||||
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")
|
||||
self.keep("attime", {"times": times, "rows": self.rows_text(rows), "types": types})
|
||||
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):
|
||||
@@ -399,14 +443,124 @@ class HistoryGate:
|
||||
report["session_close"] = {"held": counts.get("held"), "after": after, "lines": self.status_lines(abandoned.stdout)}
|
||||
return report
|
||||
|
||||
def end_only_reference(self, source, origin, count):
|
||||
"""The latest `count` stored rows at or before the window end, newest first, from a FORWARD origin read."""
|
||||
end = self.window[1]
|
||||
reference = self.cli(source, ["-n", origin, "--start", _iso(end - timedelta(seconds=count * 4)), "--end",
|
||||
_iso(end + timedelta(seconds=1)), "--max", "1000"], "origin-end-only-reference")
|
||||
self.runner.check(reference.returncode == 0, "origin forward reference read for the end-only case")
|
||||
rows = [r for r in history_smoke._cli_rows(reference.stdout) if r[0] <= end]
|
||||
return list(reversed(rows))[:count]
|
||||
|
||||
def scenario_H07(self):
|
||||
"""Gateway backend: reverse (start > end) and end-only raw reads through the projection — the server walks them back from
|
||||
forward gateway reads (#686) — equal to the origin and to the forward rows reversed."""
|
||||
consumer = self.runner.primary("consumer")
|
||||
report = {}
|
||||
source, origin = self.origin_node("raw", "counter")
|
||||
# Part 11: a reverse read's StartTime (the later bound) is inclusive and its EndTime exclusive, so its rows are the stored
|
||||
# rows in (W0, W1] — a forward read one second past W1, filtered, is the independent reference.
|
||||
forward = self.cli(source, ["-n", origin, "--start", _iso(self.window[0]), "--end", _iso(self.window[1] + timedelta(seconds=1)),
|
||||
"--max", "1000"], "origin-forward")
|
||||
forward_rows = [r for r in history_smoke._cli_rows(forward.stdout) if self.window[0] < r[0] <= self.window[1]]
|
||||
self.runner.check(forward.returncode == 0 and len(forward_rows) >= 20, "origin forward window holds history")
|
||||
reverse = ["--start", _iso(self.window[1]), "--end", _iso(self.window[0])]
|
||||
for label, extra in (("paged", ["--page-size", "7"]), ("whole", [])):
|
||||
origin_rev = self.cli(source, ["-n", origin, *reverse, *extra, "--max", "1000"], f"origin-reverse-{label}")
|
||||
projected_rev = self.cli(consumer, ["-n", self.projected[("raw", "counter")], *reverse, *extra, "--max", "1000"],
|
||||
f"reverse-{label}")
|
||||
rows, origin_rows = history_smoke._cli_rows(projected_rev.stdout), history_smoke._cli_rows(origin_rev.stdout)
|
||||
self.runner.check(origin_rev.returncode == 0 and projected_rev.returncode == 0, f"reverse {label} read served on both")
|
||||
self.runner.check(rows == origin_rows, f"reverse {label}: projected rows equal the origin row-for-row")
|
||||
self.runner.check(rows == list(reversed(forward_rows)), f"reverse {label}: the stored rows of (W0, W1], newest first")
|
||||
entry = {"rows": len(rows), "first": str(rows[0]) if rows else None, "last": str(rows[-1]) if rows else None}
|
||||
if extra:
|
||||
pages = self.page_lines(projected_rev.stdout)
|
||||
self.runner.check(len(pages) >= 2 and all("Good" in line for line in pages), "reverse paged: several Good pages")
|
||||
self.runner.check(pages[-1].split("continuation=")[1].startswith("no"), "reverse paged: the last page has no continuation")
|
||||
entry["page_lines"] = pages
|
||||
self.keep("reverse", self.rows_text(rows))
|
||||
report["reverse_" + label] = entry
|
||||
end_only = ["--start", MIN_TIME, "--end", _iso(self.window[1]), "--page-size", "5", "--max", "20"]
|
||||
origin_eo = self.cli(source, ["-n", origin, *end_only], "origin-end-only")
|
||||
projected_eo = self.cli(consumer, ["-n", self.projected[("raw", "counter")], *end_only], "end-only")
|
||||
rows, origin_rows = history_smoke._cli_rows(projected_eo.stdout), history_smoke._cli_rows(origin_eo.stdout)
|
||||
expected = self.end_only_reference(source, origin, 20)
|
||||
pages = self.page_lines(projected_eo.stdout)
|
||||
self.runner.check(origin_eo.returncode == 0 and projected_eo.returncode == 0, "end-only read served on both")
|
||||
self.runner.check(len(pages) == 4 and all("Good" in line for line in pages), "end-only: four Good pages of five")
|
||||
self.runner.check(rows == origin_rows, "end-only: projected rows equal the origin row-for-row")
|
||||
self.runner.check(len(rows) == 20 and rows == expected, "end-only: the latest 20 rows at or before EndTime, newest first")
|
||||
self.keep("end_only", self.rows_text(rows))
|
||||
report["end_only"] = {"rows": len(rows), "first": str(rows[0]) if rows else None, "last": str(rows[-1]) if rows else None,
|
||||
"page_lines": pages}
|
||||
return report
|
||||
|
||||
def scenario_H08(self):
|
||||
"""Gateway backend, strict ceiling (run alone, after restarting the gateway with `MaxValuesCeiling = C` and
|
||||
`AllowStreamingBeyondCeiling = false`): the H01/H03/H07 answers re-read through ceiling-bounded pages (#694)."""
|
||||
self.runner.check(self.backend == "gateway" and self.gateway_ceiling is not None, "H08 needs the gateway backend and --gateway-ceiling")
|
||||
consumer = self.runner.primary("consumer")
|
||||
limit = self.gateway_ceiling - 16 # RawPageLimit: L = learned ceiling − 16
|
||||
report = {"ceiling": self.gateway_ceiling, "page_limit": limit}
|
||||
rows_of = lambda result: self.rows_text(history_smoke._cli_rows(result.stdout))
|
||||
source, origin = self.origin_node("raw", "counter")
|
||||
forward = self.baseline["forward_raw"]
|
||||
self.runner.check(len(forward) > self.gateway_ceiling, "the baseline window holds more rows than the ceiling")
|
||||
# (a) one read capped above the ceiling, on the origin and through the projection: every row, in order.
|
||||
for label, node, host in (("origin", origin, source), ("projected", self.projected[("raw", "counter")], consumer)):
|
||||
whole = self.cli(host, ["-n", node, *self.window_args(), "--max", "1000"], f"ceiling-whole-{label}")
|
||||
self.runner.check(whole.returncode == 0 and rows_of(whole) == forward, f"{label}: a read above the ceiling returns the baseline rows")
|
||||
# (b) pages asked for 100 rows come back ceiling-sized (<= L - 1) with continuations, and still equal the baseline.
|
||||
paged = self.cli(consumer, ["-n", self.projected[("raw", "counter")], *self.window_args(), "--page-size", "100", "--max", "1000"],
|
||||
"ceiling-paged")
|
||||
pages = self.page_lines(paged.stdout)
|
||||
sizes = self.page_sizes(pages)
|
||||
self.runner.check(paged.returncode == 0 and all("Good" in line for line in pages), "ceiling paged: every page Good")
|
||||
self.runner.check(len(pages) >= 2 and max(sizes) <= limit - 1, "ceiling paged: pages are ceiling-sized, not 100")
|
||||
self.runner.check(rows_of(paged) == forward, "ceiling paged: rows equal the unconstrained baseline")
|
||||
report["paged"] = pages
|
||||
# (c) reverse and end-only, walked back under the ceiling.
|
||||
reverse = self.cli(consumer, ["-n", self.projected[("raw", "counter")], "--start", _iso(self.window[1]), "--end", _iso(self.window[0]),
|
||||
"--page-size", "100", "--max", "1000"], "ceiling-reverse")
|
||||
reverse_pages = self.page_lines(reverse.stdout)
|
||||
self.runner.check(reverse.returncode == 0 and rows_of(reverse) == self.baseline["reverse"], "ceiling reverse equals the baseline")
|
||||
self.runner.check(max(self.page_sizes(reverse_pages)) <= limit - 1, "ceiling reverse: pages are ceiling-sized")
|
||||
end_only = self.cli(consumer, ["-n", self.projected[("raw", "counter")], "--start", MIN_TIME, "--end", _iso(self.window[1]),
|
||||
"--page-size", "5", "--max", "20"], "ceiling-end-only")
|
||||
self.runner.check(end_only.returncode == 0 and rows_of(end_only) == self.baseline["end_only"], "ceiling end-only equals the baseline")
|
||||
report["reverse"] = reverse_pages
|
||||
# (d) AtTime under the ceiling: the baseline values.
|
||||
attime = self.baseline["attime"]
|
||||
at = self.cli(consumer, ["-n", self.projected[("raw", "counter")], "--at-time", attime["times"]], "ceiling-attime")
|
||||
self.runner.check(at.returncode == 0 and rows_of(at) == attime["rows"], "ceiling AtTime equals the baseline")
|
||||
# (e) a raw-evaluated aggregate whose window exceeds the ceiling: the projection answers exactly what the origin answers.
|
||||
aggregate = [*self.window_args(), "--aggregate", "Average", "--interval", "10000"]
|
||||
origin_avg = self.cli(source, ["-n", origin, *aggregate], "ceiling-origin-average")
|
||||
projected_avg = self.cli(consumer, ["-n", self.projected[("raw", "counter")], *aggregate], "ceiling-average")
|
||||
observed = lambda result: ("Good", rows_of(result)) if result.returncode == 0 else (self.error_status(result), None)
|
||||
self.runner.check(observed(origin_avg) == observed(projected_avg), "ceiling Average: the projection answers what the origin answers")
|
||||
report["average"] = {"origin": observed(origin_avg)[0], "projected": observed(projected_avg)[0],
|
||||
"equals_baseline": observed(projected_avg)[1] == self.baseline.get("average")}
|
||||
return report
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------- run
|
||||
|
||||
def run(self, selection):
|
||||
chosen = [row["id"] for row in self.catalog] if selection == "all" else [selection]
|
||||
applies = lambda row: self.backend in row.get("backends", [self.backend])
|
||||
chosen = ([row["id"] for row in self.catalog if applies(row) and not row.get("run_alone")] if selection == "all" else [selection])
|
||||
self.runner.publish()
|
||||
self.runner.rig.seed_helper("snapshot")
|
||||
self.runner.active, self.runner.deadline = "H00", time.monotonic() + 900
|
||||
self.accumulate()
|
||||
if self.backend != "gateway":
|
||||
self.accumulate()
|
||||
elif chosen == ["H08"]:
|
||||
# The ceiling leg re-reads the unconstrained leg's window and compares with its answers.
|
||||
recorded = json.loads((self.runner.folder / GATEWAY_BASELINE).read_text())
|
||||
self.window = tuple(datetime.fromisoformat(w.replace("Z", "+00:00")) for w in recorded.pop("window"))
|
||||
self.baseline = recorded
|
||||
else:
|
||||
self.gateway_window()
|
||||
self.resolve_projected()
|
||||
rows = []
|
||||
for name in chosen:
|
||||
@@ -438,8 +592,12 @@ def main(argv=None):
|
||||
parser.add_argument("--run-id", required=True)
|
||||
parser.add_argument("--scenario", default="all")
|
||||
parser.add_argument("--pinned-build", action="store_true")
|
||||
parser.add_argument("--gateway-ceiling", type=int, default=None,
|
||||
help="H08 only: the strict MaxValuesCeiling the host-run gateway was restarted with (> 16)")
|
||||
arguments = parser.parse_args(argv)
|
||||
gate = HistoryGate(arguments.run_id, pinned_build=arguments.pinned_build)
|
||||
if arguments.gateway_ceiling is not None and arguments.gateway_ceiling <= 16:
|
||||
parser.error("--gateway-ceiling must exceed the 16-row allowance")
|
||||
gate = HistoryGate(arguments.run_id, pinned_build=arguments.pinned_build, gateway_ceiling=arguments.gateway_ceiling)
|
||||
rows = gate.run(arguments.scenario)
|
||||
return 0 if all(row["passed"] for row in rows) else 1
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import socket
|
||||
import tempfile
|
||||
import time
|
||||
from urllib.parse import urljoin, urlsplit
|
||||
@@ -147,17 +148,40 @@ def _plain_host(value):
|
||||
return re.split(r"[,:/\\]", value, maxsplit=1)[0]
|
||||
|
||||
|
||||
def validate_fixture_endpoints(document, *, local_services):
|
||||
# #923: the one non-run-owned endpoint a `--history-backend gateway` run may name — the HOST-run read-only HistorianGateway,
|
||||
# reached from the containers through the Docker host alias, and only under this exact key.
|
||||
HOST_GATEWAY_ALIAS = "host.docker.internal"
|
||||
GATEWAY_ENDPOINT_KEY = "ServerHistorian__Endpoint"
|
||||
|
||||
|
||||
def validate_host_gateway_endpoint(value):
|
||||
"""A plaintext h2c URL `http://host.docker.internal:<port>` — no credentials, path, query or fragment."""
|
||||
try:
|
||||
parsed = urlsplit(value) if isinstance(value, str) else None
|
||||
port = parsed.port if parsed is not None else None
|
||||
except ValueError:
|
||||
parsed, port = None, None
|
||||
if (parsed is None or parsed.scheme != "http" or parsed.hostname != HOST_GATEWAY_ALIAS or port is None
|
||||
or parsed.username is not None or parsed.password is not None or parsed.path not in ("", "/")
|
||||
or parsed.query or parsed.fragment):
|
||||
raise RigError("the gateway endpoint must be http://host.docker.internal:<port>")
|
||||
return value
|
||||
|
||||
|
||||
def validate_fixture_endpoints(document, *, local_services, host_gateway_keys=()):
|
||||
"""Reject endpoint escape in resolved Compose/config/seed data, without DNS.
|
||||
|
||||
Pass resolved data, never a YAML file with uninterpreted environment expansion.
|
||||
Image registries are build inputs; endpoint URLs, SQL connection hosts, and
|
||||
host/server/address configuration values must name an explicit local service
|
||||
or loopback. No arbitrary private subnet is treated as local.
|
||||
or loopback. No arbitrary private subnet is treated as local. The only exception
|
||||
is `host_gateway_keys` (a gateway-backend run passes `ServerHistorian__Endpoint`):
|
||||
a value under exactly such a key must be the host-run gateway URL and nothing else.
|
||||
"""
|
||||
services = set(local_services)
|
||||
if not services or any(not isinstance(name, str) or not _SERVICE_PATTERN.fullmatch(name) for name in services):
|
||||
raise RigError("an explicit local service allowlist is required")
|
||||
host_gateway_keys = frozenset(host_gateway_keys)
|
||||
|
||||
def check_host(host):
|
||||
if not _host_allowed(host, services):
|
||||
@@ -174,6 +198,9 @@ def validate_fixture_endpoints(document, *, local_services):
|
||||
elif isinstance(value, str):
|
||||
if "${" in value:
|
||||
raise RigError("fixture configuration must be fully resolved")
|
||||
if key in host_gateway_keys:
|
||||
validate_host_gateway_endpoint(value)
|
||||
return
|
||||
urls = _URL_PATTERN.findall(value)
|
||||
for url in urls:
|
||||
try:
|
||||
@@ -476,7 +503,11 @@ NODES = tuple(f"{pair}-{n}" for pair in ("control", "source", "consumer") for n
|
||||
# `questdb` exists only on a `--history-backend questdb` run (compose.history.questdb.yml), `opcplc` only on a `--conditions`
|
||||
# run (compose.conditions.yml); listing them is the DNS allowlist.
|
||||
SERVICES = ("sql", "migrator", "device", "seeder", "questdb", "opcplc", *NODES)
|
||||
HISTORY_BACKENDS = ("sqlserver", "questdb")
|
||||
HISTORY_BACKENDS = ("sqlserver", "questdb", "gateway")
|
||||
# #923 gateway backend defaults: the host-run read-only gateway's loopback gRPC port, and the fixture tags bound read-only to
|
||||
# real historian system tags (1 Hz UInt2 seconds counter, a 10 s Float, a string). Overridable through the same env names.
|
||||
GATEWAY_DEFAULT_ENDPOINT = "http://host.docker.internal:5231"
|
||||
GATEWAY_DEFAULT_TAGS = "counter=SysTimeSec,flt=SysDataAcqOverallItemsPerSec,text=SysString"
|
||||
|
||||
|
||||
def run_command(argv, *, timeout=120, environment=None):
|
||||
@@ -741,6 +772,8 @@ class LocalRig:
|
||||
files.extend(["--file", str(HERE / "compose.history.yml")])
|
||||
if self.environment.get("GRPC_DATA_HISTORY_BACKEND") == "questdb":
|
||||
files.extend(["--file", str(HERE / "compose.history.questdb.yml")])
|
||||
if self.environment.get("GRPC_DATA_HISTORY_BACKEND") == "gateway":
|
||||
files.extend(["--file", str(HERE / "compose.history.gateway.yml")])
|
||||
if self.environment.get("GRPC_DATA_CONDITIONS") == "1":
|
||||
files.extend(["--file", str(HERE / "compose.conditions.yml")])
|
||||
if self.environment.get("GRPC_DATA_SOURCE_PINNED") == "1":
|
||||
@@ -948,6 +981,18 @@ class LocalRig:
|
||||
raise RigError("unknown history backend")
|
||||
settings["GRPC_DATA_HISTORY"] = "1"
|
||||
settings["GRPC_DATA_HISTORY_BACKEND"] = history_backend
|
||||
if history_backend == "gateway":
|
||||
endpoint = validate_host_gateway_endpoint(os.environ.get("GRPC_DATA_HISTORY_GATEWAY_ENDPOINT") or GATEWAY_DEFAULT_ENDPOINT)
|
||||
tags = os.environ.get("GRPC_DATA_HISTORY_GATEWAY_TAGS") or GATEWAY_DEFAULT_TAGS
|
||||
if not re.fullmatch(r"[a-z]+=[A-Za-z0-9_.]+(?:,[a-z]+=[A-Za-z0-9_.]+)*", tags):
|
||||
raise RigError("gateway tag bindings must be name=historianTag[,...]")
|
||||
# Fail before any build: the gateway is not run-owned, so `up` cannot start it.
|
||||
try:
|
||||
socket.create_connection(("127.0.0.1", urlsplit(endpoint).port), timeout=5).close()
|
||||
except OSError:
|
||||
raise RigError("the host-run HistorianGateway is not listening on the host loopback") from None
|
||||
settings["GRPC_DATA_HISTORY_GATEWAY_ENDPOINT"] = endpoint
|
||||
settings["GRPC_DATA_HISTORY_GATEWAY_TAGS"] = tags
|
||||
if conditions:
|
||||
settings["GRPC_DATA_CONDITIONS"] = "1"
|
||||
pinned = None
|
||||
@@ -974,7 +1019,8 @@ class LocalRig:
|
||||
# builds can still be collected by exact observed object IDs on `down`.
|
||||
atomic_write_secret(self.folder / "setup.json", json.dumps({"run_id": self.run_id, "docker_context": self.context["Name"], "project": self.project}))
|
||||
resolved = json.loads(self.compose("config", "--format", "json"))
|
||||
validate_fixture_endpoints(resolved, local_services=SERVICES)
|
||||
validate_fixture_endpoints(resolved, local_services=SERVICES,
|
||||
host_gateway_keys={GATEWAY_ENDPOINT_KEY} if settings.get("GRPC_DATA_HISTORY_BACKEND") == "gateway" else ())
|
||||
try:
|
||||
self.compose("build", "--pull", "migrator", "device", "control-1", "seeder", *(["source-1"] if pinned else []),
|
||||
timeout=2400 if pinned else 1800) # a pinned run builds a second Host image
|
||||
@@ -1440,7 +1486,8 @@ def main(argv=None):
|
||||
parser.add_argument("--conditions", action="store_true", help="up only: add the A2a conditions overlay (AlarmSubscribe exports + one scripted alarm)")
|
||||
parser.add_argument("--history", action="store_true", help="up only: add the H2 history overlay (SOURCE historian + history seed profile)")
|
||||
parser.add_argument("--history-backend", choices=HISTORY_BACKENDS, default=None,
|
||||
help="up --history only: the SOURCE historian backend (sqlserver = the run's SQL container, default; questdb = a run-owned QuestDB)")
|
||||
help="up --history only: the SOURCE historian backend (sqlserver = the run's SQL container, default; questdb = a run-owned QuestDB; "
|
||||
"gateway = a host-run read-only HistorianGateway, README)")
|
||||
arguments = parser.parse_args(argv)
|
||||
try:
|
||||
if arguments.action == "preflight":
|
||||
|
||||
@@ -1608,6 +1608,34 @@
|
||||
"origin open continuations >= 1 while held, 0 after the consumer session close",
|
||||
"resume after an origin rebuild BadContinuationPointInvalid, fresh Good"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "H07",
|
||||
"title": "Gateway origin: reverse and end-only raw reads through the projection (#923)",
|
||||
"driver": "history_gate.py",
|
||||
"backends": ["gateway"],
|
||||
"restores_baseline": true,
|
||||
"timeout_seconds": 600,
|
||||
"coverage": [
|
||||
"reverse (start > end) paged and whole: projected = origin = forward rows newest first",
|
||||
"end-only (unspecified StartTime) paged: the latest 20 rows at or before EndTime, newest first, = origin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "H08",
|
||||
"title": "Gateway origin behind a strict row ceiling: ceiling-bounded pages equal the unconstrained baseline (#923)",
|
||||
"driver": "history_gate.py",
|
||||
"backends": ["gateway"],
|
||||
"run_alone": true,
|
||||
"restores_baseline": true,
|
||||
"timeout_seconds": 900,
|
||||
"coverage": [
|
||||
"run alone with --gateway-ceiling C after restarting the gateway (MaxValuesCeiling=C, AllowStreamingBeyondCeiling=false)",
|
||||
"a read capped above the ceiling returns every baseline row (origin and projected)",
|
||||
"100-row pages come back ceiling-sized (<= C - 17) with continuations, rows = baseline",
|
||||
"reverse and end-only under the ceiling = baseline; AtTime = baseline",
|
||||
"raw-evaluated Average over more rows than the ceiling: projected answer = origin answer"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -29,6 +29,23 @@ const DataOperations operations = DataOperations.Browse | DataOperations.Metadat
|
||||
// exports gain HistoryRead, and a second principal's export lacks it. Unset ⇒ the v1 fixture, unchanged.
|
||||
var history = Environment.GetEnvironmentVariable("GRPC_DATA_HISTORY") == "1";
|
||||
var grantedOperations = history ? operations | DataOperations.HistoryRead : operations;
|
||||
// #923 Gateway origin backend (`rig.py up --history --history-backend gateway`): `name=historianTag,...` binds the historized
|
||||
// fixture tags READ-ONLY (lmxopcua#899 `historianReadOnly`) to existing tags of the real historian behind a read-only
|
||||
// HistorianGateway, so OtOpcUa never provisions or records into them. Unset ⇒ the tags own their history, as before.
|
||||
var gatewayTags = (Environment.GetEnvironmentVariable("GRPC_DATA_HISTORY_GATEWAY_TAGS") ?? "")
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||
.Select(pair => pair.Split('=', 2, StringSplitOptions.TrimEntries))
|
||||
.ToDictionary(pair => pair.Length == 2 && pair[0].Length > 0 && pair[1].Length > 0 ? pair[0] : throw new InvalidOperationException("GRPC_DATA_HISTORY_GATEWAY_TAGS entries are name=historianTag"),
|
||||
pair => pair[1], StringComparer.Ordinal);
|
||||
if (gatewayTags.Count > 0 && !history) throw new InvalidOperationException("GRPC_DATA_HISTORY_GATEWAY_TAGS needs the history profile");
|
||||
string HistoryConfig(string name, string tagConfig)
|
||||
{
|
||||
if (!gatewayTags.TryGetValue(name, out var historianTag)) return tagConfig;
|
||||
var node = System.Text.Json.Nodes.JsonNode.Parse(tagConfig)!.AsObject();
|
||||
node["historianTagname"] = historianTag;
|
||||
node["historianReadOnly"] = true;
|
||||
return node.ToJsonString();
|
||||
}
|
||||
// A2a smoke profile (opt-in, `rig.py up --conditions`): SOURCE exports gain AlarmSubscribe and the SOURCE equipment gets
|
||||
// one scripted alarm, ScalarHigh (scalar > 100), so a condition stream sees a snapshot and a delta. Unset ⇒ v1 fixture.
|
||||
var conditions = Environment.GetEnvironmentVariable("GRPC_DATA_CONDITIONS") == "1";
|
||||
@@ -360,7 +377,7 @@ try
|
||||
db.Tags.Add(new() { TagRowId = Guid.NewGuid(), TagId = "source-" + name, DeviceId = "source-device", Name = name, DataType = "UInt16",
|
||||
AccessLevel = writable ? TagAccessLevel.ReadWrite : TagAccessLevel.Read, WriteIdempotent = false, PollGroupId = "source-fast",
|
||||
TagConfig = history && name == "counter"
|
||||
? JsonSerializer.Serialize(new { region = "HoldingRegisters", address, dataType = "UInt16", writable, isHistorized = true })
|
||||
? HistoryConfig(name, JsonSerializer.Serialize(new { region = "HoldingRegisters", address, dataType = "UInt16", writable, isHistorized = true }))
|
||||
: JsonSerializer.Serialize(new { region = "HoldingRegisters", address, dataType = "UInt16", writable }) });
|
||||
db.Tags.Add(new() { TagRowId = Guid.NewGuid(), TagId = "source-vector", DeviceId = "source-device", Name = "vector", DataType = "UInt16",
|
||||
AccessLevel = TagAccessLevel.ReadWrite, WriteIdempotent = false, PollGroupId = "source-fast",
|
||||
@@ -368,14 +385,14 @@ try
|
||||
db.Tags.Add(new() { TagRowId = Guid.NewGuid(), TagId = "source-text", DeviceId = "source-device", Name = "text", DataType = "String",
|
||||
AccessLevel = TagAccessLevel.ReadWrite, WriteIdempotent = false, PollGroupId = "source-fast",
|
||||
TagConfig = history
|
||||
? """{"region":"HoldingRegisters","address":40,"dataType":"String","stringLength":16,"writable":true,"isHistorized":true}"""
|
||||
? HistoryConfig("text", """{"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}""" });
|
||||
TagConfig = HistoryConfig("flt", """{"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();
|
||||
|
||||
@@ -551,6 +551,35 @@ class RuntimeCompositionTests(unittest.TestCase):
|
||||
self.assertFalse(instance.health(row))
|
||||
|
||||
|
||||
class HostGatewayEndpointTests(unittest.TestCase):
|
||||
"""#923: a gateway-backend run may name the host-run HistorianGateway, under ServerHistorian__Endpoint only."""
|
||||
|
||||
def test_host_gateway_url_allowed_only_under_the_named_key(self):
|
||||
row = {"ServerHistorian__Endpoint": "http://host.docker.internal:5231"}
|
||||
rig.validate_fixture_endpoints(row, local_services={"source-1"}, host_gateway_keys={rig.GATEWAY_ENDPOINT_KEY})
|
||||
# Positive control for the exception: without the key opt-in the same row is outside the allowlist.
|
||||
with self.assertRaises(rig.RigError):
|
||||
rig.validate_fixture_endpoints(row, local_services={"source-1"})
|
||||
with self.assertRaises(rig.RigError):
|
||||
rig.validate_fixture_endpoints({"Mesh__Endpoint": "http://host.docker.internal:5231"}, local_services={"source-1"},
|
||||
host_gateway_keys={rig.GATEWAY_ENDPOINT_KEY})
|
||||
|
||||
def test_the_gateway_key_accepts_nothing_but_the_plain_host_alias_url(self):
|
||||
for value in ["https://host.docker.internal:5231", "http://host.docker.internal", "http://10.100.0.48:5221",
|
||||
"http://wonder-sql-vd03.zmr.zimmer.com:5221", "http://user:key@host.docker.internal:5231",
|
||||
"http://host.docker.internal:5231/escape", "http://host.docker.internal:5231?k=v", "http://source-1:5231", ""]:
|
||||
with self.subTest(value=value), self.assertRaises(rig.RigError):
|
||||
rig.validate_fixture_endpoints({"ServerHistorian__Endpoint": value}, local_services={"source-1"},
|
||||
host_gateway_keys={rig.GATEWAY_ENDPOINT_KEY})
|
||||
|
||||
def test_gateway_backend_overlay_layers_after_the_history_overlay(self):
|
||||
instance = rig.LocalRig.__new__(rig.LocalRig)
|
||||
instance.environment = {"GRPC_DATA_HISTORY": "1", "GRPC_DATA_HISTORY_BACKEND": "gateway"}
|
||||
files = [f for f in instance.compose_files() if f != "--file"]
|
||||
self.assertEqual([Path(f).name for f in files], ["compose.yml", "compose.history.yml", "compose.history.gateway.yml"])
|
||||
self.assertIn("gateway", rig.HISTORY_BACKENDS)
|
||||
|
||||
|
||||
class AkkaSeedEndpointTests(unittest.TestCase):
|
||||
def test_named_akka_system_in_owned_seed_context_is_not_a_password(self):
|
||||
rig.validate_fixture_endpoints({"Cluster__SeedNodes__0": "akka.tcp://otopcua@source-1:4053"}, local_services={"source-1"})
|
||||
|
||||
Reference in New Issue
Block a user