Skip to content

Commit a27230e

Browse files
ericdalloeca-agent
andcommitted
Fix Windows integration test: notification ordering race in MCP remote tests
On Windows, the `toolCallRunning` and `progress/Calling tool` notifications can arrive in either order due to thread scheduling differences. The `mcp-remote-tool-list-changed-via-tool-call` test assumed strict ordering, causing it to fail on Windows CI. Add `match-contents-unordered` helper that collects N notifications and verifies each expected spec is matched regardless of arrival order. Apply it to both `mcp-remote-tool-call-in-chat` and `mcp-remote-tool-list-changed-via-tool-call` tests for the racing pair. 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
1 parent 7e625c5 commit a27230e

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

integration-test/integration/chat/mcp_remote_test.clj

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[clojure.test :refer [deftest is testing]]
55
[integration.eca :as eca]
66
[integration.fixture :as fixture]
7-
[integration.helper :refer [match-content]]
7+
[integration.helper :refer [match-content match-contents-unordered]]
88
[llm-mock.mocks :as llm.mocks]
99
[matcher-combinators.matchers :as m]
1010
[matcher-combinators.test :refer [match?]]
@@ -107,12 +107,14 @@
107107
:id "mcp-tool-1"
108108
:arguments {:message "hello from mcp"}
109109
:manualApproval false})
110-
(match-content chat-id "assistant" {:type "toolCallRunning"
111-
:origin "mcp"
112-
:name "echo"
113-
:id "mcp-tool-1"
114-
:arguments {:message "hello from mcp"}})
115-
(match-content chat-id "system" {:type "progress" :state "running" :text "Calling tool"})
110+
;; toolCallRunning and progress may arrive in either order on Windows
111+
(match-contents-unordered
112+
[chat-id "assistant" {:type "toolCallRunning"
113+
:origin "mcp"
114+
:name "echo"
115+
:id "mcp-tool-1"
116+
:arguments {:message "hello from mcp"}}]
117+
[chat-id "system" {:type "progress" :state "running" :text "Calling tool"}])
116118

117119
;; Tool called result — echo returns the same message
118120
(match-content chat-id "assistant" {:type "toolCalled"
@@ -237,12 +239,14 @@
237239
:id "mcp-add-tool-1"
238240
:arguments {:name "multiply"}
239241
:manualApproval false})
240-
(match-content chat-id "assistant" {:type "toolCallRunning"
241-
:origin "mcp"
242-
:name "add-tool"
243-
:id "mcp-add-tool-1"
244-
:arguments {:name "multiply"}})
245-
(match-content chat-id "system" {:type "progress" :state "running" :text "Calling tool"})
242+
;; toolCallRunning and progress may arrive in either order on Windows
243+
(match-contents-unordered
244+
[chat-id "assistant" {:type "toolCallRunning"
245+
:origin "mcp"
246+
:name "add-tool"
247+
:id "mcp-add-tool-1"
248+
:arguments {:name "multiply"}}]
249+
[chat-id "system" {:type "progress" :state "running" :text "Calling tool"}])
246250

247251
;; Tool result
248252
(match-content chat-id "assistant" {:type "toolCalled"

integration-test/integration/helper.clj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@
7171
:content content}
7272
(eca/client-awaits-server-notification :chat/contentReceived))))
7373

74+
(defn match-contents-unordered
75+
"Consume the next N chat/contentReceived notifications and verify that
76+
each SPEC is matched by exactly one of them, regardless of arrival
77+
order. Each spec is a triple [chat-id role content]."
78+
[& specs]
79+
(let [n (count specs)
80+
actuals (mapv (fn [_] (eca/client-awaits-server-notification :chat/contentReceived))
81+
(range n))]
82+
(doseq [[chat-id role content] specs]
83+
(is (some #(match? {:chatId chat-id :role role :content content} %) actuals)
84+
(str "Expected a notification with role=" role
85+
" content=" content
86+
" but none of the " n " received matched")))))
87+
7488
(defn match-rewrite-content [rewrite-id content]
7589
(is (match?
7690
{:rewriteId rewrite-id

0 commit comments

Comments
 (0)