railiance-platform/tests/test_apps_pg_capacity.py
codex dc4245361d
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Finish RPF-WP-0018; RPF-WP-0019 repository-complete
RPF-WP-0018 closed: all seven tasks done. The provider-declaration finding
was adopted upstream and its canonical form is the provider: block in
tenancy.yaml; adaptive-pricing declined the standing co-signature and
supplied typed tier minima instead, recorded in ADR-0002. Three corrections
against our own output are recorded in the documents rather than edited
away.

RPF-WP-0019 T03 done (ceiling of three, memory binding, apps-pg-2 named as
overflow, enforced by make apps-pg-verify-capacity). T01/T02 are
repository-complete: backup target, retention, per-consumer connection
limits, role timeouts and Burstable resources are declared in source and
published in s3-consumer-interfaces 1.1.0 before rollout. They stay in
progress because no live application, backup success or restore proof
exists, and declared configuration is not a section 13 artifact. T04 waits
on that window.

apps-pg R reason corrected to say the target is declared-not-applied rather
than absent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 13:35:04 +02:00

47 lines
1.7 KiB
Python

from __future__ import annotations
from copy import deepcopy
import importlib.util
from pathlib import Path
import sys
import pytest
import yaml
ROOT = Path(__file__).parents[1]
SPEC = importlib.util.spec_from_file_location(
"verify_apps_pg_capacity", ROOT / "tools/verify_apps_pg_capacity.py"
)
capacity = importlib.util.module_from_spec(SPEC)
assert SPEC.loader is not None
sys.modules[SPEC.name] = capacity
SPEC.loader.exec_module(capacity)
MAX_CONSUMERS = capacity.MAX_CONSUMERS
verify = capacity.verify
MANIFESTS = [ROOT / "helm/apps-pg-cluster.yaml", ROOT / "helm/apps-pg-2-cluster.yaml"]
def test_reviewed_apps_pg_cells_fit_capacity_and_use_distinct_backups() -> None:
assert verify(MANIFESTS) == {"apps-pg": 2, "apps-pg-2": 0}
def test_fourth_role_is_rejected(tmp_path: Path) -> None:
primary = yaml.safe_load(MANIFESTS[0].read_text(encoding="utf-8"))
template = deepcopy(primary["spec"]["managed"]["roles"][0])
while len(primary["spec"]["managed"]["roles"]) <= MAX_CONSUMERS:
role = deepcopy(template)
role["name"] = f"consumer_{len(primary['spec']['managed']['roles'])}"
primary["spec"]["managed"]["roles"].append(role)
path = tmp_path / "apps-pg.yaml"
path.write_text(yaml.safe_dump(primary), encoding="utf-8")
with pytest.raises(ValueError, match="3-consumer ceiling"):
verify([path, MANIFESTS[1]])
def test_unbounded_role_is_rejected(tmp_path: Path) -> None:
primary = yaml.safe_load(MANIFESTS[0].read_text(encoding="utf-8"))
del primary["spec"]["managed"]["roles"][0]["connectionLimit"]
path = tmp_path / "apps-pg.yaml"
path.write_text(yaml.safe_dump(primary), encoding="utf-8")
with pytest.raises(ValueError, match="connectionLimit"):
verify([path, MANIFESTS[1]])