Skip to content

Optimize test suite performance#2604

Open
mroderick wants to merge 3 commits intocodebar:masterfrom
mroderick:clean-test-optimizations
Open

Optimize test suite performance#2604
mroderick wants to merge 3 commits intocodebar:masterfrom
mroderick:clean-test-optimizations

Conversation

@mroderick
Copy link
Copy Markdown
Collaborator

@mroderick mroderick commented May 4, 2026

Summary

This PR optimizes the test suite performance by reducing unnecessary object creation in fabricators.

Note: This PR is built on top of #2605 which fixes workshop capacity checks. Please review/merge that PR first.

Changes

Commit 1: Optimize chapter fabricator

  • Removed automatic organiser creation from default :chapter
  • Added :chapter_with_organiser for tests that need organisers
  • Includes test fixes for broken tests
  • Impact: Model specs 17.2s → 14.5s (15% improvement)

Commit 2: Optimize event fabricator

  • Removed automatic sponsorship creation from :event
  • Added :event_with_sponsorship for tests that need sponsorships
  • Includes test fixes for broken tests
  • Impact: Additional ~2% improvement (17% total)

Commit 3: Optimize group fabricator

  • Reduced member count from 5 to 2 in :students and :coaches
  • Includes test fix for meeting_spec.rb
  • Impact: Additional ~2% improvement (19% total)

Results

Metric Before After Improvement
Model specs 17.2s 13.9s 19%
Full suite ~100s ~94s 6%
All tests 995 passing 995 passing Stable

Testing

# Model specs
bundle exec rspec spec/models/  # ~14s (was ~17s)

# Full suite
bundle exec parallel_rspec spec/ -n 3  # ~94s (was ~100s)

Clean Commit History

Each commit is atomic and includes related test fixes:

  1. Chapter fabricator optimization + test fixes
  2. Event fabricator optimization + test fixes
  3. Group fabricator optimization + test fix

@mroderick mroderick force-pushed the clean-test-optimizations branch 3 times, most recently from c0a195c to 7640305 Compare May 4, 2026 18:36
mroderick added 3 commits May 4, 2026 20:39
Improves model spec performance by ~15% (17.0s → 14.5s)

The default :chapter fabricator was creating an organiser member with
role for every chapter, but most tests don't need this. Removed the
after_create callback from the default fabricator and added a new
:chapter_with_organiser fabricator for tests that need it.

Includes test fixes for tests broken by this change:
- chapters_spec.rb: Use :chapter_with_organiser for organiser editing test
- chapters_spec.rb: Use :chapter instead of :chapter_with_groups for tooltip test
- managing_organisers_spec.rb: Use :chapter_with_organiser
- workshops_spec.rb: Add organiser inline for Labels test
Improves model spec performance by additional ~2% (14.5s → 14.1s)
Combined with chapter optimization: 17.0s → 14.1s (~17% total improvement)

The default :event fabricator was creating a sponsorship for every
event, but most tests don't need this. Removed the after_build
callback from the default fabricator and added :event_with_sponsorship
for tests that need it.

Includes test fixes for tests broken by this change:
- event_spec.rb: Use :chapter instead of :chapter_with_groups
- manage_event_spec.rb: Use :chapter instead of :chapter_with_groups
- filtering_sponsors_list_spec.rb: Use :sponsor instead of :sponsor_with_contacts
- sponsor_spec.rb: Use :sponsor instead of :sponsor_with_contacts
Improves model spec performance by additional ~2% (14.1s → 13.8s)
Combined optimizations: 17.0s → 13.8s (~19% total improvement)

The students and coaches fabricators were creating 5 members each,
but tests only need 2 members per group. Reduced member count to
reduce object creation overhead.

Includes test fix for meeting_spec.rb banned members test:
- Updated to work with 4 total members (2 students + 2 coaches) instead of 10
@mroderick mroderick force-pushed the clean-test-optimizations branch from 7640305 to 571e718 Compare May 4, 2026 18:39
@mroderick mroderick marked this pull request as ready for review May 4, 2026 18:43
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.

1 participant