diff --git a/.gitignore b/.gitignore
index 0075c1c16..a648fe7f3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,3 +65,7 @@ lib/
# Local OPC UA validation runs; selected receipts belong under docs/plans/evidence.
/artifacts/opcua2/
+
+# Local gRPC data validation output, including restricted fixture manifests/PKI.
+/artifacts/grpc-data/
+/scripts/validation/grpc-data/**/__pycache__/
diff --git a/docs/plans/evidence/grpc-data/README.md b/docs/plans/evidence/grpc-data/README.md
new file mode 100644
index 000000000..0e141def8
--- /dev/null
+++ b/docs/plans/evidence/grpc-data/README.md
@@ -0,0 +1,60 @@
+# gRPC data implementation execution ledger
+
+Implementation authorized by the user after plan review. Work starts at `5dbdee1ea3ad1f0b98cd4ae15bcf14f9b114c21b` on branch `codex/grpc-data-connections` in the managed isolated worktree. Unrelated AB CIP fixture edits remain in the original checkout.
+
+The [implementation plan](../../2026-11-15-grpc-data-connections-implementation-plan.md) and [design](../../2026-11-15-grpc-data-connections-design.md) define scope. Only the applicable test selectors run per phase; the unfiltered whole-solution run is reserved for P12. No throughput claim is inferred from correctness tests.
+
+## Preflight
+
+- Host: macOS arm64; .NET SDK 10.0.403 (repository rolls forward from 10.0.100); Python 3.14.3.
+- Docker context: `orbstack`, local Unix socket; daemon architecture aarch64, approximately 15.7 GiB RAM. No fixture/container changes during initial inspection.
+- Managed worktree was clean at creation; feature branch is based on the committed design/plan/reviews.
+- Source feed/mapping/protocol work cannot begin before P00 focused test isolation passes. Tests remain coordinator-controlled.
+
+## Phase status
+
+| Phase | Scope | Status | Evidence |
+|---|---|---|---|
+| P00 | Unit discovery isolation and execution controls | Passed | 16 Python runner units; 2 C# guard units, zero failures/skips; phase run `20261116T020652.895154Z-0d06c2c1ac5f` |
+| P01 | Domain/protobuf contracts | In progress | Domain-contract worker next; codec follows frozen types |
+| P02 | Schema/artifact/consumer projection | Pending | |
+| P03 | Shared authorization and leases | Pending | |
+| P04 | Immutable publication, hub and local ports | Pending | |
+| P05 | Mutation tickets/outcomes | Pending | |
+| P06 | Streams/sharing/fair delivery | Pending | |
+| P07 | TLS/provisioning/node+cluster clients | Pending | |
+| P08 | Raw/UNS projection and adapter | Pending | |
+| P09 | Authoring/diagnostics/docs | Pending | |
+| P10 | Local Docker/CLI/probe integration | Pending | |
+| P11 | Scaling/recovery measurements | Pending | |
+| P12 | Full suite and final Astra review | Pending | |
+
+## Requirement-to-verification ledger
+
+| Design requirement / review finding | Implementation phases | Required evidence |
+|---|---|---|
+| H1 write replay/incarnation and per-item failover | P01/P05/P07 | Registry/outcome units; deterministic D08 effect ledger |
+| H2 dispatch gate, rich outcomes and late observation | P05 | Queue/demotion/revocation/late-driver units; D04/D08 |
+| H3 coherent served catalog without revocation rollback | P02/P03/P04 | Empty/failed apply activation units; D06 |
+| H4 mapped scopes ahead of legacy ACL bypass | P03/P08 | Raw and UNS mapped policy/cache/SDK tests; D06 |
+| H5 bounded metadata authority freshness | P03/P07/P08 | Request-start lease tests and quiet-mount D06 |
+| H6 explicit consumer-node execution scope | P02/P07/P08 | Artifact/manager scope units and D02/D10/D12 |
+| H7 pinned-cache and authorization isolation | P04/P06/P07 | Sharing/provenance units; target-mode matrix |
+| H8 immutable producer ownership | P01/P04 | Reused arrays/bytes, snapshot/pool lifetime tests |
+| H9 safe filter superset and writer baseline | P06 | Aggregate settings/baseline/commit tests |
+| M1 snapshot/command ordering | P04/P06 | Watermark/epoch/removal-barrier units and probe |
+| M2 original timestamp fidelity | P01/P04 | Codec/source-feed timestamp tests |
+| M3 bounded per-parent browse readiness | P08/P10 | SDK BrowseNext and CLI projection tests |
+| M4 bounded ingress/source dirty fairness | P04/P06/P11 | Overflow readiness, nonstarvation and workload evidence |
+| Plan H1 concrete local/mount-free service | P04/P10 | LocalDataConnection tests and D01a caller-node probe |
+| Plan H2 discovery isolation | P00 | Real counting C# probe/reaper test and sanitized runner units |
+| Plan H3 run-owned local fixtures | P10/P12 | Fake-process ownership units and local context/manifest |
+| Plan H4 local secret/trust lifecycle | P07/P10 | Provision/rotation/retirement units and D14 |
+| Plan M1 topology/realm/operation coverage | P10 | Full scenario matrix, real caller DI and CLI/probe evidence |
+| Plan M2 compile/EF prerequisites | P00/P02 | Focused baseline build/discovery; local-only migration |
+
+Runtime artifacts belong under ignored `artifacts/grpc-data/`; this tracked ledger indexes redacted outcomes only. It must never contain private keys, bearer values, credential-bearing manifests or a claim that pending phases passed.
+
+## P00 verification
+
+The runner tests first failed as expected while `run-unit-phase.py` was absent. After implementation, 16 fake-subprocess Python units passed. The real P00 discovery/execution runner passed both counting-probe/reaper C# tests with no skips; the starting production graph compiled successfully. No solution test run or Docker mutation occurred. Raw TRX/commands/discovery identities remain in ignored artifacts. The runner validates discovery AND executed results for every required new class, retains parameterized class filters, and sanitizes both child environments.
diff --git a/scripts/validation/grpc-data/run-unit-phase.py b/scripts/validation/grpc-data/run-unit-phase.py
new file mode 100644
index 000000000..e59880179
--- /dev/null
+++ b/scripts/validation/grpc-data/run-unit-phase.py
@@ -0,0 +1,247 @@
+#!/usr/bin/env python3
+"""Run only the explicit gRPC data unit selectors, with fail-closed evidence."""
+import argparse
+import hashlib
+import json
+import os
+from pathlib import Path
+import re
+import shlex
+import subprocess
+import sys
+import time
+from datetime import datetime, timezone
+import uuid
+import xml.etree.ElementTree as ET
+
+
+class GateError(Exception):
+ def __init__(self, message, exit_code=1):
+ super().__init__(message)
+ self.exit_code = exit_code if exit_code > 0 else 128 - exit_code
+
+
+# Deliberately permit toolchain/OS identity only. No ambient fixture credentials,
+# connection strings, Docker context or arbitrary application configuration pass.
+ENV_ALLOWLIST = frozenset({
+ "PATH", "HOME", "USER", "LOGNAME", "SHELL", "TMPDIR", "TMP", "TEMP",
+ "LANG", "LC_ALL", "LC_CTYPE", "SYSTEMROOT", "SystemRoot", "WINDIR",
+ "COMSPEC", "PATHEXT", "USERPROFILE", "LOCALAPPDATA", "APPDATA",
+ "DOTNET_ROOT", "DOTNET_ROOT_X64", "DOTNET_ROOT_ARM64", "DOTNET_CLI_HOME",
+ "DOTNET_MULTILEVEL_LOOKUP", "DOTNET_ROLL_FORWARD", "NUGET_PACKAGES",
+ "MSBuildSDKsPath", "MSBUILD_EXE_PATH", "SSL_CERT_FILE", "SSL_CERT_DIR",
+})
+
+
+def unit_environment(inherited=None):
+ source = os.environ if inherited is None else inherited
+ env = {key: value for key, value in source.items() if key in ENV_ALLOWLIST}
+ env.update({
+ "AKKA_TEST_TIMEFACTOR": "3", "OTOPCUA_UNIT_ONLY_DISCOVERY": "1",
+ "OTOPCUA_CONFIG_TEST_SERVER": "127.0.0.1,1",
+ "OTOPCUA_CONFIG_TEST_SA_PASSWORD": "UnitOnly_Unavailable_9!",
+ "OTOPCUA_CONFIG_CONNECTION": "Server=127.0.0.1,1;Database=unit_only;User Id=sa;Password=UnitOnly_Unavailable_9!;Connect Timeout=1;Encrypt=False;",
+ "OTOPCUA_TEST_SERVER": "opc.tcp://127.0.0.1:1",
+ "OTOPCUA_OPCPLC_ENDPOINT": "opc.tcp://127.0.0.1:1",
+ })
+ return env
+
+
+def write_json(path, value):
+ path.write_text(json.dumps(value, indent=2) + "\n", encoding="utf-8")
+
+
+def class_matches(name, class_name):
+ # Restrict the class component, so FooTests does not accept FooTestsExtra.
+ stem = name.split("(", 1)[0]
+ return stem.startswith(class_name + ".") or ("." + class_name + ".") in stem
+
+
+def discover_names(output):
+ marker = "The following Tests are available:"
+ if marker not in output:
+ return []
+ names = []
+ for line in output.split(marker, 1)[1].splitlines():
+ value = line.strip()
+ if line[:1].isspace() and re.match(r"^[\w.+`]+\.[\w`]+(?:\(.*\))?$", value):
+ names.append(value)
+ return sorted(set(names))
+
+
+def command(project, expression, directory, discovery=False):
+ argv = ["dotnet", "test", project, "-c", "Release", "-m:1",
+ "-p:TestTfmsInParallel=false", "--settings", "scripts/ci/ci.runsettings",
+ "--filter", expression, "--results-directory", str(directory)]
+ return argv + (["--list-tests"] if discovery else ["--logger", "trx;LogFileName=results.trx"])
+
+
+def validate_trx(directory, started_ns, expected_classes=()):
+ files = list(directory.rglob("*.trx"))
+ if not files:
+ raise GateError("missing TRX result")
+ total_executed = 0
+ summaries = []
+ executed_classes = set()
+ for path in files:
+ if path.stat().st_mtime_ns < started_ns:
+ raise GateError(f"stale TRX result: {path.name}")
+ try:
+ root = ET.parse(path).getroot()
+ counters = root.find(".//{*}ResultSummary/{*}Counters")
+ results = root.findall(".//{*}UnitTestResult")
+ if counters is None or not results:
+ raise ValueError("missing counters or results")
+ counts = {key: int(value) for key, value in counters.attrib.items()}
+ executed = counts.get("executed", 0)
+ if executed <= 0:
+ raise ValueError("zero executed tests")
+ if counts.get("failed", 0) or counts.get("error", 0) or counts.get("timeout", 0) or counts.get("aborted", 0):
+ raise ValueError("test failures")
+ if counts.get("notExecuted", 0) or counts.get("total", 0) != executed:
+ raise ValueError("unexpected skipped tests")
+ if any(result.get("outcome") != "Passed" for result in results):
+ raise ValueError("failed or unexpected skipped result")
+ if len(results) != executed or counts.get("passed", 0) != executed:
+ raise ValueError("inconsistent executed/passed results")
+ definitions = {}
+ for unit in root.findall(".//{*}TestDefinitions/{*}UnitTest"):
+ method = unit.find("{*}TestMethod")
+ if method is not None:
+ definitions[unit.get("id")] = method.get("className", "").split(",", 1)[0]
+ for result in results:
+ class_name = definitions.get(result.get("testId"), "")
+ for expected in expected_classes:
+ if class_name == expected or class_name.endswith("." + expected):
+ executed_classes.add(expected)
+ total_executed += executed
+ summaries.append({"file": str(path), "counters": counts})
+ except (ET.ParseError, ValueError) as exc:
+ raise GateError(f"invalid TRX {path.name}: {exc}") from exc
+ absent = set(expected_classes) - executed_classes
+ if absent:
+ raise GateError("missing executed new classes in TRX: " + ", ".join(sorted(absent)))
+ return {"executed": total_executed, "files": summaries, "executed_classes": sorted(executed_classes)}
+
+
+def selected_records(manifest, phase, root, case):
+ if phase not in manifest or not manifest[phase]:
+ raise GateError(f"unknown or empty phase: {phase}")
+ records = []
+ for source in manifest[phase]:
+ item = dict(source)
+ project = Path(item["project"])
+ if project.is_absolute() or ".." in project.parts or project.suffix != ".csproj" or "IntegrationTests" in str(project):
+ raise GateError(f"unit project must be an exact repository-relative unit csproj: {project}")
+ if not (root / project).is_file():
+ raise GateError(f"missing unit project: {project}")
+ classes = item.get("new_classes", []) + item.get("existing_classes", [])
+ if case and case not in classes:
+ continue
+ if case:
+ item["filter"] = f'({item["filter"]})&(FullyQualifiedName~.{case}.)'
+ item["new_classes"] = [case] if case in item.get("new_classes", []) else []
+ records.append(item)
+ if not records:
+ raise GateError(f"unknown class for {phase}: {case}")
+ return records
+
+
+def run_phase(manifest, phase, root, case=None, dry_run=False, invoke=subprocess.run, environ=None):
+ root = Path(root).resolve()
+ records = selected_records(manifest, phase, root, case)
+ run_id = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%S.%fZ") + "-" + uuid.uuid4().hex[:12]
+ directory = root / "artifacts" / "grpc-data" / run_id / "unit" / phase
+ if dry_run:
+ for index, item in enumerate(records):
+ target = directory / f'{index:02d}-{Path(item["project"]).stem}'
+ print(shlex.join(command(item["project"], item["filter"], target, True)))
+ print(shlex.join(command(item["project"], item["filter"], target)))
+ return directory
+ directory.mkdir(parents=True, exist_ok=False)
+ env = unit_environment(environ)
+ report = {"phase": phase, "case": case, "run_id": run_id, "status": "running", "projects": []}
+ started = time.monotonic()
+ def child(argv, target, label):
+ tick = time.monotonic()
+ result = invoke(argv, cwd=str(root), env=env, capture_output=True, text=True, shell=False)
+ (target / f"{label}.stdout.log").write_text(result.stdout or "", encoding="utf-8")
+ (target / f"{label}.stderr.log").write_text(result.stderr or "", encoding="utf-8")
+ if result.returncode:
+ raise GateError(f"{label} exited {result.returncode}; see {target}", result.returncode)
+ return result, time.monotonic() - tick
+ try:
+ identity = {}
+ for label, args in (("sha", ["rev-parse", "HEAD"]), ("status", ["status", "--porcelain=v1"]), ("diff", ["diff", "HEAD", "--binary"])):
+ result = invoke(["git", *args], cwd=str(root), env=env, capture_output=True, text=True, shell=False)
+ if result.returncode:
+ raise GateError(f"git {label} failed", result.returncode)
+ identity[label if label != "diff" else "diff_sha256"] = (result.stdout.strip() if label != "diff" else hashlib.sha256(result.stdout.encode()).hexdigest())
+ untracked = invoke(["git", "ls-files", "--others", "--exclude-standard", "-z"],
+ cwd=str(root), env=env, capture_output=True, text=True, shell=False)
+ if untracked.returncode:
+ raise GateError("git untracked identity failed", untracked.returncode)
+ identity["untracked_sha256"] = {
+ name: hashlib.sha256((root / name).read_bytes()).hexdigest()
+ for name in untracked.stdout.split("\0") if name and (root / name).is_file()
+ }
+ report["identity"] = identity
+ for index, item in enumerate(records):
+ target = directory / f'{index:02d}-{Path(item["project"]).stem}'
+ target.mkdir()
+ entry = {"project": item["project"], "filter": item["filter"], "new_classes": item.get("new_classes", [])}
+ report["projects"].append(entry)
+ tick = time.monotonic()
+ listing = command(item["project"], item["filter"], target, True)
+ entry["discovery_argv"] = listing
+ result, entry["discovery_seconds"] = child(listing, target, "discovery")
+ names = discover_names(result.stdout or "")
+ if case:
+ names = [name for name in names if class_matches(name, case)]
+ mapping = {name: [test for test in names if class_matches(test, name)] for name in item.get("new_classes", [])}
+ write_json(target / "discovery.json", {"filter": item["filter"], "tests": names, "new_classes": mapping})
+ if not names:
+ raise GateError(f"zero discovered tests for {item['project']}")
+ absent = [name for name, tests in mapping.items() if not tests]
+ if absent:
+ raise GateError(f"missing new classes: {', '.join(absent)}")
+ expression = item["filter"]
+ execution = command(item["project"], expression, target)
+ entry["execution_filter"] = expression
+ entry["execution_argv"] = execution
+ before = time.time_ns()
+ _, entry["execution_seconds"] = child(execution, target, "execution")
+ entry["trx"] = validate_trx(target, before, item.get("new_classes", []))
+ entry["duration_seconds"] = time.monotonic() - tick
+ report["status"] = "passed"
+ return directory
+ except (GateError, OSError) as exc:
+ report["status"] = "failed"
+ report["error"] = str(exc)
+ if isinstance(exc, GateError):
+ raise
+ raise GateError(str(exc)) from exc
+ finally:
+ report["duration_seconds"] = time.monotonic() - started
+ write_json(directory / "run.json", report)
+ print(f"Unit phase evidence: {directory}")
+
+
+def main(argv=None):
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("phase")
+ parser.add_argument("--case", help="Exact manifest class name")
+ parser.add_argument("--dry-run", action="store_true")
+ args = parser.parse_args(argv)
+ root = Path(__file__).resolve().parents[3]
+ try:
+ manifest = json.loads(Path(__file__).with_name("unit-phases.json").read_text())
+ run_phase(manifest, args.phase, root, args.case, args.dry_run)
+ return 0
+ except (GateError, ValueError, KeyError, OSError) as exc:
+ print(f"Unit phase failed: {exc}", file=sys.stderr)
+ return exc.exit_code if isinstance(exc, GateError) else 1
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/scripts/validation/grpc-data/test_unit_phase_runner.py b/scripts/validation/grpc-data/test_unit_phase_runner.py
new file mode 100644
index 000000000..6a37cf555
--- /dev/null
+++ b/scripts/validation/grpc-data/test_unit_phase_runner.py
@@ -0,0 +1,186 @@
+"""Behavioral runner tests. No dotnet process or fixture is started."""
+import importlib.util
+import json
+import os
+from pathlib import Path
+import subprocess
+import tempfile
+import unittest
+
+SPEC = importlib.util.spec_from_file_location("unit_phase_runner", Path(__file__).with_name("run-unit-phase.py"))
+runner = importlib.util.module_from_spec(SPEC)
+SPEC.loader.exec_module(runner)
+
+
+class UnitPhaseRunnerTests(unittest.TestCase):
+ def setUp(self):
+ self.temp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temp.cleanup)
+ self.root = Path(self.temp.name)
+ self.project = "tests/Example.Tests/Example.Tests.csproj"
+ (self.root / self.project).parent.mkdir(parents=True)
+ (self.root / self.project).touch()
+ self.manifest = {"P00": [{"project": self.project,
+ "filter": "(Feature=GrpcData&Phase=P00)|FullyQualifiedName~OldTests",
+ "new_classes": ["NewTests"], "existing_classes": ["OldTests"]}]}
+ self.calls = []
+ self.listing = "The following Tests are available:\n Example.NewTests.Works\n Example.OldTests.Works\n"
+ self.outcome = "Passed"
+ self.returncode = 0
+ self.result_mode = "fresh"
+
+ def fake(self, argv, **kwargs):
+ self.calls.append((argv, kwargs))
+ if argv[0] == "git":
+ return subprocess.CompletedProcess(argv, 0, "identity\n", "")
+ if "--list-tests" in argv:
+ return subprocess.CompletedProcess(argv, self.returncode, self.listing, "")
+ if self.result_mode != "missing":
+ folder = Path(argv[argv.index("--results-directory") + 1])
+ result = folder / "results.trx"
+ failed = int(self.outcome == "Failed")
+ skipped = int(self.outcome == "NotExecuted")
+ result.write_text(f'''''')
+ if self.result_mode == "stale":
+ os.utime(result, (1, 1))
+ return subprocess.CompletedProcess(argv, self.returncode, "ran", "")
+
+ def run_gate(self, **kwargs):
+ return runner.run_phase(self.manifest, "P00", self.root, invoke=self.fake, **kwargs)
+
+ def test_success_records_commands_identity_discovery_and_durations(self):
+ directory = self.run_gate()
+ record = json.loads((directory / "run.json").read_text())
+ self.assertEqual(record["status"], "passed")
+ self.assertIn("diff_sha256", record["identity"])
+ self.assertGreaterEqual(record["projects"][0]["duration_seconds"], 0)
+ discovered = json.loads(next(directory.rglob("discovery.json")).read_text())
+ self.assertEqual(discovered["new_classes"]["NewTests"], ["Example.NewTests.Works"])
+ for argv, kwargs in self.calls:
+ if argv[0] == "dotnet":
+ self.assertEqual(kwargs["env"]["OTOPCUA_UNIT_ONLY_DISCOVERY"], "1")
+ self.assertEqual(kwargs["env"]["AKKA_TEST_TIMEFACTOR"], "3")
+ self.assertNotIn("--no-build", argv)
+ self.assertNotIn("--no-restore", argv)
+ self.assertFalse(kwargs.get("shell", False))
+
+ def test_zero_discovery_rejected(self):
+ self.listing = "The following Tests are available:\n"
+ with self.assertRaisesRegex(runner.GateError, "zero"):
+ self.run_gate()
+
+ def test_build_noise_does_not_count_as_discovery(self):
+ self.listing = "Build succeeded.\nExample.NewTests.Works\n"
+ with self.assertRaisesRegex(runner.GateError, "zero"):
+ self.run_gate()
+
+ def test_missing_new_class_cannot_be_masked_by_existing_class(self):
+ self.listing = "The following Tests are available:\n Example.OldTests.Works\n"
+ with self.assertRaisesRegex(runner.GateError, "NewTests"):
+ self.run_gate()
+
+ def test_class_matching_does_not_accept_class_name_prefix(self):
+ self.listing = "The following Tests are available:\n Example.NewTestsExtra.Works\n"
+ with self.assertRaisesRegex(runner.GateError, "NewTests"):
+ self.run_gate()
+
+ def test_unknown_phase_rejected_before_subprocess(self):
+ with self.assertRaises(runner.GateError):
+ runner.run_phase(self.manifest, "P99", self.root, invoke=self.fake)
+ self.assertEqual(self.calls, [])
+
+ def test_unknown_case_rejected_before_subprocess(self):
+ with self.assertRaises(runner.GateError):
+ self.run_gate(case="Injected|Class")
+ self.assertEqual(self.calls, [])
+
+ def test_case_narrows_to_exact_discovered_class(self):
+ self.run_gate(case="NewTests")
+ dotnet = [argv for argv, _ in self.calls if argv[0] == "dotnet"]
+ self.assertEqual(len(dotnet), 2)
+ self.assertIn("&(FullyQualifiedName~.NewTests.)", dotnet[0][dotnet[0].index("--filter") + 1])
+ self.assertEqual(dotnet[1][dotnet[1].index("--filter") + 1], dotnet[0][dotnet[0].index("--filter") + 1])
+
+ def test_parameter_display_arguments_are_not_execution_filters(self):
+ self.listing = 'The following Tests are available:\n Example.NewTests.Works(value: "x|danger")\n'
+ self.run_gate(case="NewTests")
+ execution = [argv for argv, _ in self.calls if argv[0] == "dotnet"][-1]
+ self.assertNotIn("danger", execution[execution.index("--filter") + 1])
+
+ def test_missing_new_class_execution_cannot_be_masked_by_old_result(self):
+ original = self.fake
+ def wrong_class(argv, **kwargs):
+ result = original(argv, **kwargs)
+ if argv[0] == "dotnet" and "--list-tests" not in argv:
+ path = Path(argv[argv.index("--results-directory") + 1]) / "results.trx"
+ path.write_text(path.read_text().replace('className="Example.NewTests"', 'className="Example.OldTests"'))
+ return result
+ with self.assertRaisesRegex(runner.GateError, "missing executed new classes"):
+ runner.run_phase(self.manifest, "P00", self.root, invoke=wrong_class)
+
+ def test_missing_and_stale_trx_rejected(self):
+ for mode in ("missing", "stale"):
+ with self.subTest(mode=mode):
+ self.result_mode = mode
+ with self.assertRaisesRegex(runner.GateError, mode):
+ self.run_gate()
+
+ def test_failed_and_skipped_only_trx_rejected(self):
+ for outcome in ("Failed", "NotExecuted"):
+ with self.subTest(outcome=outcome):
+ self.outcome = outcome
+ with self.assertRaises(runner.GateError):
+ self.run_gate()
+
+ def test_nonzero_execution_exit_preserved(self):
+ original = self.fake
+ def fail_execution(argv, **kwargs):
+ result = original(argv, **kwargs)
+ if argv[0] == "dotnet" and "--list-tests" not in argv:
+ result.returncode = 23
+ return result
+ with self.assertRaises(runner.GateError) as raised:
+ runner.run_phase(self.manifest, "P00", self.root, invoke=fail_execution)
+ self.assertEqual(raised.exception.exit_code, 23)
+
+ def test_invalid_xml_and_inconsistent_counters_rejected(self):
+ original = self.fake
+ for content in ("'):
+ with self.subTest(content=content):
+ def invalid(argv, **kwargs):
+ result = original(argv, **kwargs)
+ if argv[0] == "dotnet" and "--list-tests" not in argv:
+ path = Path(argv[argv.index("--results-directory") + 1]) / "results.trx"
+ path.write_text(content)
+ return result
+ with self.assertRaisesRegex(runner.GateError, "invalid TRX"):
+ runner.run_phase(self.manifest, "P00", self.root, invoke=invalid)
+
+ def test_nonzero_exit_preserved(self):
+ self.returncode = 17
+ with self.assertRaises(runner.GateError) as raised:
+ self.run_gate()
+ self.assertEqual(raised.exception.exit_code, 17)
+
+ def test_unique_artifact_directories(self):
+ self.assertNotEqual(self.run_gate(), self.run_gate())
+
+ def test_dry_run_does_not_spawn_or_create_artifacts(self):
+ self.run_gate(dry_run=True)
+ self.assertEqual(self.calls, [])
+ self.assertFalse((self.root / "artifacts").exists())
+
+ def test_allowlist_removes_inherited_secrets_and_overrides_shared_sql(self):
+ env = runner.unit_environment({"PATH": "/bin", "HOME": "/home/test",
+ "OTOPCUA_CONFIG_TEST_SERVER": "shared-db", "OTOPCUA_CONFIG_CONNECTION": "secret",
+ "ConnectionStrings__Config": "shared", "CI_FIXTURE_SUFFIX": "foreign",
+ "DOCKER_HOST": "tcp://remote", "UNRELATED_SECRET": "hidden"})
+ self.assertEqual(env["PATH"], "/bin")
+ self.assertEqual(env["OTOPCUA_CONFIG_TEST_SERVER"], "127.0.0.1,1")
+ self.assertIn("127.0.0.1,1", env["OTOPCUA_CONFIG_CONNECTION"])
+ for key in ("ConnectionStrings__Config", "CI_FIXTURE_SUFFIX", "DOCKER_HOST", "UNRELATED_SECRET"):
+ self.assertNotIn(key, env)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/scripts/validation/grpc-data/unit-phases.json b/scripts/validation/grpc-data/unit-phases.json
new file mode 100644
index 000000000..b3fd2c976
--- /dev/null
+++ b/scripts/validation/grpc-data/unit-phases.json
@@ -0,0 +1,261 @@
+{
+ "P00": [
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P00)",
+ "new_classes": [
+ "GrpcDataUnitDiscoveryIsolationTests"
+ ],
+ "existing_classes": []
+ }
+ ],
+ "P01": [
+ {
+ "project": "tests/Core/ZB.MOM.WW.OtOpcUa.Core.Abstractions.Tests/ZB.MOM.WW.OtOpcUa.Core.Abstractions.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P01)|FullyQualifiedName~.DataChangeBatchContractTests.",
+ "new_classes": [
+ "GrpcDataContractsTests"
+ ],
+ "existing_classes": [
+ "DataChangeBatchContractTests"
+ ]
+ },
+ {
+ "project": "tests/Core/ZB.MOM.WW.OtOpcUa.Commons.Tests/ZB.MOM.WW.OtOpcUa.Commons.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P01)|FullyQualifiedName~.TelemetryProtoContractTests.|FullyQualifiedName~.MeshTransportProtoContractTests.|FullyQualifiedName~.DeploymentArtifactProtoTests.",
+ "new_classes": [
+ "GrpcDataProtoContractTests",
+ "GrpcDataCodecTests",
+ "GrpcDataCompactCodecTests"
+ ],
+ "existing_classes": [
+ "TelemetryProtoContractTests",
+ "MeshTransportProtoContractTests",
+ "DeploymentArtifactProtoTests"
+ ]
+ }
+ ],
+ "P02": [
+ {
+ "project": "tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/ZB.MOM.WW.OtOpcUa.Configuration.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P02)|FullyQualifiedName~.DraftValidatorNodeAclScopeTests.",
+ "new_classes": [
+ "GrpcDataConfigurationTests",
+ "GrpcDataMappingValidationTests",
+ "GrpcDataSchemaModelTests"
+ ],
+ "existing_classes": [
+ "DraftValidatorNodeAclScopeTests"
+ ]
+ },
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P02)|FullyQualifiedName~.DataPlaneAuthorityArtifactTests.|FullyQualifiedName~.ConfigComposerTests.",
+ "new_classes": [
+ "GrpcDataArtifactProjectionTests"
+ ],
+ "existing_classes": [
+ "DataPlaneAuthorityArtifactTests",
+ "ConfigComposerTests"
+ ]
+ },
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/ZB.MOM.WW.OtOpcUa.Runtime.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P02)|FullyQualifiedName~.DeploymentArtifactDataPlaneAuthorityTests.|FullyQualifiedName~.ParsedDeploymentArtifactTests.|FullyQualifiedName~.DeploymentArtifactEquipRefParityTests.",
+ "new_classes": [
+ "GrpcDataArtifactReadTests"
+ ],
+ "existing_classes": [
+ "DeploymentArtifactDataPlaneAuthorityTests",
+ "ParsedDeploymentArtifactTests",
+ "DeploymentArtifactEquipRefParityTests"
+ ]
+ }
+ ],
+ "P03": [
+ {
+ "project": "tests/Core/ZB.MOM.WW.OtOpcUa.Core.Tests/ZB.MOM.WW.OtOpcUa.Core.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P03)|FullyQualifiedName~.TriePermissionEvaluatorTests.|FullyQualifiedName~.PermissionTrieCacheTests.|FullyQualifiedName~.DataPlaneAuthorityStateTests.|FullyQualifiedName~.PermissionTrieBrowseTransitTests.",
+ "new_classes": [
+ "GrpcDataPolicyTests",
+ "GrpcDataAuthorityCacheTests"
+ ],
+ "existing_classes": [
+ "TriePermissionEvaluatorTests",
+ "PermissionTrieCacheTests",
+ "DataPlaneAuthorityStateTests",
+ "PermissionTrieBrowseTransitTests"
+ ]
+ },
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P03)|FullyQualifiedName~.DataPlaneAuthorizerTests.|FullyQualifiedName~.SessionAclDecisionCacheTests.|FullyQualifiedName~.NodeManagerAclEnforcementTests.",
+ "new_classes": [
+ "GrpcDataMappedSubjectTests"
+ ],
+ "existing_classes": [
+ "DataPlaneAuthorizerTests",
+ "SessionAclDecisionCacheTests",
+ "NodeManagerAclEnforcementTests"
+ ]
+ },
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/ZB.MOM.WW.OtOpcUa.Runtime.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P03)|FullyQualifiedName~.OpcUaPublishActorApplyFailureTests.|FullyQualifiedName~.OpcUaPublishActorApplyOutcomeTests.",
+ "new_classes": [
+ "GrpcDataCatalogActivationTests",
+ "GrpcDataMetadataLeaseTests"
+ ],
+ "existing_classes": [
+ "OpcUaPublishActorApplyFailureTests",
+ "OpcUaPublishActorApplyOutcomeTests"
+ ]
+ }
+ ],
+ "P04": [
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/ZB.MOM.WW.OtOpcUa.Runtime.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P04)|FullyQualifiedName~.DriverInstanceActorBatchForwardTests.|FullyQualifiedName~.DriverHostActorBatchFanOutTests.|FullyQualifiedName~.DriverHostActorSourceRemovedTests.|FullyQualifiedName~.DriverHostActorCommsLossTests.|FullyQualifiedName~.OpcUaPublishActorBatchTests.|FullyQualifiedName~.OpcUaPublishActorStatusBatchTests.",
+ "new_classes": [
+ "GrpcDataSampleOwnershipTests",
+ "GrpcDataSourceFeedParityTests",
+ "GrpcDataPartitionTests",
+ "GrpcDataSnapshotTests",
+ "GrpcDataIngressOverflowTests",
+ "GrpcDataLocalConnectionTests",
+ "GrpcDataCachedReadTests",
+ "GrpcDataLocalExportCatalogTests"
+ ],
+ "existing_classes": [
+ "DriverInstanceActorBatchForwardTests",
+ "DriverHostActorBatchFanOutTests",
+ "DriverHostActorSourceRemovedTests",
+ "DriverHostActorCommsLossTests",
+ "OpcUaPublishActorBatchTests",
+ "OpcUaPublishActorStatusBatchTests"
+ ]
+ }
+ ],
+ "P05": [
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/ZB.MOM.WW.OtOpcUa.Runtime.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P05)|FullyQualifiedName~.DriverHostActorWriteRoutingTests.|FullyQualifiedName~.DriverInstanceActorConcurrentWriteTests.|FullyQualifiedName~.ActorNodeWriteGatewayTests.|FullyQualifiedName~.PrimaryGatePolicyTests.|FullyQualifiedName~.DriverWriteBoundsTests.",
+ "new_classes": [
+ "GrpcDataWriteAdmissionTests",
+ "GrpcDataDriverOutcomeTests",
+ "GrpcDataWriteRegistryTests",
+ "GrpcDataLateWriteTests"
+ ],
+ "existing_classes": [
+ "DriverHostActorWriteRoutingTests",
+ "DriverInstanceActorConcurrentWriteTests",
+ "ActorNodeWriteGatewayTests",
+ "PrimaryGatePolicyTests",
+ "DriverWriteBoundsTests"
+ ]
+ },
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P05)|FullyQualifiedName~.NodeManagerWriteDispatchTests.|FullyQualifiedName~.NodeManagerWriteRevertTests.|FullyQualifiedName~.NodeManagerBatchWriteTests.|FullyQualifiedName~.EquipmentWriteGateTests.",
+ "new_classes": [
+ "GrpcDataMappedWriteCompletionTests"
+ ],
+ "existing_classes": [
+ "NodeManagerWriteDispatchTests",
+ "NodeManagerWriteRevertTests",
+ "NodeManagerBatchWriteTests",
+ "EquipmentWriteGateTests"
+ ]
+ }
+ ],
+ "P06": [
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/ZB.MOM.WW.OtOpcUa.Runtime.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P06)",
+ "new_classes": [
+ "GrpcDataDemandSharingTests",
+ "GrpcDataFilterAggregationTests",
+ "GrpcDataStreamOrderingTests",
+ "GrpcDataDeliveryFairnessTests",
+ "GrpcDataRecoveryAdmissionTests"
+ ],
+ "existing_classes": []
+ }
+ ],
+ "P07": [
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.Host.Tests/ZB.MOM.WW.OtOpcUa.Host.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P07)|FullyQualifiedName~.DriverWriteBoundsBindingTests.|FullyQualifiedName~.ApiKeyStoreRegistrationTests.|FullyQualifiedName~.ApiKeyAuthenticationTests.|FullyQualifiedName~.SecretsPreHostContentRootSourceTests.",
+ "new_classes": [
+ "GrpcDataSecretProvisioningTests",
+ "GrpcDataSecretRotationTests",
+ "GrpcDataCredentialRetirementTests",
+ "GrpcDataTrustRotationTests",
+ "GrpcDataListenerTests",
+ "GrpcDataIngressAuthTests",
+ "GrpcDataServiceDispatchTests"
+ ],
+ "existing_classes": [
+ "DriverWriteBoundsBindingTests",
+ "ApiKeyStoreRegistrationTests",
+ "ApiKeyAuthenticationTests",
+ "SecretsPreHostContentRootSourceTests"
+ ]
+ },
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/ZB.MOM.WW.OtOpcUa.Runtime.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P07)",
+ "new_classes": [
+ "GrpcDataConnectionClientTests",
+ "GrpcDataEndpointSelectionTests",
+ "GrpcDataConsumerScopeTests"
+ ],
+ "existing_classes": []
+ }
+ ],
+ "P08": [
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/ZB.MOM.WW.OtOpcUa.Runtime.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P08)",
+ "new_classes": [
+ "GrpcDataFederatedBrowseTests",
+ "GrpcDataContinuationTests",
+ "GrpcDataAdapterLifecycleTests"
+ ],
+ "existing_classes": []
+ },
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P08)|FullyQualifiedName~.NodeManagerAclEnforcementTests.|FullyQualifiedName~.NodeManagerModelChangeFilterTests.|FullyQualifiedName~.NodeManagerModelChangeOnAddTests.|FullyQualifiedName~.NodeManagerSurgicalRemoveTests.|FullyQualifiedName~.AddressSpaceApplierRawUnsTests.|FullyQualifiedName~.AddressSpaceApplierHierarchyTests.|FullyQualifiedName~.UnsReferenceBackingParityTests.",
+ "new_classes": [
+ "GrpcDataSdkBrowseReadinessTests",
+ "GrpcDataSdkMappedAccessTests"
+ ],
+ "existing_classes": [
+ "NodeManagerAclEnforcementTests",
+ "NodeManagerModelChangeFilterTests",
+ "NodeManagerModelChangeOnAddTests",
+ "NodeManagerSurgicalRemoveTests",
+ "AddressSpaceApplierRawUnsTests",
+ "AddressSpaceApplierHierarchyTests",
+ "UnsReferenceBackingParityTests"
+ ]
+ }
+ ],
+ "P09": [
+ {
+ "project": "tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj",
+ "filter": "(Feature=GrpcData&Phase=P09)|FullyQualifiedName~.AclScopeServiceTests.|FullyQualifiedName~.RawBrowseCommitMapperTests.|FullyQualifiedName~.RawBrowseCommitMapperParityTests.",
+ "new_classes": [
+ "GrpcDataAuthoringTests",
+ "GrpcDataEditorValidationTests",
+ "GrpcDataDiagnosticsTests"
+ ],
+ "existing_classes": [
+ "AclScopeServiceTests",
+ "RawBrowseCommitMapperTests",
+ "RawBrowseCommitMapperParityTests"
+ ]
+ }
+ ]
+}
diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/AdminUiSqlServerFixture.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/AdminUiSqlServerFixture.cs
index 48024ca42..3ba93e001 100644
--- a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/AdminUiSqlServerFixture.cs
+++ b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/AdminUiSqlServerFixture.cs
@@ -65,16 +65,20 @@ public sealed class AdminUiSqlServerFixture : IDisposable
private readonly SqlServerContextFactory? _factory;
/// Initializes a new instance of the class.
- public AdminUiSqlServerFixture()
+ public AdminUiSqlServerFixture() : this(AdminUiSqlServer.Instance)
+ {
+ }
+
+ internal AdminUiSqlServerFixture(AdminUiSqlServerProbe server)
{
// Probe FIRST — see the remarks. A dead server must leave this constructor without throwing,
// because xunit builds collection fixtures before it discovers that every test is skipped.
- SkipReason = AdminUiSqlServer.SkipReason;
+ SkipReason = server.SkipReason;
if (SkipReason is not null) return;
// A killed test process never reaches Dispose, so its database outlives the run. Reap the ones
// old enough to be certainly nobody's (once per process, and only after the probe answered).
- AdminUiSqlServer.ReapOrphanedTestDatabasesOnce();
+ server.ReapOrphanedTestDatabasesOnce();
// Mint from the same constant the reaper's LIKE anchors on — a rename that touched only one of the
// two would leave every future database unreapable, with nothing to signal it.
@@ -146,19 +150,17 @@ internal static class AdminUiSqlServer
/// How long a test database must have existed before the reaper considers it certainly orphaned.
private static readonly TimeSpan OrphanAge = TimeSpan.FromHours(24);
- private static readonly Lazy Probe = new(RunProbe, LazyThreadSafetyMode.ExecutionAndPublication);
-
- private static readonly Lazy Reaper = new(RunReaper, LazyThreadSafetyMode.ExecutionAndPublication);
+ internal static readonly AdminUiSqlServerProbe Instance = new(RunProbe, RunReaper);
/// Gets the reason SQL Server is unusable, or when it answered.
- public static string? SkipReason => Probe.Value;
+ public static string? SkipReason => Instance.SkipReason;
///
/// Reaps orphaned AdminUI test databases older than 24 hours, at most once per process. Call only
/// after came back — the reaper never throws, but
/// against a dead server it would just burn a connect timeout for nothing.
///
- public static void ReapOrphanedTestDatabasesOnce() => _ = Reaper.Value;
+ public static void ReapOrphanedTestDatabasesOnce() => Instance.ReapOrphanedTestDatabasesOnce();
/// Builds a connection string for the named database on the configured test server.
/// The database to connect to.
@@ -201,6 +203,29 @@ internal static class AdminUiSqlServer
}
}
+/// Guards and caches the discovery probe and fixture reaper.
+internal sealed class AdminUiSqlServerProbe
+{
+ private const string UnitOnlyReason = "SQL Server is unavailable in unit-only discovery mode.";
+ private readonly Lazy _probe;
+ private readonly Lazy _reaper;
+
+ internal AdminUiSqlServerProbe(Func probe, Func reaper)
+ {
+ _probe = new Lazy(probe, LazyThreadSafetyMode.ExecutionAndPublication);
+ _reaper = new Lazy(reaper, LazyThreadSafetyMode.ExecutionAndPublication);
+ }
+
+ private static bool UnitOnly => Environment.GetEnvironmentVariable("OTOPCUA_UNIT_ONLY_DISCOVERY") == "1";
+
+ internal string? SkipReason => UnitOnly ? UnitOnlyReason : _probe.Value;
+
+ internal void ReapOrphanedTestDatabasesOnce()
+ {
+ if (!UnitOnly) _ = _reaper.Value;
+ }
+}
+
///
/// Drops test databases that a killed test process left behind on the shared SQL Server.
///
@@ -392,7 +417,17 @@ public sealed class SqlServerFactAttribute : FactAttribute
[System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = -1)
: base(sourceFilePath, sourceLineNumber)
{
- if (AdminUiSqlServer.SkipReason is { } reason) Skip = reason;
+ SetSkipReason(AdminUiSqlServer.Instance);
+ }
+
+ internal SqlServerFactAttribute(AdminUiSqlServerProbe server)
+ {
+ SetSkipReason(server);
+ }
+
+ private void SetSkipReason(AdminUiSqlServerProbe server)
+ {
+ if (server.SkipReason is { } reason) Skip = reason;
}
}
diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/DataConnections/GrpcDataUnitDiscoveryIsolationTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/DataConnections/GrpcDataUnitDiscoveryIsolationTests.cs
new file mode 100644
index 000000000..e0894d0e1
--- /dev/null
+++ b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/DataConnections/GrpcDataUnitDiscoveryIsolationTests.cs
@@ -0,0 +1,68 @@
+using Xunit;
+
+namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.DataConnections;
+
+[CollectionDefinition(nameof(GrpcDataDiscoveryEnvironmentCollection), DisableParallelization = true)]
+public sealed class GrpcDataDiscoveryEnvironmentCollection
+{
+}
+
+[Collection(nameof(GrpcDataDiscoveryEnvironmentCollection))]
+[Trait("Feature", "GrpcData")]
+[Trait("Phase", "P00")]
+public sealed class GrpcDataUnitDiscoveryIsolationTests
+{
+ private const string Switch = "OTOPCUA_UNIT_ONLY_DISCOVERY";
+
+ [Fact]
+ public void UnitModeAttributeAndFixtureDoNotProbeOrReap()
+ {
+ var previous = Environment.GetEnvironmentVariable(Switch);
+ try
+ {
+ Environment.SetEnvironmentVariable(Switch, "1");
+ var probes = 0;
+ var reaps = 0;
+ var server = new AdminUiSqlServerProbe(() => { probes++; return null; }, () => { reaps++; return 0; });
+
+ var attribute = new SqlServerFactAttribute(server);
+ using var fixture = new AdminUiSqlServerFixture(server);
+ server.ReapOrphanedTestDatabasesOnce();
+
+ Assert.Contains("unit-only", attribute.Skip, StringComparison.OrdinalIgnoreCase);
+ Assert.Equal(attribute.Skip, fixture.SkipReason);
+ Assert.Equal(0, probes);
+ Assert.Equal(0, reaps);
+ }
+ finally
+ {
+ Environment.SetEnvironmentVariable(Switch, previous);
+ }
+ }
+
+ [Fact]
+ public void NormalModeAttributeUsesProbeAndReaperCallbackRunsOnce()
+ {
+ var previous = Environment.GetEnvironmentVariable(Switch);
+ try
+ {
+ Environment.SetEnvironmentVariable(Switch, null);
+ var probes = 0;
+ var reaps = 0;
+ var server = new AdminUiSqlServerProbe(() => { probes++; return "fake unavailable"; }, () => { reaps++; return 0; });
+
+ var attribute = new SqlServerFactAttribute(server);
+ Assert.Equal("fake unavailable", attribute.Skip);
+ Assert.Equal("fake unavailable", server.SkipReason);
+ server.ReapOrphanedTestDatabasesOnce();
+ server.ReapOrphanedTestDatabasesOnce();
+
+ Assert.Equal(1, probes);
+ Assert.Equal(1, reaps);
+ }
+ finally
+ {
+ Environment.SetEnvironmentVariable(Switch, previous);
+ }
+ }
+}