The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Fix flaky persist-refresh admin email test by giving it its own logged-in admin (#82413)
Arik Aronov98aa767a98cf
diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.ednindex bbf0c76d9f8..a0f08d5c1e5 100644--- a/.clj-kondo/config.edn+++ b/.clj-kondo/config.edn@@ -183,6 +183,9 @@clojure.core.async/to-chan!!;; writes the ratchet files from a :once fixture that finishes before the parallel testsdev.kondo-ratchet/fix!+ ;; builds Babashka's classpath cache from a :once fixture, before the parallel tests start, so that+ ;; they don't each race to create it; the side effect is process-external and idempotent+ metabase.core.modules-consistency-test/warm-babashka-classpath!metabase.ai-tracing.core/record!metabase.api.macros.defendpoint.tools-manifest/assert-optional-fields-nullable!;; MCP v2 tool tests: call-tool! dispatches a tool with no shared mutable state across testsdiff --git a/test/metabase/core/modules_consistency_test.clj b/test/metabase/core/modules_consistency_test.cljindex aae4459d320..77fe45ede6e 100644--- a/test/metabase/core/modules_consistency_test.clj+++ b/test/metabase/core/modules_consistency_test.clj@@ -40,6 +40,21 @@(defn- mage-test-paths [modules-config module](bb-eval `(#'mage.modules/module->test-paths '~modules-config '~module)))+(defn- warm-babashka-classpath!+ "Build Babashka's classpath cache once, serially, before any test runs.++ Every deftest below is `^:parallel` and each one shells out to its own `bb` process. On a machine with a+ cold cache -- a fresh CI runner -- they all start at the same moment and race to create+ `~/.config/clojure/.cpcache`. The losers die with `Error building classpath. Can't create directory`,+ which then surfaces as a confusing missing-dependency error from the first `:deps` entry Mage requires.+ One serial run first means the cache already exists by the time the parallel tests start."+ []+ (bb-eval nil))++(use-fixtures :once (fn [thunk]+ (warm-babashka-classpath!)+ (thunk)))+(deftest ^:parallel mage-file-resolution-test(testing "Mage and the linter resolve equivalent files and namespaces to the same module"(let [config '{actions {}diff --git a/test/metabase/model_persistence/task/persist_refresh_test.clj b/test/metabase/model_persistence/task/persist_refresh_test.cljindex 9f8a423963d..ad9ade182ad 100644--- a/test/metabase/model_persistence/task/persist_refresh_test.clj+++ b/test/metabase/model_persistence/task/persist_refresh_test.clj@@ -320,11 +320,18 @@(deftest publish-refresh-error-event-sends-admin-email-test(mt/with-fake-inbox(mt/with-model-cleanup [:model/TaskHistory]- (mt/with-temp [:model/Database db {:settings {:persist-models-enabled true}}+ (mt/with-temp [:model/User admin {:is_superuser true+ :email "[email protected]"}+ :model/Database db {:settings {:persist-models-enabled true}}:model/Card model {:type :model :database_id (u/the-id db)}:model/PersistedInfo persisted-info {:card_id (u/the-id model):database_id (u/the-id db):state "persisted"}]+ ;; The failure email only reaches admins who have logged in at least once --+ ;; [[metabase.channel.db/accepted-admin-emails]] filters on `last_login`. Record a login for our own+ ;; admin rather than relying on a shared test user, whose `last_login` is only set as a side effect of+ ;; some earlier test creating a session for them, and is therefore a matter of test ordering.+ (t2/update! :model/User (:id admin) {:last_login :%now})(let [^org.quartz.Trigger trigger (#'task.persist-refresh/database-trigger db "0 0 0/8 * * ? *")](#'task.persist-refresh/save-task-history!"persist-refresh" (u/the-id db)@@ -334,7 +341,7 @@:trigger trigger:error-details [{:persisted-info-id (u/the-id persisted-info):error "simulated refresh failure"}]})))- (let [msgs (get @mt/inbox "[email protected]")+ (let [msgs (get @mt/inbox (:email admin))body (-> msgs first :body first :content str)](is (= 1 (count msgs)))(is (re-find #"Model cache refresh failed" (str (:subject (first msgs)))))