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

Remove usage of ReportDetails/files_array #911

Merged
merged 1 commit into from
Oct 31, 2024
Merged

Conversation

Swatinem
Copy link
Contributor

This removes all usage of ReportDetails. The base definitions still exist.

@Swatinem Swatinem self-assigned this Oct 22, 2024
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.22%. Comparing base (cdebb02) to head (90e7eb8).
Report is 9 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #911      +/-   ##
==========================================
- Coverage   96.23%   96.22%   -0.01%     
==========================================
  Files         823      823              
  Lines       18972    18963       -9     
==========================================
- Hits        18257    18248       -9     
  Misses        715      715              
Flag Coverage Δ
unit 92.46% <100.00%> (-0.01%) ⬇️
unit-latest-uploader 92.46% <100.00%> (-0.01%) ⬇️

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-notifications
Copy link

codecov-notifications bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

This PR includes changes to shared. Please review them here: codecov/shared@f0e213c...78f9525

Copy link
Contributor

This PR includes changes to shared. Please review them here: codecov/shared@f0e213c...78f9525

@Swatinem Swatinem marked this pull request as ready for review October 28, 2024 10:55
@Swatinem Swatinem requested a review from a team as a code owner October 28, 2024 10:55
Copy link
Contributor

This PR includes changes to shared. Please review them here: codecov/shared@4e27927...067b2e4

@Swatinem Swatinem requested a review from a team October 28, 2024 10:57
@codecov-qa
Copy link

codecov-qa bot commented Oct 28, 2024

❌ 4 Tests Failed:

Tests completed Failed Passed Skipped
2631 4 2627 6
View the top 3 failed tests by shortest run time
api/public/v2/tests/test_test_results_view.py::TestResultsViewsetTests::test_result_with_valid_super_token
Stack Traces | 0.406s run time
self = <test_test_results_view.TestResultsViewsetTests testMethod=test_result_with_valid_super_token>;
repository_artifact_permissions_has_permission = <MagicMock name='has_permission' id='139854765395888'>;

    @override_settings(SUPER_API_TOKEN="testaxs3o76rdcdpfzexuccx3uatui2nw73r")
    @patch("api.shared.permissions.RepositoryArtifactPermissions.has_permission")
    def test_result_with_valid_super_token(
        self, repository_artifact_permissions_has_permission
    ):
        repository_artifact_permissions_has_permission.return_value = False
        res = self.client.get(
            reverse(
                "api-v2-tests-results-detail",
                kwargs={
                    "service": self.org.service,
                    "owner_username": self.org.username,
                    "repo_name": self.repo.name,
                    "pk": self.test_instances[0].pk,
                },
            ),
            HTTP_AUTHORIZATION="Bearer testaxs3o76rdcdpfzexuccx3uatui2nw73r",
        )
        assert res.status_code == 200
        assert res.json() == {
            "id": self.test_instances[0].id,
            "name": self.test_instances[0].test.name,
            "test_id": self.test_instances[0].test_id,
            "failure_message": self.test_instances[0].failure_message,
            "duration_seconds": self.test_instances[0].duration_seconds,
            "commitid": self.test_instances[0].commitid,
            "outcome": self.test_instances[0].outcome,
            "branch": self.test_instances[0].branch,
            "repoid": self.test_instances[0].repoid,
            "failure_rate": self.test_instances[0].test.failure_rate,
            "commits_where_fail": self.test_instances[0].test.commits_where_fail,
&gt;       }
E       AttributeError: 'Test' object has no attribute 'failure_rate'

.../v2/tests/test_test_results_view.py:245: AttributeError
api/public/v2/tests/test_test_results_view.py::TestResultsViewsetTests::test_list_filters
Stack Traces | 0.425s run time
self = &lt;test_test_results_view.TestResultsViewsetTests testMethod=test_list_filters&gt;

    def test_list_filters(self):
        url = reverse(
            "api-v2-tests-results-list",
            kwargs={
                "service": self.org.service,
                "owner_username": self.org.username,
                "repo_name": self.repo.name,
            },
        )
        res = self.client.get(f"{url}?commit_id={self.test_instances[0].commitid}")
        assert res.status_code == status.HTTP_200_OK
        assert res.json() == {
            "count": 1,
            "next": None,
            "previous": None,
            "results": [
                {
                    "id": self.test_instances[0].id,
                    "name": self.test_instances[0].test.name,
                    "test_id": self.test_instances[0].test_id,
                    "failure_message": self.test_instances[0].failure_message,
                    "duration_seconds": self.test_instances[0].duration_seconds,
                    "commitid": self.test_instances[0].commitid,
                    "outcome": self.test_instances[0].outcome,
                    "branch": self.test_instances[0].branch,
                    "repoid": self.test_instances[0].repoid,
                    "failure_rate": self.test_instances[0].test.failure_rate,
                    "commits_where_fail": self.test_instances[
                        0
                    ].test.commits_where_fail,
                },
            ],
            "total_pages": 1,
&gt;       }
E       AttributeError: 'Test' object has no attribute 'failure_rate'

