This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-04
Channels
- # announcements (4)
- # aws (3)
- # babashka (58)
- # beginners (59)
- # biff (6)
- # cider (3)
- # clj-kondo (48)
- # clj-on-windows (1)
- # cljdoc (1)
- # clojure (136)
- # clojure-europe (19)
- # clojure-gamedev (7)
- # clojure-germany (2)
- # clojure-nl (7)
- # clojure-norway (1)
- # clojure-portugal (1)
- # clojure-uk (4)
- # clojurescript (41)
- # community-development (2)
- # core-async (5)
- # cursive (10)
- # data-oriented-programming (1)
- # data-science (1)
- # datahike (5)
- # datomic (60)
- # docker (2)
- # emacs (13)
- # figwheel-main (19)
- # fulcro (12)
- # graalvm (9)
- # holy-lambda (41)
- # honeysql (14)
- # introduce-yourself (3)
- # jobs (4)
- # lsp (11)
- # nrepl (1)
- # off-topic (9)
- # other-languages (2)
- # pathom (22)
- # portal (5)
- # re-frame (17)
- # remote-jobs (4)
- # reveal (14)
- # shadow-cljs (1)
- # tools-build (7)
- # tools-deps (47)
- # xtdb (8)
- # yada (2)
Hi, I have a question regarding a core.async test. I have a potentially infinite lazy-seq that is being produced to a chan
(named request-chan
) via onto-chan!
. I’m performing some parallel operation and producing results to another chan
named response-chan
. However, I only want this operation to run for a certain period of time, so I have another go
block where I call close!
on request-chan
after a timeout
chan produces a value. I have a test written that calls (a/into [] response-chan)
before setting up the pipeline and timeout. My test then blocks until the result from the aforementioned a/into
is available. My test then asserts that the result is non-empty. My test specifies a timeout value of 100ms. Locally, this test always passes. However, on our CI server where multiple tests from multiple projects are competing for CPU resources, this test can become resource starved. The timeout
fires and closes the request-chan
before onto-chan!
can produce anything from the lazy-seq onto the chan. Has anyone run into similar issues before? Any suggestions on how we should design our tests around this?
You'll kind of have the problem that if your thing doesn't work your test never finishes though, but you could put a much bigger timeout on it then. So it could end either in 5min or if something was taken.
(a/go
(let [res (a/alt! response-chan :success
(a/timeout 5000) :failed)]
(a/close! request-chan)
(is (= res :success)))
That makes sense. I’ll go that route. Thank you!