Commit Graph

22 Commits (stable/train)

Author SHA1 Message Date
Boden R 7a58374fde make sql fixtures public
This patch makes the _StaticSqlFixture and _SqlFixture fixture classes
public by removing the leading underscore in the name. Based on
recent testing [1][2] the current versions of these fixtures seems to
work for consumers.


Change-Id: I5e9497d650176201407f0823f0fce46e009fb89c
2019-06-28 09:39:42 -06:00
Boden R 96b82602fb sync sql fixtures from neutron
This patch updates the sql fixtures in neutron_lib.fixtures to
match their implementation in neutron. This is necessary due to some
issues with the existing fixtures in neutron-lib. The fixtures are
still marked private as we'll need to test them again before
making them public for consumption.

Sample consumption patch:

Change-Id: I3e1ed2374125f2ac1e57db70bf206fdbeb3f82e4
2019-05-22 06:17:57 -06:00
Boden R c220374779 use once rather than always for filterwarnings
The previous update to the WarningsFixture in [1] didn't account for
the use of "once" vs "always" for the filterwarnings call. This patch
switches over to "once" for parity with neutron.


Change-Id: Id1bdd97634be0de52b3ad0697740cc1621c9682a
2019-05-06 15:10:23 -06:00
Boden R c58df6994f update db fixtures for consumption testing
Today neutron-lib has a SqlFixture that's public, but not used by
anyone else. However, this fixture doesn't contain the same
functionality as the fixture in neutron; so neutron breaks when
using it as-is today.

This patch preps for consumption of the SqlFixture(s) by:
- Moving a few more of SqlFixtures from neutron into lib; these are used
by consumers today.
- Updates the existing SqlFixture to include some functionality that
neutron requires.
- Makes all these SqlFixtures private. This is temporary so that we can
have a little time to test them in neutron and other's gates while
making sure no one uses them from lib. Once we are done testing we
will update them again in lib to be public and consume them. At that
point some UTs can also be added with a release note.

Neutron sample consumption patch:

Change-Id: Iaefc83d852a8dca48569e543f535f7c49f5ad0db
2019-04-15 06:02:39 -06:00
Boden R b4ecdc9945 fix WarningsFixture for public consumption
The was recently made public and along with it the
WarningsFixture. However the WarningsFixture as-is doesn't support
filtering warnings from other modules. This patch address that by
accepting an constructor arg to add other module regular expressions to
filter. It also moves WarningsFixture to the fixture module where it
seems to make the most sense.

For a sample consumption patch see:

Change-Id: I08c713916aef407ba108ed2c67c3e99892f5883a
2019-04-10 07:19:42 -06:00
Boden R ef9c2ae111 rehome used
This patch rehomes the OpenFixture class and reset_random_seed function
both which are from as they are used by consumers
today [1].


Change-Id: I3d13a747f31e39c11f42e2f543eae3823cfbe356
2019-03-08 14:53:39 -07:00
Boden R 70612663ef fix DBResourceExtendFixture fixture
Commit e5afd0b9cb rehomed the
resource_extend db module into neutron-lib and included a testing
fixture. However the fixture submitted in that commit incorrectly
backed-up/restored the _DECORATED_EXTEND_METHODS rather than the
_resource_extend_functions as it should've. This patch fixes that

Change-Id: I6f313d8b03cbe985a2f231e99c4b6c0d1af7a8c4
2018-11-09 06:27:33 -07:00
Boden R e5afd0b9cb rehome the resource_extend db module
This patch rehomes neutron.db._resource_extend into neutron-lib. While
the module is private in neutron, it's used by consumers today [1]. The
patch also includes a test fixture along with unit tests and a
release note.


Change-Id: I2306ba92dcf4a989c7c73e5f0ef4bfb4f804b6cd
2018-10-25 15:42:00 -06:00
Steve Kowalik c436b10e56 Switch to oslo_messaging.ConfFixture.transport_url
oslo_messaging's rpc_backend setting, which is set by
ConfFixture.transport_driver has been deprecated since Newton. To allow
oslo_messaging to remove it, switch to setting transport_url instead.

