Testing & Validation
The Kubernetes lexicon includes scripts to verify the full import–serialize roundtrip and validate serialized YAML against a real cluster.
Roundtrip tests
Section titled “Roundtrip tests”The roundtrip test suite clones kubernetes/examples and runs each manifest through the full pipeline:
Input YAML → parse → generate TS → dynamic import → serialize YAML → re-parse → compare“Pass” means the serialized YAML, when re-parsed, produces the same number of resources with matching kind values. Exact YAML comparison is intentionally skipped — key ordering, quoting, and comments differ between input and output.
Running
Section titled “Running”cd lexicons/k8s
# Full roundtrip (clones repo on first run)just full-roundtrip
# Skip clone if repo is already cachedjust full-roundtrip --skip-clone
# Parse + generate only (skip serialize phase)just full-roundtrip --skip-clone --skip-serialize
# Verbose output + filter to a specific manifestjust full-roundtrip --skip-clone --verbose --manifest guestbookThe test requires just generate to have been run first so the generated index exports real constructors. If the generated index is empty, the test falls back to parse-only mode automatically.
Parse-only roundtrip
Section titled “Parse-only roundtrip”The original parse-only roundtrip test is still available:
just import-samples --skip-clone --verbosek3d cluster validation
Section titled “k3d cluster validation”The k3d validation script applies serialized YAML to a real Kubernetes cluster to verify the output is valid and deployable.
Prerequisites
Section titled “Prerequisites”Running
Section titled “Running”cd lexicons/k8s
# Create cluster, run tests, delete clusterjust k3d-validate
# Keep cluster for manual inspectionjust k3d-validate --keep-cluster
# Reuse an existing clusterjust k3d-validate --reuse-cluster --verboseAfter --keep-cluster, inspect resources manually:
kubectl get allkubectl get deployments,servicesSafe manifest allowlist
Section titled “Safe manifest allowlist”The script uses a curated allowlist of ~14 manifests known to work on bare k3d (no cloud volumes, CRDs, or GPUs). These include:
- Guestbook — Deployments and Services for frontend + Redis
- Cassandra — Headless Service
- vLLM — Service
What it validates
Section titled “What it validates”For each manifest the script:
- Runs the full roundtrip (YAML → Chant DSL → YAML)
- Applies the serialized YAML with
kubectl apply - Verifies the resource exists with
kubectl get
A failure at any stage is reported with the specific phase that failed.
See also
Section titled “See also”- Importing Existing YAML — convert existing K8s manifests into typed TypeScript