Azure / Azure/azure-cli-extensions

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

Open
#3,396 1 comment 0 reactions 1 assignee Claimed by @kairu-ms View on GitHub
CI feature-request p3_e3
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

### Description of issue (in as much detail as possible)

-----

Fail reason:
https://github.com/Azure/azure-cli-extensions/blob/5c45cddc34a0a4a80b9c7d801d3700066cc18587/scripts/ci/util.py#L82
```
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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.