Fix a problem where tests were leaving leftover jobs in the database - #28
Merged
Conversation
Fix a problem where tests were leaving leftover jobs in the database which turns out to be because SQLAlchemy stupidly doesn't start a transaction when `begin()` is called, which was having the effect of the unique job check starting a top-level transaction instead of savepoint, thereby committing insert results outside of the test transactions. This took an insanely long time to track down, and I ended up adding a number of extra measures to help find the problem which I'm also keeping for the time begin: * `RIVER_DEBUG` activates debug logging for SQLAlchemy, showing queries and connection pool activity. * An autorunning fixture checks for extra jobs after each test case to make sure nothing gets leftover. * `SimpleArgs` starts to internalize the name of the test that created it, so upon seeing an extraneous row, it's easy to know exactly where it came from. It becomes a fixture to make this terse.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix a problem where tests were leaving leftover jobs in the database
which turns out to be because SQLAlchemy stupidly doesn't start a
transaction when
begin()is called, which was having the effect of theunique job check starting a top-level transaction instead of savepoint,
thereby committing insert results outside of the test transactions.
This took an insanely long time to track down, and I ended up adding a
number of extra measures to help find the problem which I'm also keeping
for the time begin:
RIVER_DEBUGactivates debug logging for SQLAlchemy, showing queriesand connection pool activity.
An autorunning fixture checks for extra jobs after each test case to
make sure nothing gets leftover.
SimpleArgsstarts to internalize the name of the test that createdit, so upon seeing an extraneous row, it's easy to know exactly where
it came from. It becomes a fixture to make this terse.