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
d2e706ec
Unverified
Commit
d2e706ec
authored
4 years ago
by
Raimon Grau
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
disable settings cache to fix flakiness (#14541)
parent
da8fd268
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/metabase/cmd/dump_to_h2_test.clj
+35
-31
35 additions, 31 deletions
test/metabase/cmd/dump_to_h2_test.clj
test/metabase/cmd/load_and_dump_test.clj
+13
-13
13 additions, 13 deletions
test/metabase/cmd/load_and_dump_test.clj
with
48 additions
and
44 deletions
test/metabase/cmd/dump_to_h2_test.clj
+
35
−
31
View file @
d2e706ec
...
...
@@ -10,11 +10,13 @@
[
metabase.db.connection
:as
mdb.connection
]
[
metabase.db.spec
:as
db.spec
]
[
metabase.driver
:as
driver
]
[
metabase.models
:refer
[
Setting
Database
]]
[
metabase.models
:refer
[
Database
Setting
]]
[
metabase.models.setting
:as
setting
]
[
metabase.test
:as
mt
]
[
metabase.test.data.interface
:as
tx
]
[
metabase.util.encryption-test
:as
eu
]
[
metabase.util.files
:as
u.files
]
[
metabase.util.i18n.impl
:as
i18n.impl
]
[
toucan.db
:as
db
]))
(
deftest
dump-deletes-target-db-files-tests
...
...
@@ -69,36 +71,38 @@
h2-file-default-enc
(
format
"/tmp/out-%s.db"
(
mt/random-name
))
db-name
(
str
"test_"
(
mt/random-name
))]
(
mt/test-drivers
#
{
:h2
:postgres
:mysql
}
(
binding
[
mdb.connection/*db-type*
driver/*driver*
mdb.connection/*jdbc-spec*
(
persistent-jdbcspec
driver/*driver*
db-name
)
db/*db-connection*
(
persistent-jdbcspec
driver/*driver*
db-name
)
db/*quoting-style*
driver/*driver*
]
(
when-not
(
=
driver/*driver*
:h2
)
(
tx/create-db!
driver/*driver*
{
:database-name
db-name
}))
(
load-from-h2/load-from-h2!
h2-fixture-db-file
)
(
eu/with-secret-key
"89ulvIGoiYw6mNELuOoEZphQafnF/zYe+3vT+v70D1A="
(
db/insert!
Setting
{
:key
"my-site-admin"
,
:value
"baz"
})
(
db/update!
Database
1
{
:details
"{\"db\":\"/tmp/test.db\"}"
})
(
dump-to-h2/dump-to-h2!
h2-file-plaintext
{
:dump-plaintext?
true
})
(
dump-to-h2/dump-to-h2!
h2-file-enc
{
:dump-plaintext?
false
})
(
dump-to-h2/dump-to-h2!
h2-file-default-enc
))
(
with-redefs
[
i18n.impl/site-locale-from-setting-fn
(
atom
(
constantly
false
))]
(
binding
[
setting/*disable-cache*
true
mdb.connection/*db-type*
driver/*driver*
mdb.connection/*jdbc-spec*
(
persistent-jdbcspec
driver/*driver*
db-name
)
db/*db-connection*
(
persistent-jdbcspec
driver/*driver*
db-name
)
db/*quoting-style*
driver/*driver*
]
(
when-not
(
=
driver/*driver*
:h2
)
(
tx/create-db!
driver/*driver*
{
:database-name
db-name
}))
(
load-from-h2/load-from-h2!
h2-fixture-db-file
)
(
eu/with-secret-key
"89ulvIGoiYw6mNELuOoEZphQafnF/zYe+3vT+v70D1A="
(
db/insert!
Setting
{
:key
"my-site-admin"
,
:value
"baz"
})
(
db/update!
Database
1
{
:details
"{\"db\":\"/tmp/test.db\"}"
})
(
dump-to-h2/dump-to-h2!
h2-file-plaintext
{
:dump-plaintext?
true
})
(
dump-to-h2/dump-to-h2!
h2-file-enc
{
:dump-plaintext?
false
})
(
dump-to-h2/dump-to-h2!
h2-file-default-enc
))
(
testing
"decodes settings and dashboard.details"
(
jdbc/with-db-connection
[
target-conn
(
copy.h2/h2-jdbc-spec
h2-file-plaintext
)]
(
is
(
=
"baz"
(
:value
(
first
(
jdbc/query
target-conn
"select value from SETTING where key='my-site-admin';"
)))))
(
is
(
=
"{\"db\":\"/tmp/test.db\"}"
(
:details
(
first
(
jdbc/query
target-conn
"select details from metabase_database where id=1;"
)))))))
(
testing
"decodes settings and dashboard.details"
(
jdbc/with-db-connection
[
target-conn
(
copy.h2/h2-jdbc-spec
h2-file-plaintext
)]
(
is
(
=
"baz"
(
:value
(
first
(
jdbc/query
target-conn
"select value from SETTING where key='my-site-admin';"
)))))
(
is
(
=
"{\"db\":\"/tmp/test.db\"}"
(
:details
(
first
(
jdbc/query
target-conn
"select details from metabase_database where id=1;"
)))))))
(
testing
"when flag is set to false, encrypted settings and dashboard.details are still encrypted"
(
jdbc/with-db-connection
[
target-conn
(
copy.h2/h2-jdbc-spec
h2-file-enc
)]
(
is
(
not
(
=
"baz"
(
:value
(
first
(
jdbc/query
target-conn
"select value from SETTING where key='my-site-admin';"
))))))
(
is
(
not
(
=
"{\"db\":\"/tmp/test.db\"}"
(
:details
(
first
(
jdbc/query
target-conn
"select details from metabase_database where id=1;"
))))))))
(
testing
"when flag is set to false, encrypted settings and dashboard.details are still encrypted"
(
jdbc/with-db-connection
[
target-conn
(
copy.h2/h2-jdbc-spec
h2-file-enc
)]
(
is
(
not
(
=
"baz"
(
:value
(
first
(
jdbc/query
target-conn
"select value from SETTING where key='my-site-admin';"
))))))
(
is
(
not
(
=
"{\"db\":\"/tmp/test.db\"}"
(
:details
(
first
(
jdbc/query
target-conn
"select details from metabase_database where id=1;"
))))))))
(
testing
"defaults to not decrypting"
(
jdbc/with-db-connection
[
target-conn
(
copy.h2/h2-jdbc-spec
h2-file-default-enc
)]
(
is
(
not
(
=
"baz"
(
:value
(
first
(
jdbc/query
target-conn
"select value from SETTING where key='my-site-admin';"
))))))
(
is
(
not
(
=
"{\"db\":\"/tmp/test.db\"}"
(
:details
(
first
(
jdbc/query
target-conn
"select details from metabase_database where id=1;"
)))))))))))))
(
testing
"defaults to not decrypting"
(
jdbc/with-db-connection
[
target-conn
(
copy.h2/h2-jdbc-spec
h2-file-default-enc
)]
(
is
(
not
(
=
"baz"
(
:value
(
first
(
jdbc/query
target-conn
"select value from SETTING where key='my-site-admin';"
))))))
(
is
(
not
(
=
"{\"db\":\"/tmp/test.db\"}"
(
:details
(
first
(
jdbc/query
target-conn
"select details from metabase_database where id=1;"
)))))))))))))
)
This diff is collapsed.
Click to expand it.
test/metabase/cmd/load_and_dump_test.clj
+
13
−
13
View file @
d2e706ec
...
...
@@ -6,14 +6,12 @@
[
metabase.cmd.dump-to-h2
:as
dump-to-h2
]
[
metabase.cmd.load-from-h2
:as
load-from-h2
]
[
metabase.db.connection
:as
mdb.connection
]
[
metabase.db.setup
:as
mdb.setup
]
[
metabase.db.spec
:as
db.spec
]
[
metabase.driver
:as
driver
]
[
metabase.models.setting
:as
setting
]
[
metabase.util.i18n.impl
:as
i18n.impl
]
[
metabase.test
:as
mt
]
[
metabase.test.data.interface
:as
tx
]
[
toucan.db
:as
db
]
[
toucan.util.test
:as
tt
]))
[
metabase.test.data.interface
:as
tx
]))
(
defn-
abs-path
[
path
]
...
...
@@ -24,9 +22,10 @@
(
let
[
h2-fixture-db-file
(
abs-path
"frontend/test/__runner__/test_db_fixture.db"
)
h2-file
(
abs-path
"/tmp/out.db"
)
db-name
"dump-test"
]
(
mt/test-drivers
#
{
:postgres
:mysql
:h2
}
(
mt/test-drivers
#
{
:mysql
:postgres
:h2
}
(
h2/delete-existing-h2-database-files!
h2-file
)
(
binding
[
mdb.connection/*db-type*
driver/*driver*
(
binding
[
setting/*disable-cache*
true
mdb.connection/*db-type*
driver/*driver*
mdb.connection/*jdbc-spec*
(
if
(
=
driver/*driver*
:h2
)
{
:subprotocol
"h2"
:subname
(
format
"mem:%s;DB_CLOSE_DELAY=10"
(
mt/random-name
))
...
...
@@ -36,10 +35,11 @@
((
case
driver/*driver*
:postgres
db.spec/postgres
:mysql
db.spec/mysql
)
details
)))]
(
when-not
(
=
driver/*driver*
:h2
)
(
tx/create-db!
driver/*driver*
{
:database-name
db-name
}))
(
load-from-h2/load-from-h2!
h2-fixture-db-file
)
(
dump-to-h2/dump-to-h2!
h2-file
)
(
is
(
not
(
compare-h2-dbs/different-contents?
h2-file
h2-fixture-db-file
))))))))
(
with-redefs
[
i18n.impl/site-locale-from-setting-fn
(
atom
(
constantly
false
))]
(
when-not
(
=
driver/*driver*
:h2
)
(
tx/create-db!
driver/*driver*
{
:database-name
db-name
}))
(
load-from-h2/load-from-h2!
h2-fixture-db-file
)
(
dump-to-h2/dump-to-h2!
h2-file
)
(
is
(
not
(
compare-h2-dbs/different-contents?
h2-file
h2-fixture-db-file
)))))))))
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