Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
7b962f73
Unverified
Commit
7b962f73
authored
1 year ago
by
Cam Saul
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix Liquibase when running Cypress tests locally (#33629)
parent
c1d88bae
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/api/testing.clj
+11
-1
11 additions, 1 deletion
src/metabase/api/testing.clj
src/metabase/db/liquibase.clj
+8
-2
8 additions, 2 deletions
src/metabase/db/liquibase.clj
src/metabase/db/setup.clj
+6
-3
6 additions, 3 deletions
src/metabase/db/setup.clj
with
25 additions
and
6 deletions
src/metabase/api/testing.clj
+
11
−
1
View file @
7b962f73
...
...
@@ -5,7 +5,9 @@
[
clojure.string
:as
str
]
[
compojure.core
:refer
[
POST
]]
[
metabase.api.common
:as
api
]
[
metabase.config
:as
config
]
[
metabase.db.connection
:as
mdb.connection
]
[
metabase.db.setup
:as
mdb.setup
]
[
metabase.util.files
:as
u.files
]
[
metabase.util.log
:as
log
])
(
:import
...
...
@@ -61,7 +63,15 @@
(
doseq
[
sql-args
[[
"SET LOCK_TIMEOUT 180000"
]
[
"DROP ALL OBJECTS"
]
[
"RUNSCRIPT FROM ?"
snapshot-path
]]]
(
jdbc/execute!
{
:connection
conn
}
sql-args
))))
(
jdbc/execute!
{
:connection
conn
}
sql-args
)))
;; don't know why this happens but when I try to test things locally with `yarn-test-cypress-open-no-backend` and a
;; backend server started with `dev/start!` the snapshots are always missing columms added by DB migrations. So let's
;; just check and make sure it's fully up to date in this scenario. Not doing this outside of dev because it seems to
;; work fine for whatever reason normally and we don't want tests taking 5 million years to run because we're wasting
;; a bunch of time initializing Liquibase and checking for unrun migrations for every test when we don't need to. --
;; Cam
(
when
config/is-dev?
(
mdb.setup/migrate!
(
mdb.connection/db-type
)
mdb.connection/*application-db*
:up
)))
(
defn-
increment-app-db-unique-indentifier!
"Increment the [[mdb.connection/unique-identifier]] for the Metabase application DB. This effectively flushes all
...
...
This diff is collapsed.
Click to expand it.
src/metabase/db/liquibase.clj
+
8
−
2
View file @
7b962f73
...
...
@@ -4,8 +4,10 @@
[
clojure.java.jdbc
:as
jdbc
]
[
clojure.string
:as
str
]
[
metabase.config
:as
config
]
[
metabase.db.custom-migrations
]
[
metabase.db.liquibase.h2
:as
liquibase.h2
]
[
metabase.db.liquibase.mysql
:as
liquibase.mysql
]
[
metabase.plugins.classloader
:as
classloader
]
[
metabase.util
:as
u
]
[
metabase.util.i18n
:refer
[
trs
]]
[
metabase.util.log
:as
log
]
...
...
@@ -13,9 +15,9 @@
[
toucan2.connection
:as
t2.conn
])
(
:import
(
java.io
StringWriter
)
(
liquibase
Contexts
LabelExpression
Liquibase
)
(
liquibase.change.custom
CustomChangeWrapper
)
(
liquibase.changelog
ChangeSet
)
(
liquibase
Contexts
LabelExpression
Liquibase
)
(
liquibase.database
Database
DatabaseFactory
)
(
liquibase.database.jvm
JdbcConnection
)
(
liquibase.exception
LockException
)
...
...
@@ -23,6 +25,10 @@
(
set!
*warn-on-reflection*
true
)
(
comment
;; load our custom migrations
metabase.db.custom-migrations/keep-me
)
;; register our custom MySQL SQL generators
(
liquibase.mysql/register-mysql-generators!
)
...
...
@@ -54,7 +60,7 @@
(
.findCorrectDatabaseImplementation
(
DatabaseFactory/getInstance
)
liquibase-conn
)))
(
defn-
liquibase
^
Liquibase
[
^
Database
database
]
(
Liquibase.
changelog-file
(
ClassLoaderResourceAccessor.
)
database
))
(
Liquibase.
changelog-file
(
ClassLoaderResourceAccessor.
(
classloader/the-classloader
)
)
database
))
(
s/defn
do-with-liquibase
"Impl for [[with-liquibase-macro]]."
...
...
This diff is collapsed.
Click to expand it.
src/metabase/db/setup.clj
+
6
−
3
View file @
7b962f73
...
...
@@ -9,7 +9,7 @@
(
:require
[
honey.sql
:as
sql
]
[
metabase.db.connection
:as
mdb.connection
]
metabase.db.custom-migrations
;; load our custom migrations
[
metabase.db.custom-migrations
]
[
metabase.db.jdbc-protocols
:as
mdb.jdbc-protocols
]
[
metabase.db.liquibase
:as
liquibase
]
[
metabase.driver.sql-jdbc.connection
:as
sql-jdbc.conn
]
...
...
@@ -29,8 +29,11 @@
(
set!
*warn-on-reflection*
true
)
;;; needed so the `:h2` dialect gets registered with Honey SQL
(
comment
metabase.util.honey-sql-2/keep-me
)
(
comment
;; load our custom migrations
metabase.db.custom-migrations/keep-me
;; needed so the `:h2` dialect gets registered with Honey SQL
metabase.util.honey-sql-2/keep-me
)
(
defn-
print-migrations-and-quit-if-needed!
"If we are not doing auto migrations then print out migration SQL for user to run manually. Then throw an exception to
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment