Skip to content

Conversation

@solnic
Copy link
Collaborator

@solnic solnic commented Oct 30, 2025

This fixes and simplifies test rails app setup for our sentry-rails test suite. Previous solution suffered from too much duplication and global state pollution. I tried to stick to a regular Rails setup as much as possible here.

In summary:

  • Use same models/controllers/views for all rails test app versions because they are identical
  • Use regular schema.rb file and load it just once in before(:suite)
  • Derive version-specific Sentry::TestRailsApp from a base Sentry:Rails:::Test::Application so that we can just leverage regular inheritance for version-specific tweaks
  • Do not allow nested make_basic_app calls - this causes issues as more global bloat is created (hence some specs were tweaked to not do this)
  • Move make_basic_app to a dedicated Sentry::Rails::TestHelper that gets included in all spec examples

This makes the spec suite more stable and faster:

  • On 6.1 ~40s down to ~16s
  • On 7.1 ~1.5m down to ~1m
  • On 8.0 ~4.5m down to ~3.25m
  • On 8.1 ~4m down to ~3m

Notice that the suite gets slower and slower with each Rails version. This is because Rails accumulates more global state and there are still some leakages. We can keep improving it every time there's a chance. I'm gonna call it a day for now as it's already a huge improvement 😄

#skip-changelog

@solnic solnic changed the title Solnic/rails improve test app setup chore(rails): improve test app setup Oct 30, 2025
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.41%. Comparing base (997ef4e) to head (398048f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2762      +/-   ##
==========================================
- Coverage   97.25%   90.41%   -6.84%     
==========================================
  Files         130      131       +1     
  Lines        5240     5250      +10     
==========================================
- Hits         5096     4747     -349     
- Misses        144      503     +359     
Components Coverage Δ
sentry-ruby 97.60% <ø> (+0.05%) ⬆️
sentry-rails 55.84% <ø> (-40.94%) ⬇️
sentry-sidekiq 95.05% <ø> (ø)
sentry-resque 94.44% <ø> (ø)
sentry-delayed_job 94.68% <ø> (ø)
sentry-opentelemetry 99.31% <ø> (ø)
see 20 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@solnic solnic force-pushed the solnic/rails-improve-test-app-setup branch 7 times, most recently from a280fbd to 2246749 Compare October 31, 2025 13:42
@solnic solnic changed the base branch from master to solnic/rails-8.1-in-test-setup October 31, 2025 13:43
@solnic solnic force-pushed the solnic/rails-improve-test-app-setup branch 3 times, most recently from d7edc11 to 50cd1fe Compare October 31, 2025 19:44
@solnic solnic force-pushed the solnic/rails-8.1-in-test-setup branch from c828b49 to 2bdf4ff Compare November 3, 2025 11:58
Base automatically changed from solnic/rails-8.1-in-test-setup to master November 3, 2025 12:15
@solnic solnic force-pushed the solnic/rails-improve-test-app-setup branch 3 times, most recently from 31fc3d2 to 7598a13 Compare November 3, 2025 14:15
@solnic solnic force-pushed the solnic/rails-improve-test-app-setup branch from a39df47 to 398048f Compare November 3, 2025 15:08
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