Commit Graph

116 Commits

Author SHA1 Message Date
Slawek Kaplonski b19b55909d Don't set and remove immediately DEAD VLAN tag in tests
In fullstack and functional tests where OVSPortFixture is used to create
port in OVS bridge, just after port was created by ovs interface driver,
DEAD_VLAN tag was removed from the port as it's not needed in tests.
But this could cause race condition and instead of removing DEAD_VLAN
tag, actually correct tag configured by e.g. neutron_openvswitch_agent
was removed and traffic to such port wasn't working at all.

To avoid that race, now method which adds setting DEAD_VLAN tag to the
port_replace transaction is now mocked so there will be no DEAD VLAN tag
set on such port at all.

This patch also removes unstable test decorator from the
TestDhcpAgentHA.test_multiple_agents_for_network fullstack test as it
seems for me that this was the reason why this test was failing pretty
often.

Closes-Bug: #2000150
Change-Id: I3938c94bbd531fac461e80e791c128821a4f837f
2023-04-28 09:58:54 +00:00
Rodolfo Alonso Hernandez f235ce8791 Add new debugging logs for ``ARPSpoofTestCase``
In case of error, the class ``ARPSpoofTestCase`` now provides the IPv6
and IPv4 neigh list of the source and destination ports.

This patch also adds a retry branch on the ``assert_ping`` method. If
enabled, if the first ping command fails, the method will try to execute
it again.

Related-Bug: #2003196
Change-Id: I4d1a6c799004339489fe35b44b7682f8f744560b
2023-01-19 17:32:36 +01:00
Slawek Kaplonski 370d8bcea3 [Fullstack] Wait 10 seconds to ensure that MAC address is configured
In Linuxbridge and OVS PortFixture, when port is created, in the fake
vm's namespace it needs to have correct mac address configured.
It seems that for some reason it's not properly configured sometimes and
that may cause failure of e.g. DHCP tests.
So this patch adds retries for 10 seconds to ensure that MAC address is
configured to the one which should be.

Closes-bug: #2000150
Change-Id: I8c6d226e626812c3ccf0a2681be68a5b080b3463
2022-12-21 17:59:14 +01:00
Miguel Lavalle 33de608f04 Avoid race condition when deleting trunk bridges
Prior to this change, trunk bridges are created by os-vif but deleted
by Neutron when the last vif is removed from it. This creates race
conditions in some use cases, like DPDK with vhostuserclient mode, when
VMs are rebooted. To avoid these races, Neutron will not delete trunk
bridges anymore. Their creation and deletion will be os-vif's
responsiblity. Since [1], Nova uses the os-vif version that contains
this functionality.

This patch also changes the trunk status change event. During a live
migration, when the trunk parent port has been bound to the destination
host (that means there is only one port binding associated) and the
status has changed to ACTIVE, the method triggers the subport binding
to the new host too. This is because there could be a race condition
between the subport binding, triggered by the OVS agent, and the parent
port binding, triggered by Nova. If when the OVS agent tries to bind the
subports, the parent port is still bound to the source host, the subport
binding remains in the source host too, instead of changing to the
destination.

This patch also reverts [2] and [3]. As commented in the previous
paragraph, this patch fixes the issue reported in LP#1997025. The trunk
port live migration with ML2/OVS must be fixed with this patch.

[1]https://review.opendev.org/c/openstack/nova/+/865031
[2]https://review.opendev.org/c/openstack/neutron/+/865295
[3]https://review.opendev.org/c/openstack/neutron/+/865424

Closes-Bug: #1869244
Closes-Bug: #1997025

Change-Id: I4e16357f3ff214fcf41e418982806c24088a2665
2022-11-17 10:39:30 +01:00
Rajesh Tailor 732c1dcbc2 Fix typos in error/log messages
This change fixes some typos in ERROR and LOG messages.

