Commit Graph

21 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez 4df5f2f41b [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
2024-02-07 08:25:29 +00:00
Slawek Kaplonski 670cc383e0 [S-RBAC] Switch to new policies by default
As part of the Secure RBAC community goal, we should switch options
"enforce_new_defaults" and "enforce_scope" to be True by default.
It will be still possible to fallback to old policy rules by configuring
those config options to False in Neutron config.

Change-Id: I09c0026ccf87e6c0bb1fa59165c03dc508fba6fa
2023-04-21 16:22:42 +02:00
Jakub Libosvar 8ccbbb2292 [quota] Enable ``DbQuotaDriverNull`` as a production driver
Enabled ``DbQuotaDriverNull`` as a productio quota database
quota driver. This driver does not enforce any quota nor have access
to the database. When using this quota driver, the API will return
the default empty values expected from the ``QuotaDriverAPI`` class.

Closes-bug: #1960032

Change-Id: Iafa24753e657746a8b8165b5a63c17de9a9ba791
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
Co-Authored-By: Rodolfo Alonso Hernandez <ralonsoh@redhat.com>
2022-04-05 10:10:46 +00:00
Rodolfo Alonso Hernandez ad31c58d60 Remove ``ConfDriver`` code
The quota driver ``ConfDriver`` was deprecated in Liberty release.

``NullQuotaDriver`` is created for testing although it could be used
in production if no quota enforcement is needed. However, because
the Quota engine is not plugable (is an extension always loaded), it
could be interesting to make it plugable as any other plugin.

This patch also creates a Quota engine driver API class that should be
used in any Quota engine driver. Currently it is used in the three
in-tree drivers implemented: ``NullQuotaDriver``, ``DbQuotaDriver``
and ``DbQuotaNoLockDriver``.

Change-Id: Ib4af80e18fac52b9f68f26c84a215415e63c2822
Closes-Bug: #1928211
2021-07-26 15:00:32 +00:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04:00
Boden R ee77344ac1 use api def ALIAS in supported_extension_aliases
Today a number of classes define their supported_extension_aliases
using static strings rather than API definition ALIASes. This patch
switches them to use the ALIAS where applicable.

Change-Id: I716270c68a9fcd850c3c26de31bc13ea16def23d
2019-04-08 08:30:20 -06:00
Isaku Yamahata 0063aa33c6 pecan.jsonify v1.3 adjustment
From pecan v1.3, pecan.jsonify uses json.Encoder unconditionally so that
jsonifying mock fails.
Pecan v1.2 uses simplejson.Encoder as encoder which accidentally encodes
MagicMock as {} due to check of '_asdict' attributes.
Since pecan.jsonify uses __json__ magic method when it's defined,
add __json__ method to mocks to return {} as json encode.

Closes-bug: #1754978
Change-Id: Iac955a7de2a1b66b5b56a73f5cc8a4e75150f82e
2018-04-18 15:37:20 +00:00
Boden R 9e67ba5052 use core resource api defs from lib
The core resource API definitions are in neutron-lib and are already
setup in a RESOURCES map, similar to neutron's global
RESOURCE_ATTRIBUTE_MAP. However, a number of consumers directly use
RESOURCE_ATTRIBUTE_MAP and moreover can perform some interesting
operations on it while mockin" for tests. For that reason this
patch proposes we phase in the use of neutron's RESOURCES map rather
than a rip and replace of RESOURCE_ATTRIBUTE_MAP.

This patch removes the API definitions for the core neutron resources
by updating neutron's global RESOURCE_ATTRIBUTE_MAP to reference lib's
RESOURCE map. In addition the AttributeMapMemento class is removed; it
no longer servers a purpose and neutron-lib's fixture should be used
in its place.

This patch should be safe to merge without worry of impacting consumers.
No one is using AttributeMapMemento [1] and the global map only changed
its reference value.

[1] http://codesearch.openstack.org/?q=AttributeMapMemento

Change-Id: Ib04fddcbd4465074452b71b16befa4e33b27259e
2017-11-08 09:48:50 -07:00
Boden R 0a1405794f use service type constants from neutron_lib plugins
The well known service type constants are in
neutron_lib.plugins.constants, but for legacy reasons a few still exist
and are referenced from neutron_lib.constants that we'd like to remove.
This patch switches references over to neutron_lib's plugin constants.

Change-Id: I1861448cec303725b30cef8f42029f467f9e03a3
2017-06-27 15:16:05 -06:00
Jenkins 6187d3af33 Merge "Fix call a method of extension class" 2017-04-02 03:26:12 +00:00
Hirofumi Ichihara 2873bb3acf Fix call a method of extension class
Some UTs have wrong method call about extension class.
This patch fixes the call.

TrivialFix

Change-Id: I86adc31dac5b4e56edb200b9c7c369112c7d8977
2017-03-30 16:37:23 +09:00
Boden R 9658b4b34e use neutron_lib's provider_net api-def
Neutron-lib 1.1.0 is now out and contains the provider
network API definition (as per commit [1]). This patch
moves neutron references over to the neutron-lib
version.

NeutronLibImpact
- Consumers using the public constants within neutron's
providernet API extension must now use the values
from neutron-lib.

[1] cba0f9f0dd920b1f828c4bba3bd388d5b4eb9abf

Change-Id: I46390a159e93642901de87ea6604f2e7ffa03bad
2017-03-15 06:27:58 -06:00
Armando Migliaccio ca751a1486 Spin off context module
NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
2017-03-06 16:25:29 +00:00
Ihar Hrachyshka 61eb74af31 Remove allow_pagination and allow_sorting config options
They were deprecated in Newton. This patch cleans them up.

Note: it does not mean that the features will not work anymore. On the
contrary, now API will consistently sort and paginate for plugins that
honour the relevant sorting/pagination parameters.

Note2: base resource controller still allows to pass
allow_pagination=False and allow_sorting=False parameters to disable the
features if a registered plugin does not support the features yet.

Change-Id: I5fd30b20f645846d9366740372c4815c4b33e2eb
Related-Bug: #1566514
2016-11-29 12:34:19 +00:00
Armando Migliaccio 17563a802e Adopt neutron-lib plugin directory
Neutron Manager is loaded at the very startup of the neutron
server process and with it plugins are loaded and stored for
lookup purposes as their references are widely used across the
entire neutron codebase.

Rather than holding these references directly in NeutronManager
this patch refactors the code so that these references are held
by a plugin directory.

This allows subprojects and other parts of the Neutron codebase
to use the directory in lieu of the manager. The result is a
leaner, cleaner, and more decoupled code.

Usage pattern [1,2] can be translated to [3,4] respectively.

[1] manager.NeutronManager.get_service_plugins()[FOO]
[2] manager.NeutronManager.get_plugin()
[3] directory.get_plugin(FOO)
[4] directory.get_plugin()

The more entangled part is in the neutron unit tests, where the
use of the manager can be simplified as mocking is typically
replaced by a call to the directory add_plugin() method. This is
safe as each test case gets its own copy of the plugin directory.
That said, unit tests that look more like API tests and that rely on
the entire plugin machinery, need some tweaking to avoid stumbling
into plugin loading failures.

Due to the massive use of the manager, deprecation warnings are
considered impractical as they cause logs to bloat out of proportion.

Follow-up patches that show how to adopt the directory in neutron
subprojects are tagged with topic:plugin-directory.

NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I7331e914234c5f0b7abe836604fdd7e4067551cf
2016-11-23 04:45:33 -07:00
Dariusz Smigiel dd5976b7ab Accept and return project_id for API calls
Update the API to accept project_id in requests and return
project_id in responses.

For now, the API treats tenant_id and project_id equivalently.
It accepts either or both in requests.
It returns both in responses, depending on filters.

We include an extension to indicate that support for project_id
is enabled in the API.

Completes: blueprint keystone-v3

APIImpact: Describe how the Networking API supports Keystone V3.

Co-Authored-By: Henry Gessau <HenryG@gessau.net>
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>

Change-Id: I8775aa8a477191ef21e7c3c6da31d098befefc3c
2016-09-12 19:23:53 +00:00
Yatin Kumbhare 6b4be76e14 Fix params order in assertEqual
Fix params order to correspond to real signature:
assertEqual(expected, actual)

Change-Id: I722b998f6eae47076f3d10213073296a0a9a2081
Closes-Bug: #1277104
2016-02-03 11:54:29 +05:30
ChangBo Guo(gcb) c3d65a0ed9 Switch to oslo_utils.uuidutils
Get rid of oslo-incubator uuidutils

Closes-Bug: #1467020
Depends-On: I2df519965883b05d5d58cdc4785c850b0685dc2c
Depends-On: I9f8e98ad9517864a9ffdacf01c0a9a5aab554edb
Depends-On: Ied0faac809a5b72b1cd466c8babc9ca5418692c3
Change-Id: Iebe491b981b4b7c02785412fadd27678bb5e47de
2015-06-22 11:06:18 +00:00
Brent Eagles 35acb27da0 Refactor RESOURCE_ATTRIBUTE_MAP cleanup
This patch adds a AttributeMapMemento class that can be used for
restoring the RESOURCE_ATTRIBUTE_MAP on test tear down. Tests containing
their own cleanup code have been modified to use it instead.

Change-Id: I7ce5182bdfb8f541741a327feada63a29ddac2ae
2015-04-22 12:02:34 -02:30
Pritesh Kothari 809e434d2d Moving VLAN Transparency support from core to extension
* Moving VLAN Transparency support from core to extension
* Remove the older unit tests and add new corresponding ones

DocImpact
Closes-Bug: #1434667

Change-Id: Ic551475ed7b64aad9627a57abb0df41acc19bfc1
2015-04-08 08:35:13 -07:00
Maru Newby 1105782e39 Reorganize unit test tree
This change ensures that the structure of the unit test tree matches
that of the code tree to make it obvious where to find tests for a
given module.  A check is added to the pep8 job to protect against
regressions.

The plugin test paths are relocated to neutron/tests/unit/plugins
but are otherwise ignored for now.

Change-Id: If307593259139171be21a71c58e3a34bf148cc7f
Partial-Bug: #1440834
2015-04-06 23:28:31 +00:00