nic-6443 opened a new pull request, #13234:
URL: https://github.com/apache/apisix/pull/13234

   ### Description
   
   This replaces inline `content_by_lua_block` mock servers across all AI test 
files with a centralized fixture-based system, cutting ~1200 lines of 
duplicated mock code.
   
   Tests now specify mock responses via the `X-AI-Fixture` request header, 
pointing to static fixture files in `t/fixtures/`.
   
   ### What changed
   
   **Infrastructure:**
   - `t/lib/fixture_loader.lua`: loads fixture files, auto-detects Content-Type 
(.json/.sse), supports `{{model}}` template substitution and 
`X-AI-Fixture-Status` for custom status codes
   - `t/lib/server.lua`: added AI endpoints (v1_chat_completions, v1_messages, 
v1_embeddings, v1_responses, delay_v1_chat_completions, etc.) that dispatch to 
fixture_loader
   - `t/fixtures/`: 31 fixture files organized by provider (openai, anthropic, 
protocol-conversion, vertex-ai, aliyun, prometheus)
   
   **22 test files converted** from inline mocks to fixture-based approach.
   
   **Files kept with inline mocks** (require dynamic/stateful behavior):
   - ai-proxy-multi.balancer.t, ai-proxy-multi3.t
   - ai-aliyun-content-moderation.t (moderation endpoint)
   - ai-proxy.t TEST 20/22/23/24b (header forwarding), TEST 31 (fragmented SSE)
   
   ### How it works
   
   ```
   Before:  server { listen 6724; content_by_lua_block { ... 50+ lines ... } }
   After:   --- more_headers\n  X-AI-Fixture: openai/chat-basic.json
   ```
   
   The fixture loader reads the file and serves it with the correct 
Content-Type. The `{{model}}` template gets replaced with the model from the 
request body at serve time.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to