Add generic Knative service contract
This commit is contained in:
parent
4a0cc103e8
commit
f906d26807
4 changed files with 62 additions and 2 deletions
23
tests/test_contract.py
Normal file
23
tests/test_contract.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from pathlib import Path
|
||||
import yaml
|
||||
|
||||
ROOT = Path(__file__).parents[1]
|
||||
|
||||
def service():
|
||||
return yaml.safe_load((ROOT / "examples/service.yaml").read_text())
|
||||
|
||||
def test_safe_generic_service():
|
||||
item = service()
|
||||
assert item["apiVersion"] == "serving.knative.dev/v1"
|
||||
assert item["metadata"]["annotations"]["serving.knative.dev/visibility"] == "cluster-local"
|
||||
template = item["spec"]["template"]
|
||||
assert template["metadata"]["annotations"]["autoscaling.knative.dev/min-scale"] == "0"
|
||||
assert int(template["metadata"]["annotations"]["autoscaling.knative.dev/max-scale"]) > 0
|
||||
assert template["spec"]["containerConcurrency"] > 0
|
||||
assert "@sha256:" in template["spec"]["containers"][0]["image"]
|
||||
assert "qonto" not in (ROOT / "examples/service.yaml").read_text().lower()
|
||||
|
||||
def test_traffic_is_deterministic():
|
||||
traffic = service()["spec"]["traffic"]
|
||||
assert len(traffic) == 1
|
||||
assert sum(target["percent"] for target in traffic) == 100
|
||||
Loading…
Add table
Add a link
Reference in a new issue