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

dev: Clean up some unneccesary mocks to speed up gazebo tests #3604

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

ajay-sentry
Copy link
Contributor

@ajay-sentry ajay-sentry commented Dec 20, 2024

Description

Friday afternoon "chores" had me looking at the Test Analytics tool on Codecov for the Gazebo repo just because I hadn't in a while. I was surprised to see that some tests were taking over 5 seconds to run, with one being an even more abnormal "18 seconds."

Screenshot 2024-12-20 at 2 16 50 PM

Screenshot of initial test analytics page

I used the historical selector in the top to narrow my search to the last 7 days to see if it was just a blip of some weird data or if there was actually something abnormal going on here. To my surprise, even at 7 days I was seeing some similarly high test times and had to do a double check locally to see if I could reproduce those exact tests.

Screenshot 2024-12-20 at 2 16 02 PM

Screenshot of last 7 days data

Locally, I booted up the Commit.jsx test suite to see if I was also seeing some slow test suite run times since I wasn't completely convinced still. Lo and behold, I was seeing "13 seconds" as a pretty routine runtime for that suite. Using cursor, I literally just plugged in, any idea what I can do to make this test suite run faster? Cursor immediately spat back out, "yeah you probably don't need this mock," which after double checking I think is correct? if someone else could double check these aren't just poorly written tests, I think this just works? In any case, the test suite passed and I was able to do a similar fix for the rest of the tests that were

So yes, test analytics works, and hopefully we get a little extra speed from our test suite now as well! Oh and cursor works too I guess.

Screenshots of the test runs before and after

Screenshot 2024-12-20 at 2 02 28 PM Screenshot 2024-12-20 at 2 03 46 PM Screenshot 2024-12-20 at 2 06 52 PM Screenshot 2024-12-20 at 2 09 05 PM

Link to Sample Entry

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@codecov-staging
Copy link

codecov-staging bot commented Dec 20, 2024

Bundle Report

Bundle size has no change ✅

Copy link

codecov bot commented Dec 20, 2024

Bundle Report

Bundle size has no change ✅

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.00%. Comparing base (9034486) to head (b5dd699).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3604   +/-   ##
=======================================
  Coverage   99.00%   99.00%           
=======================================
  Files         810      810           
  Lines       14562    14569    +7     
  Branches     4143     4154   +11     
=======================================
+ Hits        14417    14424    +7     
  Misses        138      138           
  Partials        7        7           

see 14 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.75% <ø> (+<0.01%) ⬆️
Services 99.36% <ø> (ø)
Shared 99.32% <ø> (ø)
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9034486...b5dd699. Read the comment docs.

@codecov-notifications
Copy link

codecov-notifications bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main    #3604   +/-   ##
=======================================
  Coverage   99.00%   99.00%           
=======================================
  Files         810      810           
  Lines       14562    14569    +7     
  Branches     4150     4161   +11     
=======================================
+ Hits        14417    14424    +7     
  Misses        138      138           
  Partials        7        7           

see 14 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.75% <ø> (+<0.01%) ⬆️
Services 99.36% <ø> (ø)
Shared 99.32% <ø> (ø)
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9034486...b5dd699. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.00%. Comparing base (9034486) to head (b5dd699).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main    #3604   +/-   ##
=======================================
  Coverage   99.00%   99.00%           
=======================================
  Files         810      810           
  Lines       14562    14569    +7     
  Branches     4150     4161   +11     
=======================================
+ Hits        14417    14424    +7     
  Misses        138      138           
  Partials        7        7           

see 14 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.75% <ø> (+<0.01%) ⬆️
Services 99.36% <ø> (ø)
Shared 99.32% <ø> (ø)
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9034486...b5dd699. Read the comment docs.

Copy link

codecov-public-qa bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.00%. Comparing base (9034486) to head (b5dd699).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main    #3604   +/-   ##
=======================================
  Coverage   99.00%   99.00%           
=======================================
  Files         810      810           
  Lines       14562    14569    +7     
  Branches     4143     4154   +11     
=======================================
+ Hits        14417    14424    +7     
  Misses        138      138           
  Partials        7        7           

see 14 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.75% <ø> (+<0.01%) ⬆️
Services 99.36% <ø> (ø)
Shared 99.32% <ø> (ø)
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9034486...b5dd699. Read the comment docs.

@@ -6,19 +6,6 @@ import { MemoryRouter, Route } from 'react-router-dom'

import ToggleHeader from './ToggleHeader'

const mocks = vi.hoisted(() => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this mock wasn't doing anything

@codecov-releaser
Copy link
Contributor

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
b5dd699 Fri, 20 Dec 2024 22:24:19 GMT Cloud Enterprise

Copy link
Contributor

@suejung-sentry suejung-sentry left a comment

Choose a reason for hiding this comment

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

Nice find!

@@ -1316,12 +1318,6 @@ describe('DefaultOrgSelector', () => {
render(<DefaultOrgSelector />, { wrapper: wrapper() })
mocks.useIntersection.mockReturnValue({ isIntersecting: true })

const selectOrg = await screen.findByRole('button', {
Copy link
Contributor

Choose a reason for hiding this comment

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

yea this is fine. was scratching my head for a bit, but I get it now. This interaction is just trying to mimic real usage, but the test isn't doing that anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that's what I figured lol. With the mock "mocking" what the button click would have done anyway maybe there was some interaction that was tripping over itself?

@@ -359,12 +349,12 @@ describe('CommitsTab', () => {

describe('when there is a next page', () => {
it('calls fetchNextPage', async () => {
const { fetchNextPage, user } = setup({ hasNextPage: true })
const { fetchNextPage } = setup({ hasNextPage: true })
Copy link
Contributor

Choose a reason for hiding this comment

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

seems fine

Copy link
Contributor

Choose a reason for hiding this comment

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

yep same as the rest lol.

Copy link
Contributor

@spalmurray-codecov spalmurray-codecov left a comment

Choose a reason for hiding this comment

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

This is really interesting to me. They all follow the pattern of:

  1. set mock isintersecting true at the start of a test
  2. do some unnecessary UI interaction
  3. assert the isintersecting had the desired result

Not really tracking why this had such a crazy effect on runtimes, but hey if it works, it works 😅

@ajay-sentry ajay-sentry added this pull request to the merge queue Dec 20, 2024
Merged via the queue into main with commit 6a6fd2c Dec 20, 2024
62 checks passed
@ajay-sentry ajay-sentry deleted the Ajay/speed-up-gazebo-tests branch December 20, 2024 23:51
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.

4 participants