Change-Id: I4ec5b10cdd38bb8734b70d459b2afe99275cd8bd
2022-06-29 15:59:22 +05:30
Oleg Bondarev 0ddca28454 Make sure "dead vlan" ports cannot transmit packets
https://review.opendev.org/c/openstack/neutron/+/820897 added
a dead vlan flow that pushes the dead vlan tag onto frames
belonging to dead ports before these ports are reassigned to
their proper vlans. However add_flow and delete_flows race and
delete_flows may run before add_flow, in this case deleting 0 flows
but not giving us a chance to detect this: neither does it throw
an error nor does it return the number of deleted flows.
This leads to port staying inaccessible forever and hence
breaks corresponding DHCP or router.

Current patch suggests another approach to make sure no packets are
leaked from newly plugged ports: setting their "vlan_mode" attribute
to "trunk" and "trunks"=[4095] (along with assigning dead VLAN tag).
With this OVS normal pipeline will allow only packets tagged with 4095
from such ports [1], which normally not happens, but even if it does -
default rule in br-int will drop them anyway.
Thus untagged packets from such ports will also be dropped until
ovs agent sets proper VLAN tag and clears vlan_mode to default
("access").

This approach avoids the race between dhcp/l3 and ovs agents because
dhcp/l3 agents no longer modify flow table.

This partially reverts commit 7aae31c9f9

[1] https://docs.openvswitch.org/en/latest/ref/ovs-actions.7/?highlight=ovs-actions#the-ovs-normal-pipeline

Closes-Bug: #1930414
Closes-Bug: #1959564
Change-Id: I0391dd24224f8656a09ddb002e7dae8783ba37a4
2022-02-04 16:43:03 +03:00
Slawek Kaplonski 729290357b [tests] Don't fail if kill cmd says that process don't exists
In e.g. functional tests, if kill command called by
RootHelperProcess.kill() method will return error that process
with specified PID don't exists, test should not fails.

This patch adds handling of such case in this method and reraise
exception always if error code is different than 1 or
raised exception have got different error message.

Change-Id: I92c8f74f1dd2e76141e1e024a22589e9ddc4ff57
Closes-Bug: #1843418
2022-01-19 07:37:50 +00:00
Rodolfo Alonso Hernandez 8127221479 Check a namespace existence by checking only its own directory
To check the existance of a namespace, instead of listing the
namespaces directory (by default "/var/run/netns"), this patch
directly checks the existence of the namespace directory, using
"os.path.exists".

This check is faster than listing the whole directory and avoids
timeout problems as reported in the related bug.

Closes-Bug: #1947974
Change-Id: I558d50d28378beb3710d98a2113ff9549c82ae17
2021-10-25 09:59:32 +00:00
Rodolfo Alonso 19eb12bd29 Revert "Implement "kill" method using os.kill()"
This reverts commit 4b21111eb1.

Reason for revert: This method is unstable and prone to timeouts

Change-Id: I6064d60e4d63b085046aace7683d766a79dd22da
2021-03-25 22:05:58 +00:00
Rodolfo Alonso Hernandez 4b21111eb1 Implement "kill" method using os.kill()
Implement the "kill" method (send a signal to a process) using the
Python native library "os".

In functional tests, "RootHelperProcess.kill" method should not fail if
the process does not exist.

Closes-Bug: #1843446
Closes-Bug: #1843418

Change-Id: Iee97a83779dd3e20eb3a223fb8557a94b8f15dc0
2021-03-22 08:58:20 +00:00
Rodolfo Alonso Hernandez ee00bddce7 Remove rootwrap execution (6)
Replace rootwrap execution with privsep context execution.
This series of patches will progressively replace any
rootwrap call.

This patch migrates the "kill_process" method to privsep and
removes the unneeded rootwrap filters.

Change-Id: I48461be8b08cbc21c8af371f551b944343ba37bf
Story: #2007686
Task: #41558
2021-03-05 10:03:22 +00:00
Rodolfo Alonso Hernandez 5a419cbc84 Remove rootwrap execution (5)
Replace rootwrap execution with privsep context execution.
This series of patches will progressively replace any
rootwrap call.

