rail-knative/tests/test_substrate_requests.py

34 lines
1.4 KiB
Python
Raw Normal View History

from pathlib import Path
import yaml
ROOT = Path(__file__).parents[1]
SUBSTRATE = ROOT / "substrate/v1.22.0"
# Live on railiance01 since 2026-09-21; see docs/substrate-runbook.md.
DECLARED = {
("knative-serving", "activator", "activator"): "50m",
("knative-serving", "autoscaler", "autoscaler"): "30m",
("knative-serving", "controller", "controller"): "30m",
("knative-serving", "webhook", "webhook"): "30m",
("knative-serving", "net-kourier-controller", "controller"): "30m",
("kourier-system", "3scale-kourier-gateway", "kourier-gateway"): "50m",
}
def test_patches_declare_exactly_the_cpu_requests():
found = {}
for doc in yaml.safe_load_all((SUBSTRATE / "cpu-requests.patch.yaml").read_text()):
assert doc["kind"] == "Deployment"
(container,) = doc["spec"]["template"]["spec"]["containers"]
# Only CPU requests: no limits, no memory, nothing else.
assert container["resources"] == {"requests": {"cpu": container["resources"]["requests"]["cpu"]}}
key = (doc["metadata"]["namespace"], doc["metadata"]["name"], container["name"])
found[key] = container["resources"]["requests"]["cpu"]
assert found == DECLARED
def test_kustomization_patches_the_pinned_assets():
k = yaml.safe_load((SUBSTRATE / "kustomization.yaml").read_text())
assert k["resources"] == ["core.yaml", "kourier.yaml"]
assert k["patches"] == [{"path": "cpu-requests.patch.yaml"}]