summaryrefslogtreecommitdiff
path: root/tests/unittests/sources/azure/test_errors.py
diff options
context:
space:
mode:
authorChris Patterson <cpatterson@microsoft.com>2023-05-11 11:43:13 -0700
committerGitHub <noreply@github.com>2023-05-11 13:43:13 -0500
commit481bf4d3c3460fe398c74c950eb02f8562e1c20a (patch)
treede8487d377980ba69c62e40afb36265968485c5f /tests/unittests/sources/azure/test_errors.py
parent0c4d53f2b756c8ecc3c17e3403ba66ebb5ce1560 (diff)
downloadcloud-init-git-481bf4d3c3460fe398c74c950eb02f8562e1c20a.tar.gz
azure/errors: add host reporting for dhcp errors (#2167)
- Add host_only flag to _report_failure() to allow caller to only report the failure to host. This is for cases where we don't want _report_failure() to attempt DHCP or we expect that we may recover from the reported error (there is no issue reporting multiple times to host, whereas fabric reports will immediately fail the VM provisioning). - Add ReportableErrorDhcpLease() to report lease failures. - Add ReportableErrorDhcpInterfaceNotFound() to report errors where the DHCP interface hasn't been found yet. - Add TestReportFailure class with new test coverage. Will migrate other _report_failure() tests in the future as they currently depend on TestAzureDataSource/CiTestCase. Future work will add the interface name to supporting data, but as that information is not available with iface=None, another PR will explicitly add a call to net.find_fallback_nic() to specify it. Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
Diffstat (limited to 'tests/unittests/sources/azure/test_errors.py')
-rw-r--r--tests/unittests/sources/azure/test_errors.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unittests/sources/azure/test_errors.py b/tests/unittests/sources/azure/test_errors.py
index d2213613..e9d3e039 100644
--- a/tests/unittests/sources/azure/test_errors.py
+++ b/tests/unittests/sources/azure/test_errors.py
@@ -119,6 +119,21 @@ def test_reportable_errors(
assert error.as_encoded_report() == "|".join(data)
+def test_dhcp_lease():
+ error = errors.ReportableErrorDhcpLease(duration=5.6, interface="foo")
+
+ assert error.reason == "failure to obtain DHCP lease"
+ assert error.supporting_data["duration"] == 5.6
+ assert error.supporting_data["interface"] == "foo"
+
+
+def test_dhcp_interface_not_found():
+ error = errors.ReportableErrorDhcpInterfaceNotFound(duration=5.6)
+
+ assert error.reason == "failure to find DHCP interface"
+ assert error.supporting_data["duration"] == 5.6
+
+
def test_unhandled_exception():
source_error = None
try: