fix(deploy): transition node intelligence source atomically
This commit is contained in:
@@ -34,11 +34,20 @@ RUNNER = load_runner()
|
||||
|
||||
class EngineProviderAuthorityDiagnosticsTest(unittest.TestCase):
|
||||
def require_historical_target(self):
|
||||
source_entries = [
|
||||
relative_path
|
||||
for relative_path in RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_ARTIFACT_ENTRIES
|
||||
if relative_path != RUNNER.ENGINE_NODE_INTELLIGENCE_DESCRIPTOR_REL
|
||||
]
|
||||
current_sha256 = {
|
||||
relative_path: hashlib.sha256((ENGINE_ROOT / relative_path).read_bytes()).hexdigest()
|
||||
for relative_path in RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_ARTIFACT_ENTRIES
|
||||
for relative_path in source_entries
|
||||
}
|
||||
if current_sha256 != RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_TARGET_SHA256:
|
||||
expected_sha256 = {
|
||||
relative_path: RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_TARGET_SHA256[relative_path]
|
||||
for relative_path in source_entries
|
||||
}
|
||||
if current_sha256 != expected_sha256:
|
||||
self.skipTest("historical provider authority diagnostics source has advanced")
|
||||
|
||||
def build(self, artifact_dir):
|
||||
@@ -96,14 +105,20 @@ class EngineProviderAuthorityDiagnosticsTest(unittest.TestCase):
|
||||
def test_preflight_requires_the_exact_deployed_predecessor(self):
|
||||
with tempfile.TemporaryDirectory(prefix="nodedc-provider-authority-preflight-") as directory:
|
||||
root = Path(directory)
|
||||
relative_path = RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_ARTIFACT_ENTRIES[0]
|
||||
path = root / relative_path
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text("predecessor\n", encoding="utf-8")
|
||||
expected = RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_PREDECESSOR_SHA256[relative_path]
|
||||
for relative_path in RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_ARTIFACT_ENTRIES:
|
||||
path = root / relative_path
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text("predecessor\n", encoding="utf-8")
|
||||
|
||||
def predecessor_sha256(path):
|
||||
relative_path = path.relative_to(root).as_posix()
|
||||
return RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_PREDECESSOR_SHA256[
|
||||
relative_path
|
||||
]
|
||||
|
||||
with (
|
||||
mock.patch.object(RUNNER, "component_root", return_value=root),
|
||||
mock.patch.object(RUNNER, "sha256_file", return_value=expected),
|
||||
mock.patch.object(RUNNER, "sha256_file", side_effect=predecessor_sha256),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"preflight_engine_credential_backend_runtime",
|
||||
@@ -123,10 +138,14 @@ class EngineProviderAuthorityDiagnosticsTest(unittest.TestCase):
|
||||
def test_healthchecks_dispatch_authority_diagnostics_acceptance(self):
|
||||
entries = RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_ARTIFACT_ENTRIES
|
||||
root = Path("/engine")
|
||||
target_hash = next(iter(RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_TARGET_SHA256.values()))
|
||||
|
||||
def target_sha256(path):
|
||||
relative_path = path.relative_to(root).as_posix()
|
||||
return RUNNER.ENGINE_PROVIDER_AUTHORITY_DIAGNOSTICS_TARGET_SHA256[relative_path]
|
||||
|
||||
with (
|
||||
mock.patch.object(RUNNER, "component_root", return_value=root),
|
||||
mock.patch.object(RUNNER, "sha256_file", return_value=target_hash),
|
||||
mock.patch.object(RUNNER, "sha256_file", side_effect=target_sha256),
|
||||
mock.patch.object(RUNNER, "healthcheck_compose_service"),
|
||||
mock.patch.object(RUNNER, "component_healthchecks", return_value=()),
|
||||
mock.patch.object(
|
||||
@@ -147,16 +166,23 @@ class EngineProviderAuthorityDiagnosticsTest(unittest.TestCase):
|
||||
def test_live_acceptance_uses_private_node_reconciliation_contract(self):
|
||||
self.require_historical_target()
|
||||
expected_live = "engine-private-node-reconciliation:exact-id-or-name:v1"
|
||||
with (
|
||||
mock.patch.object(RUNNER, "component_root", return_value=ENGINE_ROOT),
|
||||
mock.patch.object(RUNNER, "engine_backend_container_id", return_value="backend"),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"run_engine_backend_probe",
|
||||
return_value=expected_live,
|
||||
) as backend_probe,
|
||||
):
|
||||
result = RUNNER.accept_engine_provider_authority_diagnostics_runtime()
|
||||
with tempfile.TemporaryDirectory(prefix="nodedc-provider-authority-live-") as directory:
|
||||
root = Path(directory)
|
||||
built = self.build(root / "artifact")
|
||||
_manifest, _entries, payload = RUNNER.load_artifact(
|
||||
Path(built["artifact"]),
|
||||
root / "loaded",
|
||||
)
|
||||
with (
|
||||
mock.patch.object(RUNNER, "component_root", return_value=payload),
|
||||
mock.patch.object(RUNNER, "engine_backend_container_id", return_value="backend"),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"run_engine_backend_probe",
|
||||
return_value=expected_live,
|
||||
) as backend_probe,
|
||||
):
|
||||
result = RUNNER.accept_engine_provider_authority_diagnostics_runtime()
|
||||
self.assertEqual(result["live"], expected_live)
|
||||
self.assertEqual(backend_probe.call_args.args[1], "Engine private node validation reconciliation")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user