Commit Graph

16 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez 0c1818fbb0 Migrate "netstat" to oslo.privsep
Change-Id: If9e4c1513553c4bd10fd3b91c28c4d3f806ed816
Story: #2007686
Task: #40047
2020-06-19 14:59:11 +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
Michael Johnson d1d0a04c37 Remove Neutron LBaaS
Neutron-LBaaS has now been retired and there will be no Train
release[1]. This patch removes neutron-lbaas references from
neutron.

[1] https://review.opendev.org/658494

Closes-Bug: #1833125
Change-Id: I0fe3fbaf4adf7fb104632fd94cd093e701e12289
2019-09-20 07:46:06 +00:00
Daniel Alvarez f30fc92adf netns_cleanup: Remove unused parameter from unplug_devices()
A conf object was passed in to the unplug_devices method
which was not used. This patch is removing it and adapting the
tests to the new prototype.

Also, there's apparently no callers outside neutron that could
get broken as per codesearch.openstack.org.

Change-Id: Ie19b8e4056b1f27be3cae51e74759ebfed41074e
Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
2018-10-10 11:15:59 +02:00
Brian Haley 4f627b4e8d Change ip_lib network namespace code to use pyroute2
Change network namespace add/delete/list code to use
pyroute2 library instead of calling /sbin/ip.

Also changed all in-tree callers to use the new calls.

Closes-bug: #1717582
Related-bug: #1492714

Change-Id: Id802e77543177fbb95ff15c2c7361172e8824633
2017-10-04 21:09:28 +00:00
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
Ihar Hrachyshka 1ae91ce9be ip_lib: ignore gre and lo devices in get_devices by default
This is the most common use pattern for the method, so it makes sense to
make it default.

(Actually, it may be that there are no usage for the arguments
whatsoever, but better safe than sorry.)

NeutronLibImpact this change potentially breaks callers of get_devices
that may want to get the automatic devices by default. Those imaginary
callers may need to set exclude_gre_devices and/or exclude_loopback to
True from now on.

Change-Id: Ic32b8abc7f8502b8907ae21c996e13cb8fd5401d
Related-Bug: #1604115
2017-04-13 15:03:06 -07:00
Ihar Hrachyshka 91c15edf54 Ignore gre devices in namespaces when cleaning up devices
Agents and netns_cleanup tool attempt to clean up devices from
namespaces before destroying namespaces, but they should skip doing it
for gre devices that are automatic and show up depending on kernel
modules loaded.

Change-Id: Ie95890ed92ac73ec8e2d118a9727b9e1624a5178
Related-Bug: #1604115
2017-04-13 15:02:35 -07:00
Daniel Alvarez 3f9f740d81 Fix netns_cleanup interrupted on rwd I/O
Functional tests for netns_cleanup have been failing a few times
in the gate lately. After thorough tests we've seen that the issue was
related to using rootwrap-daemon inside a wait_until_true loop. When
timeout fired while utils.execute() was reading from rootwrap-daemon,
it got interrupted and the output of the last command was not read.
Therefore, next calls to utils.execute() would read the output of
their previous command rather than their own, leading to unexpected
results.

This fix will poll existing processes in the namespace without making
use of the wait_until_true loop. Instead, it will check elapsed time
and raise the exception if timeout is exceeded.

Also, i'm removing debug traces introduced in
327f7fc4d5 which helped finding the root
cause of this bug.

Change-Id: Ie233261e4be36eecaf6ec6d0532f0f5e2e996cd2
Closes-Bug: #1654287
2017-01-12 03:52:30 +00:00
Daniel Alvarez 1d38f30555 Kill processes when cleaning up namespaces
This patch will kill processes that are listening on any port/UNIX
socket within the namespace to be cleaned up. To kill them it will
issue a SIGTERM to them (or to their parents if they were forked) and,
if they don't die after a few seconds, a SIGKILL to them and all their
children.

This is intended for those cases when there's no specific cleanup and
serves as a fallback method.

Change-Id: I4195f633ef4a1788496d1293846f19eef89416aa
Partial-Bug: #1403455
2016-12-20 10:52:41 +00:00
Victor Morales 7eff6aff42 Fix check_asserttruefalse syntax validator
According to Neutron developer documentation[1], it's better to use
assertTrue/False methods instead of generic assertEqual. The regex
created for check_asserttruefalse was skipping unit tests located on
test_netns_cleanup.py file.  This change includes those scenarios.

[1] http://docs.openstack.org/developer/neutron/devref/effective_neutron.html#mocking-and-testing

Change-Id: Id2eacf14d4b0740f3b044520074c7ab78768b319
2016-08-11 13:49:47 +00:00
Inessa Vasilevskaya bdeb7bcc2b enable OVSDB native interface by default
- unit tests were fixed mainly by mocking
  Connection class of native implementation.

- some ovs-lib tests rely on direct ovs-vsctl
  output. Temporarily decorated with @vsctl_only.

UpgradeImpact

Change-Id: I2632b0e21edd61536867a9fc830a45d9899091e4
2016-06-25 10:43:12 +03:00
Ilya Shakhat ada05d657c Make netns_cleanup to purge resources of selected agent only
A new option --agent-type is introduced into netns_cleanup. When it is set
the utility processes namespaces for selected agent only. Possible values
are 'dhcp', 'l3', 'lbaas'. When the option is not set the behaviour stays
unchanged - all namespaces are processed.

Change-Id: Idaaffce767654bf21701a5329742f10a241b2cbf
2016-02-11 12:19:26 +03:00
lzklibj 3491cbc0c5 Unify assertEqual for empty usages
Update previous assertEqual(observed, *empty) usages to
assertEqual(*empty*, observed).

This patch aslo update hacking check for assertEqual with
empty types.

Change-Id: I981277618f92254a5beb9d3308a317d8c14e125c
2016-01-07 10:06:35 +00:00
Itzik Brown 4eafec58f2 Adding a cleanup for 'qlbaas-' namespaces in netns_cleanup
Change-Id: I2f8c2c037419953d6f6a9416472f4e5fb73d53db
Closes-Bug: 1456151
2015-07-21 13:52:57 +03: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