Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Ensure thread performing migration finishes first (#63184)

lbrdnk4a01316597f0
diff --git a/enterprise/backend/test/metabase_enterprise/semantic_search/migration_test.clj b/enterprise/backend/test/metabase_enterprise/semantic_search/migration_test.clj
index dce18a83bd8..a6855883ac2 100644
--- a/enterprise/backend/test/metabase_enterprise/semantic_search/migration_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/semantic_search/migration_test.clj
@@ -60,6 +60,7 @@
(testing "Migration of simultaneous init attempt is blocked"
(let [original-write-fn @#'semantic.db.migration/write-successful-migration!
original-migrate-fn @#'semantic.db.connection/do-with-migrate-tx
+ original-maybe-migrate @#'semantic.db.migration/maybe-migrate!
results (atom {:executed-migrations 0
:log []})]
(with-redefs-fn {;; TODO: why in ci init index won't succeed -- http on embedding
@@ -72,6 +73,12 @@
(apply original-migrate-fn args)
(swap! results update :log conj [tid :ended (t/local-date-time)]))
nil)
+ ;; add delay into migration function to ensure that thread performing migration
+ ;; finishes earlier
+ #'semantic.db.migration/maybe-migrate!
+ (fn [& args]
+ (Thread/sleep 200)
+ (apply original-maybe-migrate args))
#'semantic.db.migration/write-successful-migration!
(fn [& args]
(Thread/sleep 2000)