This patch migrates some missing execution methods present in
the code and removes unneeded rootwrap filters.

Story: #2007686
Task: #41558

Change-Id: I1542dc4cf98658fc9a40018192498c7a5cd1c3fe
2021-02-19 08:47:17 +00:00
Rodolfo Alonso Hernandez 7928b0d755 Remove rootwrap execution (2)
Replace rootwrap execution with privsep context execution.
This series of patches will progressively replace any
rootwrap call.

Change-Id: Id3db4fbba44dd5644563481b6767ad0acbdcfb3e
Story: #2007686
Task: #41558
2021-02-06 16:23:03 +00:00
Rodolfo Alonso Hernandez c89c1f53db Remove rootwrap execution (1)
Replace rootwrap execution with privsep context execution.
This series of patches will progressively replace any
rootwrap call.

This patch replaces some "IpNetnsCommand" command execution
methods.

Change-Id: Ic5fdf221a2a2cd0951539b0e040d2a941feee287
Story: #2007686
Task: #41558
2021-02-06 16:22:43 +00:00
Rodolfo Alonso Hernandez 996aa45e13 Capture timeout exception when deleting NamespaceFixture
Until the related bug is fixed, if the namespace created in a
NamespaceFixture cannot be deleted due to a timeout exception,
the exception will be dismissed and a warning message logged.

The leftover namespace will not affect other test cases.

Change-Id: Idb262024ca74aaa924525150e610642f493c5dc4
Related-Bug: #1838793
2020-10-06 13:39:41 +00:00
Rodolfo Alonso Hernandez 24b379ad4d Implement "BridgeDevice" with Pyroute2
Change-Id: I9e64a4d4b931a132d25434eaeb9dcec6ebf0e6f8
Story: #2007686
Task: #39975
2020-07-06 11:01:21 +00:00
Brian Haley 08a60f7483 Remove usage of six.add_metaclass
With python 3.x, classes can use the metaclass= logic
to not require usage of the six library.

One step in removing all of six usage from neutron.

Change-Id: I2f815e412d9a96eb5faf2b3bb3a1e393a9db9309
2020-05-21 14:41:18 -04:00
Slawek Kaplonski c92950b0ee [Fullstack] Handle properly BrokenPipeError exception
NetcatTester class should handle BrokenPipeError exception
and not raise it to fail test immediately if nc process wasn't
yet started when it tries first time to read/write something to
it.

Change-Id: Ica953cc2038b24c4b3985447b393763912aa6abd
Closes-Bug: #1871908
2020-04-14 11:35:44 +00:00
Rodolfo Alonso Hernandez cc3b9df426 "ping"/"ping6" command support in rootwrap filters
To have correct support in rootwrap, "ping"/"ping6" command should
have the correct filters in rootwrap.

Because "ping" command is harmless, "CommandFilter" is used to allow
any binary call, regardless of the parameters used and the order.

Nevertheless, this patch also proposes to use "ping"/"ping6" with
the same parameters and a specific order, to help in the debug
process:
- ping[6] -W <timeout> <address>
- ping[6] -W <timeout> -c <count> <address>
- ping[6] -W <timeout> -c <count> -i <interval> <address>

Those commands could be called from inside a namespace. The needed
filter is also added in this patch.

Change-Id: Ie5cbc0dcc76672b26cd2605f08cfd17a30b4c905
Closes-Bug: #1863006
2020-02-13 11:58:01 +00:00
Rodolfo Alonso Hernandez 97773eaea6 Increase log information when a RootHelperProcess fails
If a RootHelperProcess does not start, add more information to the
exception raised: the command return code, the stdout and the stderr.

Change-Id: I229e926341c5e6c8b06f59950e3ae09864d0f1f6
Closes-Bug: #1861221
2020-01-30 16:58:12 +00:00
Rodolfo Alonso Hernandez 728d8ee4b1 NetcatTester.stop_processes skip "No such process" exception
If any of the processes, client or server, spawned by NetcatTester is
not present during the stop command (kill signal sent), by default the
method will not raise an exception.

