Skip to content

refactor: improve river test retries#1843

Merged
kian99 merged 3 commits intocanonical:v3from
kian99:river-test-speedup
Feb 2, 2026
Merged

refactor: improve river test retries#1843
kian99 merged 3 commits intocanonical:v3from
kian99:river-test-speedup

Conversation

@kian99
Copy link
Contributor

@kian99 kian99 commented Jan 30, 2026

Description

This PR makes some minor improvements to our River tests and DB migrations:

  1. Speeds up our River tests. 2 tests in the upgrade_test worker were taking 20s and 40s because they were retrying a job and River's default retry policy is 1s->16s->1m21s, etc. See https://riverqueue.com/docs/job-retries. Now running go test ./internal/river -count=1 takes around 12s on my machine. Previously it was taking ~70s
  2. When running the tests with verbose=true, one would see ERROR: 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 with tx, err := sqlDb.Begin(). That's been fixed. I've also simplified the helper we use to create the test database.
  3. I've removed handleDeprecatedMigrations which 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

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

@kian99 kian99 requested a review from a team as a code owner January 30, 2026 14:56
Copy link
Contributor

@luci1900 luci1900 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted code and rollback tests, what's not to like?

Copy link
Contributor

@SimoneDutto SimoneDutto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good good


tx, err := sqlDb.Begin()
c.Assert(err, qt.IsNil)
defer func() { _ = tx.Rollback() }()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the "success" test case, maybe we should commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kian99 kian99 merged commit 9d14100 into canonical:v3 Feb 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants