Reviewed: https://review.opendev.org/c/openstack/neutron/+/908255 Committed: https://opendev.org/openstack/neutron/commit/4df5f2f41baede43b3e87ff8b716a7e6c773fbea Submitter: "Zuul (22348)" Branch: master
commit 4df5f2f41baede43b3e87ff8b716a7e6c773fbea Author: Rodolfo Alonso Hernandez <[email protected]> Date: Wed Feb 7 08:15:03 2024 +0000 [UT] Fix ``APIv2TestBase`` derived test classes The method test calling ``_post_request`` with create or update operations, were not properly patching the ML2 plugin ``create_network`` and `update_network`` methods. With Python3.12, the mock object passed (instead of a dictionary with a reduced network definition) don't have a ``__json__`` method and fails during the encoding. NOTE: this has been manually tested with Python3.12. Currently this patch cannot be tested in the CI. Closes-Bug: #2051928 Change-Id: Ie30af0c655d2f27d9039ff7933e81603047da6f4 ** Changed in: neutron Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to neutron. https://bugs.launchpad.net/bugs/2051928 Title: tests - Python 3.12 - TypeError: Object of type _SentinelObject is not JSON serializable Status in neutron: Fix Released Bug description: Executing unit tests with Python 3.12 results in some test failures which I think are todo with the way the unit tests mock the __json__ method in the tools module: neutron.tests.unit.api.v2.test_base.RegistryNotificationTest.test_networks_create_bulk_registry_publish ------------------------------------------------------------------------------------------------------- Captured traceback: ~~~~~~~~~~~~~~~~~~~ Traceback (most recent call last): File "/home/jamespage/src/upstream/openstack/neutron/neutron/tests/base.py", line 178, in func return f(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jamespage/src/upstream/openstack/neutron/neutron/tests/unit/api/v2/test_base.py", line 1300, in test_networks_create_bulk_registry_publish self._test_registry_publish('create', 'network', input) File "/home/jamespage/src/upstream/openstack/neutron/neutron/tests/unit/api/v2/test_base.py", line 1269, in _test_registry_publish res = self.api.post_json( ^^^^^^^^^^^^^^^^^^^ No tests were successful during the run File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/webtest/utils.py", line 34, in wrapper return self._gen_request(method, url, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/webtest/app.py", line 749, in _gen_request return self.do_request(req, status=status, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/webtest/app.py", line 646, in do_request self._check_status(status, res) File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/webtest/app.py", line 675, in _check_status raise AppError( webtest.app.AppError: Bad response: 500 Internal Server Error (not 200 OK or 3xx redirect for http://localhost/networks) b'{"NeutronError": {"type": "HTTPInternalServerError", "message": "Request Failed: internal server error while processing your request.", "detail": ""}}' Captured pythonlogging: ~~~~~~~~~~~~~~~~~~~~~~~ ERROR [neutron.pecan_wsgi.hooks.translation] POST failed. Traceback (most recent call last): File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/pecan/core.py", line 682, in __call__ self.invoke_controller(controller, args, kwargs, state) File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/pecan/core.py", line 603, in invoke_controller result = self.render(template, result) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/pecan/core.py", line 414, in render return renderer.render(template, namespace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/pecan/templating.py", line 23, in render return encode(namespace) ^^^^^^^^^^^^^^^^^ File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/pecan/jsonify.py", line 154, in encode return _instance.encode(obj) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/json/encoder.py", line 200, in encode chunks = self.iterencode(o, _one_shot=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/json/encoder.py", line 258, in iterencode return _iterencode(o, 0) ^^^^^^^^^^^^^^^^^ File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/pecan/jsonify.py", line 148, in default return jsonify(obj) ^^^^^^^^^^^^ File "/usr/lib/python3.12/functools.py", line 909, in wrapper return dispatch(args[0].__class__)(*args, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/pecan/jsonify.py", line 143, in jsonify return _default.default(obj) ^^^^^^^^^^^^^^^^^^^^^ File "/home/jamespage/src/upstream/openstack/neutron/.tox/py312/lib/python3.12/site-packages/pecan/jsonify.py", line 129, in default return JSONEncoder.default(self, obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/json/encoder.py", line 180, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type _SentinelObject is not JSON serializable Digging in I can see all of the plugin child calls being updated, however I don't see them actually called under Python 3.12. This issue impacts the following unit tests: FAIL: neutron.tests.unit.api.v2.test_base.RegistryNotificationTest.test_network_create_registry_publish FAIL: neutron.tests.unit.api.v2.test_base.RegistryNotificationTest.test_network_update_registry_publish FAIL: neutron.tests.unit.api.v2.test_base.RegistryNotificationTest.test_networks_create_bulk_registry_publish FAIL: neutron.tests.unit.api.v2.test_base.NotificationTest.test_network_create_notifier FAIL: neutron.tests.unit.api.v2.test_base.NotificationTest.test_network_update_notifier FAIL: neutron.tests.unit.api.v2.test_base.QuotaTest.test_create_network_quota_without_limit FAIL: neutron.tests.unit.extensions.test_providernet.ProvidernetExtensionTestCase.test_network_create_with_provider_attrs FAIL: neutron.tests.unit.extensions.test_providernet.ProvidernetExtensionTestCase.test_network_update_with_provider_attrs To manage notifications about this bug go to: https://bugs.launchpad.net/neutron/+bug/2051928/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

