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

Reenable test #1019

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Reenable test #1019

wants to merge 4 commits into from

Conversation

trent-codecov
Copy link
Contributor

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Copy link

codecov bot commented Jan 21, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1788 1 1787 4
View the top 1 failed tests by shortest run time
tasks/tests/unit/test_upload_task.py::TestUploadTaskIntegration::test_upload_task_upload_processing_delay_upload_is_none
Stack Traces | 46.9s run time
self = <worker.tasks.tests.unit.test_upload_task.TestUploadTaskIntegration object at 0x7f8e47028050>
mocker = <pytest_mock.plugin.MockFixture object at 0x7f8e4458a8d0>
mock_configuration = <shared.config.ConfigHelper object at 0x7f8e446d99c0>
dbsession = <sqlalchemy.orm.session.Session object at 0x7f8e3ff9fd40>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7f8e45813290>
celery_app = <Celery celery.tests at 0x7f8e458e2d50>

    @pytest.mark.django_db(databases={"default"}, transaction=True)
    def test_upload_task_upload_processing_delay_upload_is_none(
        self,
        mocker,
        mock_configuration,
        dbsession,
        mock_storage,
        celery_app,
    ):
        mock_configuration.set_params({"setup": {"upload_processing_delay": 1000}})
        mocker.patch.object(UploadTask, "app", celery_app)
        mocker.patch(
            "tasks.upload.possibly_update_commit_from_provider_info", return_value=True
        )
        mocker.patch.object(UploadTask, "possibly_setup_webhooks", return_value=True)
        mocked_chord = mocker.patch("tasks.upload.chord")
        commit = CommitFactory.create(
            parent_commit_id=None,
            message="",
            commitid="abf6d4df662c47e32460020ab14abf9303581429",
            repository__owner__unencrypted_oauth_token="test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy",
            repository__owner__username="ThiagoCodecov",
            repository__yaml={"codecov": {"max_report_age": "1y ago"}},
            repository__name="example-python",
            pullid=1,
        )
        dbsession.add(commit)
        dbsession.flush()
    
        redis = get_redis_connection()
        redis.lpush(
            f"uploads/{commit.repoid}/{commit.commitid}",
            '{"build": "part1", "url": "someurl1"}',
        )
        redis.lpush(
            f"uploads/{commit.repoid}/{commit.commitid}",
            '{"build": "part2", "url": "someurl2"}',
        )
    
>       result = UploadTask().run_impl(dbsession, commit.repoid, commit.commitid)

