Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Sidekiq fake! instead of inline! in specs #25369

Merged

Conversation

mjankowski
Copy link
Contributor

In the spirit of previous PRs about paperclip processing (#25359) and factory build (#25360) -- there are many places throughout the spec suite which are running background sidekiq jobs inline, but where the specs don't need that to happen and aren't verifying anything related to that happening.

The default mode for sidekiq testing is to run in fake mode (makes job information accessible to specs, but doesn't actually run the jobs), but we were overriding that to run in inline mode.

This changes removes that override so that we go back to fake mode, and adds an opt-in for examples to get the inline behavior in specs where it's actually required.

In my local spec suite runs this change drops the full run from ~8:45 or so to around ~6:05 (~2:30 improvement).

One sort of awkward thing here is the mix of opting in to the inline behavior at different levels (describe, context, it) in this diff. I tried to keep this consistent at first, but there are some specs where we have what should be one-time setup code running once for every example because before(:each) is the default. I suspect there is good opportunity here for more speedup refactoring and might grab that next ... but I decided to limit this PR to the narrow sidekiq mode speedup instead of also changing those here.

@renchap renchap added testing Automated lint and test suites ruby Pull requests that update Ruby code labels Jun 11, 2023
ykzts
ykzts previously approved these changes Jun 12, 2023
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions
Copy link
Contributor

This pull request has resolved merge conflicts and is ready for review.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2023

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2023

This pull request has resolved merge conflicts and is ready for review.

@mjankowski mjankowski force-pushed the spec-performance-sidekiq-fake branch 2 times, most recently from 0bd63d0 to 88520ef Compare July 9, 2023 23:46
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions
Copy link
Contributor

This pull request has resolved merge conflicts and is ready for review.

@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@mjankowski mjankowski force-pushed the spec-performance-sidekiq-fake branch from 6a9669d to 059544c Compare July 17, 2023 16:12
@github-actions
Copy link
Contributor

This pull request has resolved merge conflicts and is ready for review.

@mjankowski mjankowski force-pushed the spec-performance-sidekiq-fake branch 2 times, most recently from 8996a63 to 47e080a Compare July 17, 2023 17:27
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@mjankowski mjankowski force-pushed the spec-performance-sidekiq-fake branch from 47e080a to 674587b Compare July 28, 2023 21:52
Copy link
Contributor

github-actions bot commented Dec 1, 2023

This pull request has merge conflicts that must be resolved before it can be merged.

@mjankowski mjankowski force-pushed the spec-performance-sidekiq-fake branch 2 times, most recently from 55f82fb to 5b96e5b Compare December 1, 2023 11:38
Copy link
Contributor

github-actions bot commented Dec 1, 2023

This pull request has resolved merge conflicts and is ready for review.

Copy link
Contributor

github-actions bot commented Dec 6, 2023

This pull request has merge conflicts that must be resolved before it can be merged.

Copy link
Contributor

github-actions bot commented Dec 6, 2023

This pull request has resolved merge conflicts and is ready for review.

@mjankowski mjankowski force-pushed the spec-performance-sidekiq-fake branch 2 times, most recently from 994a160 to dc2a979 Compare December 22, 2023 16:18
@mjankowski mjankowski force-pushed the spec-performance-sidekiq-fake branch 2 times, most recently from 602837b to 3aad08f Compare January 2, 2024 15:31
@mjankowski
Copy link
Contributor Author

Rebased, current benchmark (local run):

  • Main branch runs in ~6 mins, hits 88.79% coverage reported by simplecov
  • This PR branch runs in ~4:20, and hits 88.68% coverage

Much of the coverage lines difference is around lines which are not necessarily asserted against, and just run incidentally as part of running the full job. Obviously this is useful to have in place, but it makes tracking down what needs to be added to restore the coverage a little harder. Most of the files with changed coverages are in the single digit lines changed now - https://app.codecov.io/gh/mastodon/mastodon/pull/25369/indirect-changes - and the two larger ones I think are just side effects of not having file attachments in their unit tests, etc...

I guess I'm curious what the target is here? Are we close enough to merge at this point? If not, is the target to lose zero coverage (in which case I can continue to add coverage in the gaps)? Something else? Other than the coverage concern, are there any other blockers to merging here?

@ClearlyClaire
Copy link
Contributor

Sorry for the late reply. I'd like to avoid any coverage regression if possible. This is the only concern I have regarding this PR, it looks fine otherwise!

Looks like most of the coverage regression could be recovered by:

  • testing media attachments in spec/services/suspend_account_service_spec.rb and spec/services/spec/services/remove_status_service_spec.rb
  • testing media attachments and lists in spec/services/fan_out_on_write_service_spec.rb

@mjankowski mjankowski force-pushed the spec-performance-sidekiq-fake branch from 42ee675 to 8b99843 Compare January 9, 2024 15:52
@mjankowski
Copy link
Contributor Author

Rebased to get another CodeCov run ... we're down to just 1 or 2 LOC changes in the remaining files.

@ClearlyClaire ClearlyClaire added this pull request to the merge queue Jan 10, 2024
Merged via the queue into mastodon:main with commit 00341c7 Jan 10, 2024
28 checks passed
@mjankowski mjankowski deleted the spec-performance-sidekiq-fake branch January 10, 2024 13:14
hteumeuleu pushed a commit to hteumeuleu/mastodon that referenced this pull request Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ruby Pull requests that update Ruby code testing Automated lint and test suites
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants