-
Notifications
You must be signed in to change notification settings - Fork 28
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
add percent changes to test results and flakes aggregates #829
Conversation
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
📢 Thoughts on this report? Let us know! |
❌ 2 Tests Failed:
View the top 2 failed tests by shortest run time
To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard |
Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time. ❌ Failed Test Results:Completed 2345 tests with View the full list of failed testspytest
|
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #829 +/- ##
==========================================
+ Coverage 96.28% 96.31% +0.03%
==========================================
Files 818 818
Lines 18818 18975 +157
==========================================
+ Hits 18118 18275 +157
Misses 700 700
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
||
flake_aggregates = ariadne_load_local_graphql(__file__, "flake_aggregates.graphql") | ||
|
||
__all__ = ["get_current_license", "flake_aggregates_bindable"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need get_current_license here?
__file__, "test_results_aggregates.graphql" | ||
) | ||
|
||
__all__ = ["get_current_license", "test_results_aggregates_bindable"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar story with if we need get_current_license
return obj["flake_rate"] | ||
|
||
|
||
@flake_aggregates_bindable.field("flakeCountPercentChange") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would personally organize these in "bunches" like flakeCount together and then flakeRate together vs. all the counts and all the %'s
I could see either approach tho
|
||
|
||
@flake_aggregates_bindable.field("flakeRatePercentChange") | ||
def resolve_flake_rate_percent_change(obj, _) -> float | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in what situation would we return None for these? Vs. returning 0
repository: Repository, | ||
info: GraphQLResolveInfo, | ||
): | ||
queryset = await sync_to_async(generate_test_results_aggregates)( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can you just do a return await here for both of these resolvers?
@@ -25,6 +25,16 @@ def resolve_failure_rate(test, info) -> float | None: | |||
return test["failure_rate"] | |||
|
|||
|
|||
@test_result_bindable.field("flakeRate") | |||
def resolve_flake_rate(test, info) -> float | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when would we want these to return None vs. 0?
|
||
@test_results_aggregates_bindable.field("slowestTestsRunTimePercentChange") | ||
def resolve_slowest_tests_run_time_percent_change(obj, _) -> float | None: | ||
return obj.get("slowest_tests_duration_percent_change") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why is this called duration vs. runTime like the other? and to make resolver name
|
||
|
||
@test_results_aggregates_bindable.field("totalRunTimePercentChange") | ||
def resolve_run_time_percent_change(obj, _) -> float | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly when would these be None vs. 0?
utils/test_results.py
Outdated
commits_where_fail: list[str] | None | ||
average_duration: float | None | ||
def slow_test_threshold(num_tests: int): | ||
threshold = floor(num_tests * (100 - SLOW_TEST_PERCENTILE) * 0.01) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: / 100 is a little easier to understand what we're doing here vs. * .01
utils/test_results.py
Outdated
def slow_test_threshold(num_tests: int): | ||
threshold = floor(num_tests * (100 - SLOW_TEST_PERCENTILE) * 0.01) | ||
if threshold == 0: | ||
if num_tests < (1 / ((100 - SLOW_TEST_PERCENTILE) * 0.01)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line needed? When would this statement be false if we're taking the floor already on line 30
utils/test_results.py
Outdated
repoid: int, | ||
branch: str | None = None, | ||
history: dt.timedelta | None = None, | ||
parameter: GENERATE_TEST_RESULT_PARAM | None = None, | ||
) -> QuerySet: | ||
""" | ||
Function that retrieves aggregated information about all tests in a given repository, for a given time range, optionally filtered by branch name. | ||
The fields it calculates are: the test failure rate, commits where this test failed, and average duration of the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as well as last duration, flake rate, etc
utils/test_results.py
Outdated
branch=branch | ||
) | ||
totals = totals.filter(branch=branch) | ||
print(parameter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder prints
utils/test_results.py
Outdated
test_ids = [flake.test_id for flake in flakes] | ||
|
||
totals = totals.filter(test_id__in=test_ids) | ||
case GENERATE_TEST_RESULT_PARAM.FAILED: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: do cases in python automatically have break statements built in?
utils/test_results.py
Outdated
|
||
|
||
def percent_diff(a: int | float, b: int | float) -> int | float: | ||
c = (a - b) / b * 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just return this instead of doing variable assignment
utils/test_results.py
Outdated
) -> dict[str, int | float]: | ||
diff_dict = {} | ||
|
||
for s in ls: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: list comprehension
utils/test_results.py
Outdated
) -> dict[str, float | int] | None: | ||
repo = Repository.objects.get(repoid=repoid) | ||
time_ago = ( | ||
(dt.datetime.now(dt.UTC) - history) if history is not None else thirty_days_ago |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can simplify these if else's a bit if we set History to be a const dependent on it's value being passed in OR dt.timedelta(days=30)
so then we can just do time_ago = (
(dt.datetime.now(dt.UTC) - history) and double_time_ago = time_ago -
history
WIth something like history = history or dt.timedelta(days=30)
utils/test_results.py
Outdated
test_rollups = test_rollups.filter(date__lte=until.date()) | ||
|
||
if len(test_rollups) == 0: | ||
assert 0 == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder remove assert
d0fdc20
to
a57b8f3
Compare
This adds PercentChange fields to both the TestResultsAggregates and the FlakeAggregates. These work by getting the aggregates for the previous historical period and comparing them with the ones for the current historical period and getting a percentage difference.
a57b8f3
to
2a2d550
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks goooood
This adds PercentChange fields to both the TestResultsAggregates
and the FlakeAggregates. These work by getting the aggregates
for the previous historical period and comparing them with the
ones for the current historical period and getting a percentage difference.