Skip to content

Commit dfff5f5

Browse files
EItanyaclaudeOpSpawn Agent
authored
fix: use oTEL Context instead of LogRecord (#1371)
Updates oTEL libraries to get rid of the spam logged deprecation warning Fixes #1366 --------- Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io> Signed-off-by: OpSpawn Agent <agent@opspawn.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: OpSpawn Agent <agent@opspawn.com>
1 parent 3baeb86 commit dfff5f5

32 files changed

Lines changed: 322 additions & 89 deletions
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
name: run-e2e-tests
3+
description: Run and debug kagent end-to-end tests. Use when the user asks to run e2e tests, debug e2e test failures, or understand the e2e test setup.
4+
allowed-tools: Bash, Read, Grep, Glob
5+
argument-hint: "[test-name-pattern]"
6+
---
7+
8+
# Running Kagent E2E Tests
9+
10+
## Prerequisites
11+
12+
1. A running Kind cluster with kagent deployed:
13+
```bash
14+
make create-kind-cluster
15+
make helm-install
16+
```
17+
18+
2. Test agent images built and pushed to the local registry (for BYO agent tests):
19+
- `localhost:5001/basic-openai:latest`
20+
- `localhost:5001/poem-flow:latest`
21+
- `kind-registry:5000/kebab-maker:latest` (for skill tests)
22+
23+
3. The `kagent-tool-server` RemoteMCPServer must exist in the `kagent` namespace.
24+
25+
4. The `kebab-agent` must be deployed in the `kagent` namespace (used by `TestE2EInvokeExternalAgent`).
26+
27+
## Environment Variables
28+
29+
Set `KAGENT_URL` using the controller's load balancer IP (no port-forward needed):
30+
```bash
31+
export KAGENT_URL="http://$(kubectl get svc -n kagent kagent-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}'):8083"
32+
```
33+
34+
| Variable | Default | Description |
35+
|----------|---------|-------------|
36+
| `KAGENT_URL` | `http://localhost:8083` | Base URL of the kagent controller. Use the load balancer command above rather than port-forwarding. |
37+
| `KAGENT_LOCAL_HOST` | Auto-detected (`host.docker.internal` on macOS, `172.17.0.1` on Linux) | Host IP accessible from inside Kind pods (for mock LLM server) |
38+
| `SKIP_CLEANUP` | (unset) | If set and test fails, skip deleting test resources for debugging |
39+
40+
## Running Tests
41+
42+
If the user provides a test name pattern via `$ARGUMENTS`, run that specific test. Otherwise run all e2e tests.
43+
44+
All commands must be run from the `go/` directory.
45+
46+
Set `KAGENT_URL` before every test command:
47+
```bash
48+
export KAGENT_URL="http://$(kubectl get svc -n kagent kagent-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}'):8083"
49+
```
50+
51+
Run all e2e tests:
52+
```bash
53+
KAGENT_URL="$KAGENT_URL" go test -v -count=1 ./test/e2e/ -failfast
54+
```
55+
56+
Run a single test (using `$ARGUMENTS` as the pattern):
57+
```bash
58+
KAGENT_URL="$KAGENT_URL" go test -v -count=1 -run "$ARGUMENTS" ./test/e2e/
59+
```
60+
61+
Run with shuffle (to detect ordering dependencies):
62+
```bash
63+
KAGENT_URL="$KAGENT_URL" go test -v -count=1 ./test/e2e/ -failfast -shuffle=on
64+
```
65+
66+
## Test Structure
67+
68+
Tests live in `go/test/e2e/invoke_api_test.go`. Each test:
69+
1. Starts a mock LLM server (via `mockllm`) that listens on the host
70+
2. Creates K8s resources (ModelConfig, Agent, optionally MCPServer)
71+
3. Waits for `condition=Ready` on the Agent CR
72+
4. Polls the A2A endpoint via `waitForEndpoint()` until it returns non-5xx
73+
5. Sends A2A messages (sync and/or streaming) and checks responses
74+
6. Cleans up resources (or logs debug info on failure)
75+
76+
The mock LLM server runs on the test host machine and must be reachable from inside Kind pods. The `KAGENT_LOCAL_HOST` variable controls what IP is used — auto-detected as `172.17.0.1` on Linux and `host.docker.internal` on macOS.
77+
78+
## Debugging Failures
79+
80+
When a test fails, the cleanup function automatically logs:
81+
- Agent CR YAML
82+
- Pod logs for all pods matching the agent
83+
- Pod describe output
84+
- Deployment describe output
85+
- Service describe output
86+
87+
To manually investigate after a failed test (run with `SKIP_CLEANUP=1` to preserve resources):
88+
89+
```bash
90+
SKIP_CLEANUP=1 KAGENT_URL="$KAGENT_URL" go test -v -count=1 -run TestName ./test/e2e/
91+
```
92+
93+
Then inspect:
94+
```bash
95+
kubectl get agents -n kagent
96+
kubectl describe agent <agent-name> -n kagent
97+
kubectl get pods -n kagent -l app.kubernetes.io/managed-by=kagent
98+
kubectl logs -n kagent -l app.kubernetes.io/name=<agent-name>
99+
kubectl get events -n kagent --sort-by=.lastTimestamp
100+
kubectl logs -n kagent deployments/kagent-controller
101+
kubectl get endpoints <agent-name> -n kagent
102+
```
103+
104+
## Common Failure Modes
105+
106+
- **Empty streaming response / "does not contain"**: The stream connected but the agent returned 0 events (not fully warmed up). The retry logic handles this — if it still fails after retries, check if the agent pod is crash-looping or if the mock LLM server is unreachable from inside the cluster.
107+
- **"connection refused" to agent pod**: The agent deployment/service hasn't propagated yet. `waitForEndpoint()` should handle this. If persistent, check `kubectl get endpoints <agent-name> -n kagent`.
108+
- **"serviceaccount not found"**: The controller hasn't finished creating all child resources for the agent. This is a timing issue handled by `waitForEndpoint()`.
109+
- **"All connection attempts failed" (MCP server)**: The MCPServer's pod isn't ready or its service isn't resolvable from the agent pod. Check `kubectl get mcpservers -n kagent` and `kubectl describe mcpserver <name> -n kagent`.
110+
- **Mock LLM server unreachable from pods**: The `KAGENT_LOCAL_HOST` is wrong for your environment. On Linux it defaults to `172.17.0.1` (the docker bridge IP). Set it explicitly if your setup differs.
111+
- **`TestE2EInvokeExternalAgent` fails**: The `kebab-agent` must be pre-deployed. This agent is not created by the test — it must exist beforehand.
112+
- **`TestE2EInvokeOpenAIAgent` or `TestE2EInvokeCrewAIAgent` fails with image pull error**: The BYO agent images must be built and pushed to the local registry (`localhost:5001`) before running these tests.

go/internal/controller/translator/agent/adk_api_translator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ func (a *adkApiTranslator) buildManifest(
505505
Env: env,
506506
ReadinessProbe: &corev1.Probe{
507507
ProbeHandler: corev1.ProbeHandler{
508-
HTTPGet: &corev1.HTTPGetAction{Path: "/health", Port: intstr.FromString("http")},
508+
HTTPGet: &corev1.HTTPGetAction{Path: "/.well-known/agent.json", Port: intstr.FromString("http")},
509509
},
510510
InitialDelaySeconds: 15,
511511
TimeoutSeconds: 15,

go/internal/controller/translator/agent/testdata/outputs/agent_with_allowed_headers.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
],
201201
"readinessProbe": {
202202
"httpGet": {
203-
"path": "/health",
203+
"path": "/.well-known/agent.json",
204204
"port": "http"
205205
},
206206
"initialDelaySeconds": 15,

go/internal/controller/translator/agent/testdata/outputs/agent_with_code.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
],
193193
"readinessProbe": {
194194
"httpGet": {
195-
"path": "/health",
195+
"path": "/.well-known/agent.json",
196196
"port": "http"
197197
},
198198
"initialDelaySeconds": 15,

go/internal/controller/translator/agent/testdata/outputs/agent_with_cross_namespace_tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
],
206206
"readinessProbe": {
207207
"httpGet": {
208-
"path": "/health",
208+
"path": "/.well-known/agent.json",
209209
"port": "http"
210210
},
211211
"initialDelaySeconds": 15,

go/internal/controller/translator/agent/testdata/outputs/agent_with_custom_sa.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
],
161161
"readinessProbe": {
162162
"httpGet": {
163-
"path": "/health",
163+
"path": "/.well-known/agent.json",
164164
"port": "http"
165165
},
166166
"initialDelaySeconds": 15,

go/internal/controller/translator/agent/testdata/outputs/agent_with_http_toolserver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
],
200200
"readinessProbe": {
201201
"httpGet": {
202-
"path": "/health",
202+
"path": "/.well-known/agent.json",
203203
"port": "http"
204204
},
205205
"initialDelaySeconds": 15,

go/internal/controller/translator/agent/testdata/outputs/agent_with_mcp_service.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
],
196196
"readinessProbe": {
197197
"httpGet": {
198-
"path": "/health",
198+
"path": "/.well-known/agent.json",
199199
"port": "http"
200200
},
201201
"initialDelaySeconds": 15,

go/internal/controller/translator/agent/testdata/outputs/agent_with_nested_agent.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
],
194194
"readinessProbe": {
195195
"httpGet": {
196-
"path": "/health",
196+
"path": "/.well-known/agent.json",
197197
"port": "http"
198198
},
199199
"initialDelaySeconds": 15,

go/internal/controller/translator/agent/testdata/outputs/agent_with_passthrough.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
],
179179
"readinessProbe": {
180180
"httpGet": {
181-
"path": "/health",
181+
"path": "/.well-known/agent.json",
182182
"port": "http"
183183
},
184184
"initialDelaySeconds": 15,

0 commit comments

Comments
 (0)