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

feat: add history, fix percent_diff rounding and flake aggregate time #857

Closed
wants to merge 2 commits into from

Conversation

joseph-sentry
Copy link
Contributor

  • add history to TestResults, TestResultsAggregate and FlakeAggregate GQL models
  • fix percent_diff function rounding to round up to 5 digits
  • fix flake aggregate time bound checking to be accurate

- add history to TestResults, TestResultsAggregate and FlakeAggregate
  GQL models
- fix percent_diff function rounding to round up to 5 digits
- fix flake aggregate time bound checking to be accurate
@joseph-sentry joseph-sentry requested a review from a team as a code owner October 4, 2024 20:01
@codecov-notifications
Copy link

Codecov Report

Attention: Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
graphql_api/types/repository/repository.py 90.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Oct 4, 2024

Codecov Report

Attention: Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.29%. Comparing base (6a28fb7) to head (168b7c4).
Report is 13 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
graphql_api/types/repository/repository.py 90.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #857      +/-   ##
==========================================
- Coverage   96.31%   96.29%   -0.02%     
==========================================
  Files         818      818              
  Lines       18971    18985      +14     
==========================================
+ Hits        18271    18282      +11     
- Misses        700      703       +3     
Flag Coverage Δ
unit 92.62% <90.32%> (-0.02%) ⬇️
unit-latest-uploader 92.62% <90.32%> (-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.

@codecov-qa
Copy link

codecov-qa bot commented Oct 4, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2381 1 2380 6
View the top 1 failed tests by shortest run time
graphql_api.tests.test_flake_aggregates.TestResultTestCase test_fetch_test_result_total_runtime
Stack Traces | 0.612s run time
self = &lt;graphql_api.tests.test_flake_aggregates.TestResultTestCase testMethod=test_fetch_test_result_total_runtime&gt;

    def test_fetch_test_result_total_runtime(self) -&gt; None:
        query = """
            query {
               owner(username: "%s") {
                    repository(name: "%s") {
                        ... on Repository {
                            flakeAggregates {
                                flakeRate
                                flakeCount
                                flakeRatePercentChange
                                flakeCountPercentChange
                            }
                        }
                    }
                 }
            }
        """ % (self.owner.username, self.repository.name)
    
        result = self.gql_request(query, owner=self.owner)
    
        assert "errors" not in result
&gt;       assert result["owner"]["repository"]["flakeAggregates"] == {
            "flakeRate": 0.2,
            "flakeCount": 30,
            "flakeRatePercentChange": -66.66666666666666,
            "flakeCountPercentChange": 100.0,
        }
E       AssertionError: assert {'flakeCount'...Change': None} == {'flakeCount'...6666666666666}
E         
E         Omitting 2 identical items, use -vv to show
E         Differing items:
E         {'flakeRatePercentChange': None} != {'flakeRatePercentChange': -66.66666666666666}
E         {'flakeCountPercentChange': None} != {'flakeCountPercentChange': 100.0}
E         Use -v to get more diff

graphql_api/tests/test_flake_aggregates.py:80: AssertionError

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Copy link

Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time.

❌ Failed Test Results:

Completed 2387 tests with 1 failed, 2380 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: graphql_api.tests.test_flake_aggregates.TestResultTestCase
    Test name: test_fetch_test_result_total_runtime

    self = <graphql_api.tests.test_flake_aggregates.TestResultTestCase testMethod=test_fetch_test_result_total_runtime>

    def test_fetch_test_result_total_runtime(self) -> None:
    query = """
    query {
    owner(username: "%s") {
    repository(name: "%s") {
    ... on Repository {
    flakeAggregates {
    flakeRate
    flakeCount
    flakeRatePercentChange
    flakeCountPercentChange
    }
    }
    }
    }
    }
    """ % (self.owner.username, self.repository.name)

    result = self.gql_request(query, owner=self.owner)

    assert "errors" not in result
    > assert result["owner"]["repository"]["flakeAggregates"] == {
    "flakeRate": 0.2,
    "flakeCount": 30,
    "flakeRatePercentChange": -66.66666666666666,
    "flakeCountPercentChange": 100.0,
    }
    E AssertionError: assert {'flakeCount'...Change': None} == {'flakeCount'...6666666666666}
    E
    E Omitting 2 identical items, use -vv to show
    E Differing items:
    E {'flakeRatePercentChange': None} != {'flakeRatePercentChange': -66.66666666666666}
    E {'flakeCountPercentChange': None} != {'flakeCountPercentChange': 100.0}
    E Use -v to get more diff

    graphql_api/tests/test_flake_aggregates.py:80: AssertionError

return await sync_to_async(generate_test_results_aggregates)(
repoid=repository.repoid
repoid=repository.repoid, history=history
)


@repository_bindable.field("flakeAggregates")
@convert_kwargs_to_snake_case
Copy link
Contributor

Choose a reason for hiding this comment

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

we actually don't need the @convert_kwargs decorator anymore due to

schema = make_executable_schema(types, *bindables, convert_names_case=True)

@@ -199,14 +199,14 @@ def percent_diff(
) -> int | float | None:
if past_value == 0:
return None
return (current_value - past_value) / past_value * 100
return round((current_value - past_value) / past_value * 100, 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Great change

Q(end_date__date__lte=until.date())
& Q(end_date__date__gt=since.date())
)
Q(start_date__date__lte=until.date())
Copy link
Contributor

Choose a reason for hiding this comment

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

start date < until date but end date > since date?

Could you remind me again what start and end mean in this context?
I'd figure we'd want start > until and end < since but I could just be messing with my head

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