From 7da958d4c86e623966e0359fa993035ee61391d2 Mon Sep 17 00:00:00 2001 From: yang_zhuang_zhuang <1162011203@qq.com> Date: Fri, 1 Apr 2022 16:28:12 +0800 Subject: [PATCH] Fix test_net.py testcase fail --- ...itional-mocks-to-test_net-tests-1356.patch | 40 +++++++++++++++++++ cloud-init.spec | 9 ++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 backport-testing-add-additional-mocks-to-test_net-tests-1356.patch diff --git a/backport-testing-add-additional-mocks-to-test_net-tests-1356.patch b/backport-testing-add-additional-mocks-to-test_net-tests-1356.patch new file mode 100644 index 0000000..8a29b6c --- /dev/null +++ b/backport-testing-add-additional-mocks-to-test_net-tests-1356.patch @@ -0,0 +1,40 @@ +From d8f39d79fcdb548252823949a4b24f49a00e8c27 Mon Sep 17 00:00:00 2001 +From: yangzz-97 <70520104+yangzz-97@users.noreply.github.com> +Date: Thu, 31 Mar 2022 22:00:33 +0800 +Subject: [PATCH] testing: add additional mocks to test_net tests (#1356) + +Tests in tests/unittests/test_net.py::TestGetInterfaces were missing +mocks for bond and failover calls. + +Signed-off-by: yangzz-97 +--- + tests/unittests/test_net.py | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py +index 6294f4b..ce19498 100644 +--- a/tests/unittests/test_net.py ++++ b/tests/unittests/test_net.py +@@ -5404,12 +5404,18 @@ class TestGetInterfaces(CiTestCase): + def _se_interface_has_own_mac(self, name): + return name in self.data['own_macs'] + ++ def _se_is_bond(self, name): ++ return name in self.data["bonds"] ++ ++ def _se_is_netfailover(self, name): ++ return False ++ + def _mock_setup(self): + self.data = copy.deepcopy(self._data) + self.data['devices'] = set(list(self.data['macs'].keys())) + mocks = ('get_devicelist', 'get_interface_mac', 'is_bridge', + 'interface_has_own_mac', 'is_vlan', 'device_driver', +- 'device_devid') ++ 'device_devid', 'is_bond', 'is_netfailover') + self.mocks = {} + for n in mocks: + m = mock.patch('cloudinit.net.' + n, +-- +1.8.3.1 + diff --git a/cloud-init.spec b/cloud-init.spec index 34f4e83..c891066 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -1,6 +1,6 @@ Name: cloud-init Version: 19.4 -Release: 6 +Release: 7 Summary: the defacto multi-distribution package that handles early initialization of a cloud instance. License: ASL 2.0 or GPLv3 URL: http://launchpad.net/cloud-init @@ -16,6 +16,7 @@ Patch5: add-variable-to-forbid-tmp-dir.patch Patch6: backport-CVE-2020-8631-utils-use-SystemRandom-when-generating-random-passwo.patch Patch7: backport-CVE-2020-8632-cc_set_password-increase-random-pwlength-from-9-to-2.patch Patch8: backport-CVE-2021-3429-write-passwords-only-to-serial-console-lock-down-clo.patch +Patch9: backport-testing-add-additional-mocks-to-test_net-tests-1356.patch Patch9000: Fix-the-error-level-logs-displayed-for-the-cloud-init-local-service.patch @@ -124,6 +125,12 @@ fi %exclude /usr/share/doc/* %changelog +* Fri Apr 1 2022 yangzhuangzhuang - 19.4-7 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Fix test_net.py testcase fail + * Sat Dec 4 2021 yangzhuangzhuang - 19.4-6 - Type:bugfix - ID:NA -- Gitee