Skip to content

Commit

Permalink
replace clamav fixture blind sleep with health polling
Browse files Browse the repository at this point in the history
  • Loading branch information
Erno Kuusela committed Aug 15, 2023
1 parent 0552802 commit 61eed6d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/laundry/antivirus_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@
[ring.mock.request :as mock]
[ring.util.request]))

(defn query-clamav-health! []
(let [ret (shell/sh
"docker" "inspect" "-f" "{{.State.Running}}" "laundry-clamav")]
(-> ret
:out
string/trim-newline)))

(defn laundry-clamav-fixture! [f]
(shell/sh "docker" "run" "--name" "laundry-clamav" "--env" "CLAMAV_NO_FRESHCLAMD=true" "--network=none" "--rm" "-d" "clamav/clamav:latest")
;; clamd bootup is somewhat slow, thus need to sleep a bit before container can be used
(Thread/sleep 30000)
;; clamd bootup is slow, thus need to wait for container healthy stat
(while (not= "healthy" (query-clamav-health!))
(println "waiting for clamav container healthy status")
(Thread/sleep 5000))
(f)
(shell/sh "docker" "stop" "laundry-clamav"))

Expand Down

0 comments on commit 61eed6d

Please sign in to comment.