From bcc251800b9e60c541de860dc8a1ced70622ee43 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrangé" Date: Thu, 18 Sep 2025 13:57:45 +0100 Subject: tests/functional: retry when seeing ConnectionError exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Reviewed-by: Thomas Huth Message-ID: <20250918125746.1165658-2-berrange@redhat.com> Signed-off-by: Thomas Huth --- tests/functional/qemu_test/asset.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/functional/qemu_test/asset.py') 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 @@ class Asset: 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) -- cgit 1.4.1 From 097bbfc5e0ba889ce17106ef941a56111c3de270 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrangé" Date: Thu, 18 Sep 2025 13:57:46 +0100 Subject: tests/functional: treat unknown exceptions as transient faults MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To maximise the robustness of the functional tests we want to treat most asset download failures as non-fatal to the test suite. Instead it should just skip the tests which need that particular asset. The only time aim to make it fatal is for 404 errors which are highly likely to reflect genuine problems to be fixed. We catch certain exception classes and handle them as transient errors, but unfortunately it is proving difficult to predict what exception classes urlopen() is capable of raising, with new possibilities being discovered. To provide a fail-safe, treat the generic Exception class as being a transient error too. This may well mask certain genuine bugs, but it is preferrable to prioritize running the test suite to the greatest extent practical. Signed-off-by: Daniel P. Berrangé Reviewed-by: Thomas Huth Message-ID: <20250918125746.1165658-3-berrange@redhat.com> Signed-off-by: Thomas Huth --- tests/functional/qemu_test/asset.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/functional/qemu_test/asset.py') diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py index f8b87d2153..2971a989d1 100644 --- a/tests/functional/qemu_test/asset.py +++ b/tests/functional/qemu_test/asset.py @@ -188,7 +188,8 @@ class Asset: continue except Exception as e: tmp_cache_file.unlink() - raise AssetError(self, "Unable to download: %s" % 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) -- cgit 1.4.1