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

[GQL] Add filters to the testResults field on the Repository #824

Merged
merged 8 commits into from
Oct 3, 2024

Conversation

joseph-sentry
Copy link
Contributor

we want to be able to filter by flaky tests, failed tests and the
slowest tests, because we want the clickable headers in the UI

@@ -579,8 +584,22 @@ async def resolve_test_results(
filters=None,
**kwargs,
):
queryset = await sync_to_async(aggregate_test_results)(
repoid=repository.repoid, branch=filters.get("branch") if filters else None
parameter = None
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to handle a default case here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the default case is a noop so i don't think so



@test_results_aggregates_bindable.field("totalRunTime")
def resolve_name(obj, _) -> float:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think our naming convention for these functions is resolve_bindable_field_name



@flake_aggregates_bindable.field("flakeCount")
def resolve_name(obj, _) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

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

reminder to update these function names to the actual resolve value

@@ -1,6 +1,8 @@
enum TestResultsOrderingParameter {
LAST_DURATION
AVG_DURATION
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to add an annotation to avg_duration marking it as deprecated, and then creating a follow up ticket for removal. Apps can handle the removal

@@ -0,0 +1,5 @@
enum TestResultsFilterParameter {
FLAKY_TESTS,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need one of these for Skips too?

@@ -593,3 +612,24 @@ async def resolve_test_results(
else OrderingDirection.DESC,
**kwargs,
)


@repository_bindable.field("testResultsHeaders")
Copy link
Contributor

Choose a reason for hiding this comment

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

thought we had agreed to keep the name generic vs. "headers" in case design changes or we want to use aspects of this object elsewhere

- TestResultsHeaders represents the information displayed in the Test
Analytics UI that is related to test results, total duration of tests,
accumulated duration of the 5% slowest tests, total number of failures,
and total number of skips

- a field of type TestResultsHeaders was added to the Repository model
- rename the TestResultsHeaders GQL model to TestResultsAggregates
- create the FlakeAggregates that contains flakeCount and flakeRate
  and uses the flaky_failure_count field from the DailyTestRollup
we want to be able to filter by flaky tests, failed tests and the
slowest tests, because we want the clickable headers in the UI
@joseph-sentry joseph-sentry force-pushed the joseph/test-results-more-filters branch from dd0ef86 to 63d364f Compare October 3, 2024 16:32
@codecov-notifications
Copy link

codecov-notifications bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 98.36066% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
utils/test_results.py 96.42% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 98.36066% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.28%. Comparing base (5ffafce) to head (1db8145).
Report is 3 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
utils/test_results.py 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #824      +/-   ##
==========================================
+ Coverage   96.26%   96.28%   +0.01%     
==========================================
  Files         818      818              
  Lines       18778    18818      +40     
==========================================
+ Hits        18076    18118      +42     
+ Misses        702      700       -2     
Flag Coverage Δ
unit 92.56% <98.36%> (+0.02%) ⬆️
unit-latest-uploader 92.56% <98.36%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joseph-sentry joseph-sentry marked this pull request as ready for review October 3, 2024 17:19
@joseph-sentry joseph-sentry requested a review from a team as a code owner October 3, 2024 17:19
)

thirty_days_ago = dt.date.today() - dt.timedelta(days=30)

SLOW_TEST_PERCENTILE = 95


def slow_test_threshold(num_tests: int):
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be simplified to

percentile = (100-95)/100

slow_tests_to_return = floor(percentile * total_tests)
return max(slow_tests_to_return,1)

Copy link
Contributor

@ajay-sentry ajay-sentry left a comment

Choose a reason for hiding this comment

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

lgtm

- refactor slow test threshold function to be more readable
- rework skipped test filter to show tests that are skipping tests all
  100% of the time
- fix the fail rate and flake rate division by zero error when pass +
  fail = 0
@joseph-sentry joseph-sentry added this pull request to the merge queue Oct 3, 2024
Merged via the queue into main with commit acf749e Oct 3, 2024
17 of 19 checks passed
@joseph-sentry joseph-sentry deleted the joseph/test-results-more-filters branch October 3, 2024 20:42
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