From ab1972f0cea7f6200d45b89d8d13d9a8c9fd1eeb Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 17:26:38 +0700 Subject: [PATCH 1/3] Run both operators and the client on kind in CI Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01AuvXe8Sd1zPn6vNm5hzbdH --- .github/workflows/kind-smoke.yml | 45 ++++++++ docs/smoke-test.md | 9 ++ hack/kind-smoke.sh | 176 +++++++++++++++++++++++++++++++ hack/kind-smoke/agents.yaml | 38 +++++++ 4 files changed, 268 insertions(+) create mode 100644 .github/workflows/kind-smoke.yml create mode 100755 hack/kind-smoke.sh create mode 100644 hack/kind-smoke/agents.yaml diff --git a/.github/workflows/kind-smoke.yml b/.github/workflows/kind-smoke.yml new file mode 100644 index 0000000..8573f5e --- /dev/null +++ b/.github/workflows/kind-smoke.yml @@ -0,0 +1,45 @@ +name: kind-smoke +# Runs agentops-operator, ai-agent-edge-tunnel and this client together on a kind +# cluster, from the main branches of the two operators. Needs no Cloudflare +# credentials; see hack/kind-smoke.sh for what is and is not covered. +on: + push: + branches: [main] + pull_request: + workflow_dispatch: +permissions: + contents: read +jobs: + kind-smoke: + runs-on: ubuntu-latest + timeout-minutes: 25 + steps: + - uses: actions/checkout@v4 + with: + path: agentops-client + - uses: actions/checkout@v4 + with: + repository: SteadyInfraTech/agentops-operator + path: agentops-operator + - uses: actions/checkout@v4 + with: + repository: SteadyInfraTech/ai-agent-edge-tunnel + path: ai-agent-edge-tunnel + - uses: actions/setup-go@v5 + with: + go-version-file: agentops-client/go.mod + cache-dependency-path: agentops-client/go.sum + - name: Install kind + run: | + curl -sSLo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.24.0/kind-linux-amd64 + chmod +x kind + sudo mv kind /usr/local/bin/kind + kind version + - name: Smoke test + working-directory: agentops-client + run: ./hack/kind-smoke.sh + - name: Dump cluster state on failure + if: failure() + run: | + kubectl get pods -A || true + kubectl get agentsessions,agentedgetunnels -A -o yaml || true diff --git a/docs/smoke-test.md b/docs/smoke-test.md index 0fd9201..f4929e4 100644 --- a/docs/smoke-test.md +++ b/docs/smoke-test.md @@ -87,3 +87,12 @@ Expected, in order: kubectl -n delete agentsession smoke --ignore-not-found make undeploy # in each operator repository; the edge one also removes its AgentEdgeTunnels ``` + +## Automated version + +`.github/workflows/kind-smoke.yml` runs `hack/kind-smoke.sh` on every pull request: it builds both +operators from their `main` branches, installs them into a kind cluster and runs the cluster half of +this checklist with a fake Cloudflare token. It covers the installs, binding, `sessionRef` waiting and +pinning, termination, RBAC, validation and the client's `Expose` and `Complete`. It does **not** cover +anything that needs real Cloudflare (tunnel, DNS, Access application, connector, the public URL), so +section 2 and the leak check above still have to be done by hand with a real zone. diff --git a/hack/kind-smoke.sh b/hack/kind-smoke.sh new file mode 100755 index 0000000..d15ee3d --- /dev/null +++ b/hack/kind-smoke.sh @@ -0,0 +1,176 @@ +#!/usr/bin/env bash +# Smoke test of agentops-operator, ai-agent-edge-tunnel and this client together on a kind cluster. +# +# It needs no Cloudflare account: the edge operator gets a fake token, so everything that talks to +# Cloudflare (tunnel, DNS, Access application, connector, public URL) is NOT covered. It covers the +# cluster half: installs, CRDs, binding, sessionRef waiting and pinning, termination, RBAC, validation +# and the client's Expose/Complete. +# +# Environment: +# OPERATOR_DIR checkout of agentops-operator (default ../agentops-operator) +# EDGE_DIR checkout of ai-agent-edge-tunnel (default ../ai-agent-edge-tunnel) +# CLUSTER kind cluster name (default agentops-smoke) +# Needs docker, kind, kubectl, kustomize and go on PATH. +set -euo pipefail + +HERE="$(cd "$(dirname "$0")/.." && pwd)" +OPERATOR_DIR="$(cd "${OPERATOR_DIR:-$HERE/../agentops-operator}" && pwd)" +EDGE_DIR="$(cd "${EDGE_DIR:-$HERE/../ai-agent-edge-tunnel}" && pwd)" +CLUSTER="${CLUSTER:-agentops-smoke}" +NS=smoke +OP_IMG=agentops-operator:ci +EDGE_IMG=ai-agent-edge-tunnel:ci +AGENT_IMG=echo-agent:ci + +pass=0 +step() { printf '\n== %s\n' "$*"; } +ok() { printf 'PASS: %s\n' "$*"; pass=$((pass + 1)); } +fail() { printf 'FAIL: %s\n' "$*" >&2; diagnose; exit 1; } + +diagnose() { + echo "---- diagnostics ----" >&2 + kubectl get agentsessions,agentedgetunnels,agentservices,agentpools -A -o wide >&2 || true + kubectl -n "$NS" get agentedgetunnels -o yaml >&2 || true + kubectl -n agentops-operator-system logs deploy/agentops-operator-controller-manager --tail=80 >&2 || true + kubectl -n edge-tunnel-system logs deploy/edge-tunnel-controller-manager --tail=80 >&2 || true + kubectl get pods -A >&2 || true +} + +# field NAME KIND JSONPATH prints a field of an object in $NS, or nothing. +field() { kubectl -n "$NS" get "$2" "$1" -o "jsonpath=$3" 2>/dev/null || true; } + +# wait_field NAME KIND JSONPATH WANT TIMEOUT_SECONDS +wait_field() { + local end=$((SECONDS + $5)) got="" + while [ "$SECONDS" -lt "$end" ]; do + got="$(field "$1" "$2" "$3")" + [ "$got" = "$4" ] && return 0 + sleep 2 + done + echo "timed out: $2/$1 $3 is '$got', wanted '$4'" >&2 + return 1 +} + +step "cluster" +if ! kind get clusters | grep -qx "$CLUSTER"; then kind create cluster --name "$CLUSTER" --wait 120s; fi +kubectl cluster-info >/dev/null + +step "build and load images" +docker build -t "$OP_IMG" "$OPERATOR_DIR" +docker build -f "$OPERATOR_DIR/examples/echo-agent/Dockerfile" -t "$AGENT_IMG" "$OPERATOR_DIR" +docker build -t "$EDGE_IMG" "$EDGE_DIR" +for img in "$OP_IMG" "$AGENT_IMG" "$EDGE_IMG"; do kind load docker-image "$img" --name "$CLUSTER"; done + +step "install agentops-operator" +(cd "$OPERATOR_DIR" && make install deploy IMG="$OP_IMG") +kubectl -n agentops-operator-system patch deploy agentops-operator-controller-manager --type=json \ + -p='[{"op":"add","path":"/spec/template/spec/containers/0/imagePullPolicy","value":"IfNotPresent"}]' +kubectl -n agentops-operator-system rollout status deploy/agentops-operator-controller-manager --timeout=180s +ok "agentops-operator is running" + +step "install ai-agent-edge-tunnel (fake Cloudflare credentials)" +kubectl create namespace edge-tunnel-system --dry-run=client -o yaml | kubectl apply -f - +kubectl -n edge-tunnel-system create secret generic edge-tunnel-cloudflare \ + --from-literal=account-id=smoke --from-literal=api-token=smoke --dry-run=client -o yaml | kubectl apply -f - +kubectl -n edge-tunnel-system create configmap edge-tunnel-config \ + --from-literal=EDGE_BASE_DOMAIN=agents.example.test \ + --from-literal=CONNECTOR_IMAGE=cloudflare/cloudflared:2024.1.0 --dry-run=client -o yaml | kubectl apply -f - +(cd "$EDGE_DIR" && make deploy IMG="$EDGE_IMG") +kubectl -n edge-tunnel-system patch deploy edge-tunnel-controller-manager --type=json \ + -p='[{"op":"add","path":"/spec/template/spec/containers/0/imagePullPolicy","value":"IfNotPresent"}]' +kubectl -n edge-tunnel-system rollout status deploy/edge-tunnel-controller-manager --timeout=180s +ok "ai-agent-edge-tunnel is running" + +step "CRDs from both groups are served" +kubectl get crd agentsessions.agents.steadyinfra.com agentedgetunnels.edge.steadyinfra.com >/dev/null +ok "CRDs installed" + +step "agent pool" +kubectl create namespace "$NS" --dry-run=client -o yaml | kubectl apply -f - +kubectl -n "$NS" apply -f "$HERE/hack/kind-smoke/agents.yaml" +kubectl -n "$NS" rollout status deploy --timeout=180s 2>&1 || true +end=$((SECONDS + 180)) +until [ "$(kubectl -n "$NS" get pods -o jsonpath='{.items[*].status.containerStatuses[*].ready}' 2>/dev/null)" = "true" ]; do + [ "$SECONDS" -lt "$end" ] || fail "no ready agent pod" + sleep 3 +done +ok "agent pod is ready" + +step "RBAC: the edge operator may read sessions, not change them" +SA=system:serviceaccount:edge-tunnel-system:edge-tunnel-controller-manager +[ "$(kubectl auth can-i get agentsessions.agents.steadyinfra.com -n "$NS" --as "$SA")" = yes ] || fail "edge operator cannot get agentsessions" +for verb in create update patch delete; do + [ "$(kubectl auth can-i "$verb" agentsessions.agents.steadyinfra.com -n "$NS" --as "$SA")" = no ] || fail "edge operator can $verb agentsessions" +done +ok "edge operator RBAC on agentsessions is get-only" + +step "validation: a tunnel is never public by omission" +if kubectl -n "$NS" apply --dry-run=server -f - >/dev/null 2>&1 <<'E2' +apiVersion: edge.steadyinfra.com/v1alpha1 +kind: AgentEdgeTunnel +metadata: {name: nosecurity} +spec: + sessionRef: {name: x} + cloudflare: {zoneID: zone, subdomain: nosecurity} +E2 +then fail "a tunnel with no access rule was accepted"; fi +ok "tunnel without allowedEmails or allowPublic is rejected" + +step "sessionRef waits for a session that does not exist yet" +kubectl -n "$NS" apply -f - <<'E2' +apiVersion: edge.steadyinfra.com/v1alpha1 +kind: AgentEdgeTunnel +metadata: {name: early} +spec: + sessionRef: {name: early} + cloudflare: {zoneID: zone, subdomain: early} + security: {allowedEmails: [smoke@example.com]} +E2 +sleep 15 +[ -z "$(field early agentedgetunnel '{.status.sessionUID}')" ] || fail "tunnel pinned a session that does not exist" +ok "tunnel waits, nothing pinned" + +step "session binds and the waiting tunnel pins it" +kubectl -n "$NS" apply -f - <<'E2' +apiVersion: agents.steadyinfra.com/v1alpha1 +kind: AgentSession +metadata: {name: early} +spec: + poolRef: {name: smoke} + userID: smoke +E2 +wait_field early agentsession '{.status.phase}' Bound 120 || fail "session never became Bound" +uid="$(field early agentsession '{.metadata.uid}')" +endpoint="$(field early agentsession '{.status.endpoint}')" +wait_field early agentedgetunnel '{.status.sessionUID}' "$uid" 120 || fail "tunnel did not pin the session UID" +[ "$(field early agentedgetunnel '{.status.sessionEndpoint}')" = "$endpoint" ] || fail "tunnel pinned a different endpoint than the session reports" +ok "session Bound ($endpoint) and pinned by the tunnel" + +step "completing the session ends the tunnel" +kubectl -n "$NS" patch agentsession early --type merge -p '{"spec":{"completed":true}}' +wait_field early agentedgetunnel '{.status.phase}' Terminated 120 || fail "tunnel did not terminate after the session completed" +ok "tunnel Terminated after session completion" + +step "client: Expose creates both objects, then Complete ends the session" +# Cloudflare is fake, so Wait cannot succeed: the example must time out, clean up and exit non-zero. +if (cd "$HERE" && go run ./examples/smoke -namespace "$NS" -name viaclient -pool smoke \ + -zone-id zone -email smoke@example.com -timeout 45s); then + fail "the smoke example succeeded although Cloudflare is fake" +fi +owner="$(kubectl -n "$NS" get agentedgetunnel viaclient -o jsonpath='{.metadata.ownerReferences[0].kind}')" +[ "$owner" = AgentSession ] || fail "tunnel created by the client has no AgentSession ownerReference (got '$owner')" +[ "$(field viaclient agentsession '{.spec.completed}')" = true ] || fail "the client did not complete the session after Wait failed" +suid="$(field viaclient agentsession '{.metadata.uid}')" +wait_field viaclient agentedgetunnel '{.status.sessionUID}' "$suid" 60 || fail "client-created tunnel did not pin its session" +ok "client created session and owned tunnel, and completed the session after the failed wait" + +step "deleting the session deletes its tunnel" +kubectl -n "$NS" delete agentsession viaclient --wait=true +end=$((SECONDS + 60)) +while kubectl -n "$NS" get agentedgetunnel viaclient >/dev/null 2>&1; do + [ "$SECONDS" -lt "$end" ] || fail "tunnel outlived its deleted session" + sleep 2 +done +ok "tunnel garbage-collected with its session" + +printf '\nAll %d checks passed. Not covered: anything that needs real Cloudflare.\n' "$pass" diff --git a/hack/kind-smoke/agents.yaml b/hack/kind-smoke/agents.yaml new file mode 100644 index 0000000..3e0d7c7 --- /dev/null +++ b/hack/kind-smoke/agents.yaml @@ -0,0 +1,38 @@ +# A minimal agent pool for the kind smoke test. The image is built from +# agentops-operator's examples/echo-agent and loaded into kind as echo-agent:ci. +apiVersion: agents.steadyinfra.com/v1alpha1 +kind: AgentRuntime +metadata: + name: echo-runtime +spec: + framework: custom + image: echo-agent:ci + imagePullPolicy: IfNotPresent + port: 8080 + probes: + livenessPath: /healthz + readinessPath: /readyz +--- +apiVersion: agents.steadyinfra.com/v1alpha1 +kind: AgentService +metadata: + name: echo + labels: + agents.steadyinfra.com/pool: smoke +spec: + runtimeRef: + name: echo-runtime + replicas: 1 + model: + provider: openai + name: unused +--- +apiVersion: agents.steadyinfra.com/v1alpha1 +kind: AgentPool +metadata: + name: smoke +spec: + selector: + matchLabels: + agents.steadyinfra.com/pool: smoke + maxSessionsPerReplica: 10 From 7ec01b823e318a586f4046d88fef36c0528d613f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 17:32:40 +0700 Subject: [PATCH 2/3] kind-smoke: the access-policy refusal comes from the controller, not the API server Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01AuvXe8Sd1zPn6vNm5hzbdH --- docs/smoke-test.md | 5 +++-- hack/kind-smoke.sh | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/smoke-test.md b/docs/smoke-test.md index f4929e4..d11660a 100644 --- a/docs/smoke-test.md +++ b/docs/smoke-test.md @@ -74,7 +74,8 @@ Expected, in order: - **Order independence.** Apply the tunnel before the session (with `kubectl`, not the client); it should wait, not fail. - **Public by omission is refused.** An `AgentEdgeTunnel` with neither `allowedEmails` nor - `allowPublic` must be rejected by the API server. + `allowPublic` goes to `Failed` with a "no access policy" message and nothing is created in Cloudflare. + (The API server only rejects setting both.) - **Re-binding terminates.** If the session's `status.endpoint` changes, the tunnel ends instead of being re-pointed. - **Leaks.** After all of the above, list tunnels, DNS records and Access applications in Cloudflare @@ -93,6 +94,6 @@ make undeploy # in each operator repository; the edge one also removes it `.github/workflows/kind-smoke.yml` runs `hack/kind-smoke.sh` on every pull request: it builds both operators from their `main` branches, installs them into a kind cluster and runs the cluster half of this checklist with a fake Cloudflare token. It covers the installs, binding, `sessionRef` waiting and -pinning, termination, RBAC, validation and the client's `Expose` and `Complete`. It does **not** cover +pinning, termination, RBAC, the access-policy refusal and the client's `Expose` and `Complete`. It does **not** cover anything that needs real Cloudflare (tunnel, DNS, Access application, connector, the public URL), so section 2 and the leak check above still have to be done by hand with a real zone. diff --git a/hack/kind-smoke.sh b/hack/kind-smoke.sh index d15ee3d..21193c4 100755 --- a/hack/kind-smoke.sh +++ b/hack/kind-smoke.sh @@ -3,7 +3,7 @@ # # It needs no Cloudflare account: the edge operator gets a fake token, so everything that talks to # Cloudflare (tunnel, DNS, Access application, connector, public URL) is NOT covered. It covers the -# cluster half: installs, CRDs, binding, sessionRef waiting and pinning, termination, RBAC, validation +# cluster half: installs, CRDs, binding, sessionRef waiting and pinning, termination, RBAC, access-policy refusal # and the client's Expose/Complete. # # Environment: @@ -105,16 +105,24 @@ done ok "edge operator RBAC on agentsessions is get-only" step "validation: a tunnel is never public by omission" -if kubectl -n "$NS" apply --dry-run=server -f - >/dev/null 2>&1 <<'E2' +# The CRD only rejects allowedEmails together with allowPublic; the controller refuses a tunnel with +# neither, so this shows up as Failed in status, before anything is created in Cloudflare. +kubectl -n "$NS" apply -f - <<'E2' apiVersion: edge.steadyinfra.com/v1alpha1 kind: AgentEdgeTunnel metadata: {name: nosecurity} spec: - sessionRef: {name: x} + service: {name: echo, port: 8080} cloudflare: {zoneID: zone, subdomain: nosecurity} E2 -then fail "a tunnel with no access rule was accepted"; fi -ok "tunnel without allowedEmails or allowPublic is rejected" +wait_field nosecurity agentedgetunnel '{.status.phase}' Failed 60 || fail "a tunnel with no access rule was not marked Failed" +case "$(field nosecurity agentedgetunnel '{.status.message}')" in + *"no access policy"*) ;; + *) fail "Failed for the wrong reason: $(field nosecurity agentedgetunnel '{.status.message}')" ;; +esac +[ -z "$(field nosecurity agentedgetunnel '{.status.tunnelID}')" ] || fail "a Cloudflare tunnel was created for an unprotected spec" +kubectl -n "$NS" delete agentedgetunnel nosecurity --wait=true +ok "tunnel without allowedEmails or allowPublic is refused before anything is created" step "sessionRef waits for a session that does not exist yet" kubectl -n "$NS" apply -f - <<'E2' From 5847fa4c43ae6e5e6c757911bcf8a00516344f40 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 17:41:25 +0700 Subject: [PATCH 3/3] kind-smoke: verify the kind checksum; wait on the agent Deployment; assert the waiting message Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01AuvXe8Sd1zPn6vNm5hzbdH --- .github/workflows/kind-smoke.yml | 1 + hack/kind-smoke.sh | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/kind-smoke.yml b/.github/workflows/kind-smoke.yml index 8573f5e..df3b0aa 100644 --- a/.github/workflows/kind-smoke.yml +++ b/.github/workflows/kind-smoke.yml @@ -32,6 +32,7 @@ jobs: - name: Install kind run: | curl -sSLo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.24.0/kind-linux-amd64 + echo "b89aada5a39d620da3fcd16435b7f28d858927dd53f92cbac77686b0588b600d kind" | sha256sum -c - chmod +x kind sudo mv kind /usr/local/bin/kind kind version diff --git a/hack/kind-smoke.sh b/hack/kind-smoke.sh index 21193c4..e523ae4 100755 --- a/hack/kind-smoke.sh +++ b/hack/kind-smoke.sh @@ -88,12 +88,13 @@ ok "CRDs installed" step "agent pool" kubectl create namespace "$NS" --dry-run=client -o yaml | kubectl apply -f - kubectl -n "$NS" apply -f "$HERE/hack/kind-smoke/agents.yaml" -kubectl -n "$NS" rollout status deploy --timeout=180s 2>&1 || true -end=$((SECONDS + 180)) -until [ "$(kubectl -n "$NS" get pods -o jsonpath='{.items[*].status.containerStatuses[*].ready}' 2>/dev/null)" = "true" ]; do - [ "$SECONDS" -lt "$end" ] || fail "no ready agent pod" - sleep 3 +# The smoke namespace holds only the agent's Deployment, so wait on that rather than on pods. +end=$((SECONDS + 60)) +until kubectl -n "$NS" get deploy -o name 2>/dev/null | grep -q .; do + [ "$SECONDS" -lt "$end" ] || fail "the agent Deployment was never created" + sleep 2 done +kubectl -n "$NS" wait --for=condition=Available deployment --all --timeout=180s || fail "the agent Deployment never became Available" ok "agent pod is ready" step "RBAC: the edge operator may read sessions, not change them" @@ -134,7 +135,8 @@ spec: cloudflare: {zoneID: zone, subdomain: early} security: {allowedEmails: [smoke@example.com]} E2 -sleep 15 +wait_field early agentedgetunnel '{.status.message}' 'waiting for AgentSession "early" to exist' 120 || fail "tunnel did not report waiting for the session" +sleep 10 [ -z "$(field early agentedgetunnel '{.status.sessionUID}')" ] || fail "tunnel pinned a session that does not exist" ok "tunnel waits, nothing pinned"