Change-Id: If8cf47a01dc353734ad07ca6cd4db7bec6c90fb6
Closes-Bug: #1852869
2019-11-20 17:47:17 +00:00
Rodolfo Alonso Hernandez be7bb4d0f5 Kill all processes running in a namespace before deletion
In "NamespaceFixture", before deleting the namespace, this patch
introduces a check to first kill all processes running on it.

Closes-Bug: #1838793

Change-Id: I27f3db33f2e7ab685523fd2d6922177d7c9cb71b
2019-08-21 09:03:54 +00:00
LIU Yulong c0132acb52 Explicitly set neutron service ports for fullstack
Fullstack neutron-server seems do not accept any connection
during the running period sometimes. This patch explicitly
set listening port range for neutron-server API and ovs agent
openflow.
And make sure other client side connection port does not seize
the server side listening.

Change-Id: If2a7977a3ac795db0bc7f726c0b26c5de638ea47
2019-03-18 16:32:21 +08:00
Nate Johnston 6098fc7430 Incorporate capability for multiple mac generation
The bulk port creation scenario requires the ability to generate
multiple MAC addresses for the bulk added ports.  This change leverages
the code added in [1] to make bulk MAC creation available.

[1] https://review.openstack.org/510830

Implements: blueprint speed-up-neutron-bulk-creation
Depends-On: https://review.openstack.org/613149
Change-Id: Ia769dadf69781ba511a19c52998949b668963a19
2018-11-08 09:43:33 -05:00
Brian Haley 2b57f08576 Fix flake8 H404 errors
Fix H404 error and start enforcing it.

Trivialfix

Change-Id: Iaa6fb4f1f07dee32a944259ab65204360d9db7ea
2018-10-05 21:48:41 +00:00
Hongbin Lu 46913a69fd Use constant IP_VERSION_4/6 in functional tests
Change-Id: I62b5a37508838a42b03a39de02660b8cafc08c41
2018-08-27 21:45:56 +00:00
Miguel Angel Ajo 88f5e11d8b Avoid agents adding ports as trunk by default.
Agent OVS interface code adds ports without a vlan tag,
if neutron-openvswitch-agent fails to set the tag, or takes
too long, the port will be a trunk port, receiving
traffic from the external network or any other port
sending traffic on br-int.

Also, those kinds of ports are triggering a code path
on the ovs-vswitchd revalidator thread which can eventually
hog the CPU of the host (that's a bug under investigation [1])

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1558336

Co-Authored-By: Slawek Kaplonski <skaplons@redhat.com>
Change-Id: I024bbbdf7059835b2f23c264b48478c71633a43c
Closes-Bug: 1767422
2018-05-09 14:07:27 +02:00
Brian Haley 7cfdf4aa81 Fix all pep8 E129 errors
Fixed all pep8 E129 errors and changed tox.ini to no longer
ignore them.

Change-Id: I0b06d99ce1d473b79a4cfdd173baa4f02e653847
2018-05-03 13:44:04 +09:00
Jakub Libosvar 8b2c40366b ovs-fw: Apply openflow rules immediately during update
Because update operation updates openflow rules three times:
 1) New rules with new cookie
 2) Delete old rules with old cookie
 3) Change new cookie back to old cookie

and the step 2) uses --strict parameter, it's needed to apply rules
before deleting the old rules because --strict parameter cannot be
combined with non-strict. This patch applies openflow rules after
step 1), then --strict rules in step 2 are applied right away and then
rest of delete part from 2) and all new rules from 3) are applied
together.

This patch adds optional interval parameter to Pinger class which sends
more ICMP packets per second in the firewall blink tests to increase a
chance of sending a packet while firewall is in inconsistent state.

Change-Id: I25d9c87225feda1b5ddd442dd01529424186e05b
Closes-bug: #1708731
2018-04-23 14:49:16 +00:00
Jenkins 8df4cf30de Merge "Change ip_lib network namespace code to use pyroute2" 2017-10-13 22:53:20 +00:00
Dongcan Ye 5907b1d924 Fix wrong OS ENV type
If we set environment for Neutron tests in tox.ini, we may get
type error like:
TypeError: %d format: a number is required, not str

os.environ.get method will get string, not integer. This patch
fix it.

Change-Id: Ie71302b8e33586082ae8334e6317e30d382e893a
2017-10-10 21:12:07 +08: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
Armando Migliaccio c7ad529983 make net_helpers functions work on OpenSUSE
/sbin may not be in the regular user's PATH or tools like sysctl/ss
may require root privileges to execute correctly on OpenSUSE, and this
makes net_helpers functions fail with OSError. There is no harm in
running ss or sysctl as root user for these functions and that allows
fullstack/functional tests to operate correctly on OpenSUSE.

The change requires a testcase to inherit from BaseSudoTestCase due
to the new run_as_root=True flag.

Change-Id: Ia4f2af1d44faacf5f7ab5471b4f18ecb27f06549
2017-09-20 09:59:44 -07:00
sindhu devale 51ca683797 Refactoring agent linux&ovsdb config
Refactoring neutron agent linux and ovsdb config opts
to be in neutron/conf/agent so that all the config options
reside in a centralized location. This simplifies the
process of looking up the config opts and provides an easy
way to import.

NeutronLibImpact

Change-Id: Ib1e0e63dec2985c417412d1ecc68e2a74ef87182
Partial-Bug: #1563069
2017-08-25 10:41:39 -04:00
Jakub Libosvar a41ce8d6bb tests: Log spawned processes by RootHelperProcess
This patch logs the command spawned by RootHelperProcess, it is
handy when debugging failed functional tests on upstream gate.

Change-Id: I743a223c4ff4882fdd760a20823150558d5e5f4a
2017-08-16 14:01:04 +02:00
Jakub Libosvar 6370a04710 ovsfw: Fix overlapping MAC addresses on integration bridge
The patch relies on the fact that traffic not going from instance
(and thus port not managed by firewall) is tagged. Traffic coming from
the instance is not tagged and thus net register is used for marking
such traffic. These two approaches make matching rules unique even if
two ports from different networks share its' mac addressess.

Traffic coming from trusted ports is marked with network in registry
so firewall can decide later to which network traffic belongs.

Closes-bug: #1626010

Change-Id: Ia05d75a01b0469a0eaa82ada67b16a9481c50f1c
2017-07-20 14:26:07 +00:00
Jenkins 211fb55fab Merge "net_helpers: Set process streams to text mode" 2017-06-16 04:33:10 +00:00
Jakub Libosvar 5d619e54e2 net_helpers: Set process streams to text mode
RootHelperProcess extends Popen from subprocess and sets all
stdin/stdout/stderr descriptors to PIPE. These descriptors use byte
array by default in Python 3. If universal_newlines [1] is set for Popen
object, then those descriptors work in text mode.

[1] https://docs.python.org/3.5/library/subprocess.html#popen-constructor

Change-Id: I3fa2192271aed81fb6da658b8196b365a20fa286
2017-06-15 12:32:18 +00:00
Bernard Cafarelli 681f611249
python3: use a list of IPDevice objects in tests
Fixes "TypeError: unhashable type: 'IPDevice'" in
neutron.tests.functional.agent.linux.test_ipset.IpsetManagerTestCase

IPDevice class defines an __eq__() method, which in Python 3 disables
the default __hash__() method (and cannot be used in a set). Use a list
instead as it is enough for the test

Change-Id: I09c538908e55df1b8d305265774c57df1ec42f21
2017-06-14 18:29:28 +02:00
Ihar Hrachyshka fea1b91a88 python3: return str from read_stdout
The result later may be concatenated with another str, and it will then
fail with: TypeError: can't concat bytes to str

It's safer to always return a str into test cases.

