wanaku-tests

Write a test plan

Test plans are Markdown documents in plans/ for both humans and AI agents. Midnight Saci runs them. The Markdown must follow the Saci plan format. Read Write a test plan and the test plan format of Saci first. This page adds the rules for Wanaku plans.

Structure

A test plan has three layers:

  1. Main plan (plans/<name>.md) — the test scenario with phases and assertions.
  2. Common steps (plans/common/*.md) — reusable procedures shared across plans (Keycloak setup, namespace creation, cleanup).
  3. Environment variables — all configurable values declared upfront so the same plan works across versions and clusters.

For OpenShift-based plans, the namespace/project name must default to a unique value per run so multiple plans can execute in the same cluster without colliding. If a shared namespace is required, it should be set explicitly by the operator of the test run.

Phases, not scripts

Organize tests into numbered phases that run sequentially. Each phase groups related assertions. This makes it easy to skip phases, resume after failure, or run a subset.

Phase 0: Manual prerequisites
Phase 1: Environment setup
Phase 2-N: Test scenarios
Phase N+1: Cleanup

Every step must be verifiable

Each step needs: a command, an expected outcome, and a PASS/FAIL assertion. Avoid steps that only run a command without checking the result.

# Bad — runs but doesn't verify
oc apply -f my-resource.yaml

# Good — verifies the outcome
oc apply -f my-resource.yaml
oc wait myresource/name --for=condition=Ready --timeout=120s -n "${NAMESPACE}"

Prefer polling over sleeping

Use oc wait, oc rollout status, or a polling loop instead of fixed sleep calls. Clusters vary in speed — a 10s sleep that works locally may fail in CI and waste time on fast clusters.

# Bad
sleep 15
oc get deployment foo

# Good — deterministic wait
oc wait --for=condition=Available deployment/foo --timeout=120s -n "${NAMESPACE}"

# Good — polling for deletion
while oc get deployment foo -n "${NAMESPACE}" > /dev/null 2>&1; do
  sleep 3
done

Parametrize images and versions

Never hard-code image tags. Define environment variables with sensible defaults so the same plan can test different releases.

export MY_IMAGE="${MY_IMAGE:-quay.io/org/component:latest}"

Then use ${MY_IMAGE} in CR specs and image assertions.

Extract reusable steps into common docs

If a procedure appears in more than one plan (or is likely to), move it to plans/common/. The common doc should:

Reference common docs from the main plan with a link and a brief note on what variables must be set before and after:

Follow [common/keycloak-setup.md](common/keycloak-setup.md). After completion,
`KEYCLOAK_URL` and `WANAKU_OIDC_SECRET` must be set.

Keep the main plan lean

The main plan should only contain logic unique to that test scenario. If a step duplicates a common doc, replace it with a reference. This prevents drift between documents.

Use the Wanaku CLI, not raw API clients

Test plans must use the Wanaku CLI for all interactions with Wanaku Server, Wanaku Barn and Keycloak. The Saci worker image has wanaku on the PATH. Outside the image, use a wanaku binary that is installed on the system, or the CLI jar file built from wanaku-barn (java -jar apps/wanaku-cli/target/quarkus-app/quarkus-run.jar). For Keycloak administration (users, credentials, realm), use the standalone wanaku-keycloak-admin binary. The image also has it on the PATH.

Do not use curl, wget, httpie, or other HTTP clients to call Wanaku or Keycloak APIs unless the test is specifically oriented to verify HTTP-level behavior (e.g., checking raw HTTP status codes on health endpoints, testing Streamable HTTP headers, or verifying endpoint reachability before the CLI can connect), or the API has no CLI command (for example the enable/disable, audit and metrics routes of Wanaku Server).

# Bad — uses curl to list tools
curl -s "${WANAKU_SERVER_URL}/api/v1/tools" | jq '.data[].name'

# Good — uses the CLI
wanaku tools list --host "${WANAKU_SERVER_URL}" --no-auth --plain

# Acceptable — specifically testing HTTP endpoint reachability
curl -s -o /dev/null -w "%{http_code}" "${WANAKU_SERVER_URL}/health"

Shell compatibility

Use POSIX-compatible constructs. Avoid bash-only features like ${!VAR} (indirect expansion) since the executor may use zsh or sh. If bash is required, wrap the block in bash -c '...'.

Include negative tests

Verify that invalid inputs are rejected gracefully — missing required fields, references to non-existent resources, malformed data. These often catch real bugs.

Components under test

Wanaku is now two processes. Each test plan must state which of them it needs:

Component Source Role Local URL Health check
Wanaku Server wanaku-ai/wanaku (Rust) MCP endpoint, namespaces, forwards, discovered tools/resources/prompts, admin UI management http://localhost:8080, MCP http://localhost:8081/<namespace>/mcp GET /health
Wanaku Barn wanaku-ai/wanaku-barn (Java) Service catalogs, service templates, data stores, kamelets, semantic routers, audit, backup http://localhost:8180 GET /q/health/ready

Use these common procedures:

Point each CLI command at the component that owns the API:

Keep these differences from the Java router in mind:

Do not put credentials in a plan

Generate a value when the plan creates the account, and read it from the environment when the plan uses an existing system. See Credentials.

Cleanup must be idempotent

Use --ignore-not-found=true on all delete commands and 2>/dev/null || true on wait commands. A cleanup phase that fails on missing resources makes re-runs painful.

Checklist for new plans

Next steps