|
17 | 17 |
|
18 | 18 | from oslo_utils import uuidutils
|
19 | 19 |
|
20 |
| -from neutron.agent.common import ovs_lib |
21 | 20 | from neutron.agent.ovn.agent import ovsdb as agent_ovsdb
|
22 | 21 | from neutron.agent.ovn.extensions import qos_hwol
|
23 | 22 | from neutron.common.ovn import constants as ovn_const
|
24 | 23 | from neutron.common.ovn import utils
|
25 | 24 | from neutron.common import utils as n_utils
|
26 |
| -from neutron.tests import base as test_base |
27 |
| -from neutron.tests.common import net_helpers |
28 | 25 | from neutron.tests.functional import base
|
29 | 26 |
|
30 | 27 |
|
31 | 28 | class OVSInterfaceEventTestCase(base.TestOVNFunctionalBase):
|
32 | 29 |
|
33 |
| - @test_base.unstable_test( |
34 |
| - 'LP#2006603, it is being addressed in ' |
35 |
| - 'https://review.opendev.org/c/openstack/neutron/+/873118') |
| 30 | + def _cleanup(self): |
| 31 | + self.ovs_idl.del_port(self.port_name, bridge=self.br_name).execute( |
| 32 | + check_error=False) |
| 33 | + self.ovs_idl.del_br(self.br_name).execute(check_error=False) |
| 34 | + |
36 | 35 | def test_port_creation_and_deletion(self):
|
37 | 36 | def check_add_port_called():
|
38 | 37 | try:
|
39 | 38 | mock_agent.qos_hwol_ext.add_port.assert_has_calls(
|
40 |
| - [mock.call('port_iface-id', port_name)]) |
| 39 | + [mock.call(port_iface_id, self.port_name)]) |
41 | 40 | return True
|
42 | 41 | except AssertionError:
|
43 | 42 | return False
|
44 | 43 |
|
45 | 44 | def check_remove_egress_called():
|
46 | 45 | try:
|
47 | 46 | mock_agent.qos_hwol_ext.remove_egress.assert_has_calls(
|
48 |
| - [mock.call('port_iface-id')]) |
| 47 | + [mock.call(port_iface_id)]) |
49 | 48 | return True
|
50 | 49 | except AssertionError:
|
51 | 50 | return False
|
52 | 51 |
|
| 52 | + port_iface_id = 'port_iface-id' |
53 | 53 | mock_agent = mock.Mock()
|
54 | 54 | events = [qos_hwol.OVSInterfaceEvent(mock_agent)]
|
55 |
| - agent_ovsdb.MonitorAgentOvsIdl(events=events).start() |
56 |
| - br = self.useFixture(net_helpers.OVSBridgeFixture()).bridge |
57 |
| - self.ovs_bridge = ovs_lib.OVSBridge(br.br_name) |
58 |
| - port_name = ('port-' + uuidutils.generate_uuid())[:8] |
59 |
| - |
60 |
| - self.ovs_bridge.add_port( |
61 |
| - port_name, ('external_ids', {'iface-id': 'port_iface-id'})) |
62 |
| - n_utils.wait_until_true(check_add_port_called, timeout=5) |
63 |
| - |
64 |
| - self.ovs_bridge.delete_port(port_name) |
65 |
| - n_utils.wait_until_true(check_remove_egress_called, timeout=5) |
| 55 | + self.ovs_idl = agent_ovsdb.MonitorAgentOvsIdl(events=events).start() |
| 56 | + self.br_name = ('brtest-' + uuidutils.generate_uuid())[:13] |
| 57 | + self.port_name = ('port-' + uuidutils.generate_uuid())[:13] |
| 58 | + self.addCleanup(self._cleanup) |
| 59 | + with self.ovs_idl.transaction() as txn: |
| 60 | + txn.add(self.ovs_idl.add_br(self.br_name)) |
| 61 | + txn.add(self.ovs_idl.add_port(self.br_name, self.port_name)) |
| 62 | + txn.add(self.ovs_idl.iface_set_external_id( |
| 63 | + self.port_name, 'iface-id', port_iface_id)) |
| 64 | + txn.add(self.ovs_idl.db_set( |
| 65 | + 'Interface', self.port_name, ('type', 'internal'))) |
| 66 | + |
| 67 | + exc = Exception('Port %s was not added to the bridge %s' % |
| 68 | + (self.port_name, self.br_name)) |
| 69 | + n_utils.wait_until_true(check_add_port_called, timeout=5, |
| 70 | + exception=exc) |
| 71 | + |
| 72 | + self.ovs_idl.del_port(self.port_name).execute(check_error=True) |
| 73 | + exc = Exception('Port %s was not deleted from the bridge %s' % |
| 74 | + (self.port_name, self.br_name)) |
| 75 | + n_utils.wait_until_true(check_remove_egress_called, timeout=5, |
| 76 | + exception=exc) |
66 | 77 |
|
67 | 78 |
|
68 | 79 | class QoSBandwidthLimitEventTestCase(base.TestOVNFunctionalBase):
|
|
0 commit comments