42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|||
|
|
import pathlib
|
||
|
|
import sys
|
||
|
|
|
||
|
|
import yaml
|
||
|
|
|
||
|
|
|
||
|
|
documents = [item for item in yaml.safe_load_all(pathlib.Path(sys.argv[1]).read_text()) if item]
|
||
|
|
deployments = [item for item in documents if item.get("kind") == "Deployment"]
|
||
|
|
services = [item for item in documents if item.get("kind") == "Service"]
|
||
|
|
claims = [item for item in documents if item.get("kind") == "PersistentVolumeClaim"]
|
||
|
|
|
||
|
|
assert len(deployments) == 1
|
||
|
|
assert len(services) == 1
|
||
|
|
deployment = deployments[0]
|
||
|
|
service = services[0]
|
||
|
|
selector = deployment["spec"]["selector"]["matchLabels"]
|
||
|
|
pod = deployment["spec"]["template"]
|
||
|
|
pod_labels = pod["metadata"]["labels"]
|
||
|
|
assert all(pod_labels.get(key) == value for key, value in selector.items())
|
||
|
|
assert service["spec"]["selector"] == selector
|
||
|
|
|
||
|
|
container = pod["spec"]["containers"][0]
|
||
|
|
http_port = next(port for port in container["ports"] if port["name"] == "http")
|
||
|
|
service_port = service["spec"]["ports"][0]
|
||
|
|
assert service_port["targetPort"] == http_port["name"]
|
||
|
|
assert service_port["port"] == http_port["containerPort"]
|
||
|
|
|
||
|
|
mounts = container["volumeMounts"]
|
||
|
|
assert {mount["subPath"] for mount in mounts} == {"models", "output", "input", "user"}
|
||
|
|
data_volume = next(volume for volume in pod["spec"]["volumes"] if volume["name"] == mounts[0]["name"])
|
||
|
|
claim = data_volume.get("persistentVolumeClaim", {}).get("claimName")
|
||
|
|
assert claim
|
||
|
|
if claims:
|
||
|
|
assert len(claims) == 1
|
||
|
|
assert claims[0]["metadata"]["name"] == claim
|
||
|
|
|
||
|
|
for probe_name in ("startupProbe", "readinessProbe", "livenessProbe"):
|
||
|
|
assert container[probe_name]["httpGet"]["path"] == "/system_stats"
|
||
|
|
|
||
|
|
print("ComfyUI chart render relationships are valid")
|