Skip to content

Conversation

@bgentry
Copy link
Contributor

@bgentry bgentry commented Sep 28, 2025

I wanted to refactor this so feature extensions are defined entirely in pro and not in the OSS Go code. I can still do a little more cleanup here to consolidate some semi-redundant flags (both "queries" vs "table" flags for some features) but will do that later.

I then added a flag for durable periodic jobs, and finally implemented a UI for listing durable periodic jobs.

In the future I'd like to link to jobs in the list produced by this periodic job but we don't have metadata filtering yet.

Size Light Dark
Mobile Screenshot 2025-09-27 at 8 27 45 PM Screenshot 2025-09-27 at 8 27 35 PM
Desktop Screenshot 2025-09-27 at 8 27 55 PM Screenshot 2025-09-27 at 8 27 24 PM

@bgentry bgentry requested a review from brandur September 28, 2025 01:29
@bgentry bgentry force-pushed the bg-durable-periodic-jobs-ui branch 2 times, most recently from c493ad7 to 310a2c5 Compare September 28, 2025 20:08
Copy link
Collaborator

@brandur brandur left a comment

Choose a reason for hiding this comment

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

Cool.

"riverqueue.com/riverui/internal/riverinternaltest"
)

func TestProEndpointsExtensions(t *testing.T) { //nolint:paralleltest
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI, alternatively these could use the schema test helpers + parallel as long as they're provided with the "no schema reuse" option (so schema changes don't accidentally land in a subsequent test).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh good call. I went to look into this and there were some complications, including that this repo is still using a forked internal riverinternaltest (you can see from the diff you commented on). I had to refactor a few test setup bits to make this work, but I think everything is all converted over as of the last commit and this file no long disables parallel tests.

Move all Pro-related flags into the extensions setup so there's no need
to check for these Pro artifacts in OSS.

Also add a flag for durable periodic jobs.
Also fix Queue stories that depend on feature flags.
@bgentry bgentry force-pushed the bg-durable-periodic-jobs-ui branch 2 times, most recently from c3fdb97 to 7e4222e Compare September 29, 2025 19:49
@bgentry
Copy link
Contributor Author

bgentry commented Sep 29, 2025

@brandur Please take a look at the final commit here if you have time (you may have further suggestions to clean it up). I'll merge this meanwhile and am happy to follow up on any fixes.

Copy link
Collaborator

@brandur brandur left a comment

Choose a reason for hiding this comment

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

Cool.


pool := riversharedtest.DBPool(ctx, tb)
driver := riverpropgxv5.New(pool)
tx, schema := riverdbtest.TestTx(ctx, tb, driver, opts)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I'm not sure about these helpers like this that just abstract away setting like three variables. It doesn't save much code, adds a layer of indirection, and makes it such that if you ever need a more complex test case that needs access to something else like the database pool, you can't get to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the issue is the underlying helper in riverdbtest.TestTxPgx isn't quite composable enough because it constructs its own (non-Pro) driver and doesn't return the driver. I have a cleanup in riverqueue/river#1048 that I think takes care of these concerns and avoids the need to duplicate nearly-identical helpers in a few places.


// The same thing as the built-in riverdbtest.TestTxPgx does.
_, err := tx.Exec(ctx, "SET search_path TO '"+schema+"'")
require.NoError(tb, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but it uses a non-pro driver and thus doesn't apply pro migrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored version uses the more flexible helper exposed in riverqueue/river#1048 to avoid duplicating all of this.

Also, to keep naming more intuitive and consistent with riverdbtest, I renamed this riverprodbtest instead of protestinternal.

common_test.go Outdated
_, err := tx.Exec(ctx, "SET search_path TO '"+schema+"'")
require.NoError(tb, err)

return driver, tx
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this the same as your other new test helper below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed thanks to reusable helper in riverqueue/river#1048

@bgentry bgentry force-pushed the bg-durable-periodic-jobs-ui branch 2 times, most recently from c88c99d to e6f8860 Compare October 1, 2025 01:42
"riverqueue.com/riverpro/driver/riverpropgxv5"
)

func DriverAndTestTx(ctx context.Context, tb testing.TB, opts *riverdbtest.TestTxOpts) (driver.ProDriver[pgx.Tx], pgx.Tx) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

One more small ask, but can we get rid of this? It's a helper that (1) defines one variable, and (2) calls another helper. It's mostly used by shared setup blocks anyway, so it's not like this code needs to be repeated in that many places (four places by my count).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, done ✅ It was doing a lot more before upstreaming the flexible helper and no longer makes sense as-is.

Also refactor to leverage shared DB test TX helpers and parallelize
endpoint detection tests which modify the schema (by disbling sharing on
those tests).
@bgentry bgentry force-pushed the bg-durable-periodic-jobs-ui branch from e6f8860 to aede13b Compare October 1, 2025 12:12
@bgentry bgentry merged commit ba48132 into master Oct 1, 2025
19 checks passed
@bgentry bgentry deleted the bg-durable-periodic-jobs-ui branch October 1, 2025 13:06
bgentry added a commit that referenced this pull request Oct 10, 2025
Fixes #396. Or at least the remaining parts of it not already fixed by
PR #435.
bgentry added a commit that referenced this pull request Oct 10, 2025
Fixes #396. Or at least the remaining parts of it not already fixed by
PR #435.
bgentry added a commit that referenced this pull request Oct 11, 2025
* use parallel test infra where possible

Fixes #396. Or at least the remaining parts of it not already fixed by
PR #435.

* use postgres 16–18 for CI
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