run-tests
Run unit, integration, conformance, or e2e tests for coraza-kubernetes-operator
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Run unit, integration, conformance, or e2e tests for coraza-kubernetes-operator
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | run-tests |
| description | Run unit, integration, conformance, or e2e tests for coraza-kubernetes-operator |
| user_invocable | true |
| allowed_tools | Bash, Read, Grep, Glob |
Run the appropriate tests for the coraza-kubernetes-operator project.
You are about to run tests for this project. Follow these rules strictly.
Ask yourself: what changed? Pick the narrowest test tier that covers the change.
| Tier | Build tag | What it tests | When to use |
|---|---|---|---|
| Unit | (none) | Controller logic via envtest, utils, API types | Code-only changes (no cluster needed) |
| Integration | integration | Full operator in a Kind cluster + Istio | Operator behavior, gateway proxying, metrics |
| Conformance | conformance | CoreRuleSet parity via go-ftw against a live gateway | Rule processing changes |
| E2E | e2e | End-to-end scenarios | Full-stack validation |
If the user says "run tests" without specifying, run unit tests first. Only escalate to integration/conformance/e2e if the change clearly requires it or the user asks.
ISTIO_VERSION is always required. The unit test suite downloads Istio CRDs at startup and will fail immediately without it.
Read ISTIO_VERSION from the Makefile default. Never hardcode a version—always check the Makefile first:
grep '^ISTIO_VERSION' Makefile
Other variables (needed only for integration/conformance/e2e):
| Variable | Default | Purpose |
|---|---|---|
KIND_CLUSTER_NAME | coraza-kubernetes-operator-integration | Kind cluster name |
ISTIO_GATEWAY_REVISION | coraza | istio.io/rev label on test Gateways |
K8S_VERSION | (latest GA) | envtest binary version for unit tests |
ISTIO_VERSION=<version> go test ./internal/controller/... -count=1 -timeout 180s
To run a specific test:
ISTIO_VERSION=<version> go test ./internal/controller/... -run 'TestName' -count=1 -timeout 180s
To run all unit tests (including API types, cmd, etc.):
ISTIO_VERSION=<version> go test ./... -count=1 -timeout 180s
Do NOT use go build or go vet to verify test files. They ignore _test.go files. Use go test -c or go test -run instead.
These tests run against a real Kind cluster. Before running them, you MUST ensure the cluster has the latest code:
If changes touched RBAC markers (+kubebuilder:rbac), CRD types (api/), or Helm templates:
make manifests generate # Regenerate CRDs and RBAC from markers
make helm.sync # Sync generated CRDs + RBAC into the Helm chart
If any Go code changed (controllers, cmd, etc.):
make build.image # Build the operator container image
make cluster.load-images # Load it into the Kind cluster
If manifests changed (Step 1) or the image changed (Step 2):
make deploy # Helm upgrade --install with current image + chart
If only the image changed (no manifest changes), a rollout restart suffices:
kubectl rollout restart deployment/coraza-kubernetes-operator -n coraza-system
kubectl rollout status deployment/coraza-kubernetes-operator -n coraza-system --timeout=60s
make test.integration # Integration tests
make test.conformance # Conformance tests (also runs coreruleset parity check)
make test.e2e # End-to-end tests
If the Kind cluster does not exist yet:
make cluster.kind # Creates cluster + installs Istio + MetalLB + deploys operator
Common failure mode: "engine never gets ready" or resources stuck in Progressing almost always means the operator image in the cluster is stale, or RBAC/CRDs are out of sync with the code. Rebuild, reload, and redeploy.
make lint # golangci-lint with -tags integration
make lint.fix # auto-fix lint issues
make lint.api # kube-api-linter for API types
go build ./... does NOT compile test files. It silently ignores _test.go. Always use go test -c or go test -run to verify test compilation.integration build tag. Running go test ./test/integration/... without -tags=integration finds zero tests.conformance build tag. Same pattern.make manifests helm.sync deploy, not just an image reload. The ClusterRole/Role in the cluster must match the controller's expectations.