Skip to content

Commit

Permalink
Timeout integration tests after waiting 30s for server response (cloj…
Browse files Browse the repository at this point in the history
…ure-lsp#1063)

Instead of letting the integration tests wait forever for a response
from the server, this times them out after 30 seconds. This will provide
some additional information in the logs about what the client was
waiting for, helping to debug flaky tests. If 30 seconds isn't long
enough for certain requests, we can either make the timeout longer, or
make the timeout configurable per request.
  • Loading branch information
mainej authored Jun 21, 2022
1 parent 5663f9c commit 6988b37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions cli/integration-test/integration/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,13 @@
#(= method-str (:method %))
:received-requests)]
(:params msg)))

(defn request-and-await-server-response! [client method body]
(let [resp (deref (send-request client method body)
30000
::timeout)]
(if (= ::timeout resp)
(do
(log client :red "timeout waiting for server response to client request:" method)
(throw (ex-info "timeout waiting for server response to client request" {:method method :body body})))
resp)))
2 changes: 1 addition & 1 deletion cli/integration-test/integration/lsp.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
(client/send-notification *mock-client* method body))

(defn request! [[method body]]
@(client/send-request *mock-client* method body))
(client/request-and-await-server-response! *mock-client* method body))

(defn client-awaits-server-diagnostics [path]
(client/await-server-diagnostics *mock-client* path))
Expand Down

0 comments on commit 6988b37

Please sign in to comment.