You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by xu...@apache.org on 2026/03/23 01:41:32 UTC

(dubbo-go-pixiu-samples) branch main updated: fix: fix CI problems (#129)

This is an automated email from the ASF dual-hosted git repository.

xuetaoli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu-samples.git


The following commit(s) were added to refs/heads/main by this push:
     new 2f0ecf9  fix: fix CI problems (#129)
2f0ecf9 is described below

commit 2f0ecf9e712a54f01ffbf27f70621fef16e4a5dc
Author: 陈乐樂 <12...@qq.com>
AuthorDate: Mon Mar 23 09:41:26 2026 +0800

    fix: fix CI problems (#129)
    
    * feat: add kvcache samples
    
    * fix some problems
    
    * fix:fix some bugs and add headers
    
    * feat:add integrate test
    
    * feat: add descriptions to readme
    
    * fix: fix ci problems
    
    * remove replace
    
    * replace gomod gosum
---
 ai/kvcache/mock/pixiu/conf.yaml         | 10 ++++++++--
 ai/kvcache/mock/server/app/main.go      | 27 +++++++++++++++++++++++----
 ai/kvcache/mock/server/engine-a/main.go | 16 ++++++++++++++++
 ai/kvcache/mock/server/engine-b/main.go | 16 ++++++++++++++++
 ai/kvcache/real-engine/pixiu/conf.yaml  | 10 ++++++++--
 go.sum                                  |  2 +-
 6 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/ai/kvcache/mock/pixiu/conf.yaml b/ai/kvcache/mock/pixiu/conf.yaml
index 7c50c85..313ad97 100644
--- a/ai/kvcache/mock/pixiu/conf.yaml
+++ b/ai/kvcache/mock/pixiu/conf.yaml
@@ -78,14 +78,20 @@ static_resources:
     - name: "mock_llm"
       lb_policy: "round_robin"
       endpoints:
-        - id: "mock-llm-a"
+        - ID: "mock-llm-a"
           socket_address:
             address: "127.0.0.1"
             port: 18091
-        - id: "mock-llm-b"
+          llm_meta:
+            retry_policy:
+              name: "NoRetry"
+        - ID: "mock-llm-b"
           socket_address:
             address: "127.0.0.1"
             port: 18092
+          llm_meta:
+            retry_policy:
+              name: "NoRetry"
 
   shutdown_config:
     timeout: "10s"
diff --git a/ai/kvcache/mock/server/app/main.go b/ai/kvcache/mock/server/app/main.go
index 957201f..95a676d 100644
--- a/ai/kvcache/mock/server/app/main.go
+++ b/ai/kvcache/mock/server/app/main.go
@@ -105,10 +105,11 @@ func main() {
 	preferredEndpoint := envOrDefault("PREFERRED_ENDPOINT_ID", "mock-llm-b")
 	engineAID := envOrDefault("LLM_A_ID", "mock-llm-a")
 	engineBID := envOrDefault("LLM_B_ID", "mock-llm-b")
+	responseDelay := envDurationMSOrDefault("MOCK_LLM_RESPONSE_DELAY_MS", 150)
 
 	controller := buildControllerMux(preferredEndpoint)
-	engineA := buildEngineAMux(engineAID)
-	engineB := buildEngineBMux(engineBID)
+	engineA := buildEngineAMux(engineAID, responseDelay)
+	engineB := buildEngineBMux(engineBID, responseDelay)
 
 	errCh := make(chan error, 3)
 	go serve("mock-controller", controllerAddr, controller, errCh)
@@ -239,7 +240,7 @@ func handleTokenEvent(stats *controllerStats, w http.ResponseWriter, r *http.Req
 	writeJSON(w, http.StatusOK, eventResp{EventID: nextEventID(op), NumTokens: len(req.Tokens)})
 }
 
-func buildEngineAMux(engineID string) http.Handler {
+func buildEngineAMux(engineID string, responseDelay time.Duration) http.Handler {
 	stats := &engineAStats{}
 	mux := http.NewServeMux()
 
@@ -294,6 +295,9 @@ func buildEngineAMux(engineID string) http.Handler {
 		stats.mu.Lock()
 		stats.chatCalls++
 		stats.mu.Unlock()
+		if responseDelay > 0 {
+			time.Sleep(responseDelay)
+		}
 
 		resp := llmResponse{
 			ID:       nextEventID("chatcmpl"),
@@ -315,7 +319,7 @@ func buildEngineAMux(engineID string) http.Handler {
 	return mux
 }
 
-func buildEngineBMux(engineID string) http.Handler {
+func buildEngineBMux(engineID string, responseDelay time.Duration) http.Handler {
 	stats := &engineBStats{}
 	mux := http.NewServeMux()
 
@@ -358,6 +362,9 @@ func buildEngineBMux(engineID string) http.Handler {
 		stats.mu.Lock()
 		stats.chatCalls++
 		stats.mu.Unlock()
+		if responseDelay > 0 {
+			time.Sleep(responseDelay)
+		}
 
 		resp := llmResponse{
 			ID:       nextEventID("chatcmpl"),
@@ -457,6 +464,18 @@ func envOrDefault(key string, fallback string) string {
 	return val
 }
 
+func envDurationMSOrDefault(key string, fallbackMS int) time.Duration {
+	val, ok := os.LookupEnv(key)
+	if !ok || strings.TrimSpace(val) == "" {
+		return time.Duration(fallbackMS) * time.Millisecond
+	}
+	ms, err := strconv.Atoi(strings.TrimSpace(val))
+	if err != nil || ms < 0 {
+		return time.Duration(fallbackMS) * time.Millisecond
+	}
+	return time.Duration(ms) * time.Millisecond
+}
+
 func max(a int, b int) int {
 	if a > b {
 		return a
diff --git a/ai/kvcache/mock/server/engine-a/main.go b/ai/kvcache/mock/server/engine-a/main.go
index bb24e05..cdaa6d0 100644
--- a/ai/kvcache/mock/server/engine-a/main.go
+++ b/ai/kvcache/mock/server/engine-a/main.go
@@ -71,6 +71,7 @@ var eventCounter uint64
 func main() {
 	addr := envOrDefault("LLM_A_ADDR", ":18091")
 	engineID := envOrDefault("LLM_A_ID", "mock-llm-a")
+	responseDelay := envDurationMSOrDefault("MOCK_LLM_RESPONSE_DELAY_MS", 150)
 	stats := &engineStats{}
 
 	mux := http.NewServeMux()
@@ -127,6 +128,9 @@ func main() {
 		stats.mu.Lock()
 		stats.chatCalls++
 		stats.mu.Unlock()
+		if responseDelay > 0 {
+			time.Sleep(responseDelay)
+		}
 
 		resp := llmResponse{
 			ID:       nextEventID("chatcmpl"),
@@ -229,3 +233,15 @@ func envOrDefault(key string, fallback string) string {
 	}
 	return val
 }
+
+func envDurationMSOrDefault(key string, fallbackMS int) time.Duration {
+	val, ok := os.LookupEnv(key)
+	if !ok || strings.TrimSpace(val) == "" {
+		return time.Duration(fallbackMS) * time.Millisecond
+	}
+	ms, err := strconv.Atoi(strings.TrimSpace(val))
+	if err != nil || ms < 0 {
+		return time.Duration(fallbackMS) * time.Millisecond
+	}
+	return time.Duration(ms) * time.Millisecond
+}
diff --git a/ai/kvcache/mock/server/engine-b/main.go b/ai/kvcache/mock/server/engine-b/main.go
index c5ebcab..caa1e92 100644
--- a/ai/kvcache/mock/server/engine-b/main.go
+++ b/ai/kvcache/mock/server/engine-b/main.go
@@ -64,6 +64,7 @@ var eventCounter uint64
 func main() {
 	addr := envOrDefault("LLM_B_ADDR", ":18092")
 	engineID := envOrDefault("LLM_B_ID", "mock-llm-b")
+	responseDelay := envDurationMSOrDefault("MOCK_LLM_RESPONSE_DELAY_MS", 150)
 	stats := &engineStats{}
 
 	mux := http.NewServeMux()
@@ -107,6 +108,9 @@ func main() {
 		stats.mu.Lock()
 		stats.chatCalls++
 		stats.mu.Unlock()
+		if responseDelay > 0 {
+			time.Sleep(responseDelay)
+		}
 
 		resp := llmResponse{
 			ID:       nextEventID("chatcmpl"),
@@ -150,3 +154,15 @@ func envOrDefault(key string, fallback string) string {
 	}
 	return val
 }
+
+func envDurationMSOrDefault(key string, fallbackMS int) time.Duration {
+	val, ok := os.LookupEnv(key)
+	if !ok || strings.TrimSpace(val) == "" {
+		return time.Duration(fallbackMS) * time.Millisecond
+	}
+	ms, err := strconv.Atoi(strings.TrimSpace(val))
+	if err != nil || ms < 0 {
+		return time.Duration(fallbackMS) * time.Millisecond
+	}
+	return time.Duration(ms) * time.Millisecond
+}
diff --git a/ai/kvcache/real-engine/pixiu/conf.yaml b/ai/kvcache/real-engine/pixiu/conf.yaml
index 4c5e56c..2d47865 100644
--- a/ai/kvcache/real-engine/pixiu/conf.yaml
+++ b/ai/kvcache/real-engine/pixiu/conf.yaml
@@ -82,14 +82,20 @@ static_resources:
     - name: "real_llm"
       lb_policy: "round_robin"
       endpoints:
-        - id: "${ENGINE_ENDPOINT_A_ID}"
+        - ID: "${ENGINE_ENDPOINT_A_ID}"
           socket_address:
             address: "${ENGINE_ENDPOINT_A_HOST}"
             port: ${ENGINE_ENDPOINT_A_PORT}
-        - id: "${ENGINE_ENDPOINT_B_ID}"
+          llm_meta:
+            retry_policy:
+              name: "NoRetry"
+        - ID: "${ENGINE_ENDPOINT_B_ID}"
           socket_address:
             address: "${ENGINE_ENDPOINT_B_HOST}"
             port: ${ENGINE_ENDPOINT_B_PORT}
+          llm_meta:
+            retry_policy:
+              name: "NoRetry"
 
   shutdown_config:
     timeout: "30s"
diff --git a/go.sum b/go.sum
index 96ccaa0..4fbaf84 100644
--- a/go.sum
+++ b/go.sum
@@ -2175,4 +2175,4 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
 sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
 sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
 sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
-sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
+sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
\ No newline at end of file