Change-Id: Ib8839df1ae7e69bd751834903adcb96395154bf6
Partial-Bug: #1712399
2018-09-10 16:28:12 -06:00
Boden R a37d43018b rehome rpc and related plumbing
As shown in the history of this patch, along with the work in [1], we've
discussed rehoming neutron.common.rpc into lib a number of times before.
One of the main reasons we've decided not to rehome in the past is that
we'd hoped the neutron.common.rcp.BackingOffClient and related plumbing
could be put into oslo.messaging. However, it's 2 years later and that
still hasn't happened [2][3].

This patch proposes we just move forward with the rehome so that we can
begin to untangle the consumers [4]. There's no reason we can't
reiterate on this code in lib; it's no more difficult than in neutron.

This patch includes rehoming of:
- neutron.common.rpc, the only difference in the lib version is that
we dynamically add all neutron_lib.exceptions by default (_DFT_EXMODS).
- neutron.common.exceptions, but exceptions are broken out into their
respective exception modules rather than lumping all together in a
generic single module.
- The fake notifier and RPC fixture, without any real changes.
- A new runtime util method to dynamically load all modules for a

For a sample neutron consumption patch see [5] that was tested with
PS10 herein.


Change-Id: I0052ba65973a993e088943056879bc6e982bd0b5
2018-07-12 13:13:21 -06:00
Boden R 108a598252 rehome model_query and its dependencies
This patch rehomes neutron.db._model_query into neutron-lib. While
our longer term goal is to use OVO rather than queries and tables, this
module is provided as a stepping stone (as mentioned in release note
herein). The patch also includes a few other APIs that are required for
the rehome including some utils and an exception class.

For more details see the spec on [1].

Also a sample consumption patch can be found on [2]. While it won't work
as-is with the depends on approach (it needs to be rebased on multiple
other DNMs in neutron) I tested it locally. In addition this change
was tested locally with a sample vmware-nsx consumption patch [3].


Change-Id: I3e4b38aa3b6460ce916091c020adedd4ed2c4d26
2018-04-20 06:18:11 -06:00
Boden R edab0eb770 rehome db api
This patch rehomes neutron.db.api into neutron-lib. In addition to the
public API's, some internal plumbing such as _add_to_rel_load_list and
_load_one_to_manys are also needed in order to bootstrap the database
environment for SQLA.

For a sample consumption patch see:

Change-Id: I753a58cd04a6b881415fbc1bf3e876da72f3da3e
2018-04-16 09:57:10 -06:00
Rodolfo Alonso Hernandez 9ef0860033 Rehome placement client to neutron-lib
The placement client is going to be used by other services aside from
segments; e.g. QoS plugin. It makes sense to move this file to a common
place, like neutron-lib.

Closes-Bug: #1723452
Partial-Bug: #1578989

Change-Id: I2f7d204828a620152ec9e005e057fc7fd77f9126
2018-01-03 10:12:08 +00:00
Gary Kotton fafb101538 Use flake8-import-order plugin
This enables the process to be automated and not rely on
review inputs.