Change-Id: I7544322f31b4eda378eb8ee541786ea2574e1cf0
2017-05-25 04:29:37 +00:00
Ihar Hrachyshka d545d19522 Fixed python3 failure in functional tests using net_helpers
.write expects a byte string in python3, while we were passing a
str. It worked in py2 but failed in py3 with:

TypeError: memoryview: a bytes-like object is required, not 'str'

Change-Id: I7f993a06bafa3cad4147f46d5d6dc10efeac3480
2017-05-24 13:56:31 -07:00
Jenkins 5e3abe8040 Merge "Simplify RootHelperProcess._read_stream()" 2017-04-17 06:56:30 +00:00
Jenkins 3b119c6471 Merge "Switch RootHelperProcess from select.poll to select.select" 2017-03-21 08:13:32 +00:00
Akihiro Motoki a7898c5495 Simplify RootHelperProcess._read_stream()
select() itself has timeout mechanism, so we do not need to use
wait_until_true wrapper.

Related-Bug: #1674557
Change-Id: I35bc4716f0d1e0d92e7b7a3f6dcb6978e9d725f9
2017-03-21 07:01:32 +00:00
Ihar Hrachyshka f48dbeda5c Switch RootHelperProcess from select.poll to select.select
The new eventlet 0.20.x that the gate was recently bumped to [1] removed
select.poll [2]. Instead, we should use select.select that is both
supported by eventlet as well as available on all platforms.

[1] I534b8d7d6c2fa00c1fa7d84b3438e6e2b2fcad9e
[2] http://eventlet.net/doc/changelog.html#id2

Change-Id: Ie649abf495e00e7e05de47520ed89bbcd28360db
Closes-Bug: #1674557
2017-03-21 05:28:02 +00:00
John Perkins 7f23ccce23 Agent common config
Refactoring Neutron configuration options for agent common config to be
in neutron/conf/agent/common. This will allow centralization of all
configuration options and provide an easy way to import.

Partial-Bug: #1563069
Change-Id: Iebac0cdd3bcfd0135349128921b7ad7a1a939ab8
Needed-By: Ib676003bbe909b5a9013a3178b12dbe291d936af
2017-03-15 09:52:18 -06:00
Jenkins 1f4f0a2d6e Merge "Connectivity tests for OVS agent failures/restarts" 2017-03-15 02:45:37 +00:00
Brian Haley bd64327007 Change in-tree code to use moved get_ip_version()
Now that get_ip_version() is in common/utils.py,
change all in-tree users to use it and not
generate removal warnings.

Trivialfix

Change-Id: I623a10f3a52f80b650e5410df8b03729eb823134
2017-03-08 11:35:29 -05:00
Hynek Mlnarik 27aee4a9c5 Connectivity tests for OVS agent failures/restarts
Adding two tests:

* A test that for native ovs-ofctl interface verifies that stopping the
  ovs-neutron-agent does not disrupt network traffic. Stopping the agent
  means also stopping the OVS bridge controller, hence OVS can decide to
  take over management of OpenFlow rules, clear them up, and this way
  cause network traffic disruption.

* A test that creates two ports in a single network, then starts
  pinging one from the other while restarting OVS agents. The test verifies
  that no packet is lost during OVS agent restarts.

Change-Id: I2cd1195fc0622c8c8d614f00e9dd6884ad388d69
Related-Bug: 1514056
Related-Bug: 1607787
2017-01-24 11:19:27 -05:00
Jakub Libosvar d5c07fe512 ovsfw: Support protocol numbers instead of just tcp and udp
Neutron API accepts also protocol numbers as protocols for security
groups. This patch makes support for it in OVS firewall driver. iptables
driver already supports it.

Fullstack test covering SCTP connection was added and it requires
ip_conntrack_proto_sctp kernel module in order to make conntrack work
with SCTP.

Change-Id: I6c5665a994c4a50ddbb95cd1360be0de0a6c7e40
Closes-bug: 1625516
2017-01-20 11:17:40 -05:00