"""Retirement must remove launch authority without disabling D3 helpers.""" from __future__ import annotations import ast from pathlib import Path import subprocess import sys import unittest ROOT = Path(__file__).resolve().parents[1] class MonolithRetirementTest(unittest.TestCase): def test_classic_ci_deployment_is_absent(self): for relative in ( ".github/workflows/deploy-ci-single-mode-environment.yml", "deployments/offline/runtime/deploy_ci_env.py", "ops/ec2/ensure_tidb_docker.sh", ): self.assertFalse((ROOT / relative).exists(), relative) def test_shared_modules_cannot_generate_or_start_a_monolithic_server(self): for relative in ( "deployments/offline/runtime/common.py", "deploy/online/runtime/common.py", ): source = (ROOT / relative).read_text() tree = ast.parse(source) names = {node.name for node in tree.body if isinstance(node, ast.FunctionDef)} self.assertFalse(names & {"write_backend_runner", "start_backend", "distribution_server_package_for_tags", "install_systemd_unit"}, relative) for node in ast.walk(tree): if isinstance(node, ast.Constant) and isinstance(node.value, str): self.assertNotIn("./cmd/crm-server", node.value, relative) self.assertNotIn("./cmd/server", node.value, relative) def test_retired_cli_fails_before_reading_environment_or_mutating_host(self): for module in ("deploy_offline_env", "deploy_staging_env"): result = subprocess.run( [sys.executable, str(ROOT / "deployments/offline/runtime" / f"{module}.py"), "--env-file", "/does-not-exist/runtime.env"], text=True, capture_output=True, timeout=15, ) self.assertNotEqual(0, result.returncode) self.assertIn("Classic monolithic deployment is retired", result.stderr) self.assertNotIn("Traceback", result.stderr) if __name__ == "__main__": unittest.main()