test(grpc-data): opt-in H2 history profile for the standalone rig (SqlServer historian overlay, history seed grants, probe HistoryRead, smoke runner)

This commit is contained in:
Joseph Doherty
2026-11-23 23:13:31 -05:00
parent abc6a1b068
commit eb29360d47
6 changed files with 344 additions and 11 deletions
+21 -4
View File
@@ -666,8 +666,15 @@ class LocalRig:
if env_path.exists():
self.environment.update(json.loads(env_path.read_text()))
def compose_files(self):
"""The run's Compose files: the v1 fixture, plus the H2 history overlay when the run opted in."""
files = ["--file", str(HERE / "compose.yml")]
if self.environment.get("GRPC_DATA_HISTORY") == "1":
files.extend(["--file", str(HERE / "compose.history.yml")])
return files
def compose(self, *args, timeout=120):
return run_command([*self.docker, "compose", "--project-name", self.project, "--file", str(HERE / "compose.yml"), *args], timeout=timeout, environment=self.environment)
return run_command([*self.docker, "compose", "--project-name", self.project, *self.compose_files(), *args], timeout=timeout, environment=self.environment)
@contextmanager
def hub_partitions(self, count):
@@ -700,7 +707,7 @@ class LocalRig:
# Inspect exact project resources before changing its owned services.
self.inspect_resources()
run_command([*self.docker, "compose", "--project-name", self.project,
"--file", str(HERE / "compose.yml"), *extra, "up", "--detach", "--no-deps", *nodes],
*self.compose_files(), *extra, "up", "--detach", "--no-deps", *nodes],
timeout=300, environment=self.environment)
manifest = self.refresh_endpoints(nodes)
self.capture(manifest)
@@ -834,7 +841,7 @@ class LocalRig:
self.save(manifest)
return manifest
def up(self, timeout=600):
def up(self, timeout=600, history=False):
import secrets
import credentials
if self.folder.exists():
@@ -854,6 +861,8 @@ class LocalRig:
settings["GRPC_DATA_SQL_PASSWORD"] = "Gd!" + secrets.token_hex(24)
import base64
settings["GRPC_DATA_SECRETS_KEK"] = base64.b64encode(secrets.token_bytes(32)).decode()
if history:
settings["GRPC_DATA_HISTORY"] = "1"
atomic_write_secret(self.folder / "environment.json", json.dumps(settings))
self.environment.update(settings)
credentials.provision_tls(self.folder / "security", NODES[2:])
@@ -926,6 +935,8 @@ class LocalRig:
manifest["node_probe_dirs"] = {node: str(self.folder / "probe" / node) for node in NODES}
manifest["credentials"] = {"cli_key_file": str(self.folder / "seed" / "cli.key"),
"data_key_files": {"source": str(self.folder / "seed" / "source.key")}}
if self.environment.get("GRPC_DATA_HISTORY") == "1":
manifest["credentials"]["data_key_files"]["source_nohistory"] = str(self.folder / "seed" / "source-nohistory.key")
manifest["state"] = "seeded"
self.capture(manifest)
return manifest
@@ -1319,6 +1330,7 @@ def main(argv=None):
parser.add_argument("action", choices=("preflight", "up", "seed", "deploy", "status", "down"))
parser.add_argument("--run-id")
parser.add_argument("--timeout", type=float, default=None)
parser.add_argument("--history", action="store_true", help="up only: add the H2 history overlay (SOURCE historian + history seed profile)")
arguments = parser.parse_args(argv)
try:
if arguments.action == "preflight":
@@ -1336,7 +1348,12 @@ def main(argv=None):
return 0
rig = LocalRig(arguments.run_id)
action = getattr(rig, arguments.action)
result = action(**({"timeout": arguments.timeout} if arguments.timeout is not None and arguments.action in {"up", "deploy"} else {}))
options = {"timeout": arguments.timeout} if arguments.timeout is not None and arguments.action in {"up", "deploy"} else {}
if arguments.history:
if arguments.action != "up":
raise RigError("--history applies to up only; the run remembers it")
options["history"] = True
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
except (RigError, ValueError, OSError, KeyError) as error: