Skip to content

Use TestOnly property in example tests - #440

Merged
brandur merged 1 commit into
masterfrom
brandur-example-test-only
Jul 9, 2024
Merged

Use TestOnly property in example tests#440
brandur merged 1 commit into
masterfrom
brandur-example-test-only

Conversation

@brandur

@brandur brandur commented Jul 9, 2024

Copy link
Copy Markdown
Contributor

I was looking into what was making the example tests so slow (some like
the periodic job enqueuer one often take 3 seconds to run), and it turns
out that the lion's share of it is from from service start up jitter.

Example tests aren't in the main river package (they're in
river_test) so they didn't previously have a way of interacting with
the client in such a way as to disable stagger. Luckily, we do have a
way now. Take advantage of the recently introduced TestOnly client
property from #414 to make all the examples faster.

I was looking into what was making the example tests so slow (some like
the periodic job enqueuer one often take 3 seconds to run), and it turns
out that the lion's share of it is from from service start up jitter.

Example tests aren't in the main `river` package (they're in
`river_test`) so they didn't previously have a way of interacting with
the client in such a way as to disable stagger. Luckily, we do have a
way now. Take advantage of the recently introduced `TestOnly` client
property from #414 to make all the examples faster.
@brandur
brandur force-pushed the brandur-example-test-only branch from 4c34aac to 0a6619b Compare July 9, 2024 00:37
@brandur
brandur requested a review from bgentry July 9, 2024 00:46

@bgentry bgentry left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome! Do you think we should add the flag to higher level docs as well? https://riverqueue.com/docs/testing

@brandur

brandur commented Jul 9, 2024

Copy link
Copy Markdown
Contributor Author

Oh yeah, good idea. I'll take that a bit later.

@brandur
brandur merged commit 79c093f into master Jul 9, 2024
@brandur
brandur deleted the brandur-example-test-only branch July 9, 2024 00:49
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.

2 participants