refactor: improve river test retries#1843
Merged
kian99 merged 3 commits intocanonical:v3from Feb 2, 2026
Merged
Conversation
luci1900
approved these changes
Jan 30, 2026
Contributor
luci1900
left a comment
There was a problem hiding this comment.
Deleted code and rollback tests, what's not to like?
SimoneDutto
approved these changes
Jan 30, 2026
|
|
||
| tx, err := sqlDb.Begin() | ||
| c.Assert(err, qt.IsNil) | ||
| defer func() { _ = tx.Rollback() }() |
Contributor
There was a problem hiding this comment.
this is the "success" test case, maybe we should commit?
Contributor
Author
There was a problem hiding this comment.
Since the test works based on the data in the tx, the test still passes/works without commit so no need.
This is also a way of doing tests I've seen in tools like Django where each test runs in a transaction and then the transaction is rolled back at the end of the test, allowing you to re-use the DB quickly.
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.
Description
This PR makes some minor improvements to our River tests and DB migrations:
go test ./internal/river -count=1takes around 12s on my machine. Previously it was taking ~70sERROR: database "jimm_test_testmigrationworker_error_6fgoa36q" is being accessed by other users. This was because we weren't commiting/rolling-back a tx we started withtx, err := sqlDb.Begin(). That's been fixed. I've also simplified the helper we use to create the test database.handleDeprecatedMigrationswhich handled scenarios where a deployment was running a now very old version of JIMM that didn't use golang-migrate and then upgraded to a version of JIMM that did. We can be quite confident that no users are running this old release so the code can finally go. At the time we likely didn't have external users anyway and it was added out of an abundance of caution.Engineering checklist