Commit Graph

14 Commits (6c9a282bcd36d744d1ad753afd8e7a219b1189c4)

Author SHA1 Message Date
Terry Wilson 1eec265ad0 Update to support the ovdsbapp 0.4.0 API
idl_factory was removed in favor of just passing in an Idl instance
as an Idl doesn't start a connection until its .run() is called.

The try/excepts will be removed when the ovsdbapp 0.4.0 constraint
changes are merged.

Change-Id: Id22faa1f6179c2fdf8a136972d65f10749c9fc2e
2017-05-17 19:58:34 +00:00
Terry Wilson e6333593ae Use the ovsdbapp library
This patch uses the ovsdbapp Python library, which is the new
project based on the Neutron OVSDB API.

The CLI implementation of the OVSDB API remains in the Neutron

Neutron continues providing the (deprecated) ability to allow
the OVSDB API to be imported from Neutron.

The deleted tests exist in the ovsdbapp project. More will be
moved later, but many of the tests in the Neutron tree use
ovs_lib, which doesn't exist in ovsdbapp so those tests will
probably stay in the Neutron tree.

Closes-Bug: #1684277
Depends-On: I3d3535b1d6fe37c78a9399903b65bbd688b1c4b9
Change-Id: Ic8c7db0e80d0ad104242322d3f1f70cab8caab92
2017-04-20 20:13:48 -05:00
XieYingYun 61682538d2 Remove unnecessary setUp function in testcase
In testcase, setUp will be called automatically. This patch used to
remove setUp functions that do nothing. Besides, it will keep code clean.

Change-Id: Ib9586a4c8fef171f0e83508d588b45097fa1c687
2017-03-30 11:20:39 +08:00
Terry Wilson 2013058e13 Refactor OVSDB native lib to be more customizable
This change, in a backward-compatible way, allows users of the
native OVSDB library to pass in their own Idl factory function
where they can return any subclass of the Idl, any schema, and
and register whatever tables/columns they want. This way, we
do not have to keep up with changes to the upstream OVSDB Idl

The Connection connection, schema_name, and idl_class arguments
are deprecated in favor of the idl_factory function.

Change-Id: I8133da63caa8937c4fce68eb2fbb73d36b894043
2016-11-08 05:58:36 +02:00
Boden R e8bd6424e9 Replace retrying with tenacity
We are replacing all usages of the 'retrying' package with
'tenacity' as the author of retrying is not actively maintaining
the project. Tenacity is a fork of retrying, but has improved the
interface and extensibility (see [1] for more details). Our end
goal here is removing the retrying package from our requirements.

Tenacity provides the same functionality as retrying, but has the
following major differences to account for:
- Tenacity uses seconds rather than ms as retrying did.
- Tenacity has different kwargs for the decorator and
Retrying class itself.
- Tenacity has a different approach for retrying args by
using classes for its stop/wait/retry kwargs.
- By default tenacity raises a RetryError if a retried callable
times out; retrying raises the last exception from the callable.
Tenacity provides backwards compatibility here by offering
the 'reraise' kwarg.
- Tenacity defines 'time.sleep' as a default value for a kwarg.
That said consumers who need to mock patch time.sleep
need to account for this via mocking of time.sleep before
tenacity is imported.
- For retries that check a result, tenacity will raise if the retried
function raises, whereas retrying retried on all exceptions.

This patch updates all usages of retrying with tenacity.
Unit tests will be included where applicable.

Note: This change is not newton critical so projects are welcome
to hold off on committing until post-newton. Ideally this change
will merge by the first part of Ocata so dependant functionality
can land and have time to solidify for Ocata.


Closes-Bug: #1635395

Change-Id: I1c0620894d07d58efbba5226b5244fec950354ca
2016-10-20 13:43:40 -06:00
Omer Anson 4264083599 Generate OVSDB schema helper in a separate method
Move the generation of the schema helper in OVSDB connection to a
different method

