Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

test(weaviate): 让并发建表的用例真的每个 worker 都去创建,消掉随机失败

linus-liu-web1912ba26c544
diff --git a/internal/application/repository/retriever/weaviate/repository_test.go b/internal/application/repository/retriever/weaviate/repository_test.go
index 37b7808d3..846084ce5 100644
--- a/internal/application/repository/retriever/weaviate/repository_test.go
+++ b/internal/application/repository/retriever/weaviate/repository_test.go
@@ -39,13 +39,18 @@ func (s *schemaTestServer) repository(t *testing.T) *weaviateRepository {
w.Header().Set("Content-Type", "application/json")
switch {
case r.Method == http.MethodGet && strings.HasPrefix(r.URL.Path, "/v1/schema/"):
- if s.probe != nil {
- s.probe()
- }
+ // Answer from the state the worker found on arrival, before the
+ // barrier releases the race. Sampling after it instead lets the
+ // winner's create turn into an "already exists" answer for whoever
+ // the scheduler runs last, so that worker skips the create
+ // entirely and fewer than `workers` creates ever reach the server.
s.mu.Lock()
s.probes++
exists := s.exists
s.mu.Unlock()
+ if s.probe != nil {
+ s.probe()
+ }
if !exists {
w.WriteHeader(http.StatusNotFound)
return