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

Release 24.8.1 #734

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Release 24.8.1 #734

merged 1 commit into from
Aug 6, 2024

Conversation

codecov-releaser
Copy link
Contributor

Release PR for 24.8.1
I've updated the version name and committed: 530ec2a.

@codecov-notifications
Copy link

codecov-notifications bot commented Aug 5, 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

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.02%. Comparing base (40e1262) to head (97287a3).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##               main       #734   +/-   ##
===========================================
  Coverage   96.02000   96.02000           
===========================================
  Files           814        814           
  Lines         18443      18443           
===========================================
  Hits          17710      17710           
  Misses          733        733           
Flag Coverage Δ
unit 91.73% <ø> (ø)
unit-latest-uploader 91.73% <ø> (ø)

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 Aug 5, 2024

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

❌ Failed Test Results:

Completed 2265 tests with 16 failed, 2243 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_asset_measurements

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_asset_measurements>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299454536336'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_asset_measurements(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    $asset: String!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    asset(name: $asset){
    name
    measurements(
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Tests can only fetch JS asset
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-06",
    "before": "2024-06-10",
    "asset": "asset-same-name-diff-modules.js",
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "asset": {
    "measurements": {
    "assetType": "JAVASCRIPT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 4126.0,
    "max": 4126.0,
    "min": 4126.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 14126.0,
    "max": 14126.0,
    "min": 14126.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 150,
    },
    "size": {
    "gzip": 14,
    "uncompress": 14126,
    },
    },
    },
    "name": "asset-same-name-diff-modules.js",
    },
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'asset': {'measurements': {'assetType': 'JAVASCRIPT_SIZE', 'change':...0, 'timestamp': '2024-06-10T00:00:00+00:00'}], 'name': 'asset-*.js', ...}, 'name': 'asset-same-name-diff-modules.js'}}}

    graphql_api/tests/test_bundle_analysis_measurements.py:756: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_branch

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_branch>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299454868384'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_branch(self, get_storage_service):
    measurements_data = [
    # 2024-06-10
    ["bundle_analysis_report_size", "super", "2024-06-10T19:07:23", 123],
    # 2024-06-06
    ["bundle_analysis_report_size", "super", "2024-06-06T19:07:23", 456],
    ]

    for item in measurements_data:
    MeasurementFactory(
    name=item[0],
    owner_id=self.org.pk,
    repo_id=self.repo.pk,
    branch="feat",
    measurable_id=item[1],
    commit_sha=self.commit.pk,
    timestamp=item[2],
    value=item[3],
    )

    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    $branch: String!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    branch: $branch
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-07",
    "before": "2024-06-10",
    "branch": "feat",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "name": "super",
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "FONT_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "IMAGE_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "REPORT_SIZE",
    "name": None,
    "size": {
    "loadTime": {"threeG": 1, "highSpeed": 0},
    "size": {"gzip": 0, "uncompress": 123},
    },
    "change": {
    "loadTime": {"threeG": -3, "highSpeed": 0},
    "size": {"gzip": 0, "uncompress": -333},
    },
    "measurements": [
    {
    "avg": 456.0,
    "min": 456.0,
    "max": 456.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 123.0,
    "min": 123.0,
    "max": 123.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    ],
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': None, 'measur... ...}, {'assetType': 'JAVASCRIPT_SIZE', 'change': None, 'measurements': [], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:2115: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_measurements

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_measurements>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299453951264'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_measurements(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Test without using asset type filters
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-06",
    "before": "2024-06-10",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 4126.0,
    "max": 4126.0,
    "min": 4126.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 14126.0,
    "max": 14126.0,
    "min": 14126.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 150,
    },
    "size": {
    "gzip": 14,
    "uncompress": 14126,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 1421.0,
    "max": 1421.0,
    "min": 1421.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 11421.0,
    "max": 11421.0,
    "min": 11421.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 121,
    },
    "size": {
    "gzip": 11,
    "uncompress": 11421,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": None,
    "measurements": [],
    "name": "asset-*.js",
    "size": None,
    },
    {
    "assetType": "FONT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 2,
    },
    "size": {
    "gzip": 0,
    "uncompress": 240,
    },
    },
    "measurements": [
    {
    "avg": 50.0,
    "max": 50.0,
    "min": 50.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 290.0,
    "max": 290.0,
    "min": 290.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 3,
    },
    "size": {
    "gzip": 0,
    "uncompress": 290,
    },
    },
    },
    {
    "assetType": "IMAGE_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 25,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2400,
    },
    },
    "measurements": [
    {
    "avg": 500.0,
    "max": 500.0,
    "min": 500.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 2900.0,
    "max": 2900.0,
    "min": 2900.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 30,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2900,
    },
    },
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 5,
    "threeG": 224,
    },
    "size": {
    "gzip": 21,
    "uncompress": 21000,
    },
    },
    "measurements": [
    {
    "avg": 5708.0,
    "max": 5708.0,
    "min": 5708.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 26708.0,
    "max": 26708.0,
    "min": 26708.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 284,
    },
    "size": {
    "gzip": 26,
    "uncompress": 26708,
    },
    },
    },
    {
    "assetType": "REPORT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 6,
    "threeG": 252,
    },
    "size": {
    "gzip": 23,
    "uncompress": 23664,
    },
    },
    "measurements": [
    {
    "avg": 6263.0,
    "max": 6263.0,
    "min": 6263.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29927.0,
    "max": 29927.0,
    "min": 29927.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 319,
    },
    "size": {
    "gzip": 29,
    "uncompress": 29927,
    },
    },
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 24,
    },
    },
    "measurements": [
    {
    "avg": 5.0,
    "max": 5.0,
    "min": 5.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29.0,
    "max": 29.0,
    "min": 29.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 29,
    },
    },
    },
    ],
    "name": "super",
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': {'loadTime': ...'max': 26708.0, 'min': 26708.0, 'timestamp': '2024-06-10T00:00:00+00:00'}], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:179: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_measurements_carryovers

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_measurements_carryovers>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299452234112'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_measurements_carryovers(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Test without using asset type filters
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-07",
    "before": "2024-06-10",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 4126.0,
    "max": 4126.0,
    "min": 4126.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 14126.0,
    "max": 14126.0,
    "min": 14126.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 150,
    },
    "size": {
    "gzip": 14,
    "uncompress": 14126,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 1421.0,
    "max": 1421.0,
    "min": 1421.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 11421.0,
    "max": 11421.0,
    "min": 11421.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 121,
    },
    "size": {
    "gzip": 11,
    "uncompress": 11421,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": None,
    "measurements": [],
    "name": "asset-*.js",
    "size": None,
    },
    {
    "assetType": "FONT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 2,
    },
    "size": {
    "gzip": 0,
    "uncompress": 240,
    },
    },
    "measurements": [
    {
    "avg": 50.0,
    "max": 50.0,
    "min": 50.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 290.0,
    "max": 290.0,
    "min": 290.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 3,
    },
    "size": {
    "gzip": 0,
    "uncompress": 290,
    },
    },
    },
    {
    "assetType": "IMAGE_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 25,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2400,
    },
    },
    "measurements": [
    {
    "avg": 500.0,
    "max": 500.0,
    "min": 500.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 2900.0,
    "max": 2900.0,
    "min": 2900.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 30,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2900,
    },
    },
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 5,
    "threeG": 224,
    },
    "size": {
    "gzip": 21,
    "uncompress": 21000,
    },
    },
    "measurements": [
    {
    "avg": 5708.0,
    "max": 5708.0,
    "min": 5708.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 26708.0,
    "max": 26708.0,
    "min": 26708.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 284,
    },
    "size": {
    "gzip": 26,
    "uncompress": 26708,
    },
    },
    },
    {
    "assetType": "REPORT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 6,
    "threeG": 252,
    },
    "size": {
    "gzip": 23,
    "uncompress": 23664,
    },
    },
    "measurements": [
    {
    "avg": 6263.0,
    "max": 6263.0,
    "min": 6263.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29927.0,
    "max": 29927.0,
    "min": 29927.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 319,
    },
    "size": {
    "gzip": 29,
    "uncompress": 29927,
    },
    },
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 24,
    },
    },
    "measurements": [
    {
    "avg": 5.0,
    "max": 5.0,
    "min": 5.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29.0,
    "max": 29.0,
    "min": 29.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 29,
    },
    },
    },
    ],
    "name": "super",
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': {'loadTime': ...'max': 26708.0, 'min': 26708.0, 'timestamp': '2024-06-10T00:00:00+00:00'}], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:936: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_no_after

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_no_after>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299452142688'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_no_after(self, get_storage_service):
    measurements_data = [
    # 2024-06-10
    ["bundle_analysis_report_size", "super", "2024-06-10T19:07:23", 123],
    # 2024-06-06
    ["bundle_analysis_report_size", "super", "2024-06-06T19:07:23", 456],
    ]

    for item in measurements_data:
    MeasurementFactory(
    name=item[0],
    owner_id=self.org.pk,
    repo_id=self.repo.pk,
    branch="feat",
    measurable_id=item[1],
    commit_sha=self.commit.pk,
    timestamp=item[2],
    value=item[3],
    )

    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime
    $branch: String!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    branch: $branch
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": None,
    "before": "2024-06-10",
    "branch": "feat",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "name": "super",
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "FONT_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "IMAGE_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "REPORT_SIZE",
    "name": None,
    "size": {
    "loadTime": {"threeG": 1, "highSpeed": 0},
    "size": {"gzip": 0, "uncompress": 123},
    },
    "change": {
    "loadTime": {"threeG": -3, "highSpeed": 0},
    "size": {"gzip": 0, "uncompress": -333},
    },
    "measurements": [
    {
    "avg": 456.0,
    "min": 456.0,
    "max": 456.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 123.0,
    "min": 123.0,
    "max": 123.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    ],
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': None, 'measur... ...}, {'assetType': 'JAVASCRIPT_SIZE', 'change': None, 'measurements': [], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:2324: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_no_carryovers

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_no_carryovers>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299452684224'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_no_carryovers(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Test without using asset type filters
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-05",
    "before": "2024-06-10",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 4126.0,
    "max": 4126.0,
    "min": 4126.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 14126.0,
    "max": 14126.0,
    "min": 14126.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 150,
    },
    "size": {
    "gzip": 14,
    "uncompress": 14126,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 1421.0,
    "max": 1421.0,
    "min": 1421.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 11421.0,
    "max": 11421.0,
    "min": 11421.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 121,
    },
    "size": {
    "gzip": 11,
    "uncompress": 11421,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": None,
    "measurements": [],
    "name": "asset-*.js",
    "size": None,
    },
    {
    "assetType": "FONT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 2,
    },
    "size": {
    "gzip": 0,
    "uncompress": 240,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 50.0,
    "max": 50.0,
    "min": 50.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 290.0,
    "max": 290.0,
    "min": 290.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 3,
    },
    "size": {
    "gzip": 0,
    "uncompress": 290,
    },
    },
    },
    {
    "assetType": "IMAGE_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 25,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2400,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 500.0,
    "max": 500.0,
    "min": 500.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 2900.0,
    "max": 2900.0,
    "min": 2900.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 30,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2900,
    },
    },
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 5,
    "threeG": 224,
    },
    "size": {
    "gzip": 21,
    "uncompress": 21000,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 5708.0,
    "max": 5708.0,
    "min": 5708.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 26708.0,
    "max": 26708.0,
    "min": 26708.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 284,
    },
    "size": {
    "gzip": 26,
    "uncompress": 26708,
    },
    },
    },
    {
    "assetType": "REPORT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 6,
    "threeG": 252,
    },
    "size": {
    "gzip": 23,
    "uncompress": 23664,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 6263.0,
    "max": 6263.0,
    "min": 6263.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29927.0,
    "max": 29927.0,
    "min": 29927.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 319,
    },
    "size": {
    "gzip": 29,
    "uncompress": 29927,
    },
    },
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 24,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 5.0,
    "max": 5.0,
    "min": 5.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29.0,
    "max": 29.0,
    "min": 29.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 29,
    },
    },
    },
    ],
    "name": "super",
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': {'loadTime': ...'max': 26708.0, 'min': 26708.0, 'timestamp': '2024-06-10T00:00:00+00:00'}], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:1467: AssertionError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_asset

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_asset>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299417476304'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_asset(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open(
    "..../tests/samples/bundle_with_assets_and_modules.sqlite", "rb"
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b5") {
    moduleCount
    asset(name: "assets/LazyComponent-fcbb0922.js") {
    name
    normalizedName
    extension
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    modules {
    name
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > bundle_report = commit["bundleAnalysisReport"]["bundle"]
    E TypeError: 'NoneType' object is not subscriptable

    graphql_api/tests/test_commit.py:1300: TypeError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_asset_filtering

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_asset_filtering>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299456006240'>
    asset_reports_mock = <MagicMock name='asset_reports' id='140299456006816'>

    @patch("shared.bundle_analysis.BundleReport.asset_reports")
    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_asset_filtering(
    self, get_storage_service, asset_reports_mock
    ):
    storage = MemoryStorageService({})

    get_storage_service.return_value = storage
    asset_reports_mock.return_value = []

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open(
    "..../tests/samples/bundle_with_assets_and_modules.sqlite", "rb"
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!, $filters: BundleAnalysisReportFilters) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b5", filters: $filters) {
    moduleCount
    assets {
    name
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "filters": {},
    }

    configurations = [
    # No filters
    (
    {"loadTypes": None, "reportGroups": None},
    {"asset_types": None, "chunk_entry": None, "chunk_initial": None},
    ),
    ({}, {"asset_types": None, "chunk_entry": None, "chunk_initial": None}),
    # Just report groups
    (
    {"reportGroups": ["JAVASCRIPT", "FONT"]},
    {
    "asset_types": ["JAVASCRIPT", "FONT"],
    "chunk_entry": None,
    "chunk_initial": None,
    },
    ),
    # Load types -> chunk_entry cancels out
    (
    {"loadTypes": ["ENTRY", "INITIAL"]},
    {"asset_types": None, "chunk_entry": None, "chunk_initial": True},
    ),
    # Load types -> chunk_entry = True
    (
    {"loadTypes": ["ENTRY"]},
    {"asset_types": None, "chunk_entry": True, "chunk_initial": None},
    ),
    # Load types -> chunk_lazy = False
    (
    {"loadTypes": ["LAZY"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": False},
    ),
    # Load types -> chunk_initial cancels out
    (
    {"loadTypes": ["LAZY", "INITIAL"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": None},
    ),
    # Load types -> chunk_initial = True
    (
    {"loadTypes": ["INITIAL"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": True},
    ),
    # Load types -> chunk_initial = False
    (
    {"loadTypes": ["LAZY"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": False},
    ),
    ]

    for config in configurations:
    input_d, output_d = config
    variables["filters"] = input_d
    data = self.gql_request(query, variables=variables)
    > assert (
    data["owner"]["repository"]["commit"]["bundleAnalysisReport"]["bundle"]
    is not None
    )
    E TypeError: 'NoneType' object is not subscriptable

    graphql_api/tests/test_commit.py:1470: TypeError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_compare

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_compare>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299455801264'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_compare(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    base_commit_report = CommitReportFactory(
    commit=self.parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )
    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = (
    query_commit
    % """
    bundleAnalysisCompareWithParent {
    __typename
    ... on BundleAnalysisComparison {
    bundles {
    name
    changeType
    bundleData {
    size {
    uncompress
    }
    }
    bundleChange {
    size {
    uncompress
    }
    }
    }
    bundleData {
    size {
    uncompress
    }
    }
    bundleChange {
    size {
    uncompress
    }
    }
    }
    }
    """
    )

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]
    > assert commit["bundleAnalysisCompareWithParent"] == {
    "__typename": "BundleAnalysisComparison",
    "bundles": [
    {
    "name": "b1",
    "changeType": "changed",
    "bundleData": {"size": {"uncompress": 20}},
    "bundleChange": {"size": {"uncompress": 5}},
    },
    {
    "name": "b2",
    "changeType": "changed",
    "bundleData": {"size": {"uncompress": 200}},
    "bundleChange": {"size": {"uncompress": 50}},
    },
    {
    "name": "b3",
    "changeType": "added",
    "bundleData": {"size": {"uncompress": 1500}},
    "bundleChange": {"size": {"uncompress": 1500}},
    },
    {
    "name": "b5",
    "changeType": "changed",
    "bundleData": {"size": {"uncompress": 200000}},
    "bundleChange": {"size": {"uncompress": 50000}},
    },
    {
    "name": "b4",
    "changeType": "removed",
    "bundleData": {"size": {"uncompress": 0}},
    "bundleChange": {"size": {"uncompress": -15000}},
    },
    ],
    "bundleData": {"size": {"uncompress": 201720}},
    "bundleChange": {"size": {"uncompress": 36555}},
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisComparison', 'bundleChange': {'size': {'uncompress': 36555}}, 'bundleData': {'size': {'u...: {'size': {'uncompress': -15000}}, 'bundleData': {'size': {'uncompress': 0}}, 'changeType': 'removed', 'name': 'b4'}]}

    graphql_api/tests/test_commit.py:858: AssertionError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_report

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_report>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140300183136560'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundles {
    name
    assets {
    normalizedName
    }
    asset(name: "not_exist") {
    normalizedName
    }
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    isCached
    }
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    bundle(name: "not_exist") {
    name
    isCached
    }
    isCached
    }
    ... on MissingHeadReport {
    message
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundles": [
    {
    "name": "b1",
    "assets": [
    {"normalizedName": "assets/react-*.svg"},
    {"normalizedName": "assets/index-*.css"},
    {"normalizedName": "assets/LazyComponent-*.js"},
    {"normalizedName": "assets/index-*.js"},
    {"normalizedName": "assets/index-*.js"},
    ],
    "asset": None,
    "bundleData": {
    "loadTime": {
    "threeG": 0,
    "highSpeed": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 20,
    },
    },
    "isCached": False,
    },
    {
    "name": "b2",
    "assets": [
    {"normalizedName": "assets/react-*.svg"},
    {"normalizedName": "assets/index-*.css"},
    {"normalizedName": "assets/LazyComponent-*.js"},
    {"normalizedName": "assets/index-*.js"},
    {"normalizedName": "assets/index-*.js"},
    ],
    "asset": None,
    "bundleData": {
    "loadTime": {
    "threeG": 2,
    "highSpeed": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 200,
    },
    },
    "isCached": False,
    },
    {
    "name": "b3",
    "assets": [
    {"normalizedName": "assets/react-*.svg"},
    {"normalizedName": "assets/index-*.css"},
    {"normalizedName": "assets/LazyComponent-*.js"},
    {"normalizedName": "assets/index-*.js"},
    {"normalizedName": "assets/index-*.js"},
    ],
    "asset": None,
    "bundleData": {
    "loadTime": {
    "threeG": 16,
    "highSpeed": 0,
    },
    "size": {
    "gzip": 1,
    "uncompress": 1500,
    },
    },
    "isCached": False,
    },
    {
    "name": "b5",
    "assets": [
    {"normalizedName": "assets/react-*.svg"},
    {"normalizedName": "assets/index-*.css"},
    {"normalizedName": "assets/LazyComponent-*.js"},
    {"normalizedName": "assets/index-*.js"},
    {"normalizedName": "assets/index-*.js"},
    ],
    "asset": None,
    "bundleData": {
    "loadTime": {
    "threeG": 2133,
    "highSpeed": 53,
    },
    "size": {
    "gzip": 200,
    "uncompress": 200000,
    },
    },
    "isCached": False,
    },
    ],
    "bundleData": {
    "loadTime": {
    "threeG": 2151,
    "highSpeed": 53,
    },
    "size": {
    "gzip": 201,
    "uncompress": 201720,
    },
    },
    "bundle": None,
    "isCached": False,
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': None, 'bundleData': {'loadTime': {'highSpeed': 53, 'threeG': 2151}, '...dTime': {'highSpeed': 53, 'threeG': 2133}, 'size': {'gzip': 200, 'uncompress': 200000}}, 'isCached': False, ...}], ...}

    graphql_api/tests/test_commit.py:1119: AssertionError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_sqlite_file_deleted

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_sqlite_file_deleted>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299677439456'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_sqlite_file_deleted(self, get_storage_service):
    os.system("rm -rf /tmp/bundle_analysis_*")
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    base_commit_report = CommitReportFactory(
    commit=self.parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )
    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = (
    query_commit
    % """
    bundleAnalysisCompareWithParent {
    __typename
    ... on BundleAnalysisComparison {
    bundleData {
    size {
    uncompress
    }
    }
    }
    }
    """
    )

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    self.gql_request(query, variables=variables)

    for file in os.listdir("/tmp"):
    > assert not file.startswith("bundle_analysis_")
    E AssertionError: assert not True
    E + where True = <built-in method startswith of str object at 0x7f9a0377b820>('bundle_analysis_')
    E + where <built-in method startswith of str object at 0x7f9a0377b820> = 'bundle_analysis_n9g9zw_h'.startswith

    graphql_api/tests/test_commit.py:948: AssertionError
  • Class name: graphql_api.tests.test_pull.TestPullRequestList
    Test name: test_bundle_analysis_sqlite_file_deleted

    self = <graphql_api.tests.test_pull.TestPullRequestList testMethod=test_bundle_analysis_sqlite_file_deleted>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299408093600'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_sqlite_file_deleted(self, get_storage_service):
    os.system("rm -rf /tmp/bundle_analysis_*")
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    parent_commit = CommitFactory(repository=self.repository)
    commit = CommitFactory(
    repository=self.repository,
    totals={"c": "12", "diff": [0, 0, 0, 0, 0, "14"]},
    parent_commit_id=parent_commit.commitid,
    )

    base_commit_report = CommitReportFactory(
    commit=parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )
    head_commit_report = CommitReportFactory(
    commit=commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    my_pull = PullFactory(
    repository=self.repository,
    title="test-pull-request",
    author=self.owner,
    head=head_commit_report.commit.commitid,
    compared_to=base_commit_report.commit.commitid,
    behind_by=23,
    behind_by_commit="1089nf898as-jdf09hahs09fgh",
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repository),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repository),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    bundleAnalysisCompareWithBase {
    __typename
    ... on BundleAnalysisComparison {
    bundleData {
    size {
    uncompress
    }
    }
    }
    }
    """

    pull = self.fetch_one_pull_request(my_pull.pullid, query)

    > assert pull == {
    "bundleAnalysisCompareWithBase": {
    "__typename": "BundleAnalysisComparison",
    "bundleData": {
    "size": {
    "uncompress": 201720,
    }
    },
    }
    }
    E AssertionError: assert {'bundleAnaly...thBase': None} == {'bundleAnaly...s': 201720}}}}
    E
    E Differing items:
    E {'bundleAnalysisCompareWithBase': None} != {'bundleAnalysisCompareWithBase': {'__typename': 'BundleAnalysisComparison', 'bundleData': {'size': {'uncompress': 201720}}}}
    E Use -v to get more diff

    graphql_api/tests/test_pull.py:555: AssertionError
  • Class name: graphql_api.tests.test_pull.TestPullRequestList
    Test name: test_when_repository_has_null_head_has_parent_report

    self = <graphql_api.tests.test_pull.TestPullRequestList testMethod=test_when_repository_has_null_head_has_parent_report>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140300309715216'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_when_repository_has_null_head_has_parent_report(self, get_storage_service):
    os.system("rm -rf /tmp/bundle_analysis_*")
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    parent_commit = CommitFactory(repository=self.repository)

    base_commit_report = CommitReportFactory(
    commit=parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )

    my_pull = PullFactory(
    repository=self.repository,
    title="test-pull-request",
    author=self.owner,
    head=None,
    compared_to=base_commit_report.commit.commitid,
    behind_by=23,
    behind_by_commit="1089nf898as-jdf09hahs09fgh",
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repository),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    bundleAnalysisCompareWithBase {
    __typename
    ... on BundleAnalysisComparison {
    bundleData {
    size {
    uncompress
    }
    }
    bundleChange {
    size {
    uncompress
    }
    }
    }
    }
    """

    pull = self.fetch_one_pull_request(my_pull.pullid, query)

    > assert pull == {
    "bundleAnalysisCompareWithBase": {
    "__typename": "BundleAnalysisComparison",
    "bundleData": {
    "size": {
    "uncompress": 165165,
    }
    },
    "bundleChange": {
    "size": {
    "uncompress": 0,
    }
    },
    }
    }
    E AssertionError: assert {'bundleAnaly...thBase': None} == {'bundleAnaly...s': 165165}}}}
    E
    E Differing items:
    E {'bundleAnalysisCompareWithBase': None} != {'bundleAnalysisCompareWithBase': {'__typename': 'BundleAnalysisComparison', 'bundleChange': {'size': {'uncompress': 0}}, 'bundleData': {'size': {'uncompress': 165165}}}}
    E Use -v to get more diff

    graphql_api/tests/test_pull.py:324: AssertionError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_desc_commits_failed_ordering_on_test_results

    self = <django.db.backends.utils.CursorWrapper object at 0x7f9a10e73350>
    sql = 'INSERT INTO "reports_test" ("id", "external_id", "created_at", "updated_at", "repoid", "name", "testsuite", "flags_hash", "failure_rate", "commits_where_fail") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s::text[])'
    params = ('doctor', UUID('9c2a8f43-860a-4239-ac20-566eb63830ab'), datetime.datetime(2024, 8, 5, 20, 49, 36, 477183, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 8, 5, 20, 49, 36, 477190, tzinfo=datetime.timezone.utc), 1815, 'cover', ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f9a10e73350>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "reports_test_repoid_name_testsuite_flags_hash"
    E DETAIL: Key (repoid, name, testsuite, flags_hash)=(1815, cover, , ) already exists.

    .../local/lib/python3.12.../db/backends/utils.py:89: UniqueViolation

    The above exception was the direct cause of the following exception:

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_commits_failed_ordering_on_test_results>

    def test_desc_commits_failed_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    _test_instance_1 = TestInstanceFactory(
    test=test,
    created_at=datetime.datetime.now(),
    repoid=repo.repoid,
    commitid="1",
    )
    _test_instance_2 = TestInstanceFactory(
    test=test,
    created_at=datetime.datetime.now(),
    repoid=repo.repoid,
    commitid="2",
    )
    > test_2 = TestFactory(repository=repo)

    graphql_api/tests/test_repository.py:933:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:658: in create
    obj.save(force_insert=True, using=self.db)
    .../local/lib/python3.12.../db/models/base.py:814: in save
    self.save_base(
    .../local/lib/python3.12.../db/models/base.py:877: in save_base
    updated = self._save_table(
    .../local/lib/python3.12.../db/models/base.py:1020: in _save_table
    results = self._do_insert(
    .../local/lib/python3.12.../db/models/base.py:1061: in _do_insert
    return manager._insert(
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:1805: in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
    .../local/lib/python3.12.../models/sql/compiler.py:1822: in execute_sql
    cursor.execute(sql, params)
    .../local/lib/python3.12.../integrations/django/__init__.py:641: in execute
    result = real_execute(self, sql, params)
    .../local/lib/python3.12.../db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
    .../local/lib/python3.12.../db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
    .../local/lib/python3.12.../db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
    .../local/lib/python3.12.../django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <django.db.backends.utils.CursorWrapper object at 0x7f9a10e73350>
    sql = 'INSERT INTO "reports_test" ("id", "external_id", "created_at", "updated_at", "repoid", "name", "testsuite", "flags_hash", "failure_rate", "commits_where_fail") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s::text[])'
    params = ('doctor', UUID('9c2a8f43-860a-4239-ac20-566eb63830ab'), datetime.datetime(2024, 8, 5, 20, 49, 36, 477183, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 8, 5, 20, 49, 36, 477190, tzinfo=datetime.timezone.utc), 1815, 'cover', ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f9a10e73350>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E django.db.utils.IntegrityError: duplicate key value violates unique constraint "reports_test_repoid_name_testsuite_flags_hash"
    E DETAIL: Key (repoid, name, testsuite, flags_hash)=(1815, cover, , ) already exists.

    .../local/lib/python3.12.../db/backends/utils.py:89: IntegrityError
  • Class name: services.tests.test_bundle_analysis.TestBundleAnalysisComparison
    Test name: test_bundle_analysis_comparison

    self = <services.tests.test_bundle_analysis.TestBundleAnalysisComparison testMethod=test_bundle_analysis_comparison>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140300017402464'>

    @patch("services.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_comparison(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    loader = BundleAnalysisReportLoader(
    storage_service=storage,
    repo_key=ArchiveService.get_archive_hash(self.head_commit.repository),
    )

    > bac = BundleAnalysisComparison(
    loader,
    self.base_commit_report.external_id,
    self.head_commit_report.external_id,
    )

    services/tests/test_bundle_analysis.py:117:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    services/bundle_analysis.py:326: in __init__
    self.cleanup()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = BundleAnalysisComparison()

    def cleanup(self) -> None:
    > if self.comparison.head_report and self.comparison.head_report.db_session:
    E AttributeError: 'BundleAnalysisReport' object has no attribute 'db_session'

    services/bundle_analysis.py:329: AttributeError
  • Class name: services.tests.test_bundle_analysis.TestBundleAnalysisReport
    Test name: test_bundle_analysis_report

    self = <services.tests.test_bundle_analysis.TestBundleAnalysisReport testMethod=test_bundle_analysis_report>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140300017499264'>

    @patch("services.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    loader = BundleAnalysisReportLoader(
    storage_service=storage,
    repo_key=ArchiveService.get_archive_hash(self.commit.repository),
    )

    > bar = BundleAnalysisReport(loader.load(self.commit_report.external_id))

    services/tests/test_bundle_analysis.py:173:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    services/bundle_analysis.py:286: in __init__
    self.cleanup()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = BundleAnalysisReport()

    def cleanup(self) -> None:
    > if self.report and self.report.db_session:
    E AttributeError: 'BundleAnalysisReport' object has no attribute 'db_session'

    services/bundle_analysis.py:289: AttributeError

1 similar comment
Copy link

codecov-public-qa bot commented Aug 5, 2024

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

❌ Failed Test Results:

Completed 2265 tests with 16 failed, 2243 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_asset_measurements

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_asset_measurements>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299454536336'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_asset_measurements(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    $asset: String!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    asset(name: $asset){
    name
    measurements(
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Tests can only fetch JS asset
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-06",
    "before": "2024-06-10",
    "asset": "asset-same-name-diff-modules.js",
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "asset": {
    "measurements": {
    "assetType": "JAVASCRIPT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 4126.0,
    "max": 4126.0,
    "min": 4126.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 14126.0,
    "max": 14126.0,
    "min": 14126.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 150,
    },
    "size": {
    "gzip": 14,
    "uncompress": 14126,
    },
    },
    },
    "name": "asset-same-name-diff-modules.js",
    },
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'asset': {'measurements': {'assetType': 'JAVASCRIPT_SIZE', 'change':...0, 'timestamp': '2024-06-10T00:00:00+00:00'}], 'name': 'asset-*.js', ...}, 'name': 'asset-same-name-diff-modules.js'}}}

    graphql_api/tests/test_bundle_analysis_measurements.py:756: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_branch

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_branch>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299454868384'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_branch(self, get_storage_service):
    measurements_data = [
    # 2024-06-10
    ["bundle_analysis_report_size", "super", "2024-06-10T19:07:23", 123],
    # 2024-06-06
    ["bundle_analysis_report_size", "super", "2024-06-06T19:07:23", 456],
    ]

    for item in measurements_data:
    MeasurementFactory(
    name=item[0],
    owner_id=self.org.pk,
    repo_id=self.repo.pk,
    branch="feat",
    measurable_id=item[1],
    commit_sha=self.commit.pk,
    timestamp=item[2],
    value=item[3],
    )

    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    $branch: String!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    branch: $branch
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-07",
    "before": "2024-06-10",
    "branch": "feat",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "name": "super",
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "FONT_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "IMAGE_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "REPORT_SIZE",
    "name": None,
    "size": {
    "loadTime": {"threeG": 1, "highSpeed": 0},
    "size": {"gzip": 0, "uncompress": 123},
    },
    "change": {
    "loadTime": {"threeG": -3, "highSpeed": 0},
    "size": {"gzip": 0, "uncompress": -333},
    },
    "measurements": [
    {
    "avg": 456.0,
    "min": 456.0,
    "max": 456.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 123.0,
    "min": 123.0,
    "max": 123.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    ],
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': None, 'measur... ...}, {'assetType': 'JAVASCRIPT_SIZE', 'change': None, 'measurements': [], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:2115: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_measurements

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_measurements>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299453951264'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_measurements(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Test without using asset type filters
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-06",
    "before": "2024-06-10",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 4126.0,
    "max": 4126.0,
    "min": 4126.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 14126.0,
    "max": 14126.0,
    "min": 14126.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 150,
    },
    "size": {
    "gzip": 14,
    "uncompress": 14126,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 1421.0,
    "max": 1421.0,
    "min": 1421.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 11421.0,
    "max": 11421.0,
    "min": 11421.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 121,
    },
    "size": {
    "gzip": 11,
    "uncompress": 11421,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": None,
    "measurements": [],
    "name": "asset-*.js",
    "size": None,
    },
    {
    "assetType": "FONT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 2,
    },
    "size": {
    "gzip": 0,
    "uncompress": 240,
    },
    },
    "measurements": [
    {
    "avg": 50.0,
    "max": 50.0,
    "min": 50.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 290.0,
    "max": 290.0,
    "min": 290.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 3,
    },
    "size": {
    "gzip": 0,
    "uncompress": 290,
    },
    },
    },
    {
    "assetType": "IMAGE_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 25,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2400,
    },
    },
    "measurements": [
    {
    "avg": 500.0,
    "max": 500.0,
    "min": 500.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 2900.0,
    "max": 2900.0,
    "min": 2900.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 30,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2900,
    },
    },
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 5,
    "threeG": 224,
    },
    "size": {
    "gzip": 21,
    "uncompress": 21000,
    },
    },
    "measurements": [
    {
    "avg": 5708.0,
    "max": 5708.0,
    "min": 5708.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 26708.0,
    "max": 26708.0,
    "min": 26708.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 284,
    },
    "size": {
    "gzip": 26,
    "uncompress": 26708,
    },
    },
    },
    {
    "assetType": "REPORT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 6,
    "threeG": 252,
    },
    "size": {
    "gzip": 23,
    "uncompress": 23664,
    },
    },
    "measurements": [
    {
    "avg": 6263.0,
    "max": 6263.0,
    "min": 6263.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29927.0,
    "max": 29927.0,
    "min": 29927.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 319,
    },
    "size": {
    "gzip": 29,
    "uncompress": 29927,
    },
    },
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 24,
    },
    },
    "measurements": [
    {
    "avg": 5.0,
    "max": 5.0,
    "min": 5.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29.0,
    "max": 29.0,
    "min": 29.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 29,
    },
    },
    },
    ],
    "name": "super",
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': {'loadTime': ...'max': 26708.0, 'min': 26708.0, 'timestamp': '2024-06-10T00:00:00+00:00'}], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:179: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_measurements_carryovers

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_measurements_carryovers>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299452234112'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_measurements_carryovers(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Test without using asset type filters
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-07",
    "before": "2024-06-10",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 4126.0,
    "max": 4126.0,
    "min": 4126.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 14126.0,
    "max": 14126.0,
    "min": 14126.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 150,
    },
    "size": {
    "gzip": 14,
    "uncompress": 14126,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": 1421.0,
    "max": 1421.0,
    "min": 1421.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 11421.0,
    "max": 11421.0,
    "min": 11421.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 121,
    },
    "size": {
    "gzip": 11,
    "uncompress": 11421,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": None,
    "measurements": [],
    "name": "asset-*.js",
    "size": None,
    },
    {
    "assetType": "FONT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 2,
    },
    "size": {
    "gzip": 0,
    "uncompress": 240,
    },
    },
    "measurements": [
    {
    "avg": 50.0,
    "max": 50.0,
    "min": 50.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 290.0,
    "max": 290.0,
    "min": 290.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 3,
    },
    "size": {
    "gzip": 0,
    "uncompress": 290,
    },
    },
    },
    {
    "assetType": "IMAGE_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 25,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2400,
    },
    },
    "measurements": [
    {
    "avg": 500.0,
    "max": 500.0,
    "min": 500.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 2900.0,
    "max": 2900.0,
    "min": 2900.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 30,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2900,
    },
    },
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 5,
    "threeG": 224,
    },
    "size": {
    "gzip": 21,
    "uncompress": 21000,
    },
    },
    "measurements": [
    {
    "avg": 5708.0,
    "max": 5708.0,
    "min": 5708.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 26708.0,
    "max": 26708.0,
    "min": 26708.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 284,
    },
    "size": {
    "gzip": 26,
    "uncompress": 26708,
    },
    },
    },
    {
    "assetType": "REPORT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 6,
    "threeG": 252,
    },
    "size": {
    "gzip": 23,
    "uncompress": 23664,
    },
    },
    "measurements": [
    {
    "avg": 6263.0,
    "max": 6263.0,
    "min": 6263.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29927.0,
    "max": 29927.0,
    "min": 29927.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 319,
    },
    "size": {
    "gzip": 29,
    "uncompress": 29927,
    },
    },
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 24,
    },
    },
    "measurements": [
    {
    "avg": 5.0,
    "max": 5.0,
    "min": 5.0,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29.0,
    "max": 29.0,
    "min": 29.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 29,
    },
    },
    },
    ],
    "name": "super",
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': {'loadTime': ...'max': 26708.0, 'min': 26708.0, 'timestamp': '2024-06-10T00:00:00+00:00'}], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:936: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_no_after

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_no_after>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299452142688'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_no_after(self, get_storage_service):
    measurements_data = [
    # 2024-06-10
    ["bundle_analysis_report_size", "super", "2024-06-10T19:07:23", 123],
    # 2024-06-06
    ["bundle_analysis_report_size", "super", "2024-06-06T19:07:23", 456],
    ]

    for item in measurements_data:
    MeasurementFactory(
    name=item[0],
    owner_id=self.org.pk,
    repo_id=self.repo.pk,
    branch="feat",
    measurable_id=item[1],
    commit_sha=self.commit.pk,
    timestamp=item[2],
    value=item[3],
    )

    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime
    $branch: String!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    branch: $branch
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": None,
    "before": "2024-06-10",
    "branch": "feat",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "name": "super",
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "ASSET_SIZE",
    "name": "asset-*.js",
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "FONT_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "IMAGE_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    {
    "assetType": "REPORT_SIZE",
    "name": None,
    "size": {
    "loadTime": {"threeG": 1, "highSpeed": 0},
    "size": {"gzip": 0, "uncompress": 123},
    },
    "change": {
    "loadTime": {"threeG": -3, "highSpeed": 0},
    "size": {"gzip": 0, "uncompress": -333},
    },
    "measurements": [
    {
    "avg": 456.0,
    "min": 456.0,
    "max": 456.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "min": None,
    "max": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 123.0,
    "min": 123.0,
    "max": 123.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "name": None,
    "size": None,
    "change": None,
    "measurements": [],
    },
    ],
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': None, 'measur... ...}, {'assetType': 'JAVASCRIPT_SIZE', 'change': None, 'measurements': [], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:2324: AssertionError
  • Class name: graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_no_carryovers

    self = <graphql_api.tests.test_bundle_analysis_measurements.TestBundleAnalysisMeasurements testMethod=test_bundle_report_no_carryovers>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299452684224'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_no_carryovers(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Test without using asset type filters
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-05",
    "before": "2024-06-10",
    "filters": {},
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundle": {
    "measurements": [
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 4126.0,
    "max": 4126.0,
    "min": 4126.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 14126.0,
    "max": 14126.0,
    "min": 14126.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 150,
    },
    "size": {
    "gzip": 14,
    "uncompress": 14126,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 2,
    "threeG": 106,
    },
    "size": {
    "gzip": 10,
    "uncompress": 10000,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 1421.0,
    "max": 1421.0,
    "min": 1421.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 11421.0,
    "max": 11421.0,
    "min": 11421.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": "asset-*.js",
    "size": {
    "loadTime": {
    "highSpeed": 3,
    "threeG": 121,
    },
    "size": {
    "gzip": 11,
    "uncompress": 11421,
    },
    },
    },
    {
    "assetType": "ASSET_SIZE",
    "change": None,
    "measurements": [],
    "name": "asset-*.js",
    "size": None,
    },
    {
    "assetType": "FONT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 2,
    },
    "size": {
    "gzip": 0,
    "uncompress": 240,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 50.0,
    "max": 50.0,
    "min": 50.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 290.0,
    "max": 290.0,
    "min": 290.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 3,
    },
    "size": {
    "gzip": 0,
    "uncompress": 290,
    },
    },
    },
    {
    "assetType": "IMAGE_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 25,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2400,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 500.0,
    "max": 500.0,
    "min": 500.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 2900.0,
    "max": 2900.0,
    "min": 2900.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 30,
    },
    "size": {
    "gzip": 2,
    "uncompress": 2900,
    },
    },
    },
    {
    "assetType": "JAVASCRIPT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 5,
    "threeG": 224,
    },
    "size": {
    "gzip": 21,
    "uncompress": 21000,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 5708.0,
    "max": 5708.0,
    "min": 5708.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 26708.0,
    "max": 26708.0,
    "min": 26708.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 284,
    },
    "size": {
    "gzip": 26,
    "uncompress": 26708,
    },
    },
    },
    {
    "assetType": "REPORT_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 6,
    "threeG": 252,
    },
    "size": {
    "gzip": 23,
    "uncompress": 23664,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 6263.0,
    "max": 6263.0,
    "min": 6263.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29927.0,
    "max": 29927.0,
    "min": 29927.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 7,
    "threeG": 319,
    },
    "size": {
    "gzip": 29,
    "uncompress": 29927,
    },
    },
    },
    {
    "assetType": "STYLESHEET_SIZE",
    "change": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 24,
    },
    },
    "measurements": [
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-05T00:00:00+00:00",
    },
    {
    "avg": 5.0,
    "max": 5.0,
    "min": 5.0,
    "timestamp": "2024-06-06T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-07T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-08T00:00:00+00:00",
    },
    {
    "avg": None,
    "max": None,
    "min": None,
    "timestamp": "2024-06-09T00:00:00+00:00",
    },
    {
    "avg": 29.0,
    "max": 29.0,
    "min": 29.0,
    "timestamp": "2024-06-10T00:00:00+00:00",
    },
    ],
    "name": None,
    "size": {
    "loadTime": {
    "highSpeed": 0,
    "threeG": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 29,
    },
    },
    },
    ],
    "name": "super",
    },
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': {'measurements': [{'assetType': 'ASSET_SIZE', 'change': {'loadTime': ...'max': 26708.0, 'min': 26708.0, 'timestamp': '2024-06-10T00:00:00+00:00'}], 'name': None, ...}, ...], 'name': 'super'}}

    graphql_api/tests/test_bundle_analysis_measurements.py:1467: AssertionError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_asset

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_asset>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299417476304'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_asset(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open(
    "..../tests/samples/bundle_with_assets_and_modules.sqlite", "rb"
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b5") {
    moduleCount
    asset(name: "assets/LazyComponent-fcbb0922.js") {
    name
    normalizedName
    extension
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    modules {
    name
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > bundle_report = commit["bundleAnalysisReport"]["bundle"]
    E TypeError: 'NoneType' object is not subscriptable

    graphql_api/tests/test_commit.py:1300: TypeError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_asset_filtering

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_asset_filtering>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299456006240'>
    asset_reports_mock = <MagicMock name='asset_reports' id='140299456006816'>

    @patch("shared.bundle_analysis.BundleReport.asset_reports")
    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_asset_filtering(
    self, get_storage_service, asset_reports_mock
    ):
    storage = MemoryStorageService({})

    get_storage_service.return_value = storage
    asset_reports_mock.return_value = []

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open(
    "..../tests/samples/bundle_with_assets_and_modules.sqlite", "rb"
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!, $filters: BundleAnalysisReportFilters) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b5", filters: $filters) {
    moduleCount
    assets {
    name
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "filters": {},
    }

    configurations = [
    # No filters
    (
    {"loadTypes": None, "reportGroups": None},
    {"asset_types": None, "chunk_entry": None, "chunk_initial": None},
    ),
    ({}, {"asset_types": None, "chunk_entry": None, "chunk_initial": None}),
    # Just report groups
    (
    {"reportGroups": ["JAVASCRIPT", "FONT"]},
    {
    "asset_types": ["JAVASCRIPT", "FONT"],
    "chunk_entry": None,
    "chunk_initial": None,
    },
    ),
    # Load types -> chunk_entry cancels out
    (
    {"loadTypes": ["ENTRY", "INITIAL"]},
    {"asset_types": None, "chunk_entry": None, "chunk_initial": True},
    ),
    # Load types -> chunk_entry = True
    (
    {"loadTypes": ["ENTRY"]},
    {"asset_types": None, "chunk_entry": True, "chunk_initial": None},
    ),
    # Load types -> chunk_lazy = False
    (
    {"loadTypes": ["LAZY"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": False},
    ),
    # Load types -> chunk_initial cancels out
    (
    {"loadTypes": ["LAZY", "INITIAL"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": None},
    ),
    # Load types -> chunk_initial = True
    (
    {"loadTypes": ["INITIAL"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": True},
    ),
    # Load types -> chunk_initial = False
    (
    {"loadTypes": ["LAZY"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": False},
    ),
    ]

    for config in configurations:
    input_d, output_d = config
    variables["filters"] = input_d
    data = self.gql_request(query, variables=variables)
    > assert (
    data["owner"]["repository"]["commit"]["bundleAnalysisReport"]["bundle"]
    is not None
    )
    E TypeError: 'NoneType' object is not subscriptable

    graphql_api/tests/test_commit.py:1470: TypeError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_compare

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_compare>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299455801264'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_compare(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    base_commit_report = CommitReportFactory(
    commit=self.parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )
    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = (
    query_commit
    % """
    bundleAnalysisCompareWithParent {
    __typename
    ... on BundleAnalysisComparison {
    bundles {
    name
    changeType
    bundleData {
    size {
    uncompress
    }
    }
    bundleChange {
    size {
    uncompress
    }
    }
    }
    bundleData {
    size {
    uncompress
    }
    }
    bundleChange {
    size {
    uncompress
    }
    }
    }
    }
    """
    )

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]
    > assert commit["bundleAnalysisCompareWithParent"] == {
    "__typename": "BundleAnalysisComparison",
    "bundles": [
    {
    "name": "b1",
    "changeType": "changed",
    "bundleData": {"size": {"uncompress": 20}},
    "bundleChange": {"size": {"uncompress": 5}},
    },
    {
    "name": "b2",
    "changeType": "changed",
    "bundleData": {"size": {"uncompress": 200}},
    "bundleChange": {"size": {"uncompress": 50}},
    },
    {
    "name": "b3",
    "changeType": "added",
    "bundleData": {"size": {"uncompress": 1500}},
    "bundleChange": {"size": {"uncompress": 1500}},
    },
    {
    "name": "b5",
    "changeType": "changed",
    "bundleData": {"size": {"uncompress": 200000}},
    "bundleChange": {"size": {"uncompress": 50000}},
    },
    {
    "name": "b4",
    "changeType": "removed",
    "bundleData": {"size": {"uncompress": 0}},
    "bundleChange": {"size": {"uncompress": -15000}},
    },
    ],
    "bundleData": {"size": {"uncompress": 201720}},
    "bundleChange": {"size": {"uncompress": 36555}},
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisComparison', 'bundleChange': {'size': {'uncompress': 36555}}, 'bundleData': {'size': {'u...: {'size': {'uncompress': -15000}}, 'bundleData': {'size': {'uncompress': 0}}, 'changeType': 'removed', 'name': 'b4'}]}

    graphql_api/tests/test_commit.py:858: AssertionError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_report

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_report>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140300183136560'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundles {
    name
    assets {
    normalizedName
    }
    asset(name: "not_exist") {
    normalizedName
    }
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    isCached
    }
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    bundle(name: "not_exist") {
    name
    isCached
    }
    isCached
    }
    ... on MissingHeadReport {
    message
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    data = self.gql_request(query, variables=variables)
    commit = data["owner"]["repository"]["commit"]

    > assert commit["bundleAnalysisReport"] == {
    "__typename": "BundleAnalysisReport",
    "bundles": [
    {
    "name": "b1",
    "assets": [
    {"normalizedName": "assets/react-*.svg"},
    {"normalizedName": "assets/index-*.css"},
    {"normalizedName": "assets/LazyComponent-*.js"},
    {"normalizedName": "assets/index-*.js"},
    {"normalizedName": "assets/index-*.js"},
    ],
    "asset": None,
    "bundleData": {
    "loadTime": {
    "threeG": 0,
    "highSpeed": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 20,
    },
    },
    "isCached": False,
    },
    {
    "name": "b2",
    "assets": [
    {"normalizedName": "assets/react-*.svg"},
    {"normalizedName": "assets/index-*.css"},
    {"normalizedName": "assets/LazyComponent-*.js"},
    {"normalizedName": "assets/index-*.js"},
    {"normalizedName": "assets/index-*.js"},
    ],
    "asset": None,
    "bundleData": {
    "loadTime": {
    "threeG": 2,
    "highSpeed": 0,
    },
    "size": {
    "gzip": 0,
    "uncompress": 200,
    },
    },
    "isCached": False,
    },
    {
    "name": "b3",
    "assets": [
    {"normalizedName": "assets/react-*.svg"},
    {"normalizedName": "assets/index-*.css"},
    {"normalizedName": "assets/LazyComponent-*.js"},
    {"normalizedName": "assets/index-*.js"},
    {"normalizedName": "assets/index-*.js"},
    ],
    "asset": None,
    "bundleData": {
    "loadTime": {
    "threeG": 16,
    "highSpeed": 0,
    },
    "size": {
    "gzip": 1,
    "uncompress": 1500,
    },
    },
    "isCached": False,
    },
    {
    "name": "b5",
    "assets": [
    {"normalizedName": "assets/react-*.svg"},
    {"normalizedName": "assets/index-*.css"},
    {"normalizedName": "assets/LazyComponent-*.js"},
    {"normalizedName": "assets/index-*.js"},
    {"normalizedName": "assets/index-*.js"},
    ],
    "asset": None,
    "bundleData": {
    "loadTime": {
    "threeG": 2133,
    "highSpeed": 53,
    },
    "size": {
    "gzip": 200,
    "uncompress": 200000,
    },
    },
    "isCached": False,
    },
    ],
    "bundleData": {
    "loadTime": {
    "threeG": 2151,
    "highSpeed": 53,
    },
    "size": {
    "gzip": 201,
    "uncompress": 201720,
    },
    },
    "bundle": None,
    "isCached": False,
    }
    E AssertionError: assert None == {'__typename': 'BundleAnalysisReport', 'bundle': None, 'bundleData': {'loadTime': {'highSpeed': 53, 'threeG': 2151}, '...dTime': {'highSpeed': 53, 'threeG': 2133}, 'size': {'gzip': 200, 'uncompress': 200000}}, 'isCached': False, ...}], ...}

    graphql_api/tests/test_commit.py:1119: AssertionError
  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_sqlite_file_deleted

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_sqlite_file_deleted>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299677439456'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_sqlite_file_deleted(self, get_storage_service):
    os.system("rm -rf /tmp/bundle_analysis_*")
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    base_commit_report = CommitReportFactory(
    commit=self.parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )
    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = (
    query_commit
    % """
    bundleAnalysisCompareWithParent {
    __typename
    ... on BundleAnalysisComparison {
    bundleData {
    size {
    uncompress
    }
    }
    }
    }
    """
    )

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    self.gql_request(query, variables=variables)

    for file in os.listdir("/tmp"):
    > assert not file.startswith("bundle_analysis_")
    E AssertionError: assert not True
    E + where True = <built-in method startswith of str object at 0x7f9a0377b820>('bundle_analysis_')
    E + where <built-in method startswith of str object at 0x7f9a0377b820> = 'bundle_analysis_n9g9zw_h'.startswith

    graphql_api/tests/test_commit.py:948: AssertionError
  • Class name: graphql_api.tests.test_pull.TestPullRequestList
    Test name: test_bundle_analysis_sqlite_file_deleted

    self = <graphql_api.tests.test_pull.TestPullRequestList testMethod=test_bundle_analysis_sqlite_file_deleted>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140299408093600'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_sqlite_file_deleted(self, get_storage_service):
    os.system("rm -rf /tmp/bundle_analysis_*")
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    parent_commit = CommitFactory(repository=self.repository)
    commit = CommitFactory(
    repository=self.repository,
    totals={"c": "12", "diff": [0, 0, 0, 0, 0, "14"]},
    parent_commit_id=parent_commit.commitid,
    )

    base_commit_report = CommitReportFactory(
    commit=parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )
    head_commit_report = CommitReportFactory(
    commit=commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    my_pull = PullFactory(
    repository=self.repository,
    title="test-pull-request",
    author=self.owner,
    head=head_commit_report.commit.commitid,
    compared_to=base_commit_report.commit.commitid,
    behind_by=23,
    behind_by_commit="1089nf898as-jdf09hahs09fgh",
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repository),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repository),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    bundleAnalysisCompareWithBase {
    __typename
    ... on BundleAnalysisComparison {
    bundleData {
    size {
    uncompress
    }
    }
    }
    }
    """

    pull = self.fetch_one_pull_request(my_pull.pullid, query)

    > assert pull == {
    "bundleAnalysisCompareWithBase": {
    "__typename": "BundleAnalysisComparison",
    "bundleData": {
    "size": {
    "uncompress": 201720,
    }
    },
    }
    }
    E AssertionError: assert {'bundleAnaly...thBase': None} == {'bundleAnaly...s': 201720}}}}
    E
    E Differing items:
    E {'bundleAnalysisCompareWithBase': None} != {'bundleAnalysisCompareWithBase': {'__typename': 'BundleAnalysisComparison', 'bundleData': {'size': {'uncompress': 201720}}}}
    E Use -v to get more diff

    graphql_api/tests/test_pull.py:555: AssertionError
  • Class name: graphql_api.tests.test_pull.TestPullRequestList
    Test name: test_when_repository_has_null_head_has_parent_report

    self = <graphql_api.tests.test_pull.TestPullRequestList testMethod=test_when_repository_has_null_head_has_parent_report>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140300309715216'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_when_repository_has_null_head_has_parent_report(self, get_storage_service):
    os.system("rm -rf /tmp/bundle_analysis_*")
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    parent_commit = CommitFactory(repository=self.repository)

    base_commit_report = CommitReportFactory(
    commit=parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )

    my_pull = PullFactory(
    repository=self.repository,
    title="test-pull-request",
    author=self.owner,
    head=None,
    compared_to=base_commit_report.commit.commitid,
    behind_by=23,
    behind_by_commit="1089nf898as-jdf09hahs09fgh",
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repository),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    bundleAnalysisCompareWithBase {
    __typename
    ... on BundleAnalysisComparison {
    bundleData {
    size {
    uncompress
    }
    }
    bundleChange {
    size {
    uncompress
    }
    }
    }
    }
    """

    pull = self.fetch_one_pull_request(my_pull.pullid, query)

    > assert pull == {
    "bundleAnalysisCompareWithBase": {
    "__typename": "BundleAnalysisComparison",
    "bundleData": {
    "size": {
    "uncompress": 165165,
    }
    },
    "bundleChange": {
    "size": {
    "uncompress": 0,
    }
    },
    }
    }
    E AssertionError: assert {'bundleAnaly...thBase': None} == {'bundleAnaly...s': 165165}}}}
    E
    E Differing items:
    E {'bundleAnalysisCompareWithBase': None} != {'bundleAnalysisCompareWithBase': {'__typename': 'BundleAnalysisComparison', 'bundleChange': {'size': {'uncompress': 0}}, 'bundleData': {'size': {'uncompress': 165165}}}}
    E Use -v to get more diff

    graphql_api/tests/test_pull.py:324: AssertionError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_desc_commits_failed_ordering_on_test_results

    self = <django.db.backends.utils.CursorWrapper object at 0x7f9a10e73350>
    sql = 'INSERT INTO "reports_test" ("id", "external_id", "created_at", "updated_at", "repoid", "name", "testsuite", "flags_hash", "failure_rate", "commits_where_fail") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s::text[])'
    params = ('doctor', UUID('9c2a8f43-860a-4239-ac20-566eb63830ab'), datetime.datetime(2024, 8, 5, 20, 49, 36, 477183, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 8, 5, 20, 49, 36, 477190, tzinfo=datetime.timezone.utc), 1815, 'cover', ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f9a10e73350>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "reports_test_repoid_name_testsuite_flags_hash"
    E DETAIL: Key (repoid, name, testsuite, flags_hash)=(1815, cover, , ) already exists.

    .../local/lib/python3.12.../db/backends/utils.py:89: UniqueViolation

    The above exception was the direct cause of the following exception:

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_commits_failed_ordering_on_test_results>

    def test_desc_commits_failed_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    _test_instance_1 = TestInstanceFactory(
    test=test,
    created_at=datetime.datetime.now(),
    repoid=repo.repoid,
    commitid="1",
    )
    _test_instance_2 = TestInstanceFactory(
    test=test,
    created_at=datetime.datetime.now(),
    repoid=repo.repoid,
    commitid="2",
    )
    > test_2 = TestFactory(repository=repo)

    graphql_api/tests/test_repository.py:933:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:658: in create
    obj.save(force_insert=True, using=self.db)
    .../local/lib/python3.12.../db/models/base.py:814: in save
    self.save_base(
    .../local/lib/python3.12.../db/models/base.py:877: in save_base
    updated = self._save_table(
    .../local/lib/python3.12.../db/models/base.py:1020: in _save_table
    results = self._do_insert(
    .../local/lib/python3.12.../db/models/base.py:1061: in _do_insert
    return manager._insert(
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:1805: in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
    .../local/lib/python3.12.../models/sql/compiler.py:1822: in execute_sql
    cursor.execute(sql, params)
    .../local/lib/python3.12.../integrations/django/__init__.py:641: in execute
    result = real_execute(self, sql, params)
    .../local/lib/python3.12.../db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
    .../local/lib/python3.12.../db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
    .../local/lib/python3.12.../db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
    .../local/lib/python3.12.../django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <django.db.backends.utils.CursorWrapper object at 0x7f9a10e73350>
    sql = 'INSERT INTO "reports_test" ("id", "external_id", "created_at", "updated_at", "repoid", "name", "testsuite", "flags_hash", "failure_rate", "commits_where_fail") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s::text[])'
    params = ('doctor', UUID('9c2a8f43-860a-4239-ac20-566eb63830ab'), datetime.datetime(2024, 8, 5, 20, 49, 36, 477183, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 8, 5, 20, 49, 36, 477190, tzinfo=datetime.timezone.utc), 1815, 'cover', ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f9a10e73350>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E django.db.utils.IntegrityError: duplicate key value violates unique constraint "reports_test_repoid_name_testsuite_flags_hash"
    E DETAIL: Key (repoid, name, testsuite, flags_hash)=(1815, cover, , ) already exists.

    .../local/lib/python3.12.../db/backends/utils.py:89: IntegrityError
  • Class name: services.tests.test_bundle_analysis.TestBundleAnalysisComparison
    Test name: test_bundle_analysis_comparison

    self = <services.tests.test_bundle_analysis.TestBundleAnalysisComparison testMethod=test_bundle_analysis_comparison>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140300017402464'>

    @patch("services.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_comparison(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    loader = BundleAnalysisReportLoader(
    storage_service=storage,
    repo_key=ArchiveService.get_archive_hash(self.head_commit.repository),
    )

    > bac = BundleAnalysisComparison(
    loader,
    self.base_commit_report.external_id,
    self.head_commit_report.external_id,
    )

    services/tests/test_bundle_analysis.py:117:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    services/bundle_analysis.py:326: in __init__
    self.cleanup()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = BundleAnalysisComparison()

    def cleanup(self) -> None:
    > if self.comparison.head_report and self.comparison.head_report.db_session:
    E AttributeError: 'BundleAnalysisReport' object has no attribute 'db_session'

    services/bundle_analysis.py:329: AttributeError
  • Class name: services.tests.test_bundle_analysis.TestBundleAnalysisReport
    Test name: test_bundle_analysis_report

    self = <services.tests.test_bundle_analysis.TestBundleAnalysisReport testMethod=test_bundle_analysis_report>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='140300017499264'>

    @patch("services.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    loader = BundleAnalysisReportLoader(
    storage_service=storage,
    repo_key=ArchiveService.get_archive_hash(self.commit.repository),
    )

    > bar = BundleAnalysisReport(loader.load(self.commit_report.external_id))

    services/tests/test_bundle_analysis.py:173:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    services/bundle_analysis.py:286: in __init__
    self.cleanup()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = BundleAnalysisReport()

    def cleanup(self) -> None:
    > if self.report and self.report.db_session:
    E AttributeError: 'BundleAnalysisReport' object has no attribute 'db_session'

    services/bundle_analysis.py:289: AttributeError

@jason-ford-codecov jason-ford-codecov added this pull request to the merge queue Aug 6, 2024
Merged via the queue into main with commit 839a1bb Aug 6, 2024
18 checks passed
@jason-ford-codecov jason-ford-codecov deleted the release/24.8.1 branch August 6, 2024 21:22
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.

3 participants