In the OVSDB connection class, move the code retrieving the schema
helper to a separate method. This will allow subclasses to override this
method, and retrieve the schema helper in a different manner, or provide
it to the Connection subclass in advance.

This use-case came up in Dragonflow, where we wanted to retrieve
specific columns within specific tables, and not the whole tables.

Change-Id: I634841a2402e5d9bcbf1983a17eee2bb1a6299fb
Related-Bug: 1612403
2016-10-17 20:40:22 +03:00
Jenkins 8bf83baa2a Merge "Allow to override Idl class in OVSDB Connection" 2016-10-13 19:00:29 +00:00
Omer Anson 070ee35b9c Allow to override Idl class in OVSDB Connection
Add an option to neutron.agent.ovsdb.native.connection.Connection to
override the Idl class that is created to communicate with OVSDB.

This is a feature that would help in Dragonflow[1], where the notify
method should be overriden before start() is called, in order to receive
all events in real-time, and not retroactively.

[1] d17ae9705a/dragonflow/ovsdb/ (L135)

Change-Id: I49da05f02a00352b1b1db863d244e97f9c148804
Closes-Bug: 1627615
2016-10-13 13:51:57 +03:00
Terry Wilson 5c09536386 Enable OVSDB Connection unit tests for py3
The OVS Python library is available for Python 3 and these tests
now run fine under Python 3, so go ahead and run them.

Change-Id: I579e2d3d3e016befafc61332bcc9147aaa385fe0
2016-10-03 04:35:28 -05:00
Oleg Bondarev a5d19b41a5 Mock threading.Thread to prevent daemon creation by unit tests
calls Connection.start() which starts a daemon with a while True loop
full of mocks. mock._CallList of those mocks start to grow very
quick and finally eat all available memory.

Closes-Bug: #1595878
Change-Id: Ie053a2248925ce5bb960207c16c23b261d1d458c
2016-06-29 09:04:01 +00:00
Jakub Libosvar 9cc3d60d56 ovsdb: Don't skip ovsdb test cases in py34 suite
Post-2.5 ovs Python library now supports Python 3 [1] and we require
2.6dev version for py34 job, so we're fine to run ovsdb tests with
Python 3.

[1] 99c8be3ee4

Change-Id: Id87223eea45d1343a05d8fdcde08f26fe5486a30
2016-05-27 10:56:27 +00:00
Inessa Vasilevskaya dc7e2b10e8 unit: fix ValueError on TransactionQueue init with py34
With native ovsdb_interface several py34 tests fail
with ValueError during ovs_lib.OVSBridge creation
because of unbuffered text I/O in TransactionQueue
This patch fixes the issue by switching to binary mode
in os.fdopen

Change-Id: I4158cc24f6b28a290a4a4d4bec6c2383c6bf12aa
Closes-Bug: #1580270
2016-05-21 03:11:21 +03:00
Jakub Libosvar 99f2224e6b Mock out poller in ovsdb unittests
The second thread running in ovsdb connection crashed due to not passing
file descriptor to poller. This patch mocks out the poller as it's not
used in the tests to avoid false tracebacks in the logs.

Change-Id: I62e87e3248d176e5db7fe57bfb4467176ba05392
Closes-Bug: 1583069
2016-05-18 09:36:13 +00:00
lzklibj 667ea2ac7c Allow OVSDB Connection to register certain tables
Current OVSDB Connection will register all tables with schema_helper.
It doesn't matter for most cases, but for implementation for bp
routed-networks in networking-ovn, we don't need all tables in OVN_
Southbound DB are registered. We only need a certain table named
Chassis can be registered.

This patch add a parameter for OVSDB Connection to allow it to
register certain tables, instead of all tables.

Change-Id: I79df60a08a7a6c555b07a9b566d7c09b97e2463c
Closes-Bug: #1568718
2016-04-22 08:43:28 +00:00