Skip to content
Snippets Groups Projects
Commit d889a04a authored by Ryan Senior's avatar Ryan Senior
Browse files

Fix an H2 sync timezone test issue [ci drivers]

An incorrect query was written to pull the test-data DB that depending
on the order the tests were ran, would querying against a Druid DB
accidentally instead of the H2 db.
parent c8242c02
No related branches found
No related tags found
No related merge requests found
......@@ -19,11 +19,15 @@
(datasets/expect-with-engines #{:h2 :postgres}
[{:timezone-id "UTC"} true true true]
(data/dataset test-data
(let [db (db/select-one Database [:name "test-data"])
(let [db (data/db)
tz-on-load (db-timezone db)
_ (db/update! Database (:id db) :timezone nil)
tz-after-update (db-timezone db)]
;; It looks like we can get some stale timezone information depending on which thread is used for querying the
;; database in sync. Clearing the connection pool to ensure we get the most updated TZ data
(tu/clear-connection-pool db)
[(sut/only-step-keys (sut/sync-database! "sync-timezone" db))
;; On startup is the timezone specified?
(boolean (time/time-zone-for-id tz-on-load))
......@@ -35,7 +39,7 @@
(datasets/expect-with-engines #{:postgres}
["UTC" "UTC"]
(data/dataset test-data
(let [db (db/select-one Database [:name "test-data"])]
(let [db (data/db)]
(sync-tz/sync-timezone! db)
[(db-timezone db)
;; This call fails as the dates on PostgreSQL return 'AEST'
......
......@@ -437,7 +437,7 @@
{:cron-schedule (.getCronExpression ^CronTrigger trigger)
:data (into {} (.getJobDataMap trigger))}))))}))))))
(defn- clear-connection-pool
(defn clear-connection-pool
"It's possible that a previous test ran and set the session's timezone to something, then returned the session to
the pool. Sometimes that connection's session can remain intact and subsequent queries will continue in that
timezone. That causes problems for tests that we can determine the database's timezone. This function will reset the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment