Conversation
hubertdeng123
left a comment
There was a problem hiding this comment.
It seems like data is preserved in the database across test runs with this approach after reading. CI passed though, so guess that isn't a problem?
It's preserved across pytest invocations but each testing shard is one pytest invocation. |
|
My point is to my understanding it should be best practice to clear data in the db between test runs to ensure the tests are stateless. This seems to not be aligned with this, so wondering if that's really the case. It seems like the root cause here may be different threads accessing the db at the same time. |
|
Unless you're saying that since pytest doesn't teardown the db until end of session entirely, and just rolls back transactions between test runs. Then, we'll just be skipping db teardown entirely |
|
The root cause, which this PR is working around, is that pytest-django is trying to drop the database at session-end but there are still open db connections. That is a problem with the tests themselves but I'm saying it's fine to paper over because these problems (which are not tied to test incorrectness) come up at db teardown at session-end, and there is only 1 session-end. --reuse-db is mainly used locally if you want repeated |
…wn at session-end (#106999)
we've been having some maybe-test-pollution-related issues (example https://github.com/getsentry/sentry/actions/runs/20912887952/job/60079407114 but
tests/acceptance/test_trace_view_waterfall.py::TraceViewWaterfallTest::test_trace_view_waterfall_loadsis a known flake) tearing down pytest-django's test db:--reuse-dbis the only reasonable way i've found to skip db teardown at pytest session-end, and would prevent this entire class of errorssince our test shards are just one pytest invocation (and therefore one pytest test session) this is safe to do