From e6adaf39f06b0a45aafe7929cd90a33c7bd28bc8 Mon Sep 17 00:00:00 2001 From: huangtianhua Date: Thu, 18 Nov 2021 17:56:23 +0800 Subject: [PATCH] Fix build and test error (cherry picked from commit cb1c469afd2bec288dd39c478ff0533a634bc272) --- Fix-jsonpatch-related-tests.patch | 98 +++++++++++++++++++++++++++++++ openstack-ironic.spec | 15 ++++- 2 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 Fix-jsonpatch-related-tests.patch diff --git a/Fix-jsonpatch-related-tests.patch b/Fix-jsonpatch-related-tests.patch new file mode 100644 index 0000000..74eb2ed --- /dev/null +++ b/Fix-jsonpatch-related-tests.patch @@ -0,0 +1,98 @@ +diff --git a/ironic/api/controllers/v1/utils.py b/ironic/api/controllers/v1/utils.py +index 2949325..5c13d2a 100644 +--- a/ironic/api/controllers/v1/utils.py ++++ b/ironic/api/controllers/v1/utils.py +@@ -42,7 +42,8 @@ from ironic import objects + CONF = cfg.CONF + + +-_JSONPATCH_EXCEPTIONS = (jsonpatch.JsonPatchException, ++_JSONPATCH_EXCEPTIONS = (jsonpatch.JsonPatchConflict, ++ jsonpatch.JsonPatchException, + jsonpatch.JsonPointerException, + KeyError, + IndexError) +diff --git a/ironic/tests/unit/api/controllers/v1/test_deploy_template.py b/ironic/tests/unit/api/controllers/v1/test_deploy_template.py +index 049a21f..d30b763 100644 +--- a/ironic/tests/unit/api/controllers/v1/test_deploy_template.py ++++ b/ironic/tests/unit/api/controllers/v1/test_deploy_template.py +@@ -361,7 +361,8 @@ class TestPatch(BaseDeployTemplatesAPITest): + self.assertEqual('application/json', response.content_type) + self.assertEqual(http_client.BAD_REQUEST, response.status_code) + self.assertTrue(response.json['error_message']) +- self.assertIn(error_msg, response.json['error_message']) ++ #self.assertIn(error_msg, response.json['error_message']) ++ self.assertRegex(response.json['error_message'], error_msg) + self.assertFalse(mock_save.called) + return response + +@@ -539,7 +540,8 @@ class TestPatch(BaseDeployTemplatesAPITest): + } + patch = [{'path': '/steps/1', 'op': 'replace', 'value': step}] + self._test_update_bad_request( +- mock_save, patch, "list assignment index out of range") ++ mock_save, patch, "list assignment index out of range|" ++ "can't replace outside of list") + + def test_replace_empty_step_list_fail(self, mock_save): + patch = [{'path': '/steps', 'op': 'replace', 'value': []}] +@@ -567,7 +569,7 @@ class TestPatch(BaseDeployTemplatesAPITest): + + def test_remove_foo(self, mock_save): + self._test_remove_not_allowed( +- mock_save, 'foo', "can't remove non-existent object 'foo'") ++ mock_save, 'foo', "can't remove a non-existent object 'foo'") + + def test_replace_step_invalid_interface(self, mock_save): + patch = [{'path': '/steps/0/interface', 'op': 'replace', +@@ -634,12 +636,12 @@ class TestPatch(BaseDeployTemplatesAPITest): + patch = [{'path': '/non-existent', 'op': 'remove'}] + self._test_update_bad_request( + mock_save, patch, +- "can't remove non-existent object 'non-existent'") ++ "can't remove a non-existent object 'non-existent'") + + def test_remove_non_existent_step_fail(self, mock_save): + patch = [{'path': '/steps/1', 'op': 'remove'}] + self._test_update_bad_request( +- mock_save, patch, "can't remove non-existent object '1'") ++ mock_save, patch, "can't remove a non-existent object '1'") + + def test_remove_only_step_fail(self, mock_save): + patch = [{'path': '/steps/0', 'op': 'remove'}] +@@ -650,12 +652,12 @@ class TestPatch(BaseDeployTemplatesAPITest): + patch = [{'path': '/steps/0/non-existent', 'op': 'remove'}] + self._test_update_bad_request( + mock_save, patch, +- "can't remove non-existent object 'non-existent'") ++ "can't remove a non-existent object 'non-existent'") + + def test_add_root_non_existent(self, mock_save): + patch = [{'path': '/foo', 'value': 'bar', 'op': 'add'}] + self._test_update_bad_request( +- mock_save, patch, "Adding a new attribute (/foo)") ++ mock_save, patch, "Adding a new attribute \(/foo\)") + + def test_add_too_high_index_step_fail(self, mock_save): + step = { +diff --git a/ironic/tests/unit/api/controllers/v1/test_utils.py b/ironic/tests/unit/api/controllers/v1/test_utils.py +index d18fded..1c7d842 100644 +--- a/ironic/tests/unit/api/controllers/v1/test_utils.py ++++ b/ironic/tests/unit/api/controllers/v1/test_utils.py +@@ -105,7 +105,7 @@ class TestApiUtils(base.TestCase): + doc = {} + patch = [{"op": "remove", "path": "/foo"}] + self.assertRaisesRegex(exception.PatchError, +- "can't remove non-existent object 'foo'", ++ "can't remove a non-existent object 'foo'", + utils.apply_jsonpatch, doc, patch) + + def test_apply_jsonpatch_replace_non_existent_list_item(self): +@@ -113,6 +113,7 @@ class TestApiUtils(base.TestCase): + doc = [] + patch = [{"op": "replace", "path": "/0", "value": 42}] + self.assertRaisesRegex(exception.PatchError, ++ "can't replace outside of list|" + "list assignment index out of range", + utils.apply_jsonpatch, doc, patch) + diff --git a/openstack-ironic.spec b/openstack-ironic.spec index e9cc72d..fa8464e 100644 --- a/openstack-ironic.spec +++ b/openstack-ironic.spec @@ -7,7 +7,7 @@ Name: openstack-ironic # https://review.openstack.org/#/q/I1a161b2c1d1e27268065b6b4be24c8f7a5315afb,n,z Summary: OpenStack Baremetal Hypervisor API (ironic) Version: 13.0.7 -Release: 2 +Release: 3 License: ASL 2.0 URL: http://www.openstack.org Source0: https://tarballs.openstack.org/ironic/ironic-%{version}.tar.gz @@ -17,6 +17,7 @@ Source2: openstack-ironic-conductor.service Source3: ironic-rootwrap-sudoers Source4: ironic-dist.conf Source5: ironic.logrotate +Patch0: Fix-jsonpatch-related-tests.patch BuildArch: noarch BuildRequires: openstack-macros @@ -86,6 +87,7 @@ BuildRequires: python3-proliantutils BuildRequires: python3-tenacity BuildRequires: python3-webob BuildRequires: python3-pysendfile +BuildRequires: python3-wsme Requires: %{name}-api = %{version}-%{release} Requires: %{name}-conductor = %{version}-%{release} @@ -137,6 +139,7 @@ Requires: python3-swiftclient Requires: python3-tenacity Requires: python3-tooz Requires: python3-webob +Requires: python3-wsme Requires(pre): shadow-utils %description -n python3-ironic @@ -180,6 +183,7 @@ This package contains the Ironic test files. %prep # Required for tarball sources verification %setup -q -n ironic-%{upstream_version} +%patch0 -p1 # Let RPM handle the requirements %py_req_cleanup # Remove tempest plugin entrypoint as a workaround @@ -220,7 +224,9 @@ rmdir %{buildroot}%{_prefix}/etc/ironic install -p -D -m 640 %{SOURCE4} %{buildroot}/%{_datadir}/ironic/ironic-dist.conf %check -PYTHON=%{__python3} stestr run +#PYTHON=%{__python3} stestr run +export LC_ALL=en_US.UTF-8 +python3 -m stestr.cli run %files %license LICENSE @@ -234,7 +240,6 @@ PYTHON=%{__python3} stestr run %files common %doc README.rst -%doc etc/ironic/policy.yaml.sample %license LICENSE %{_bindir}/ironic-dbsync %{_bindir}/ironic-rootwrap @@ -286,7 +291,11 @@ exit 0 %changelog +* Thu Nov 18 2021 huangtianhua - 13.0.7-3 +- Adds python3-wsme as buildrequires and fix build error + * Mon Nov 15 2021 huangtianhua - 13.0.7-2 - Adds python3-pysendfile as buildrequires + * Fri Nov 05 2021 lijiawei - 13.0.7-1 - Support OpenStack Train release