.../tests/unit/test_upload_task.py:724: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tasks/upload.py:353: in run_impl
    return self.run_impl_within_lock(
.../local/lib/python3.13....../site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
tasks/upload.py:462: in run_impl_within_lock
    commit_yaml = fetch_commit_yaml_and_possibly_store(
.../local/lib/python3.13....../site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
services/repository.py:568: in fetch_commit_yaml_and_possibly_store
    commit_yaml = async_to_sync(fetch_commit_yaml_from_provider)(
.../local/lib/python3.13....../site-packages/asgiref/sync.py:277: in __call__
    return call_result.result()
.../local/lib/python3.13....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
.../local/lib/python3.13....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
.../local/lib/python3.13....../site-packages/asgiref/sync.py:353: in main_wrap
    result = await self.awaitable(*args, **kwargs)
.../local/lib/python3.13.../shared/helpers/cache.py:275: in wrapped
    result = await func(*args, **kwargs)
services/yaml/fetcher.py:19: in fetch_commit_yaml_from_provider
    yaml_content = await shared_fetch_current_yaml_from_provider_via_reference(
.../local/lib/python3.13.../shared/yaml/fetcher.py:14: in fetch_current_yaml_from_provider_via_reference
    location = await determine_commit_yaml_location(ref, repository_service)
.../local/lib/python3.13.../shared/yaml/fetcher.py:58: in determine_commit_yaml_location
    top_level_files = await repository_service.list_top_level_files(ref)
.../local/lib/python3.13.../shared/torngit/bitbucket.py:1007: in list_top_level_files
    return await self.list_files(ref, dir_path="", token=None)
.../local/lib/python3.13.../shared/torngit/bitbucket.py:1020: in list_files
    results = await self.api(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <bitbucket slug=ThiagoCodecov/example-python ownerid=61 repoid=27>
client = <httpx.AsyncClient object at 0x7f8e455a2750>, version = '2'
method = 'get'
path = '.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/'
json = False, body = None, token = None
kwargs = {'data': None, 'headers': {'Accept': 'application/json', 'User-Agent': 'Default'}, 'json': None}
url = 'https://bitbucket.org/api/2.0.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/..._consumer_key=None&oauth_token=test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy&oauth_signature=TLcJE5NVXXILc8DRIn5kDWUO3PE%3D'
headers = {'Accept': 'application/json', 'User-Agent': 'Default'}
oauth_body = None
token_to_use = {'entity_name': '61', 'key': 'test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy', 'secret': None, 'username': 'ThiagoCodecov'}
oauth_client = <Client client_key=None, client_secret=None, resource_owner_key=test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy, resource_own... callback_uri=None, rsa_key=None, verifier=None, realm=None, encoding=utf-8, decoding=None, nonce=None, timestamp=None>
log_dict = {'bot': 'ThiagoCodecov', 'endpoint': '.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/', 'event': 'api', 'method': 'get', ...}
res = <Response [500 Internal Server Error]>

    async def api(
        self, client, version, method, path, json=False, body=None, token=None, **kwargs
    ):
        url = "https://bitbucket.org/api/%s.0%s" % (version, path)
        headers = {
            "Accept": "application/json",
            "User-Agent": os.getenv("USER_AGENT", "Default"),
        }
    
        oauth_body = None
        url = url_concat(url, kwargs)
    
        if json:
            headers["Content-Type"] = "application/json"
        elif body is not None:
            headers["Content-Type"] = "application/x-www-form-urlencoded"
            oauth_body = body
    
        token_to_use = token or self.token
        oauth_client = oauth1.Client(
            self._oauth_consumer_token()["key"],
            client_secret=self._oauth_consumer_token()["secret"],
            resource_owner_key=token_to_use["key"],
            resource_owner_secret=token_to_use["secret"],
            signature_type=oauth1.SIGNATURE_TYPE_QUERY,
        )
        url, headers, oauth_body = oauth_client.sign(
            url, http_method=method, body=oauth_body, headers=headers
        )
    
        kwargs = dict(
            json=body if body is not None and json else None,
            data=oauth_body if not json else None,
            headers=headers,
        )
        log_dict = dict(
            event="api",
            endpoint=path,
            method=method,
            bot=token_to_use.get("username"),
            repo_slug=self.slug,
        )
        try:
            res = await client.request(method.upper(), url, **kwargs)
            logged_body = None
            if res.status_code >= 300 and res.text is not None:
                logged_body = res.text
            log.log(
                logging.WARNING if res.status_code >= 300 else logging.INFO,
                "Bitbucket HTTP %s",
                res.status_code,
                extra=dict(body=logged_body, **log_dict),
            )
        except (httpx.NetworkError, httpx.TimeoutException):
            raise TorngitServerUnreachableError("Bitbucket was not able to be reached.")
        if res.status_code == 599:
            raise TorngitServerUnreachableError(
                "Bitbucket was not able to be reached, server timed out."
            )
        elif res.status_code >= 500:
>           raise TorngitServer5xxCodeError("Bitbucket is having 5xx issues")
E           shared.torngit.exceptions.TorngitServer5xxCodeError: Bitbucket is having 5xx issues

.../local/lib/python3.13.../shared/torngit/bitbucket.py:109: TorngitServer5xxCodeError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@codecov-staging
Copy link

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1788 1 1787 4
View the top 1 failed tests by shortest run time
tasks/tests/unit/test_upload_task.py::TestUploadTaskIntegration::test_upload_task_upload_processing_delay_upload_is_none
Stack Traces | 46.9s run time
self = <worker.tasks.tests.unit.test_upload_task.TestUploadTaskIntegration object at 0x7f8e47028050>
mocker = <pytest_mock.plugin.MockFixture object at 0x7f8e4458a8d0>
mock_configuration = <shared.config.ConfigHelper object at 0x7f8e446d99c0>
dbsession = <sqlalchemy.orm.session.Session object at 0x7f8e3ff9fd40>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7f8e45813290>
celery_app = <Celery celery.tests at 0x7f8e458e2d50>

    @pytest.mark.django_db(databases={"default"}, transaction=True)
    def test_upload_task_upload_processing_delay_upload_is_none(
        self,
        mocker,
        mock_configuration,
        dbsession,
        mock_storage,
        celery_app,
    ):
        mock_configuration.set_params({"setup": {"upload_processing_delay": 1000}})
        mocker.patch.object(UploadTask, "app", celery_app)
        mocker.patch(
            "tasks.upload.possibly_update_commit_from_provider_info", return_value=True
        )
        mocker.patch.object(UploadTask, "possibly_setup_webhooks", return_value=True)
        mocked_chord = mocker.patch("tasks.upload.chord")
        commit = CommitFactory.create(
            parent_commit_id=None,
            message="",
            commitid="abf6d4df662c47e32460020ab14abf9303581429",
            repository__owner__unencrypted_oauth_token="test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy",
            repository__owner__username="ThiagoCodecov",
            repository__yaml={"codecov": {"max_report_age": "1y ago"}},
            repository__name="example-python",
            pullid=1,
        )
        dbsession.add(commit)
        dbsession.flush()
    
        redis = get_redis_connection()
        redis.lpush(
            f"uploads/{commit.repoid}/{commit.commitid}",
            '{"build": "part1", "url": "someurl1"}',
        )
        redis.lpush(
            f"uploads/{commit.repoid}/{commit.commitid}",
            '{"build": "part2", "url": "someurl2"}',
        )
    
>       result = UploadTask().run_impl(dbsession, commit.repoid, commit.commitid)

.../tests/unit/test_upload_task.py:724: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tasks/upload.py:353: in run_impl
    return self.run_impl_within_lock(
.../local/lib/python3.13....../site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
tasks/upload.py:462: in run_impl_within_lock
    commit_yaml = fetch_commit_yaml_and_possibly_store(
.../local/lib/python3.13....../site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
services/repository.py:568: in fetch_commit_yaml_and_possibly_store
    commit_yaml = async_to_sync(fetch_commit_yaml_from_provider)(
.../local/lib/python3.13....../site-packages/asgiref/sync.py:277: in __call__
    return call_result.result()
.../local/lib/python3.13....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
.../local/lib/python3.13....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
.../local/lib/python3.13....../site-packages/asgiref/sync.py:353: in main_wrap
    result = await self.awaitable(*args, **kwargs)
.../local/lib/python3.13.../shared/helpers/cache.py:275: in wrapped
    result = await func(*args, **kwargs)
services/yaml/fetcher.py:19: in fetch_commit_yaml_from_provider
    yaml_content = await shared_fetch_current_yaml_from_provider_via_reference(
.../local/lib/python3.13.../shared/yaml/fetcher.py:14: in fetch_current_yaml_from_provider_via_reference
    location = await determine_commit_yaml_location(ref, repository_service)
.../local/lib/python3.13.../shared/yaml/fetcher.py:58: in determine_commit_yaml_location
    top_level_files = await repository_service.list_top_level_files(ref)
.../local/lib/python3.13.../shared/torngit/bitbucket.py:1007: in list_top_level_files
    return await self.list_files(ref, dir_path="", token=None)
.../local/lib/python3.13.../shared/torngit/bitbucket.py:1020: in list_files
    results = await self.api(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <bitbucket slug=ThiagoCodecov/example-python ownerid=61 repoid=27>
client = <httpx.AsyncClient object at 0x7f8e455a2750>, version = '2'
method = 'get'
path = '.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/'
json = False, body = None, token = None
kwargs = {'data': None, 'headers': {'Accept': 'application/json', 'User-Agent': 'Default'}, 'json': None}
url = 'https://bitbucket.org/api/2.0.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/..._consumer_key=None&oauth_token=test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy&oauth_signature=TLcJE5NVXXILc8DRIn5kDWUO3PE%3D'
headers = {'Accept': 'application/json', 'User-Agent': 'Default'}
oauth_body = None
token_to_use = {'entity_name': '61', 'key': 'test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy', 'secret': None, 'username': 'ThiagoCodecov'}
oauth_client = <Client client_key=None, client_secret=None, resource_owner_key=test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy, resource_own... callback_uri=None, rsa_key=None, verifier=None, realm=None, encoding=utf-8, decoding=None, nonce=None, timestamp=None>
log_dict = {'bot': 'ThiagoCodecov', 'endpoint': '.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/', 'event': 'api', 'method': 'get', ...}
res = <Response [500 Internal Server Error]>

    async def api(
        self, client, version, method, path, json=False, body=None, token=None, **kwargs
    ):
        url = "https://bitbucket.org/api/%s.0%s" % (version, path)
        headers = {
            "Accept": "application/json",
            "User-Agent": os.getenv("USER_AGENT", "Default"),
        }
    
        oauth_body = None
        url = url_concat(url, kwargs)
    
        if json:
            headers["Content-Type"] = "application/json"
        elif body is not None:
            headers["Content-Type"] = "application/x-www-form-urlencoded"
            oauth_body = body
    
        token_to_use = token or self.token
        oauth_client = oauth1.Client(
            self._oauth_consumer_token()["key"],
            client_secret=self._oauth_consumer_token()["secret"],
            resource_owner_key=token_to_use["key"],
            resource_owner_secret=token_to_use["secret"],
            signature_type=oauth1.SIGNATURE_TYPE_QUERY,
        )
        url, headers, oauth_body = oauth_client.sign(
            url, http_method=method, body=oauth_body, headers=headers
        )
    
        kwargs = dict(
            json=body if body is not None and json else None,
            data=oauth_body if not json else None,
            headers=headers,
        )
        log_dict = dict(
            event="api",
            endpoint=path,
            method=method,
            bot=token_to_use.get("username"),
            repo_slug=self.slug,
        )
        try:
            res = await client.request(method.upper(), url, **kwargs)
            logged_body = None
            if res.status_code >= 300 and res.text is not None:
                logged_body = res.text
            log.log(
                logging.WARNING if res.status_code >= 300 else logging.INFO,
                "Bitbucket HTTP %s",
                res.status_code,
                extra=dict(body=logged_body, **log_dict),
            )
        except (httpx.NetworkError, httpx.TimeoutException):
            raise TorngitServerUnreachableError("Bitbucket was not able to be reached.")
        if res.status_code == 599:
            raise TorngitServerUnreachableError(
                "Bitbucket was not able to be reached, server timed out."
            )
        elif res.status_code >= 500:
>           raise TorngitServer5xxCodeError("Bitbucket is having 5xx issues")
E           shared.torngit.exceptions.TorngitServer5xxCodeError: Bitbucket is having 5xx issues

.../local/lib/python3.13.../shared/torngit/bitbucket.py:109: TorngitServer5xxCodeError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Jan 21, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1788 1 1787 4
View the top 1 failed tests by shortest run time
tasks/tests/unit/test_upload_task.py::TestUploadTaskIntegration::test_upload_task_upload_processing_delay_upload_is_none
Stack Traces | 46.9s run time
self = <worker.tasks.tests.unit.test_upload_task.TestUploadTaskIntegration object at 0x7f8e47028050>
mocker = <pytest_mock.plugin.MockFixture object at 0x7f8e4458a8d0>
mock_configuration = <shared.config.ConfigHelper object at 0x7f8e446d99c0>
dbsession = <sqlalchemy.orm.session.Session object at 0x7f8e3ff9fd40>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7f8e45813290>
celery_app = <Celery celery.tests at 0x7f8e458e2d50>

    @pytest.mark.django_db(databases={"default"}, transaction=True)
    def test_upload_task_upload_processing_delay_upload_is_none(
        self,
        mocker,
        mock_configuration,
        dbsession,
        mock_storage,
        celery_app,
    ):
        mock_configuration.set_params({"setup": {"upload_processing_delay": 1000}})
        mocker.patch.object(UploadTask, "app", celery_app)
        mocker.patch(
            "tasks.upload.possibly_update_commit_from_provider_info", return_value=True
        )
        mocker.patch.object(UploadTask, "possibly_setup_webhooks", return_value=True)
        mocked_chord = mocker.patch("tasks.upload.chord")
        commit = CommitFactory.create(
            parent_commit_id=None,
            message="",
            commitid="abf6d4df662c47e32460020ab14abf9303581429",
            repository__owner__unencrypted_oauth_token="test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy",
            repository__owner__username="ThiagoCodecov",
            repository__yaml={"codecov": {"max_report_age": "1y ago"}},
            repository__name="example-python",
            pullid=1,
        )
        dbsession.add(commit)
        dbsession.flush()
    
        redis = get_redis_connection()
        redis.lpush(
            f"uploads/{commit.repoid}/{commit.commitid}",
            '{"build": "part1", "url": "someurl1"}',
        )
        redis.lpush(
            f"uploads/{commit.repoid}/{commit.commitid}",
            '{"build": "part2", "url": "someurl2"}',
        )
    
>       result = UploadTask().run_impl(dbsession, commit.repoid, commit.commitid)

.../tests/unit/test_upload_task.py:724: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tasks/upload.py:353: in run_impl
    return self.run_impl_within_lock(
.../local/lib/python3.13....../site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
tasks/upload.py:462: in run_impl_within_lock
    commit_yaml = fetch_commit_yaml_and_possibly_store(
.../local/lib/python3.13....../site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
services/repository.py:568: in fetch_commit_yaml_and_possibly_store
    commit_yaml = async_to_sync(fetch_commit_yaml_from_provider)(
.../local/lib/python3.13....../site-packages/asgiref/sync.py:277: in __call__
    return call_result.result()
.../local/lib/python3.13....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
.../local/lib/python3.13....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
.../local/lib/python3.13....../site-packages/asgiref/sync.py:353: in main_wrap
    result = await self.awaitable(*args, **kwargs)
.../local/lib/python3.13.../shared/helpers/cache.py:275: in wrapped
    result = await func(*args, **kwargs)
services/yaml/fetcher.py:19: in fetch_commit_yaml_from_provider
    yaml_content = await shared_fetch_current_yaml_from_provider_via_reference(
.../local/lib/python3.13.../shared/yaml/fetcher.py:14: in fetch_current_yaml_from_provider_via_reference
    location = await determine_commit_yaml_location(ref, repository_service)
.../local/lib/python3.13.../shared/yaml/fetcher.py:58: in determine_commit_yaml_location
    top_level_files = await repository_service.list_top_level_files(ref)
.../local/lib/python3.13.../shared/torngit/bitbucket.py:1007: in list_top_level_files
    return await self.list_files(ref, dir_path="", token=None)
.../local/lib/python3.13.../shared/torngit/bitbucket.py:1020: in list_files
    results = await self.api(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <bitbucket slug=ThiagoCodecov/example-python ownerid=61 repoid=27>
client = <httpx.AsyncClient object at 0x7f8e455a2750>, version = '2'
method = 'get'
path = '.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/'
json = False, body = None, token = None
kwargs = {'data': None, 'headers': {'Accept': 'application/json', 'User-Agent': 'Default'}, 'json': None}
url = 'https://bitbucket.org/api/2.0.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/..._consumer_key=None&oauth_token=test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy&oauth_signature=TLcJE5NVXXILc8DRIn5kDWUO3PE%3D'
headers = {'Accept': 'application/json', 'User-Agent': 'Default'}
oauth_body = None
token_to_use = {'entity_name': '61', 'key': 'test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy', 'secret': None, 'username': 'ThiagoCodecov'}
oauth_client = <Client client_key=None, client_secret=None, resource_owner_key=test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy, resource_own... callback_uri=None, rsa_key=None, verifier=None, realm=None, encoding=utf-8, decoding=None, nonce=None, timestamp=None>
log_dict = {'bot': 'ThiagoCodecov', 'endpoint': '.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/', 'event': 'api', 'method': 'get', ...}
res = <Response [500 Internal Server Error]>

    async def api(
        self, client, version, method, path, json=False, body=None, token=None, **kwargs
    ):
        url = "https://bitbucket.org/api/%s.0%s" % (version, path)
        headers = {
            "Accept": "application/json",
            "User-Agent": os.getenv("USER_AGENT", "Default"),
        }
    
        oauth_body = None
        url = url_concat(url, kwargs)
    
        if json:
            headers["Content-Type"] = "application/json"
        elif body is not None:
            headers["Content-Type"] = "application/x-www-form-urlencoded"
            oauth_body = body
    
        token_to_use = token or self.token
        oauth_client = oauth1.Client(
            self._oauth_consumer_token()["key"],
            client_secret=self._oauth_consumer_token()["secret"],
            resource_owner_key=token_to_use["key"],
            resource_owner_secret=token_to_use["secret"],
            signature_type=oauth1.SIGNATURE_TYPE_QUERY,
        )
        url, headers, oauth_body = oauth_client.sign(
            url, http_method=method, body=oauth_body, headers=headers
        )
    
        kwargs = dict(
            json=body if body is not None and json else None,
            data=oauth_body if not json else None,
            headers=headers,
        )
        log_dict = dict(
            event="api",
            endpoint=path,
            method=method,
            bot=token_to_use.get("username"),
            repo_slug=self.slug,
        )
        try:
            res = await client.request(method.upper(), url, **kwargs)
            logged_body = None
            if res.status_code >= 300 and res.text is not None:
                logged_body = res.text
            log.log(
                logging.WARNING if res.status_code >= 300 else logging.INFO,
                "Bitbucket HTTP %s",
                res.status_code,
                extra=dict(body=logged_body, **log_dict),
            )
        except (httpx.NetworkError, httpx.TimeoutException):
            raise TorngitServerUnreachableError("Bitbucket was not able to be reached.")
        if res.status_code == 599:
            raise TorngitServerUnreachableError(
                "Bitbucket was not able to be reached, server timed out."
            )
        elif res.status_code >= 500:
>           raise TorngitServer5xxCodeError("Bitbucket is having 5xx issues")
E           shared.torngit.exceptions.TorngitServer5xxCodeError: Bitbucket is having 5xx issues

.../local/lib/python3.13.../shared/torngit/bitbucket.py:109: TorngitServer5xxCodeError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1788 1 1787 4
View the top 1 failed tests by shortest run time
tasks/tests/unit/test_upload_task.py::TestUploadTaskIntegration::test_upload_task_upload_processing_delay_upload_is_none
Stack Traces | 46.9s run time
self = <worker.tasks.tests.unit.test_upload_task.TestUploadTaskIntegration object at 0x7f8e47028050>
mocker = <pytest_mock.plugin.MockFixture object at 0x7f8e4458a8d0>
mock_configuration = <shared.config.ConfigHelper object at 0x7f8e446d99c0>
dbsession = <sqlalchemy.orm.session.Session object at 0x7f8e3ff9fd40>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7f8e45813290>
celery_app = <Celery celery.tests at 0x7f8e458e2d50>

    @pytest.mark.django_db(databases={"default"}, transaction=True)
    def test_upload_task_upload_processing_delay_upload_is_none(
        self,
        mocker,
        mock_configuration,
        dbsession,
        mock_storage,
        celery_app,
    ):
        mock_configuration.set_params({"setup": {"upload_processing_delay": 1000}})
        mocker.patch.object(UploadTask, "app", celery_app)
        mocker.patch(
            "tasks.upload.possibly_update_commit_from_provider_info", return_value=True
        )
        mocker.patch.object(UploadTask, "possibly_setup_webhooks", return_value=True)
        mocked_chord = mocker.patch("tasks.upload.chord")
        commit = CommitFactory.create(
            parent_commit_id=None,
            message="",
            commitid="abf6d4df662c47e32460020ab14abf9303581429",
            repository__owner__unencrypted_oauth_token="test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy",
            repository__owner__username="ThiagoCodecov",
            repository__yaml={"codecov": {"max_report_age": "1y ago"}},
            repository__name="example-python",
            pullid=1,
        )
        dbsession.add(commit)
        dbsession.flush()
    
        redis = get_redis_connection()
        redis.lpush(
            f"uploads/{commit.repoid}/{commit.commitid}",
            '{"build": "part1", "url": "someurl1"}',
        )
        redis.lpush(
            f"uploads/{commit.repoid}/{commit.commitid}",
            '{"build": "part2", "url": "someurl2"}',
        )
    
>       result = UploadTask().run_impl(dbsession, commit.repoid, commit.commitid)

.../tests/unit/test_upload_task.py:724: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tasks/upload.py:353: in run_impl
    return self.run_impl_within_lock(
.../local/lib/python3.13....../site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
tasks/upload.py:462: in run_impl_within_lock
    commit_yaml = fetch_commit_yaml_and_possibly_store(
.../local/lib/python3.13....../site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
services/repository.py:568: in fetch_commit_yaml_and_possibly_store
    commit_yaml = async_to_sync(fetch_commit_yaml_from_provider)(
.../local/lib/python3.13....../site-packages/asgiref/sync.py:277: in __call__
    return call_result.result()
.../local/lib/python3.13....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
.../local/lib/python3.13....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
.../local/lib/python3.13....../site-packages/asgiref/sync.py:353: in main_wrap
    result = await self.awaitable(*args, **kwargs)
.../local/lib/python3.13.../shared/helpers/cache.py:275: in wrapped
    result = await func(*args, **kwargs)
services/yaml/fetcher.py:19: in fetch_commit_yaml_from_provider
    yaml_content = await shared_fetch_current_yaml_from_provider_via_reference(
.../local/lib/python3.13.../shared/yaml/fetcher.py:14: in fetch_current_yaml_from_provider_via_reference
    location = await determine_commit_yaml_location(ref, repository_service)
.../local/lib/python3.13.../shared/yaml/fetcher.py:58: in determine_commit_yaml_location
    top_level_files = await repository_service.list_top_level_files(ref)
.../local/lib/python3.13.../shared/torngit/bitbucket.py:1007: in list_top_level_files
    return await self.list_files(ref, dir_path="", token=None)
.../local/lib/python3.13.../shared/torngit/bitbucket.py:1020: in list_files
    results = await self.api(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <bitbucket slug=ThiagoCodecov/example-python ownerid=61 repoid=27>
client = <httpx.AsyncClient object at 0x7f8e455a2750>, version = '2'
method = 'get'
path = '.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/'
json = False, body = None, token = None
kwargs = {'data': None, 'headers': {'Accept': 'application/json', 'User-Agent': 'Default'}, 'json': None}
url = 'https://bitbucket.org/api/2.0.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/..._consumer_key=None&oauth_token=test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy&oauth_signature=TLcJE5NVXXILc8DRIn5kDWUO3PE%3D'
headers = {'Accept': 'application/json', 'User-Agent': 'Default'}
oauth_body = None
token_to_use = {'entity_name': '61', 'key': 'test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy', 'secret': None, 'username': 'ThiagoCodecov'}
oauth_client = <Client client_key=None, client_secret=None, resource_owner_key=test7lk5ndmtqzxlx06rip65nac9c7epqopclnoy, resource_own... callback_uri=None, rsa_key=None, verifier=None, realm=None, encoding=utf-8, decoding=None, nonce=None, timestamp=None>
log_dict = {'bot': 'ThiagoCodecov', 'endpoint': '.../example-python/src/abf6d4df662c47e32460020ab14abf9303581429/', 'event': 'api', 'method': 'get', ...}
res = <Response [500 Internal Server Error]>

    async def api(
        self, client, version, method, path, json=False, body=None, token=None, **kwargs
    ):
        url = "https://bitbucket.org/api/%s.0%s" % (version, path)
        headers = {
            "Accept": "application/json",
            "User-Agent": os.getenv("USER_AGENT", "Default"),
        }
    
        oauth_body = None
        url = url_concat(url, kwargs)
    
        if json:
            headers["Content-Type"] = "application/json"
        elif body is not None:
            headers["Content-Type"] = "application/x-www-form-urlencoded"
            oauth_body = body
    
        token_to_use = token or self.token
        oauth_client = oauth1.Client(
            self._oauth_consumer_token()["key"],
            client_secret=self._oauth_consumer_token()["secret"],
            resource_owner_key=token_to_use["key"],
            resource_owner_secret=token_to_use["secret"],
            signature_type=oauth1.SIGNATURE_TYPE_QUERY,
        )
        url, headers, oauth_body = oauth_client.sign(
            url, http_method=method, body=oauth_body, headers=headers
        )
    
        kwargs = dict(
            json=body if body is not None and json else None,
            data=oauth_body if not json else None,
            headers=headers,
        )
        log_dict = dict(
            event="api",
            endpoint=path,
            method=method,
            bot=token_to_use.get("username"),
            repo_slug=self.slug,
        )
        try:
            res = await client.request(method.upper(), url, **kwargs)
            logged_body = None
            if res.status_code >= 300 and res.text is not None:
                logged_body = res.text
            log.log(
                logging.WARNING if res.status_code >= 300 else logging.INFO,
                "Bitbucket HTTP %s",
                res.status_code,
                extra=dict(body=logged_body, **log_dict),
            )
        except (httpx.NetworkError, httpx.TimeoutException):
            raise TorngitServerUnreachableError("Bitbucket was not able to be reached.")
        if res.status_code == 599:
            raise TorngitServerUnreachableError(
                "Bitbucket was not able to be reached, server timed out."
            )
        elif res.status_code >= 500:
>           raise TorngitServer5xxCodeError("Bitbucket is having 5xx issues")
E           shared.torngit.exceptions.TorngitServer5xxCodeError: Bitbucket is having 5xx issues

.../local/lib/python3.13.../shared/torngit/bitbucket.py:109: TorngitServer5xxCodeError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants