Add `test-prof` and use `set` in API specs
What does this MR do?
This does 2 things:
- Adds
test-prof
to the gem list:test-prof
provides very useful tools to see how we can improve our test suite and how much the changes we make improve things. - Use
set
in 5 API specs: I didn't want to update too many at a times, and sinceEVENT_PROF=factory.create
shows theTop 5 slowest suites (by time)
, I thought it made sense.
Are there points in the code the reviewer needs to double check?
There are some cases where we still need to use let
(e.g. if in the Branches API if we use set
for the project, the POST
test fails because the branch already exists since the branch cannot be "rollbacked" as a database attribute would be).
Improvements
Before
› EVENT_PROF=factory.create bin/rspec spec/requests/api/v3/award_emoji_spec.rb spec/requests/api/v3/boards_spec.rb spec/requests/api/v3/branches_spec.rb spec/requests/api/v3/broadcast_messages_spec.rb spec/requests/api/v3/builds_spec.rb spec/requests/api/access_requests_spec.rb spec/requests/api/award_emoji_spec.rb spec/requests/api/boards_spec.rb spec/requests/api/branches_spec.rb spec/requests/api/broadcast_messages_spec.rb
Running via Spring preloader in process 36193
[TEST PROF INFO] EventProf enabled (factory.create)
[TEST PROF INFO] EventProf results for factory.create
Total time: 01:20.455
Total events: 1396
Top 5 slowest suites (by time):
API::Branches (./spec/requests/api/branches_spec.rb:3) – 00:21.063 (228 / 110)
API::V3::Builds (./spec/requests/api/v3/builds_spec.rb:3) – 00:13.533 (235 / 42)
API::AwardEmoji (./spec/requests/api/award_emoji_spec.rb:3) – 00:11.985 (279 / 37)
API::AccessRequests (./spec/requests/api/access_requests_spec.rb:3) – 00:10.431 (104 / 48)
API::V3::AwardEmoji (./spec/requests/api/v3/award_emoji_spec.rb:3) – 00:09.467 (217 / 29)
Finished in 2 minutes 31.5 seconds (files took 1.09 seconds to load)
328 examples, 0 failures
AFTER:
› EVENT_PROF=factory.create bin/rspec spec/requests/api/v3/award_emoji_spec.rb spec/requests/api/v3/boards_spec.rb spec/requests/api/v3/branches_spec.rb spec/requests/api/v3/broadcast_messages_spec.rb spec/requests/api/v3/builds_spec.rb spec/requests/api/access_requests_spec.rb spec/requests/api/award_emoji_spec.rb spec/requests/api/boards_spec.rb spec/requests/api/branches_spec.rb spec/requests/api/broadcast_messages_spec.rb
Running via Spring preloader in process 31096
[TEST PROF INFO] EventProf enabled (factory.create)
[TEST PROF INFO] EventProf results for factory.create
Total time: 00:25.160
Total events: 402
Top 5 slowest suites (by time):
API::Branches (./spec/requests/api/branches_spec.rb:3) – 00:14.164 (119 / 110)
API::V3::AwardEmoji (./spec/requests/api/v3/award_emoji_spec.rb:3) – 00:03.212 (77 / 29)
API::AwardEmoji (./spec/requests/api/award_emoji_spec.rb:3) – 00:03.017 (99 / 37)
API::V3::Builds (./spec/requests/api/v3/builds_spec.rb:3) – 00:02.811 (64 / 42)
API::Boards (./spec/requests/api/boards_spec.rb:3) – 00:00.647 (15 / 19)
Finished in 1 minute 32.29 seconds (files took 1.32 seconds to load)
328 examples, 0 failures
39% faster.
Does this MR meet the acceptance criteria?
-
Tests added for this feature/bug - Review
-
Has been reviewed by Backend
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Squashed related commits together
What are the relevant issue numbers?
Related to #24899 (closed) and #37787 (moved).
Edited by Grzegorz Bizon