-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Reenable SQLite tests which leverage foreign key constraints et al. #24605
chore: Reenable SQLite tests which leverage foreign key constraints et al. #24605
Conversation
a96ff8d
to
910de2c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #24605 +/- ##
=======================================
Coverage 69.14% 69.14%
=======================================
Files 1946 1946
Lines 75989 75989
Branches 8479 8479
=======================================
Hits 52544 52544
Misses 21266 21266
Partials 2179 2179
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
5ede24b
to
f388c36
Compare
@@ -2498,9 +2333,11 @@ def test_get_or_create_dataset_creates_table(self): | |||
self.assertEqual(table.template_params, '{"param": 1}') | |||
|
|||
db.session.delete(table) | |||
db.session.commit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See here, specifically it mentions,
SQLite locks the database when a write is made to it, such as when an UPDATE, INSERT or DELETE is sent. When using the ORM, these get sent on flush. The database will remain locked until there is a COMMIT or ROLLBACK.
hence the need for the commit to free the lock prior to dropping the actual table.
f388c36
to
0472b0f
Compare
4101492
to
9773aeb
Compare
d8c3ba3
to
f021d99
Compare
@@ -150,7 +150,9 @@ jobs: | |||
SUPERSET_CONFIG: tests.integration_tests.superset_test_config | |||
REDIS_PORT: 16379 | |||
SUPERSET__SQLALCHEMY_DATABASE_URI: | | |||
sqlite:///${{ github.workspace }}/.temp/unittest.db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird name for a database used for integration (as opposed to unit) tests. Calling this superset.db
is inline with how the metadata database is named elsewhere—including in this workflow for MySQL and PostgreSQL.
ac0bd8f
to
8066ffb
Compare
Not a blocker for this PR but there's a task in 4.0 to drop support for SQLite to materialize SIP-33. |
00aec58
to
5148fc8
Compare
@@ -150,7 +150,9 @@ jobs: | |||
SUPERSET_CONFIG: tests.integration_tests.superset_test_config | |||
REDIS_PORT: 16379 | |||
SUPERSET__SQLALCHEMY_DATABASE_URI: | | |||
sqlite:///${{ github.workspace }}/.temp/unittest.db | |||
sqlite:///${{ github.workspace }}/.temp/superset.db?check_same_thread=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This threw me for a curveball. I was able to successfully run the tests locally but they failed remotely with a somewhat cryptic error stating a reference table being specified in this fixture didn't exist.
I speculate that this is probably due to a multithreading or connection pooling issue when running via a GitHub workflow. Ensuring a single connection per thread seems to remedy the problem. 🤞
@@ -150,7 +150,9 @@ jobs: | |||
SUPERSET_CONFIG: tests.integration_tests.superset_test_config | |||
REDIS_PORT: 16379 | |||
SUPERSET__SQLALCHEMY_DATABASE_URI: | | |||
sqlite:///${{ github.workspace }}/.temp/unittest.db | |||
sqlite:///${{ github.workspace }}/.temp/superset.db?check_same_thread=true | |||
SUPERSET__SQLALCHEMY_EXAMPLES_URI: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5148fc8
to
4651688
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
SUMMARY
In #24488 I added logic to enable foreign key support for SQLite. A positive byproduct of said change is there are a slew of SQLite integration tests which were disabled due to the lack of foreign key support (and/or blind copypasta).
This PR simply reenables the previously skipped SQLite tests.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
CI.
ADDITIONAL INFORMATION