Skip to content
Snippets Groups Projects
Unverified Commit 443adece authored by Cam Saul's avatar Cam Saul Committed by GitHub
Browse files

Potential fixes for occasional cache test failure (#11987)

parent cf70be41
No related branches found
No related tags found
No related merge requests found
......@@ -105,7 +105,6 @@
([] (rf))
([result]
;; TODO - what about the final result? Are we ignoring it completely?
(a/close! in-chan)
(let [duration-ms (- (System/currentTimeMillis) start-time)]
(log/info (trs "Query took {0} to run; miminum for cache eligibility is {1}"
......
......@@ -104,17 +104,18 @@
(let [orig @save-chan*]
(try
(reset! save-chan* save-chan)
(let [orig impl/serialize-async]
(with-redefs [impl/serialize-async (fn [& args]
(u/prog1 (apply orig args)
(a/go
(let [result (a/<! (:out-chan <>))]
(when (instance? Throwable result)
(a/>!! save-chan (or (:type (ex-data result))
::exception)))))))]
(let [orig (var-get #'cache/cache-results-async!)]
(with-redefs [cache/cache-results-async! (fn [query-hash out-chan]
(a/go
(when-let [result (a/<! out-chan)]
(when (instance? Throwable result)
(a/>!! save-chan (or (:type (ex-data result))
::exception)))))
(orig query-hash out-chan))]
(u/prog1 (thunk)
(is (= expected-result
(mt/wait-for-result save-chan 500))))))
(testing "waiting for save"
(is (= expected-result
(mt/wait-for-result save-chan 1000)))))))
(finally
(reset! save-chan* orig))))))
......@@ -130,8 +131,9 @@
(try
(reset! purge-chan* purge-chan)
(u/prog1 (thunk)
(is (= expected-result
(mt/wait-for-result purge-chan 500))))
(testing "waiting for purge"
(is (= expected-result
(mt/wait-for-result purge-chan 500)))))
(finally (reset! purge-chan* orig))))))
(defmacro ^:private wait-for-purge-result {:style/indent 1} [expected-result & body]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment