[PATCH 1/2] tests/functional: retry when seeing ConnectionError exception

Daniel P. Berrangé posted 2 patches 1 month, 3 weeks ago
Maintainers: Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>
[PATCH 1/2] tests/functional: retry when seeing ConnectionError exception
Posted by Daniel P. Berrangé 1 month, 3 weeks ago
This base class is used for many different socket connection
errors, corresponding to ECONNRESET, ECONNREFUSED, ECONNABORTED
and more. Most of these are things you might expect to see every
now and then as transient flaws. We should thus retry the asset
download when seeing them.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/functional/qemu_test/asset.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index 2dd32bf28d..f8b87d2153 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -179,6 +179,13 @@ def fetch(self):
                                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: %s" % e)
-- 
2.50.1


Re: [PATCH 1/2] tests/functional: retry when seeing ConnectionError exception
Posted by Thomas Huth 1 month, 3 weeks ago
On 18/09/2025 14.57, Daniel P. Berrangé wrote:
> This base class is used for many different socket connection
> errors, corresponding to ECONNRESET, ECONNREFUSED, ECONNABORTED
> and more. Most of these are things you might expect to see every
> now and then as transient flaws. We should thus retry the asset
> download when seeing them.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/functional/qemu_test/asset.py | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
> index 2dd32bf28d..f8b87d2153 100644
> --- a/tests/functional/qemu_test/asset.py
> +++ b/tests/functional/qemu_test/asset.py
> @@ -179,6 +179,13 @@ def fetch(self):
>                                  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: %s" % e)

Reviewed-by: Thomas Huth <thuth@redhat.com>