.../v2/tests/test_test_results_view.py:113: AttributeError
api/public/v2/tests/test_test_results_view.py::TestResultsViewsetTests::test_retrieve
Stack Traces | 0.429s run time
self = &lt;test_test_results_view.TestResultsViewsetTests testMethod=test_retrieve&gt;
get_repo_permissions = &lt;MagicMock name='get_repo_permissions' id='139855347634048'&gt;

    @patch("api.shared.repo.repository_accessors.RepoAccessors.get_repo_permissions")
    def test_retrieve(self, get_repo_permissions):
        get_repo_permissions.return_value = (True, True)
        res = self.client.get(
            reverse(
                "api-v2-tests-results-detail",
                kwargs={
                    "service": self.org.service,
                    "owner_username": self.org.username,
                    "repo_name": self.repo.name,
                    "pk": self.test_instances[0].pk,
                },
            )
        )
        assert res.status_code == status.HTTP_200_OK
        assert res.json() == {
            "id": self.test_instances[0].id,
            "name": self.test_instances[0].test.name,
            "test_id": self.test_instances[0].test_id,
            "failure_message": self.test_instances[0].failure_message,
            "duration_seconds": self.test_instances[0].duration_seconds,
            "commitid": self.test_instances[0].commitid,
            "outcome": self.test_instances[0].outcome,
            "branch": self.test_instances[0].branch,
            "repoid": self.test_instances[0].repoid,
            "failure_rate": self.test_instances[0].test.failure_rate,
            "commits_where_fail": self.test_instances[0].test.commits_where_fail,
&gt;       }
E       AttributeError: 'Test' object has no attribute 'failure_rate'

