|
19 | 19 |
|
20 | 20 | import netaddr
|
21 | 21 | from neutron_lib import constants
|
| 22 | +from neutron_lib.utils import net as net_utils |
22 | 23 | from oslo_utils import netutils
|
23 | 24 | from oslo_utils import uuidutils
|
24 | 25 | from ovsdbapp.backend.ovs_idl import connection
|
@@ -779,6 +780,45 @@ def test_ha_chassis_group_with_hc_add_two_hcg(self):
|
779 | 780 | self._check_hcg(hcg1, hcg_name1, chassis_priority1)
|
780 | 781 | self._check_hcg(hcg2, hcg_name2, chassis_priority2)
|
781 | 782 |
|
| 783 | + def _add_lrp_with_gw(self, chassis_priority=None, is_gw=True): |
| 784 | + if is_gw: |
| 785 | + hcg_name = uuidutils.generate_uuid() |
| 786 | + hcg = self.nbapi.ha_chassis_group_with_hc_add( |
| 787 | + hcg_name, chassis_priority).execute(check_error=True) |
| 788 | + kwargs = {'ha_chassis_group': hcg.uuid} |
| 789 | + else: |
| 790 | + hcg = None |
| 791 | + kwargs = {} |
| 792 | + |
| 793 | + mac = next(net_utils.random_mac_generator(['ca', 'fe', 'ca', 'fe'])) |
| 794 | + networks = ['192.0.2.0/24'] |
| 795 | + lr = self.nbapi.lr_add(uuidutils.generate_uuid()).execute( |
| 796 | + check_error=True) |
| 797 | + |
| 798 | + lrp = self.nbapi.lrp_add( |
| 799 | + lr.uuid, uuidutils.generate_uuid(), mac, networks, |
| 800 | + **kwargs).execute(check_error=True) |
| 801 | + return lr, lrp, hcg |
| 802 | + |
| 803 | + def test__get_logical_router_port_ha_chassis_group(self): |
| 804 | + chassis_priority = {'ch1': 1, 'ch2': 2, 'ch3': 3, 'ch4': 4} |
| 805 | + lr, lrp, hcg = self._add_lrp_with_gw(chassis_priority) |
| 806 | + cprio_res = self.nbapi._get_logical_router_port_ha_chassis_group(lrp) |
| 807 | + self.assertEqual([('ch4', 4), ('ch3', 3), ('ch2', 2), ('ch1', 1)], |
| 808 | + cprio_res) |
| 809 | + |
| 810 | + def test__get_logical_router_port_ha_chassis_group_with_priorities(self): |
| 811 | + chassis_priority = {'ch1': 1, 'ch2': 2, 'ch3': 3, 'ch4': 4} |
| 812 | + lr, lrp, hcg = self._add_lrp_with_gw(chassis_priority) |
| 813 | + cprio_res = self.nbapi._get_logical_router_port_ha_chassis_group( |
| 814 | + lrp, priorities=(1, 3, 4)) |
| 815 | + self.assertEqual([('ch4', 4), ('ch3', 3), ('ch1', 1)], cprio_res) |
| 816 | + |
| 817 | + def test__get_logical_router_port_ha_chassis_group_no_hcg(self): |
| 818 | + lr, lrp, hcg = self._add_lrp_with_gw(is_gw=False) |
| 819 | + cprio_res = self.nbapi._get_logical_router_port_ha_chassis_group(lrp) |
| 820 | + self.assertEqual([], cprio_res) |
| 821 | + |
782 | 822 |
|
783 | 823 | class TestIgnoreConnectionTimeout(BaseOvnIdlTest):
|
784 | 824 | @classmethod
|
|
0 commit comments