test(grpc-data-rig): #1115 scale profile (seed --scale N) and the #1026 scale gate

- device: read-only scale block (holding registers 1000..5095) + scale_set control action
- seed: GRPC_DATA_SCALE=N adds SOURCE driver modscale/dev with N UInt16 tags in TagGroups
  small (first 160) / large (rest), one RawTagGroup export + CONSUMER mapping each
  (map-scale-small|large); fixture.json records the counts
- rig.py: seed --scale N; deploy trigger gets a 60 s socket timeout (the AdminUI's
  StartDeployment ask waits up to 45 s; a 2048-tag snapshot read took ~25 s, so the
  general 15 s cap aborted the POST)
- scale_gate.py: opens a >128 and a >1024-item mapping via Client CLI recursive
  subscribes on CONSUMER, requires all Good, churns the block, restarts the SOURCE pair,
  requires all Good with a post-restart value, checks the consumer ResetHistory counter
  and the container logs for 'history expired'; PASS/FAIL + evidence/S1026-results.json

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-12-05 03:34:02 -05:00
parent 961ca2897c
commit 8ddae2f43d
7 changed files with 570 additions and 9 deletions
+30 -5
View File
@@ -504,6 +504,11 @@ NODES = tuple(f"{pair}-{n}" for pair in ("control", "source", "consumer") for n
# run (compose.conditions.yml); listing them is the DNS allowlist.
SERVICES = ("sql", "migrator", "device", "seeder", "questdb", "opcplc", *NODES)
HISTORY_BACKENDS = ("sqlserver", "questdb", "gateway")
# #1115: the device fixture's read-only scale block (device/server.py SCALE_COUNT) bounds `seed --scale N`.
SCALE_MAX_TAGS = 4096
# Longer than the AdminUI's 45 s StartDeployment ask (AdminOperationsClient.DefaultDeployAskTimeout), so the trigger
# always gets the server's own answer (Accepted, NoChanges or OutcomeUnknown).
DEPLOY_REQUEST_TIMEOUT_SECONDS = 60
# #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"
@@ -655,7 +660,7 @@ def docker_context():
return rows[0]
def http_request(method, url, *, headers, json_body=None, timeout=10):
def http_request(method, url, *, headers, json_body=None, timeout=10, max_timeout=15):
import urllib.request
import urllib.error
class NoRedirect(urllib.request.HTTPRedirectHandler):
@@ -665,7 +670,7 @@ def http_request(method, url, *, headers, json_body=None, timeout=10):
request = urllib.request.Request(url, data=data, headers={**headers, **({"Content-Type": "application/json"} if data else {})}, method=method)
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), NoRedirect())
try:
response = opener.open(request, timeout=min(timeout, 15))
response = opener.open(request, timeout=min(timeout, max_timeout))
except urllib.error.HTTPError as error:
response = error
with response:
@@ -679,6 +684,13 @@ def http_request(method, url, *, headers, json_body=None, timeout=10):
return response.status, dict(response.headers), body
def deploy_http_request(method, url, **options):
"""The deploy trigger's transport (#1115): the server's StartDeployment ask waits up to 45 s for a slow compose (a
2048-tag scale seed read its snapshot in ~25 s on emulated SQL Server); the general 15 s socket cap aborted the POST,
so the server saw a cancelled caller instead of answering Accepted/OutcomeUnknown."""
return http_request(method, url, max_timeout=DEPLOY_REQUEST_TIMEOUT_SECONDS, **options)
def wait_until(predicate, *, timeout, description, interval=1):
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
@@ -1072,9 +1084,15 @@ class LocalRig:
def seed_helper(self, action, *arguments, timeout=120):
self.compose("run", "--rm", "--no-deps", "seeder", action, *arguments, timeout=timeout)
def seed(self):
def seed(self, scale=None):
manifest = self.load()
self.seed_helper("seed")
if scale is None:
self.seed_helper("seed")
else:
# #1115 scale profile: N read-only source tags on the device's scale block, two CONSUMER mappings over them.
if type(scale) is not int or not 1 <= scale <= SCALE_MAX_TAGS:
raise RigError(f"--scale must be 1..{SCALE_MAX_TAGS}")
self.compose("run", "--rm", "--no-deps", "--env", f"GRPC_DATA_SCALE={scale}", "seeder", "seed", timeout=300)
fixture = json.loads((self.folder / "seed" / "fixture.json").read_text())
validate_fixture_endpoints(fixture.get("endpoints", {}), local_services=SERVICES)
manifest["fixture"] = fixture
@@ -1431,7 +1449,7 @@ class LocalRig:
raise RigError("sealed artifact has no required-node inventory")
return required
outcome = deploy_and_wait(manifest["endpoints"][primary + ".admin"]["url"], self.environment["GRPC_DATA_DEPLOY_KEY"],
{node + ":4053" for node in NODES}, request=http_request, timeout=remaining(), on_accepted=accepted)
{node + ":4053" for node in NODES}, request=deploy_http_request, timeout=remaining(), on_accepted=accepted)
manifest["deployment"] = {"id": outcome["deploymentId"], "revision_hash": outcome["revisionHash"], "scope_version": scope["scope_version"], "nodes": outcome["nodes"], "required_node_ids": scope["required_node_ids"]}
manifest["deployment"]["bundle_commits"] = self.wait_bundle_commits(scope["bundle_expectations"], timeout=remaining())
if require_catalog:
@@ -1488,6 +1506,9 @@ def main(argv=None):
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; "
"gateway = a host-run read-only HistorianGateway, README)")
parser.add_argument("--scale", type=int, default=None,
help=f"seed only (#1115): N (1..{SCALE_MAX_TAGS}) read-only SOURCE tags on the device scale block, "
"mapped to CONSUMER as map-scale-small (first 160) and map-scale-large (the rest); see scale_gate.py")
arguments = parser.parse_args(argv)
try:
if arguments.action == "preflight":
@@ -1522,6 +1543,10 @@ def main(argv=None):
if arguments.action != "up":
raise RigError("--source-revision applies to up only; the run remembers it")
options["source_revision"] = arguments.source_revision
if arguments.scale is not None:
if arguments.action != "seed":
raise RigError("--scale applies to seed only")
options["scale"] = arguments.scale
result = action(**options)
print(json.dumps({"run_id": result["run_id"], "state": result.get("state"), "manifest": str(rig.path), "healthy": result.get("healthy")}))
return 0