Skip to content

Commit 534d027

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Increase port name size and type to internal" into stable/2023.1
2 parents 35b8564 + 696b2f4 commit 534d027

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

neutron/tests/functional/agent/ovn/extensions/test_qos_hwol.py

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,63 @@
1717

1818
from oslo_utils import uuidutils
1919

20-
from neutron.agent.common import ovs_lib
2120
from neutron.agent.ovn.agent import ovsdb as agent_ovsdb
2221
from neutron.agent.ovn.extensions import qos_hwol
2322
from neutron.common.ovn import constants as ovn_const
2423
from neutron.common.ovn import utils
2524
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
2825
from neutron.tests.functional import base
2926

3027

3128
class OVSInterfaceEventTestCase(base.TestOVNFunctionalBase):
3229

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+
3635
def test_port_creation_and_deletion(self):
3736
def check_add_port_called():
3837
try:
3938
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)])
4140
return True
4241
except AssertionError:
4342
return False
4443

4544
def check_remove_egress_called():
4645
try:
4746
mock_agent.qos_hwol_ext.remove_egress.assert_has_calls(
48-
[mock.call('port_iface-id')])
47+
[mock.call(port_iface_id)])
4948
return True
5049
except AssertionError:
5150
return False
5251

52+
port_iface_id = 'port_iface-id'
5353
mock_agent = mock.Mock()
5454
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)
6677

6778

6879
class QoSBandwidthLimitEventTestCase(base.TestOVNFunctionalBase):

0 commit comments

Comments
 (0)