diff --git a/src/metabase/util/jvm.clj b/src/metabase/util/jvm.clj index ceef3af0f67bdc1bfe1bb6fcb0d1501e4c5067a7..cdc46ea389e9a104f152959d37084c930d4dd55c 100644 --- a/src/metabase/util/jvm.clj +++ b/src/metabase/util/jvm.clj @@ -302,7 +302,12 @@ (defn poll "Returns `(thunk)` if the result satisfies the `done?` predicate within the timeout and nil otherwise. - The default timeout is 1000ms and the default interval is 100ms." + The default timeout is 1000ms and the default interval is 100ms. + + (u/poll {:thunk (fn [] (upload!)) + :done (fn [response] (get-in response [:status :done])) + :timeout-ms 1000 + :interval-ms 100})" [{:keys [thunk done? timeout-ms interval-ms] :or {timeout-ms 1000 interval-ms 100}}] (let [start-time (System/currentTimeMillis)] diff --git a/test/metabase/api/database_test.clj b/test/metabase/api/database_test.clj index 1711e72194396e33a299727f4739c2cfc4b94a26..44ef0cf7974fec079ff7df65ef6bf69ab8ece2c1 100644 --- a/test/metabase/api/database_test.clj +++ b/test/metabase/api/database_test.clj @@ -1268,7 +1268,6 @@ (:metadata_sync_schedule db))) (is (not= (-> schedule-map-for-last-friday-at-11pm u.cron/schedule-map->cron-string) (:cache_field_values_schedule db))))))))) - (deftest update-db-to-never-scan-values-on-demand-test (with-db-scheduler-setup! (with-test-driver-available! @@ -1277,7 +1276,11 @@ (testing "update db setting to never scan should remove scan field values trigger" (testing "sanity check that it has all triggers to begin with" (is (= (task.sync-databases-test/all-db-sync-triggers-name db) - (task.sync-databases-test/query-all-db-sync-triggers-name db)))) + ;; this is flaking and I suspect it's because the triggers is created async in + ;; post-insert hook of Database + (u/poll {:thunk #(task.sync-databases-test/query-all-db-sync-triggers-name db) + :done? not-empty + :timeout-ms 300})))) (mt/user-http-request :crowberto :put 200 (format "/database/%d" (:id db)) {:details {:let-user-control-scheduling true} :schedules {:metadata_sync schedule-map-for-weekly