docs(bf-413h): verify JSON helper functions with comprehensive testing
This commit is contained in:
parent
01bc82714b
commit
e8c6b4fbb5
6 changed files with 158 additions and 17 deletions
|
|
@ -40,13 +40,13 @@ kubectl rollout undo deployment/zai-proxy -n mcp
|
|||
|
||||
- [ ] Canary is receiving traffic (if using split traffic)
|
||||
```bash
|
||||
curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/metrics | grep zai_proxy_requests_total
|
||||
curl -s http://zai-proxy-test.devpod.svc.cluster.local:8080/metrics | grep zai_proxy_requests_total
|
||||
```
|
||||
|
||||
### Functional Testing
|
||||
- [ ] Health endpoint responds
|
||||
```bash
|
||||
curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/health
|
||||
curl -s http://zai-proxy-test.devpod.svc.cluster.local:8080/health
|
||||
```
|
||||
Expected: `{"status":"ok"}`
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ kubectl rollout undo deployment/zai-proxy -n mcp
|
|||
|
||||
- [ ] Metrics are being exported
|
||||
```bash
|
||||
curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/metrics | grep zai_proxy_tokens_total
|
||||
curl -s http://zai-proxy-test.devpod.svc.cluster.local:8080/metrics | grep zai_proxy_tokens_total
|
||||
```
|
||||
Expected: Metrics with `variant="test"` label
|
||||
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ br create "Fix canary high error rate - vVERSION" \
|
|||
# Query: histogram_quantile(0.90, sum(rate(zai_proxy_request_duration_seconds_bucket{variant="test"}[5m])) by (le))
|
||||
|
||||
# 2. Check token counting overhead
|
||||
curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/metrics | \
|
||||
curl -s http://zai-proxy-test.devpod.svc.cluster.local:8080/metrics | \
|
||||
grep zai_proxy_token_count_duration_seconds
|
||||
|
||||
# 3. If token counting is slow (>100ms p99), disable it temporarily
|
||||
|
|
@ -560,7 +560,7 @@ grep -r "zai-proxy" ~/.beads-workers/*.log
|
|||
|
||||
# 4. If workers pointing to canary service, update them
|
||||
# Workers should use: http://zai-proxy.devpod.svc.cluster.local:8080
|
||||
# NOT: http://zai-proxy-canary.mcp.svc.cluster.local:8080
|
||||
# NOT: http://zai-proxy-canary.devpod.svc.cluster.local:8080
|
||||
|
||||
# 5. Restart affected workers
|
||||
# Find worker session
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ kubectl get svc zai-proxy-test -n mcp
|
|||
kubectl get endpoints zai-proxy-test -n mcp
|
||||
|
||||
# Test from devpod
|
||||
curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/health
|
||||
curl -s http://zai-proxy-test.devpod.svc.cluster.local:8080/health
|
||||
|
||||
# Check service selector matches pods
|
||||
kubectl get svc zai-proxy-test -n mcp \
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ The zai-proxy service supports **dual deployment mode** for safe testing and gra
|
|||
| Deployment | Service Name | Purpose | Endpoint URL |
|
||||
|------------|--------------|---------|--------------|
|
||||
| **Production** | `zai-proxy.devpod.svc.cluster.local:8080` | Live traffic | `http://zai-proxy.devpod.svc.cluster.local:8080/api/anthropic` |
|
||||
| **Canary** | `zai-proxy-test.mcp.svc.cluster.local:8080` | Testing new versions | `http://zai-proxy-test.devpod.svc.cluster.local:8080/api/anthropic` |
|
||||
| **Split Traffic** | `zai-proxy-canary.mcp.svc.cluster.local:8080` | Weighted traffic split | `http://zai-proxy-canary.devpod.svc.cluster.local:8080/api/anthropic` |
|
||||
| **Canary** | `zai-proxy-test.devpod.svc.cluster.local:8080` | Testing new versions | `http://zai-proxy-test.devpod.svc.cluster.local:8080/api/anthropic` |
|
||||
| **Split Traffic** | `zai-proxy-canary.devpod.svc.cluster.local:8080` | Weighted traffic split | `http://zai-proxy-canary.devpod.svc.cluster.local:8080/api/anthropic` |
|
||||
|
||||
## Architecture
|
||||
|
||||
|
|
@ -123,11 +123,11 @@ curl -s http://zai-proxy.devpod.svc.cluster.local:8080/health
|
|||
# Expected: {"status":"ok"}
|
||||
|
||||
# Test canary endpoint
|
||||
curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/health
|
||||
curl -s http://zai-proxy-test.devpod.svc.cluster.local:8080/health
|
||||
# Expected: {"status":"ok"}
|
||||
|
||||
# Test split traffic endpoint
|
||||
curl -s http://zai-proxy-canary.mcp.svc.cluster.local:8080/health
|
||||
curl -s http://zai-proxy-canary.devpod.svc.cluster.local:8080/health
|
||||
# Expected: {"status":"ok"}
|
||||
```
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ curl -s http://zai-proxy-canary.mcp.svc.cluster.local:8080/health
|
|||
```bash
|
||||
# From within a devpod, check DNS resolution
|
||||
nslookup zai-proxy.devpod.svc.cluster.local
|
||||
nslookup zai-proxy-test.mcp.svc.cluster.local
|
||||
nslookup zai-proxy-test.devpod.svc.cluster.local
|
||||
|
||||
# Check service endpoints
|
||||
kubectl get endpoints -n mcp | grep zai-proxy
|
||||
|
|
@ -195,10 +195,10 @@ br create "Test canary endpoint connectivity" \
|
|||
|
||||
```bash
|
||||
# Check canary proxy metrics
|
||||
curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/metrics | grep zai_proxy_requests_total
|
||||
curl -s http://zai-proxy-test.devpod.svc.cluster.local:8080/metrics | grep zai_proxy_requests_total
|
||||
|
||||
# Verify variant label in metrics
|
||||
curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/metrics | grep deployment_variant
|
||||
curl -s http://zai-proxy-test.devpod.svc.cluster.local:8080/metrics | grep deployment_variant
|
||||
# Should show: deployment_variant="canary"
|
||||
```
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/metrics | grep deployme
|
|||
|
||||
- [ ] **Run smoke tests on canary endpoint**
|
||||
```bash
|
||||
curl -X POST http://zai-proxy-test.mcp.svc.cluster.local:8080/v1/messages \
|
||||
curl -X POST http://zai-proxy-test.devpod.svc.cluster.local:8080/v1/messages \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $ZAI_API_KEY" \
|
||||
-d '{"model":"claude-3-sonnet","messages":[{"role":"user","content":"test"}],"max_tokens":10}'
|
||||
|
|
@ -231,7 +231,7 @@ curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/metrics | grep deployme
|
|||
|
||||
- [ ] **Review canary metrics for baseline**
|
||||
```bash
|
||||
curl -s http://zai-proxy-test.mcp.svc.cluster.local:8080/metrics
|
||||
curl -s http://zai-proxy-test.devpod.svc.cluster.local:8080/metrics
|
||||
```
|
||||
|
||||
### Migration
|
||||
|
|
@ -434,9 +434,9 @@ histogram_quantile(0.95,
|
|||
| Canary | `http://zai-proxy-test.devpod.svc.cluster.local:8080/api/anthropic` | Testing new versions |
|
||||
| Split | `http://zai-proxy-canary.devpod.svc.cluster.local:8080/api/anthropic` | Weighted traffic splitting |
|
||||
| Metrics (Prod) | `http://zai-proxy.devpod.svc.cluster.local:8080/metrics` | Production metrics |
|
||||
| Metrics (Canary) | `http://zai-proxy-test.mcp.svc.cluster.local:8080/metrics` | Canary metrics |
|
||||
| Metrics (Canary) | `http://zai-proxy-test.devpod.svc.cluster.local:8080/metrics` | Canary metrics |
|
||||
| Health (Prod) | `http://zai-proxy.devpod.svc.cluster.local:8080/health` | Production health check |
|
||||
| Health (Canary) | `http://zai-proxy-test.mcp.svc.cluster.local:8080/health` | Canary health check |
|
||||
| Health (Canary) | `http://zai-proxy-test.devpod.svc.cluster.local:8080/health` | Canary health check |
|
||||
|
||||
## Summary
|
||||
|
||||
|
|
|
|||
45
notes/bf-2kl8.md
Normal file
45
notes/bf-2kl8.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Namespace Reference Cleanup - zai-proxy.mcp → devpod
|
||||
|
||||
**Bead:** bf-2kl8
|
||||
**Date:** 2026-07-02
|
||||
**Status:** Complete
|
||||
|
||||
## Summary
|
||||
|
||||
Removed all remaining references to `zai-proxy.mcp.svc.cluster.local` from the codebase and replaced them with the correct `devpod` namespace.
|
||||
|
||||
## Files Modified
|
||||
|
||||
1. **docs/notes/CANARY_TROUBLESHOOTING_GUIDE.md**
|
||||
- Line 416: `zai-proxy-test.mcp.svc.cluster.local` → `zai-proxy-test.devpod.svc.cluster.local`
|
||||
|
||||
2. **docs/notes/CANARY_PROMOTION_CHECKLIST.md**
|
||||
- Line 43: `zai-proxy-test.mcp.svc.cluster.local` → `zai-proxy-test.devpod.svc.cluster.local`
|
||||
- Line 49: `zai-proxy-test.mcp.svc.cluster.local` → `zai-proxy-test.devpod.svc.cluster.local`
|
||||
- Line 61: `zai-proxy-test.mcp.svc.cluster.local` → `zai-proxy-test.devpod.svc.cluster.local`
|
||||
|
||||
3. **docs/notes/DEPLOYMENT.md**
|
||||
- All service endpoint URLs updated from `.mcp.svc.cluster.local` to `.devpod.svc.cluster.local`
|
||||
- References to `zai-proxy-test`, `zai-proxy-canary`, and other services fixed
|
||||
|
||||
4. **docs/notes/CANARY_ROLLBACK_PROCEDURE.md**
|
||||
- Line 411: `zai-proxy-test.mcp.svc.cluster.local` → `zai-proxy-test.devpod.svc.cluster.local`
|
||||
- Line 563: `zai-proxy-canary.mcp.svc.cluster.local` → `zai-proxy-canary.devpod.svc.cluster.local`
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
# Final verification - no remaining references in code/config/docs
|
||||
grep -r "\.mcp\.svc\.cluster\.local" --include="*.go" --include="*.yaml" --include="*.md" . 2>/dev/null | grep -v "notes/bf-3ik4.md"
|
||||
# Result: No matches found
|
||||
```
|
||||
|
||||
## Acceptance Criteria Met
|
||||
|
||||
- ✅ No `zai-proxy.mcp.svc.cluster.local` found in any .go, .yaml, .md files
|
||||
- ✅ All replacements use the correct `devpod` namespace
|
||||
- ✅ Service endpoint URLs updated consistently across all documentation
|
||||
|
||||
## Related Work
|
||||
|
||||
This cleanup follows the previous namespace migration work documented in `notes/bf-3ik4.md`.
|
||||
96
notes/bf-413h.md
Normal file
96
notes/bf-413h.md
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# JSON Helper Verification (bf-413h)
|
||||
|
||||
## Summary
|
||||
|
||||
Verified all JSON-related helper functions in `proxy/helpers_test.go` and their corresponding tests in `proxy/response_assertions_test.go`. All acceptance criteria met.
|
||||
|
||||
## Acceptance Criteria Verification
|
||||
|
||||
### 1. AssertJSONBody() validates JSON and returns boolean ✅
|
||||
|
||||
**Function signature:** `AssertJSONBody(t *testing.T, resp *http.Response) bool`
|
||||
|
||||
**Test cases verified:**
|
||||
- ✅ Valid JSON objects return `true`
|
||||
- ✅ Valid JSON arrays return `true`
|
||||
- ✅ Complex nested JSON structures return `true`
|
||||
- ✅ Invalid JSON (empty body) triggers error and returns `false`
|
||||
- ✅ Invalid JSON (malformed) triggers error and returns `false`
|
||||
|
||||
**Test function:** `TestAssertJSONBody` in `proxy/response_assertions_test.go` (lines 137-203)
|
||||
|
||||
### 2. AssertResponseField() validates specific JSON field values ✅
|
||||
|
||||
**Function signature:** `AssertResponseField(t *testing.T, resp *http.Response, field string, expectedValue interface{})`
|
||||
|
||||
**Test cases verified:**
|
||||
- ✅ String field validation with matching values
|
||||
- ✅ Multiple field checks work correctly
|
||||
- ✅ Numeric field values (JSON numbers unmarshal to float64)
|
||||
- ✅ Boolean field values
|
||||
- ✅ Missing fields trigger errors
|
||||
- ✅ Field path traversal works correctly
|
||||
|
||||
**Test function:** `TestAssertResponseField` in `proxy/response_assertions_test.go` (lines 205-247)
|
||||
|
||||
### 3. ReadResponseBody() reads response body correctly ✅
|
||||
|
||||
**Function signature:** `ReadResponseBody(t *testing.T, resp *http.Response) []byte`
|
||||
|
||||
**Test cases verified:**
|
||||
- ✅ Reads non-empty bodies correctly
|
||||
- ✅ Reads empty bodies (returns empty slice)
|
||||
- ✅ Reads binary data without corruption
|
||||
- ✅ Handles large bodies (10KB tested)
|
||||
- ✅ Preserves JSON body content exactly
|
||||
|
||||
**Test function:** `TestReadResponseBody` in `proxy/response_assertions_test.go` (lines 343-409)
|
||||
|
||||
### 4. ReadJSONResponse() parses JSON into map correctly ✅
|
||||
|
||||
**Function signature:** `ReadJSONResponse(t *testing.T, resp *http.Response) map[string]interface{}`
|
||||
|
||||
**Test cases verified:**
|
||||
- ✅ Parses simple JSON objects into maps
|
||||
- ✅ Handles nested JSON objects correctly
|
||||
- ✅ Parses JSON with various types (string, number, float, bool, null)
|
||||
- ✅ Handles complex API response structures
|
||||
- ✅ Numbers unmarshal to float64 correctly
|
||||
- ✅ Null values handled properly
|
||||
|
||||
**Test function:** `TestReadJSONResponse` in `proxy/response_assertions_test.go` (lines 411-484)
|
||||
|
||||
## Additional Integration Tests
|
||||
|
||||
The following integration tests were also verified:
|
||||
|
||||
- **TestCombinedAssertions** (lines 570-624): Verifies multiple assertions work together in realistic API scenarios
|
||||
- **TestHelperFunctionReturnValues** (lines 626-675): Validates return value types and behavior
|
||||
|
||||
## Test Results
|
||||
|
||||
All JSON helper tests passed successfully:
|
||||
|
||||
```
|
||||
--- PASS: TestAssertJSONBody (0.00s)
|
||||
--- PASS: TestAssertResponseField (0.00s)
|
||||
--- PASS: TestReadResponseBody (0.00s)
|
||||
--- PASS: TestReadJSONResponse (0.00s)
|
||||
--- PASS: TestCombinedAssertions (0.00s)
|
||||
--- PASS: TestHelperFunctionReturnValues (0.00s)
|
||||
```
|
||||
|
||||
## Error Handling Coverage
|
||||
|
||||
The tests verify proper error handling for:
|
||||
- Invalid JSON syntax (unclosed braces, truncated content)
|
||||
- Empty response bodies
|
||||
- Malformed JSON data
|
||||
- Missing response fields
|
||||
- Binary data corruption
|
||||
|
||||
All error paths correctly call `t.Errorf` or `t.Fatalf` with descriptive messages.
|
||||
|
||||
## Conclusion
|
||||
|
||||
All acceptance criteria for bead bf-413h have been verified and met. The JSON helper functions are correctly implemented with comprehensive test coverage.
|
||||
Loading…
Add table
Reference in a new issue