From c21ca0c6ddb2b3362b3d861eead97bf0a7f398a7 Mon Sep 17 00:00:00 2001 From: yang_zhuang_zhuang <1162011203@qq.com> Date: Sat, 19 Jun 2021 11:09:27 +0800 Subject: [PATCH] enable make check --- ...dbox-ca_certs-tests-to-avoid-failure.patch | 46 +++++++++++++++++++ cloud-init.spec | 13 ++++-- 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 cloud-init-20.4-sandbox-ca_certs-tests-to-avoid-failure.patch diff --git a/cloud-init-20.4-sandbox-ca_certs-tests-to-avoid-failure.patch b/cloud-init-20.4-sandbox-ca_certs-tests-to-avoid-failure.patch new file mode 100644 index 0000000..20f27e3 --- /dev/null +++ b/cloud-init-20.4-sandbox-ca_certs-tests-to-avoid-failure.patch @@ -0,0 +1,46 @@ +From f16b18607444cb41e263edfa7fb0c97ba1f7e518 Mon Sep 17 00:00:00 2001 +From: Eduardo Otubo +Date: Fri, 4 Dec 2020 11:05:08 +0100 +Subject: [PATCH] Sandbox ca_certs tests to avoid failure + +Signed-off-by: Eduardo Otubo +--- + .../unittests/test_handler/test_handler_ca_certs.py | 12 ++++-------- + 1 file changed, 4 insertions(+), 8 deletions(-) + +diff --git a/tests/unittests/test_handler/test_handler_ca_certs.py b/tests/unittests/test_handler/test_handler_ca_certs.py +index e74a0a08..a16430d5 100644 +--- a/tests/unittests/test_handler/test_handler_ca_certs.py ++++ b/tests/unittests/test_handler/test_handler_ca_certs.py +@@ -152,6 +152,7 @@ class TestAddCaCerts(TestCase): + self.paths = helpers.Paths({ + 'cloud_dir': tmpdir, + }) ++ self.add_patch("cloudinit.config.cc_ca_certs.os.stat", "m_stat") + + def test_no_certs_in_list(self): + """Test that no certificate are written if not provided.""" +@@ -215,17 +216,12 @@ class TestAddCaCerts(TestCase): + + expected = "cloud-init-ca-certs.crt\n" + +- with ExitStack() as mocks: +- mock_write = mocks.enter_context( +- mock.patch.object(util, 'write_file', autospec=True)) +- mock_stat = mocks.enter_context( +- mock.patch("cloudinit.config.cc_ca_certs.os.stat") +- ) +- mock_stat.return_value.st_size = 0 ++ with mock.patch.object(util, 'write_file', autospec=True) as m_write: ++ self.m_stat.return_value.st_size = 0 + + cc_ca_certs.add_ca_certs([cert]) + +- mock_write.assert_has_calls([ ++ m_write.assert_has_calls([ + mock.call("/usr/share/ca-certificates/cloud-init-ca-certs.crt", + cert, mode=0o644), + mock.call("/etc/ca-certificates.conf", expected, omode="wb")]) +-- +2.27.0 + diff --git a/cloud-init.spec b/cloud-init.spec index 2954dd5..f5a8a17 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -1,6 +1,6 @@ Name: cloud-init Version: 20.3 -Release: 2 +Release: 3 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 @@ -14,6 +14,7 @@ Patch2: cloud-init-19.4-no-override-default-network.patch Patch3: bugfix-cloud-init-add-openEuler-os.patch Patch4: bugfix-sort-requirements.patch Patch5: add-variable-to-forbid-tmp-dir.patch +Patch6: cloud-init-20.4-sandbox-ca_certs-tests-to-avoid-failure.patch Patch9000: Fix-the-error-level-logs-displayed-for-the-cloud-init-local-service.patch @@ -22,7 +23,7 @@ BuildRequires: iproute python3-configobj python3-httpretty >= 0.8.14-2 BuildRequires: python3-jinja2 python3-jsonpatch python3-jsonschema BuildRequires: python3-mock python3-nose python3-oauthlib python3-prettytable BuildRequires: python3-pyserial python3-PyYAML python3-requests python3-six -BuildRequires: python3-unittest2 dnf %{_vendor}-release +BuildRequires: python3-unittest2 dnf %{_vendor}-release python3-pytest passwd Requires: e2fsprogs iproute python3-libselinux net-tools python3-policycoreutils Requires: procps python3-configobj python3-jinja2 python3-jsonpatch xfsprogs @@ -60,7 +61,7 @@ install -D -m 0644 tools/21-cloudinit.conf %{buildroot}/%{_sysconfdir}/rsyslog.d rm -f $RPM_BUILD_DIR/%{name}-%{version}/tests/unittests/test_handler/test_handler_ntp.py rm -f $RPM_BUILD_DIR/%{name}-%{version}/tests/unittests/test_datasource/test_opennebula.py -#nosetests-%%{python3_version} tests/unittests/ +python3 -m pytest tests/unittests/ %pre @@ -122,6 +123,12 @@ fi %exclude /usr/share/doc/* %changelog +* Sat Jun 19 2021 yangzhuangzhuang - 20.3-3 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:enable make check + * Tue May 25 2021 yangzhuangzhuang - 20.3-2 - Type:bugfix - ID:NA -- Gitee