Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 2.52 KB

TESTING.md

File metadata and controls

59 lines (44 loc) · 2.52 KB

Testing Guide

Unit tests (tests/)

Isolated tests that need no cluster — type/JSON binding, registry metadata, retry logic, kubeconfig parsing, query/option builders, watch/informer structure, the K8s 1.36 field additions, 1.37 GA kinds, etc. Each tests/<name>_test.zig is wired in build.zig.

zig build test                 # run the whole unit suite
zig build test-retry           # a single suite (see build.zig for names)
zig build test-json-binding    # e.g. the type/continue field-binding regression

tests/migration_probe_test.zig force-compiles the public API surface — including every streaming method body — so lazy-compilation breakage fails here rather than in a downstream consumer.

Integration entrypoints (tests/entrypoints/)

Standalone executables that exercise the client against a real cluster. Because the direct TLS path has a known std.crypto.tls limitation (no certificate_request handshake handling; not caused by self-signed certs), they connect through kubectl proxy:

kubectl proxy --port=8080 --reject-paths='^$' &   # --reject-paths needed for exec/attach
zig build build-integration-tests                 # compile them all (also run in CI)
zig build test-via-proxy                           # pods / namespaces / nodes + pod CRUD
zig build test-pod-exec                            # pod exec over WebSocket (needs a running pod)
zig build test-mutating-admission-policy           # K8s >= 1.36 MutatingAdmissionPolicy CRUD
zig build test-k8s-137-crud                       # K8s >= 1.37 DeviceTaintRule / ClusterTrustBundle / StorageVersionMigration v1

For test-pod-exec, create a target pod first:

kubectl run zig-klient-exec-test --image=busybox:1.36 --restart=Never --command -- sleep 3600
kubectl wait --for=condition=Ready pod/zig-klient-exec-test

Comprehensive suite (tests/comprehensive/)

Larger scenarios (e.g. high-volume list pagination) that require a cluster — see that directory's README.

Prerequisites

  • A running cluster (Rancher Desktop, kind, minikube). Live CRUD verified against Kubernetes 1.37.0 (zig build test-k8s-137-crud) and 1.36.1 (test-mutating-admission-policy). PodCertificateRequest remains schema-only (zig build test-k8s-137).
  • kubectl proxy for the integration entrypoints (see above).

Notes

  • CI runs the unit suite on Linux + macOS with Zig 0.17.0, a zig fmt --check gate, and a Protobuf schema drift check. Integration entrypoints are compiled in CI; the kind workflow runs them nightly and on demand.