.../v2/tests/test_test_results_view.py:142: AttributeError

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 2637 tests with 4 failed, 2627 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: api.public.v2.tests.test_test_results_view.TestResultsViewsetTests
    Test name: test_list

    self = <test_test_results_view.TestResultsViewsetTests testMethod=test_list>

    def test_list(self):
    url = reverse(
    "api-v2-tests-results-list",
    kwargs={
    "service": self.org.service,
    "owner_username": self.org.username,
    "repo_name": self.repo.name,
    },
    )
    res = self.client.get(url)
    assert res.status_code == status.HTTP_200_OK
    assert res.json() == {
    "count": 2,
    "next": None,
    "previous": None,
    "results": [
    {
    "id": self.test_instances[0].id,
    "name": self.test_instances[0].test.name,
    "test_id": self.test_instances[0].test_id,
    "failure_message": self.test_instances[0].failure_message,
    "duration_seconds": self.test_instances[0].duration_seconds,
    "commitid": self.test_instances[0].commitid,
    "outcome": self.test_instances[0].outcome,
    "branch": self.test_instances[0].branch,
    "repoid": self.test_instances[0].repoid,
    "failure_rate": self.test_instances[0].test.failure_rate,
    "commits_where_fail": self.test_instances[
    0
    ].test.commits_where_fail,
    },
    {
    "id": self.test_instances[1].id,
    "name": self.test_instances[1].test.name,
    "test_id": self.test_instances[1].test_id,
    "failure_message": self.test_instances[1].failure_message,
    "duration_seconds": self.test_instances[1].duration_seconds,
    "commitid": self.test_instances[1].commitid,
    "outcome": self.test_instances[1].outcome,
    "branch": self.test_instances[1].branch,
    "repoid": self.test_instances[1].repoid,
    "failure_rate": self.test_instances[1].test.failure_rate,
    "commits_where_fail": self.test_instances[
    1
    ].test.commits_where_fail,
    },
    ],
    "total_pages": 1,
    > }
    E AttributeError: 'Test' object has no attribute 'failure_rate'

    .../v2/tests/test_test_results_view.py:78: AttributeError
  • Class name: api.public.v2.tests.test_test_results_view.TestResultsViewsetTests
    Test name: test_list_filters

    self = <test_test_results_view.TestResultsViewsetTests testMethod=test_list_filters>

    def test_list_filters(self):
    url = reverse(
    "api-v2-tests-results-list",
    kwargs={
    "service": self.org.service,
    "owner_username": self.org.username,
    "repo_name": self.repo.name,
    },
    )
    res = self.client.get(f"{url}&commit_id={self.test_instances[0].commitid}")
    assert res.status_code == status.HTTP_200_OK
    assert res.json() == {
    "count": 1,
    "next": None,
    "previous": None,
    "results": [
    {
    "id": self.test_instances[0].id,
    "name": self.test_instances[0].test.name,
    "test_id": self.test_instances[0].test_id,
    "failure_message": self.test_instances[0].failure_message,
    "duration_seconds": self.test_instances[0].duration_seconds,
    "commitid": self.test_instances[0].commitid,
    "outcome": self.test_instances[0].outcome,
    "branch": self.test_instances[0].branch,
    "repoid": self.test_instances[0].repoid,
    "failure_rate": self.test_instances[0].test.failure_rate,
    "commits_where_fail": self.test_instances[
    0
    ].test.commits_where_fail,
    },
    ],
    "total_pages": 1,
    > }
    E AttributeError: 'Test' object has no attribute 'failure_rate'

    .../v2/tests/test_test_results_view.py:113: AttributeError
  • Class name: api.public.v2.tests.test_test_results_view.TestResultsViewsetTests
    Test name: test_result_with_valid_super_token

    self = <test_test_results_view.TestResultsViewsetTests testMethod=test_result_with_valid_super_token>
    repository_artifact_permissions_has_permission = <MagicMock name='has_permission' id='139854765395888'>

    @override_settings(SUPER_API_TOKEN="testaxs3o76rdcdpfzexuccx3uatui2nw73r")
    @patch("api.shared.permissions.RepositoryArtifactPermissions.has_permission")
    def test_result_with_valid_super_token(
    self, repository_artifact_permissions_has_permission
    ):
    repository_artifact_permissions_has_permission.return_value = False
    res = self.client.get(
    reverse(
    "api-v2-tests-results-detail",
    kwargs={
    "service": self.org.service,
    "owner_username": self.org.username,
    "repo_name": self.repo.name,
    "pk": self.test_instances[0].pk,
    },
    ),
    HTTP_AUTHORIZATION="Bearer testaxs3o76rdcdpfzexuccx3uatui2nw73r",
    )
    assert res.status_code == 200
    assert res.json() == {
    "id": self.test_instances[0].id,
    "name": self.test_instances[0].test.name,
    "test_id": self.test_instances[0].test_id,
    "failure_message": self.test_instances[0].failure_message,
    "duration_seconds": self.test_instances[0].duration_seconds,
    "commitid": self.test_instances[0].commitid,
    "outcome": self.test_instances[0].outcome,
    "branch": self.test_instances[0].branch,
    "repoid": self.test_instances[0].repoid,
    "failure_rate": self.test_instances[0].test.failure_rate,
    "commits_where_fail": self.test_instances[0].test.commits_where_fail,
    > }
    E AttributeError: 'Test' object has no attribute 'failure_rate'

    .../v2/tests/test_test_results_view.py:245: AttributeError
  • Class name: api.public.v2.tests.test_test_results_view.TestResultsViewsetTests
    Test name: test_retrieve

    self = <test_test_results_view.TestResultsViewsetTests testMethod=test_retrieve>
    get_repo_permissions = <MagicMock name='get_repo_permissions' id='139855347634048'>

    @patch("api.shared.repo.repository_accessors.RepoAccessors.get_repo_permissions")
    def test_retrieve(self, get_repo_permissions):
    get_repo_permissions.return_value = (True, True)
    res = self.client.get(
    reverse(
    "api-v2-tests-results-detail",
    kwargs={
    "service": self.org.service,
    "owner_username": self.org.username,
    "repo_name": self.repo.name,
    "pk": self.test_instances[0].pk,
    },
    )
    )
    assert res.status_code == status.HTTP_200_OK
    assert res.json() == {
    "id": self.test_instances[0].id,
    "name": self.test_instances[0].test.name,
    "test_id": self.test_instances[0].test_id,
    "failure_message": self.test_instances[0].failure_message,
    "duration_seconds": self.test_instances[0].duration_seconds,
    "commitid": self.test_instances[0].commitid,
    "outcome": self.test_instances[0].outcome,
    "branch": self.test_instances[0].branch,
    "repoid": self.test_instances[0].repoid,
    "failure_rate": self.test_instances[0].test.failure_rate,
    "commits_where_fail": self.test_instances[0].test.commits_where_fail,
    > }
    E AttributeError: 'Test' object has no attribute 'failure_rate'

    .../v2/tests/test_test_results_view.py:142: AttributeError

This removes all usage of `ReportDetails`. The base definitions still exist.
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.

I double checked and didn't see any impact of removing the ReportDetails, files_array usages as proposed here on the GraphQL apis and public REST apis.
Honestly, I'm puzzled why this was here in the first place? Did some digging in the history but didn't turn up anything obvious (my best guess is at some point we moved over from reading the results of the coverage reports in reports_reportdetails.files_array and moved to a path at GCS at commits.report_storage_path)?

All the places our frontend app fetches any files data, it appears to download from the GCS path at commits.report_storage_path, so that's good, unaffected by this change.

I also smoke-tested clicked around the deployment at https://stage-app.codecov.dev/gh/codecov and didn't see anything out of place. So I think we should be good to go with this!

(disclaimer: I only lightly educated myself on the needs_recompute logic that was edited in this PR but seems generally reasonable!)

@Swatinem
Copy link
Contributor Author

Yes that was it, the ReportDetails.files_array was intended as a feature flagged replacement for the Commit.report_json (which is stored in GCS).

The feature flag never made it, and I wanted to be extra careful rolling back all the changes.

@Swatinem Swatinem added this pull request to the merge queue Oct 31, 2024
Merged via the queue into main with commit 4db2c66 Oct 31, 2024
29 of 32 checks passed
@Swatinem Swatinem deleted the swatinem/rm-reportdetails branch October 31, 2024 10:34
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.

5 participants