enable make check

This commit is contained in:
yang_zhuang_zhuang 2021-06-19 11:09:27 +08:00
parent 16ab20cd54
commit c21ca0c6dd
2 changed files with 56 additions and 3 deletions

View File

@ -0,0 +1,46 @@
From f16b18607444cb41e263edfa7fb0c97ba1f7e518 Mon Sep 17 00:00:00 2001
From: Eduardo Otubo <otubo@redhat.com>
Date: Fri, 4 Dec 2020 11:05:08 +0100
Subject: [PATCH] Sandbox ca_certs tests to avoid failure
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
---
.../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

View File

@ -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 <yangzhuangzhuang1@huawei.com> - 20.3-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:enable make check
* Tue May 25 2021 yangzhuangzhuang <yangzhuangzhuang1@huawei.com> - 20.3-2
- Type:bugfix
- ID:NA