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 the report_builder #710

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

Swatinem
Copy link
Contributor

I think the intention of the report_builder setting was to build a Report from various database tables, instead of from the report_json blob.

However, it is unclear if that is actually faster, as some of the involved tables are slow to query, and the files_array field was doing a storage request anyway.

So the code was still doing two storage requests (chunks and files_array) plus various SELECTs, instead of doing just two storage requests (report_json and chunks).

I think the intention of the `report_builder` setting was to build a `Report` from various database tables,
instead of from the `report_json` blob.

However, it is unclear if that is actually faster, as some of the involved tables are slow to query, and the `files_array` field was doing a storage request anyway.

So the code was still doing two storage requests (`chunks` and `files_array`) plus various SELECTs, instead of doing just two storage requests (`report_json` and `chunks`).
@Swatinem Swatinem requested a review from a team September 16, 2024 13:04
@Swatinem Swatinem self-assigned this Sep 16, 2024
Copy link

codecov bot commented Sep 16, 2024

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
1683 2 1681 0
View the top 2 failed tests by shortest run time
services.tests.test_report.TestReportService test_build_report_from_commit
Stack Traces | 0.053s run time
self = <worker.services.tests.test_report.TestReportService object at 0x7fc5772d7680>
dbsession = <sqlalchemy.orm.session.Session object at 0x7fc560b45790>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7fc5703b6900>

    def test_build_report_from_commit(self, dbsession, mock_storage):
        commit = CommitFactory(_report_json=None)
        dbsession.add(commit)
        report = ReportFactory(commit=commit)
        dbsession.add(report)
    
        details = ReportDetailsFactory(
            report=report,
            _files_array=[
                {
                    "filename": "awesome/__init__.py",
                    "file_index": 2,
                    "file_totals": [0, 10, 8, 2, 0, "80.00000", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": [0, 2, 1, 1, 0, "50.00000", 0, 0, 0, 0, 0, 0, 0],
                },
                {
                    "filename": "tests/__init__.py",
                    "file_index": 0,
                    "file_totals": [0, 3, 2, 1, 0, "66.66667", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": None,
                },
                {
                    "filename": "tests/test_sample.py",
                    "file_index": 1,
                    "file_totals": [0, 7, 7, 0, 0, "100", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": None,
                },
            ],
        )
        dbsession.add(details)
        totals = ReportLevelTotalsFactory(
            report=report,
            files=3,
            lines=20,
            hits=17,
            misses=3,
            partials=0,
            coverage=85.0,
            branches=0,
            methods=0,
        )
        dbsession.add(totals)
    
        upload = UploadFactory(report=report, order_number=0, upload_type="upload")
        dbsession.add(upload)
        upload_totals = UploadLevelTotalsFactory(
            upload=upload,
            files=3,
            lines=20,
            hits=17,
            misses=3,
            partials=0,
            coverage=85.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals)
        dbsession.commit()
        dbsession.flush()
    
        with open(".../tests/samples/sample_chunks_1.txt") as f:
            content = f.read().encode()
            archive_hash = ArchiveService.get_archive_hash(commit.repository)
            chunks_url = f"v4/repos/{archive_hash}/commits/{commit.commitid}/chunks.txt"
            mock_storage.write_file("archive", chunks_url, content)
    
        report = ReportService({}).build_report_from_commit(commit)
        assert report is not None
>       assert report.files == [
            "awesome/__init__.py",
            "tests/__init__.py",
            "tests/test_sample.py",
        ]
E       AssertionError: assert [] == ['awesome/__i...st_sample.py']
E         
E         Right contains 3 more items, first extra item: 'awesome/__init__.py'
E         Use -v to get more diff

services/tests/test_report.py:503: AssertionError
services.tests.test_report.TestReportService test_build_report_from_commit_with_flags
Stack Traces | 0.07s run time
self = <worker.services.tests.test_report.TestReportService object at 0x7fc5772c4f50>
dbsession = <sqlalchemy.orm.session.Session object at 0x7fc560fa3170>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7fc560fa27e0>

    def test_build_report_from_commit_with_flags(self, dbsession, mock_storage):
        commit = CommitFactory(_report_json=None)
        dbsession.add(commit)
        report = ReportFactory(commit=commit)
        dbsession.add(report)
    
        details = ReportDetailsFactory(
            report=report,
            _files_array=[
                {
                    "filename": "awesome/__init__.py",
                    "file_index": 2,
                    "file_totals": [0, 10, 8, 2, 0, "80.00000", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": [0, 2, 1, 1, 0, "50.00000", 0, 0, 0, 0, 0, 0, 0],
                },
                {
                    "filename": "tests/__init__.py",
                    "file_index": 0,
                    "file_totals": [0, 3, 2, 1, 0, "66.66667", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": None,
                },
                {
                    "filename": "tests/test_sample.py",
                    "file_index": 1,
                    "file_totals": [0, 7, 7, 0, 0, "100", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": None,
                },
            ],
        )
        dbsession.add(details)
        totals = ReportLevelTotalsFactory(
            report=report,
            files=3,
            lines=20,
            hits=17,
            misses=3,
            partials=0,
            coverage=85.0,
            branches=0,
            methods=0,
        )
        dbsession.add(totals)
    
        flag1 = RepositoryFlagFactory(
            repository=commit.repository,
            flag_name="unit",
        )
        dbsession.add(flag1)
        flag2 = RepositoryFlagFactory(
            repository=commit.repository,
            flag_name="integration",
        )
        dbsession.add(flag2)
        flag3 = RepositoryFlagFactory(
            repository=commit.repository,
            flag_name="labels-flag",
        )
        dbsession.add(flag3)
    
        upload1 = UploadFactory(
            report=report, flags=[flag1], order_number=0, upload_type="upload"
        )
        dbsession.add(upload1)
        upload_totals1 = UploadLevelTotalsFactory(
            upload=upload1,
            files=3,
            lines=20,
            hits=17,
            misses=3,
            partials=0,
            coverage=85.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals1)
        dbsession.commit()
    
        upload2 = UploadFactory(
            report=report, flags=[flag1], order_number=1, upload_type="carriedforward"
        )
        dbsession.add(upload2)
        upload_totals2 = UploadLevelTotalsFactory(
            upload=upload2,
            files=3,
            lines=20,
            hits=20,
            misses=0,
            partials=0,
            coverage=100.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals2)
        dbsession.commit()
    
        upload3 = UploadFactory(
            report=report, flags=[flag2], order_number=2, upload_type="carriedforward"
        )
        dbsession.add(upload3)
        upload_totals3 = UploadLevelTotalsFactory(
            upload=upload3,
            files=3,
            lines=20,
            hits=20,
            misses=0,
            partials=0,
            coverage=100.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals3)
        dbsession.commit()
        dbsession.flush()
    
        upload4 = UploadFactory(
            report=report, flags=[flag3], order_number=3, upload_type="upload"
        )
        dbsession.add(upload4)
        upload_totals4 = UploadLevelTotalsFactory(
            upload=upload4,
            files=3,
            lines=20,
            hits=20,
            misses=0,
            partials=0,
            coverage=100.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals4)
        dbsession.commit()
        dbsession.flush()
    
        with open(".../tests/samples/sample_chunks_1.txt") as f:
            content = f.read().encode()
            archive_hash = ArchiveService.get_archive_hash(commit.repository)
            chunks_url = f"v4/repos/{archive_hash}/commits/{commit.commitid}/chunks.txt"
            mock_storage.write_file("archive", chunks_url, content)
    
        yaml = {
            "flag_management": {
                "individual_flags": [
                    {
                        "name": "labels-flag",
                        "carryforward": True,
                        "carryforward_mode": "labels",
                    }
                ]
            }
        }
        report = ReportService(yaml).build_report_from_commit(commit)
        assert report is not None
>       assert report.files == [
            "awesome/__init__.py",
            "tests/__init__.py",
            "tests/test_sample.py",
        ]
E       AssertionError: assert [] == ['awesome/__i...st_sample.py']
E         
E         Right contains 3 more items, first extra item: 'awesome/__init__.py'
E         Use -v to get more diff

services/tests/test_report.py:698: AssertionError

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

@codecov-staging
Copy link

codecov-staging bot commented Sep 16, 2024

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
1683 2 1681 0
View the top 2 failed tests by shortest run time
services.tests.test_report.TestReportService test_build_report_from_commit
Stack Traces | 0.053s run time
self = <worker.services.tests.test_report.TestReportService object at 0x7fc5772d7680>
dbsession = <sqlalchemy.orm.session.Session object at 0x7fc560b45790>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7fc5703b6900>

    def test_build_report_from_commit(self, dbsession, mock_storage):
        commit = CommitFactory(_report_json=None)
        dbsession.add(commit)
        report = ReportFactory(commit=commit)
        dbsession.add(report)
    
        details = ReportDetailsFactory(
            report=report,
            _files_array=[
                {
                    "filename": "awesome/__init__.py",
                    "file_index": 2,
                    "file_totals": [0, 10, 8, 2, 0, "80.00000", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": [0, 2, 1, 1, 0, "50.00000", 0, 0, 0, 0, 0, 0, 0],
                },
                {
                    "filename": "tests/__init__.py",
                    "file_index": 0,
                    "file_totals": [0, 3, 2, 1, 0, "66.66667", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": None,
                },
                {
                    "filename": "tests/test_sample.py",
                    "file_index": 1,
                    "file_totals": [0, 7, 7, 0, 0, "100", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": None,
                },
            ],
        )
        dbsession.add(details)
        totals = ReportLevelTotalsFactory(
            report=report,
            files=3,
            lines=20,
            hits=17,
            misses=3,
            partials=0,
            coverage=85.0,
            branches=0,
            methods=0,
        )
        dbsession.add(totals)
    
        upload = UploadFactory(report=report, order_number=0, upload_type="upload")
        dbsession.add(upload)
        upload_totals = UploadLevelTotalsFactory(
            upload=upload,
            files=3,
            lines=20,
            hits=17,
            misses=3,
            partials=0,
            coverage=85.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals)
        dbsession.commit()
        dbsession.flush()
    
        with open(".../tests/samples/sample_chunks_1.txt") as f:
            content = f.read().encode()
            archive_hash = ArchiveService.get_archive_hash(commit.repository)
            chunks_url = f"v4/repos/{archive_hash}/commits/{commit.commitid}/chunks.txt"
            mock_storage.write_file("archive", chunks_url, content)
    
        report = ReportService({}).build_report_from_commit(commit)
        assert report is not None
>       assert report.files == [
            "awesome/__init__.py",
            "tests/__init__.py",
            "tests/test_sample.py",
        ]
E       AssertionError: assert [] == ['awesome/__i...st_sample.py']
E         
E         Right contains 3 more items, first extra item: 'awesome/__init__.py'
E         Use -v to get more diff

services/tests/test_report.py:503: AssertionError
services.tests.test_report.TestReportService test_build_report_from_commit_with_flags
Stack Traces | 0.07s run time
self = <worker.services.tests.test_report.TestReportService object at 0x7fc5772c4f50>
dbsession = <sqlalchemy.orm.session.Session object at 0x7fc560fa3170>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7fc560fa27e0>

    def test_build_report_from_commit_with_flags(self, dbsession, mock_storage):
        commit = CommitFactory(_report_json=None)
        dbsession.add(commit)
        report = ReportFactory(commit=commit)
        dbsession.add(report)
    
        details = ReportDetailsFactory(
            report=report,
            _files_array=[
                {
                    "filename": "awesome/__init__.py",
                    "file_index": 2,
                    "file_totals": [0, 10, 8, 2, 0, "80.00000", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": [0, 2, 1, 1, 0, "50.00000", 0, 0, 0, 0, 0, 0, 0],
                },
                {
                    "filename": "tests/__init__.py",
                    "file_index": 0,
                    "file_totals": [0, 3, 2, 1, 0, "66.66667", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": None,
                },
                {
                    "filename": "tests/test_sample.py",
                    "file_index": 1,
                    "file_totals": [0, 7, 7, 0, 0, "100", 0, 0, 0, 0, 0, 0, 0],
                    "diff_totals": None,
                },
            ],
        )
        dbsession.add(details)
        totals = ReportLevelTotalsFactory(
            report=report,
            files=3,
            lines=20,
            hits=17,
            misses=3,
            partials=0,
            coverage=85.0,
            branches=0,
            methods=0,
        )
        dbsession.add(totals)
    
        flag1 = RepositoryFlagFactory(
            repository=commit.repository,
            flag_name="unit",
        )
        dbsession.add(flag1)
        flag2 = RepositoryFlagFactory(
            repository=commit.repository,
            flag_name="integration",
        )
        dbsession.add(flag2)
        flag3 = RepositoryFlagFactory(
            repository=commit.repository,
            flag_name="labels-flag",
        )
        dbsession.add(flag3)
    
        upload1 = UploadFactory(
            report=report, flags=[flag1], order_number=0, upload_type="upload"
        )
        dbsession.add(upload1)
        upload_totals1 = UploadLevelTotalsFactory(
            upload=upload1,
            files=3,
            lines=20,
            hits=17,
            misses=3,
            partials=0,
            coverage=85.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals1)
        dbsession.commit()
    
        upload2 = UploadFactory(
            report=report, flags=[flag1], order_number=1, upload_type="carriedforward"
        )
        dbsession.add(upload2)
        upload_totals2 = UploadLevelTotalsFactory(
            upload=upload2,
            files=3,
            lines=20,
            hits=20,
            misses=0,
            partials=0,
            coverage=100.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals2)
        dbsession.commit()
    
        upload3 = UploadFactory(
            report=report, flags=[flag2], order_number=2, upload_type="carriedforward"
        )
        dbsession.add(upload3)
        upload_totals3 = UploadLevelTotalsFactory(
            upload=upload3,
            files=3,
            lines=20,
            hits=20,
            misses=0,
            partials=0,
            coverage=100.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals3)
        dbsession.commit()
        dbsession.flush()
    
        upload4 = UploadFactory(
            report=report, flags=[flag3], order_number=3, upload_type="upload"
        )
        dbsession.add(upload4)
        upload_totals4 = UploadLevelTotalsFactory(
            upload=upload4,
            files=3,
            lines=20,
            hits=20,
            misses=0,
            partials=0,
            coverage=100.0,
            branches=0,
            methods=0,
        )
        dbsession.add(upload_totals4)
        dbsession.commit()
        dbsession.flush()
    
        with open(".../tests/samples/sample_chunks_1.txt") as f:
            content = f.read().encode()
            archive_hash = ArchiveService.get_archive_hash(commit.repository)
            chunks_url = f"v4/repos/{archive_hash}/commits/{commit.commitid}/chunks.txt"
            mock_storage.write_file("archive", chunks_url, content)
    
        yaml = {
            "flag_management": {
                "individual_flags": [
                    {
                        "name": "labels-flag",
                        "carryforward": True,
                        "carryforward_mode": "labels",
                    }
                ]
            }
        }
        report = ReportService(yaml).build_report_from_commit(commit)
        assert report is not None
>       assert report.files == [
            "awesome/__init__.py",
            "tests/__init__.py",
            "tests/test_sample.py",
        ]
E       AssertionError: assert [] == ['awesome/__i...st_sample.py']
E         
E         Right contains 3 more items, first extra item: 'awesome/__init__.py'
E         Use -v to get more diff

services/tests/test_report.py:698: AssertionError

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

@codecov-qa
Copy link

codecov-qa bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.10%. Comparing base (8e96f4d) to head (6d7ca86).
Report is 1 commits behind head on main.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #710      +/-   ##
==========================================
- Coverage   98.09%   91.10%   -6.99%     
==========================================
  Files         434      434              
  Lines       36607    36512      -95     
==========================================
- Hits        35911    33266    -2645     
- Misses        696     3246    +2550     
Flag Coverage Δ
integration 91.10% <100.00%> (-6.99%) ⬇️
latest-uploader-overall 91.10% <100.00%> (-6.99%) ⬇️
unit 91.10% <100.00%> (-6.99%) ⬇️

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

Components Coverage Δ
NonTestCode 90.13% <100.00%> (-5.89%) ⬇️
OutsideTasks 95.89% <100.00%> (-2.21%) ⬇️
Files with missing lines Coverage Δ
services/notification/notifiers/tests/conftest.py 99.62% <100.00%> (-0.38%) ⬇️
services/report/__init__.py 93.97% <100.00%> (-3.45%) ⬇️
tasks/backfill_commit_data_to_storage.py 97.29% <100.00%> (ø)
.../unit/test_backfill_commit_data_to_storage_task.py 100.00% <ø> (ø)

... and 62 files with indirect coverage changes

Copy link

codecov-public-qa bot commented Sep 16, 2024

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

❌ Failed Test Results:

Completed 1683 tests with 2 failed, 1681 passed and 0 skipped.

View the full list of failed tests

pytest

  • Class name: services.tests.test_report.TestReportService
    Test name: test_build_report_from_commit

    self = <worker.services.tests.test_report.TestReportService object at 0x7fc5772d7680>
    dbsession = <sqlalchemy.orm.session.Session object at 0x7fc560b45790>
    mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7fc5703b6900>

    def test_build_report_from_commit(self, dbsession, mock_storage):
    commit = CommitFactory(_report_json=None)
    dbsession.add(commit)
    report = ReportFactory(commit=commit)
    dbsession.add(report)

    details = ReportDetailsFactory(
    report=report,
    _files_array=[
    {
    "filename": "awesome/__init__.py",
    "file_index": 2,
    "file_totals": [0, 10, 8, 2, 0, "80.00000", 0, 0, 0, 0, 0, 0, 0],
    "diff_totals": [0, 2, 1, 1, 0, "50.00000", 0, 0, 0, 0, 0, 0, 0],
    },
    {
    "filename": "tests/__init__.py",
    "file_index": 0,
    "file_totals": [0, 3, 2, 1, 0, "66.66667", 0, 0, 0, 0, 0, 0, 0],
    "diff_totals": None,
    },
    {
    "filename": "tests/test_sample.py",
    "file_index": 1,
    "file_totals": [0, 7, 7, 0, 0, "100", 0, 0, 0, 0, 0, 0, 0],
    "diff_totals": None,
    },
    ],
    )
    dbsession.add(details)
    totals = ReportLevelTotalsFactory(
    report=report,
    files=3,
    lines=20,
    hits=17,
    misses=3,
    partials=0,
    coverage=85.0,
    branches=0,
    methods=0,
    )
    dbsession.add(totals)

    upload = UploadFactory(report=report, order_number=0, upload_type="upload")
    dbsession.add(upload)
    upload_totals = UploadLevelTotalsFactory(
    upload=upload,
    files=3,
    lines=20,
    hits=17,
    misses=3,
    partials=0,
    coverage=85.0,
    branches=0,
    methods=0,
    )
    dbsession.add(upload_totals)
    dbsession.commit()
    dbsession.flush()

    with open(".../tests/samples/sample_chunks_1.txt") as f:
    content = f.read().encode()
    archive_hash = ArchiveService.get_archive_hash(commit.repository)
    chunks_url = f"v4/repos/{archive_hash}/commits/{commit.commitid}/chunks.txt"
    mock_storage.write_file("archive", chunks_url, content)

    report = ReportService({}).build_report_from_commit(commit)
    assert report is not None
    > assert report.files == [
    "awesome/__init__.py",
    "tests/__init__.py",
    "tests/test_sample.py",
    ]
    E AssertionError: assert [] == ['awesome/__i...st_sample.py']
    E
    E Right contains 3 more items, first extra item: 'awesome/__init__.py'
    E Use -v to get more diff

    services/tests/test_report.py:503: AssertionError
  • Class name: services.tests.test_report.TestReportService
    Test name: test_build_report_from_commit_with_flags

    self = <worker.services.tests.test_report.TestReportService object at 0x7fc5772c4f50>
    dbsession = <sqlalchemy.orm.session.Session object at 0x7fc560fa3170>
    mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7fc560fa27e0>

    def test_build_report_from_commit_with_flags(self, dbsession, mock_storage):
    commit = CommitFactory(_report_json=None)
    dbsession.add(commit)
    report = ReportFactory(commit=commit)
    dbsession.add(report)

    details = ReportDetailsFactory(
    report=report,
    _files_array=[
    {
    "filename": "awesome/__init__.py",
    "file_index": 2,
    "file_totals": [0, 10, 8, 2, 0, "80.00000", 0, 0, 0, 0, 0, 0, 0],
    "diff_totals": [0, 2, 1, 1, 0, "50.00000", 0, 0, 0, 0, 0, 0, 0],
    },
    {
    "filename": "tests/__init__.py",
    "file_index": 0,
    "file_totals": [0, 3, 2, 1, 0, "66.66667", 0, 0, 0, 0, 0, 0, 0],
    "diff_totals": None,
    },
    {
    "filename": "tests/test_sample.py",
    "file_index": 1,
    "file_totals": [0, 7, 7, 0, 0, "100", 0, 0, 0, 0, 0, 0, 0],
    "diff_totals": None,
    },
    ],
    )
    dbsession.add(details)
    totals = ReportLevelTotalsFactory(
    report=report,
    files=3,
    lines=20,
    hits=17,
    misses=3,
    partials=0,
    coverage=85.0,
    branches=0,
    methods=0,
    )
    dbsession.add(totals)

    flag1 = RepositoryFlagFactory(
    repository=commit.repository,
    flag_name="unit",
    )
    dbsession.add(flag1)
    flag2 = RepositoryFlagFactory(
    repository=commit.repository,
    flag_name="integration",
    )
    dbsession.add(flag2)
    flag3 = RepositoryFlagFactory(
    repository=commit.repository,
    flag_name="labels-flag",
    )
    dbsession.add(flag3)

    upload1 = UploadFactory(
    report=report, flags=[flag1], order_number=0, upload_type="upload"
    )
    dbsession.add(upload1)
    upload_totals1 = UploadLevelTotalsFactory(
    upload=upload1,
    files=3,
    lines=20,
    hits=17,
    misses=3,
    partials=0,
    coverage=85.0,
    branches=0,
    methods=0,
    )
    dbsession.add(upload_totals1)
    dbsession.commit()

    upload2 = UploadFactory(
    report=report, flags=[flag1], order_number=1, upload_type="carriedforward"
    )
    dbsession.add(upload2)
    upload_totals2 = UploadLevelTotalsFactory(
    upload=upload2,
    files=3,
    lines=20,
    hits=20,
    misses=0,
    partials=0,
    coverage=100.0,
    branches=0,
    methods=0,
    )
    dbsession.add(upload_totals2)
    dbsession.commit()

    upload3 = UploadFactory(
    report=report, flags=[flag2], order_number=2, upload_type="carriedforward"
    )
    dbsession.add(upload3)
    upload_totals3 = UploadLevelTotalsFactory(
    upload=upload3,
    files=3,
    lines=20,
    hits=20,
    misses=0,
    partials=0,
    coverage=100.0,
    branches=0,
    methods=0,
    )
    dbsession.add(upload_totals3)
    dbsession.commit()
    dbsession.flush()

    upload4 = UploadFactory(
    report=report, flags=[flag3], order_number=3, upload_type="upload"
    )
    dbsession.add(upload4)
    upload_totals4 = UploadLevelTotalsFactory(
    upload=upload4,
    files=3,
    lines=20,
    hits=20,
    misses=0,
    partials=0,
    coverage=100.0,
    branches=0,
    methods=0,
    )
    dbsession.add(upload_totals4)
    dbsession.commit()
    dbsession.flush()

    with open(".../tests/samples/sample_chunks_1.txt") as f:
    content = f.read().encode()
    archive_hash = ArchiveService.get_archive_hash(commit.repository)
    chunks_url = f"v4/repos/{archive_hash}/commits/{commit.commitid}/chunks.txt"
    mock_storage.write_file("archive", chunks_url, content)

    yaml = {
    "flag_management": {
    "individual_flags": [
    {
    "name": "labels-flag",
    "carryforward": True,
    "carryforward_mode": "labels",
    }
    ]
    }
    }
    report = ReportService(yaml).build_report_from_commit(commit)
    assert report is not None
    > assert report.files == [
    "awesome/__init__.py",
    "tests/__init__.py",
    "tests/test_sample.py",
    ]
    E AssertionError: assert [] == ['awesome/__i...st_sample.py']
    E
    E Right contains 3 more items, first extra item: 'awesome/__init__.py'
    E Use -v to get more diff

    services/tests/test_report.py:698: AssertionError

@Swatinem Swatinem marked this pull request as draft September 16, 2024 13:43
@Swatinem Swatinem marked this pull request as draft September 16, 2024 13:43
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.

1 participant