mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
test(integration): add e2e testing suite and infrastructure
Introduces a comprehensive integration testing setup and local development environment. Changes include: - Add `docker-compose.yml` for local stack orchestration. - Add `docker-compose.integration.yml` for the integration test environment. - Create `mock-upstream` service to simulate external LLM provider responses. - Implement Go-based end-to-end tests verifying control plane configuration and data plane routing. - Add `integration_test.sh` for quick connectivity verification.
This commit is contained in:
51
integration/mock-upstream/main.go
Normal file
51
integration/mock-upstream/main.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("ok"))
|
||||
})
|
||||
|
||||
mux.HandleFunc("/v1/chat/completions", func(w http.ResponseWriter, r *http.Request) {
|
||||
resp := map[string]interface{}{
|
||||
"id": "mock-completion",
|
||||
"object": "chat.completion",
|
||||
"choices": []map[string]interface{}{
|
||||
{
|
||||
"index": 0,
|
||||
"message": map[string]string{
|
||||
"role": "assistant",
|
||||
"content": "hello from mock",
|
||||
},
|
||||
"finish_reason": "stop",
|
||||
},
|
||||
},
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(resp)
|
||||
})
|
||||
|
||||
mux.HandleFunc("/v1/models", func(w http.ResponseWriter, r *http.Request) {
|
||||
resp := map[string]interface{}{
|
||||
"object": "list",
|
||||
"data": []map[string]string{
|
||||
{"id": "mock-model", "object": "model", "owned_by": "mock"},
|
||||
},
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(resp)
|
||||
})
|
||||
|
||||
log.Println("mock-upstream listening on :8082")
|
||||
if err := http.ListenAndServe(":8082", mux); err != nil {
|
||||
log.Fatalf("mock-upstream failed: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user