Change-Id: Ie829b9c53dd1b251785802ecbf364e97b1437ff5
2017-07-05 00:53:13 -07:00
Boden R 1a98539797 APIDefinitionFixture bugfix
Currently APIDefinitionFixture backs up the contents of its target dict
(attributes.RESOURCES and/or an API def's RESOURCE_ATTRIBUTE_MAP) and
on restore replaces the respective target with its backup copy. While
this works in a number of cases, it doesn't take into account "longer"
references to the respective dict. In some cases consumers hold a
reference to an attribute dict longer than the duration of the fixture
in which case their reference is not cleaned up on restore.

This patch address this bug and includes UTs. No release note is
included as this is only an internal behavior change.

Change-Id: Id61ba4e4649d3a73c9397632755f1cd0c38d7ab3
2017-05-24 04:45:39 -06:00
Jenkins 449f079b33 Merge "Patch _get_callback_manager for callback fixture" 2017-04-28 17:55:23 +00:00
Boden R e4016525ad Rehome neutron.api.v2.attributes
This patch rehomes a bulk of neutron.api.v2.attributes into lib
with the following notable aspects:
- A new AttributeInfo class is available and wraps a resource's
attribute dict to provide operations with the attributes. The
class can be used as a operational wrapper on a dict of attrs, or
it an be used as a transport of attrs based on the consumer's need.
- A global singleton attribute map RESOURCES is available and
is initially populated with core resources.
- Some unit tests are beefed a little and make them more modular.
- Some huge comments into the devref.
- The fixture for API defs is updated to support backing up the
global RESOURCES dict.

Change-Id: Ic455e1af2796e58025381160dc5c3b83217413fa
2017-04-25 11:27:49 -06:00
Boden R 714b810a06 Patch _get_callback_manager for callback fixture
The existing version of the callback fixture patches the global var
_CALLBACK_MANAGER, which, is returned from the callback registry
via _get_callback_manager() using a singleton checking pattern.
While this is fine in a number of cases, the implementation of
_get_callback_manager() will enclose a reference to the
_CALLBACK_MANAGER under certain testing conditions causing the fixture
to not work properly.

This patch proposes that we just mock the _get_callback_manager() return
value, which works in all cases.

No release note included because this only changes internal semantics.

Change-Id: I9966c90e3f90552b41ed84a68b19f3e540426432
2017-04-25 08:26:28 -06:00
Boden R 60bf1fb6e4 API extension updates and fixture
Today, extension loading consists of using the global attr map
[1] as a registry of the API resources known to neutron. Extension
modules are loaded using imp.load_source() [2] and once resolved
are allowed to extend other resource attrs (core or other extension
resources/attrs) in the map [3]. This is nothing new, for those
extensions which do extend others, they are supposed to update
the extensions attr map; our docs say it's so [4].

Using imp.load_source() [2] to load a module, causes it to reinitialize.
This includes recreating a copy of the RESOURCE_ATTRIBUTE_MAP
for neutron.extensions.**. The result is that the extension module object
loaded does not ref the same RESOURCE_ATTRIBUTE_MAP as the
actual neutron.extensions.mymodule anymore; it's a deep copy as part
of load_source(). This is how things have been for some time it appears.

However now we are trying to use API defs from neutron-lib that
contain the actual RESOURCE_ATTRIBUTE_MAP; imp.load_source()
no longer makes a copy and thus whats used is the single global
RESOURCE_ATTRIBUTE_MAP from it's lib definition. While this is
fine during service runtime, some tests expect the attribute maps
to have only specific values; these values can get muddied during tests
since now the single lib map gets updated [5].

This patch adds a fixture to save/restore neutron-lib api definition
maps and can be used to modify the attribute map in testing isolation.
It also includes update_attributes_map() in the API definition class
to further solidify the implementation before we start using it in

For sample usage see [6].

[6] If2e66e06b83e15ee2851ea2bc3b64ad366e675dd

Change-Id: Iff1ea5ac381f7823a3745d3956ee6179fcd07b1e
2017-03-17 12:10:24 -06:00
Armando Migliaccio dff79c608f Stop creating a context manager during db._api module import
This patch exposes accessors methods for the context manager,
pulls latest changes according to bp/enginefacade-switch, and
publishes a Sql fixture.

Original-commit: I28b741bfa27bf04cbe273586e6e3e00e14fbe683
Co-authored-by: Ann Taraday <>
Change-Id: I6e923e9b228ba20a8b782e787504239da713c652
2017-02-02 17:40:18 -08:00
Boden R fea8bb64ba Expose/Improve callback notification interface
This patch builds a small hierarchy of event objects that
represent the payload for callback notification events. The
overall goal of this work is to begin moving away from the
existing unstructured  **kwargs passed today and standardize
on a common set of event payload objects; the beginning of such
contained herein.

A PoC/dummy patch for neutron is provided in [1] that exemplifies
consumption of the new API by:
- Removes neutron.callbacks and moves all uses to
- Neutron uses of callbacks for BEFORE_RESPONSE events
now use neutron-lib.
- Neutron uses of callbacks for ROUTER and PROCESS
resource events now use neutron-lib.
- Neutron UTs updated to pass with this patch.

For existing discussion on this approach please see [2][3].

Co-Authored-By: Armando Migliaccio <>


Change-Id: If76457b1f0d5d3479e394d0dba3b22a90928f0f2
2017-01-11 13:47:12 -07:00
Armando Migliaccio 1c92b539ff Add fixture for plugin directory
This is needed to stop stubbing out _get_plugin_directory
from neutron unit tests, thus preserving testing isolation.

Change-Id: Ic94b264068955c67d71b86fe54825b9fba4533ac
2017-01-09 15:48:53 -08:00