All checks were successful
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m36s
CD Pipeline / build-and-deploy (push) Successful in 7m2s
CD Pipeline / post-deploy-checks (push) Successful in 1m53s
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
|
|
|
|
def _load_deployment(path: str) -> dict:
|
|
deployment_documents = list(
|
|
yaml.safe_load_all(
|
|
(ROOT / path).read_text(encoding="utf-8")
|
|
)
|
|
)
|
|
return next(
|
|
document
|
|
for document in deployment_documents
|
|
if document.get("kind") == "Deployment"
|
|
and document.get("metadata", {}).get("name") == "awoooi-api"
|
|
)
|
|
|
|
|
|
def _api_environment(deployment: dict) -> dict[str, str | None]:
|
|
api_container = next(
|
|
container
|
|
for container in deployment["spec"]["template"]["spec"]["containers"]
|
|
if container["name"] == "api"
|
|
)
|
|
return {item["name"]: item.get("value") for item in api_container["env"]}
|
|
|
|
|
|
def test_production_api_does_not_compete_with_openclaw_polling_owner() -> None:
|
|
config = yaml.safe_load(
|
|
(ROOT / "k8s/awoooi-prod/04-configmap.yaml").read_text(
|
|
encoding="utf-8"
|
|
)
|
|
)
|
|
deployment = _load_deployment("k8s/awoooi-prod/06-deployment-api.yaml")
|
|
main = (ROOT / "apps/api/src/main.py").read_text(encoding="utf-8")
|
|
api_env = _api_environment(deployment)
|
|
|
|
assert config["data"]["TELEGRAM_ENABLE_POLLING"] == "false"
|
|
assert api_env["TELEGRAM_ENABLE_POLLING"] == "false"
|
|
assert "if settings.TELEGRAM_ENABLE_POLLING" in main
|
|
assert 'reason="OpenClaw' in main
|
|
|
|
|
|
def test_development_api_cannot_emit_legacy_telegram_heartbeats() -> None:
|
|
config = yaml.safe_load(
|
|
(ROOT / "k8s/awoooi-dev/02-configmap.yaml").read_text(encoding="utf-8")
|
|
)
|
|
deployment = _load_deployment("k8s/awoooi-dev/04-deployment-api.yaml")
|
|
api_env = _api_environment(deployment)
|
|
|
|
assert config["data"]["TELEGRAM_ENABLE_POLLING"] == "false"
|
|
assert api_env["TELEGRAM_ENABLE_POLLING"] == "false"
|
|
# An explicit env value overrides the same key inherited from envFrom.
|
|
# This also stops old images whose heartbeat gate only checks this token.
|
|
assert api_env["OPENCLAW_TG_BOT_TOKEN"] == ""
|