Пример #1
0
    def _sync_route_members_impl(self, m_get_drv_lbaas, m_get_drv_project,
                                 m_get_drv_subnets, subnet_id, project_id,
                                 endpoints, state, spec):
        m_drv_lbaas = mock.Mock(wraps=t_lbaas.FakeLBaaSDriver())
        m_drv_project = mock.Mock()
        m_drv_project.get_project.return_value = project_id
        m_drv_subnets = mock.Mock()
        m_drv_subnets.get_subnets.return_value = {
            subnet_id: mock.sentinel.subnet
        }
        m_get_drv_lbaas.return_value = m_drv_lbaas
        m_get_drv_project.return_value = m_drv_project
        m_get_drv_subnets.return_value = m_drv_subnets

        handler = h_ing_lbaas.IngressLoadBalancerHandler()

        handler._l7_router = t_lbaas.FakeLBaaSDriver().ensure_loadbalancer(
            name='L7_Router',
            project_id=project_id,
            subnet_id=subnet_id,
            ip='1.2.3.4',
            security_groups_ids=None,
            service_type='ClusterIP')

        with mock.patch.object(handler, '_get_pod_subnet') as m_get_pod_subnet:
            m_get_pod_subnet.return_value = subnet_id
            handler._sync_lbaas_route_members(endpoints, state, spec)

        observed_targets = sorted((str(member.ip), (member.port, member.port))
                                  for member in state.members)
        return observed_targets
Пример #2
0
    def test_init(self, m_get_drv_lbaas):
        m_get_drv_lbaas.return_value = mock.sentinel.drv_lbaas

        handler = h_ing_lbaas.IngressLoadBalancerHandler()

        self.assertEqual(mock.sentinel.drv_lbaas, handler._drv_lbaas)