Skip to content

CI test_index fail without showing which download url can't access #3396

@xfz11

Description

@xfz11

Description of issue (in as much detail as possible)


Fail reason:

for try_number in range(TRIES):

    for try_number in range(TRIES):
        try:
            r = requests.get(url, stream=True)
            assert r.status_code == 200, "Request to {} failed with {}".format(url, r.status_code)
            break
        except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError) as err:
            import time
            time.sleep(0.5)
            continue
    ext_file = os.path.join(tmp_dir, filename)
    with open(ext_file, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024):
            if chunk:  # ignore keep-alive new chunks
                f.write(chunk)

If the download url can't access, then error will throw as below.
But the code should catch the error if request fails more than 3 times and log which url cause the error.

error log:
2021-05-19T03:31:26.6037344Z ====================================================================== 2021-05-19T03:31:26.6037941Z ERROR: test_checksums (__main__.TestIndex) 2021-05-19T03:31:26.6039085Z ---------------------------------------------------------------------- 2021-05-19T03:31:26.6040045Z Traceback (most recent call last): 2021-05-19T03:31:26.6041069Z File "./scripts/ci/test_index.py", line 112, in test_checksums 2021-05-19T03:31:26.6043503Z self.whl_cache_dir, self.whl_cache) 2021-05-19T03:31:26.6044259Z File "/home/vsts/work/1/s/scripts/ci/util.py", line 94, in get_whl_from_url 2021-05-19T03:31:26.6044982Z for chunk in r.iter_content(chunk_size=1024): 2021-05-19T03:31:26.6045991Z UnboundLocalError: local variable 'r' referenced before assignment 2021-05-19T03:31:26.6046711Z 2021-05-19T03:31:26.6047311Z ====================================================================== 2021-05-19T03:31:26.6047901Z ERROR: test_metadata (__main__.TestIndex) 2021-05-19T03:31:26.6050156Z ---------------------------------------------------------------------- 2021-05-19T03:31:26.6051007Z Traceback (most recent call last): 2021-05-19T03:31:26.6051762Z File "./scripts/ci/test_index.py", line 142, in test_metadata 2021-05-19T03:31:26.6052726Z self.whl_cache_dir, self.whl_cache) 2021-05-19T03:31:26.6053506Z File "/home/vsts/work/1/s/scripts/ci/util.py", line 94, in get_whl_from_url 2021-05-19T03:31:26.6054275Z for chunk in r.iter_content(chunk_size=1024): 2021-05-19T03:31:26.6055335Z UnboundLocalError: local variable 'r' referenced before assignment 2021-05-19T03:31:26.6055866Z 2021-05-19T03:31:26.6056860Z ---------------------------------------------------------------------- 2021-05-19T03:31:26.6057599Z Ran 9 tests in 40.041s

Extension name (the extension in question)

Metadata

Metadata

Assignees

Labels

CIfeature-requestThis issue requires a new behavior in the product in order be resolved.p3_e3priority=3 emergency=3

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions