Skip to content

Commit 5ceeb8b

Browse files
committed
Added deref timeouts. Adjusted sleeps.
In order to make the tests more resilient, added timeouts to derefs so that the tests would not hang. Adjusted the sleeps so that there was a better chance that the tests would not be flaky.
1 parent ce9a64a commit 5ceeb8b

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

test/eca/features/chat_test.clj

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,16 @@
258258
:call-tool-mock
259259
;; Ensure that the tools complete in the 3-2-1 order by adjusting sleep times
260260
(fn [name & _others]
261+
;; When this is called, we are already in a future.
261262
(case name
262263

263264
"ro_tool_1"
264-
(do (deep-sleep 300)
265+
(do (deep-sleep 900)
265266
{:error false
266267
:contents [{:type :text :content "RO tool call 1 result"}]})
267268

268269
"ro_tool_2"
269-
(do (deep-sleep 200)
270+
(do (deep-sleep 600)
270271
{:error false
271272
:contents [{:type :text :content "RO tool call 2 result"}]})
272273

@@ -347,8 +348,9 @@
347348
(on-prepare-tool-call {:id "call-1" :name "ro_tool_1" :arguments-text ""})
348349
(on-prepare-tool-call {:id "call-2" :name "ro_tool_2" :arguments-text ""})
349350
(on-prepare-tool-call {:id "call-3" :name "ro_tool_3" :arguments-text ""})
350-
(future (Thread/sleep 200)
351-
(deref wait-for-tool3)
351+
(future (Thread/sleep 400)
352+
(when (= :timeout (deref wait-for-tool3 10000 :timeout))
353+
(println "tool-calls-with-prompt-stop-test: deref in prompt stop future timed out"))
352354
(Thread/sleep 50)
353355
(f.chat/prompt-stop {:chat-id chat-id} (h/db*) (h/messenger) (h/metrics))
354356
(deliver wait-for-stop true))
@@ -357,23 +359,26 @@
357359
{:id "call-3" :name "ro_tool_3" :arguments {}}])))
358360
:call-tool-mock
359361
(fn [name & _others]
362+
;; When this is called, we are already in a future
360363
(case name
361364

362365
"ro_tool_1"
363-
(do (deep-sleep 350)
364-
(deref wait-for-tool2)
366+
(do (deep-sleep 1000)
367+
(when (= :timeout (deref wait-for-tool2 10000 :timeout))
368+
(println "tool-calls-with-prompt-stop-test: deref in tool 1 timed out"))
365369
{:error false
366370
:contents [{:type :text :content "RO tool call 1 result"}]})
367371

368372
"ro_tool_2"
369-
(do (deep-sleep 300)
370-
(deref wait-for-stop)
373+
(do (deep-sleep 800)
374+
(when (= :timeout (deref wait-for-stop 10000 :timeout))
375+
(println "tool-calls-with-prompt-stop-test: deref in tool 2 timed out"))
371376
(deliver wait-for-tool2 true)
372377
{:error false
373378
:contents [{:type :text :content "RO tool call 2 result"}]})
374379

375380
"ro_tool_3"
376-
(do (deep-sleep 100)
381+
(do (deep-sleep 200)
377382
(deliver wait-for-tool3 true)
378383
{:error false
379384
:contents [{:type :text :content "RO tool call 3 result"}]})))})]

0 commit comments

Comments
 (0)