aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/qemu_test/asset.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/qemu_test/asset.py')
-rw-r--r--tests/functional/qemu_test/asset.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index 704b84d..2971a98 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -15,7 +15,7 @@ import urllib.request
from time import sleep
from pathlib import Path
from shutil import copyfileobj
-from urllib.error import HTTPError
+from urllib.error import HTTPError, URLError
class AssetError(Exception):
def __init__(self, asset, msg, transient=False):
@@ -72,6 +72,10 @@ class Asset:
return self.hash == hl.hexdigest()
def valid(self):
+ if os.getenv("QEMU_TEST_REFRESH_CACHE", None) is not None:
+ self.log.info("Force refresh of asset %s", self.url)
+ return False
+
return self.cache_file.exists() and self._check(self.cache_file)
def fetchable(self):
@@ -167,9 +171,25 @@ class Asset:
raise AssetError(self, "Unable to download: "
"HTTP error %d" % e.code)
continue
+ except URLError as e:
+ # This is typically a network/service level error
+ # eg urlopen error [Errno 110] Connection timed out>
+ tmp_cache_file.unlink()
+ self.log.error("Unable to download %s: URL error %s",
+ self.url, e.reason)
+ raise AssetError(self, "Unable to download: URL error %s" %
+ e.reason, transient=True)
+ except ConnectionError as e:
+ # A socket connection failure, such as dropped conn
+ # or refused conn
+ tmp_cache_file.unlink()
+ self.log.error("Unable to download %s: Connection error %s",
+ self.url, e)
+ continue
except Exception as e:
tmp_cache_file.unlink()
- raise AssetError(self, "Unable to download: " % e)
+ raise AssetError(self, "Unable to download: %s" % e,
+ transient=True)
if not os.path.exists(tmp_cache_file):
raise AssetError(self, "Download retries exceeded", transient=True)