Ejemplo n.º 1
0
 def test_amphora_cert_rotation(
         self, mock_get_update_listener_flow, mock_api_get_session,
         mock_dyn_log_listener, mock_taskflow_load, mock_pool_repo_get,
         mock_member_repo_get, mock_l7rule_repo_get, mock_l7policy_repo_get,
         mock_listener_repo_get, mock_lb_repo_get, mock_health_mon_repo_get,
         mock_amp_repo_get):
     _flow_mock.reset_mock()
     cw = controller_worker.ControllerWorker()
     cw.amphora_cert_rotation(AMP_ID)
     (base_taskflow.BaseTaskFlowEngine._taskflow_load.
      assert_called_once_with(_flow_mock,
                              store={
                                  constants.AMPHORA: _amphora_mock,
                                  constants.AMPHORA_ID: _amphora_mock.id
                              }))
     _flow_mock.run.assert_called_once_with()
Ejemplo n.º 2
0
    def test_delete_amphora(self, mock_get_delete_amp_flow,
                            mock_api_get_session, mock_dyn_log_listener,
                            mock_taskflow_load, mock_pool_repo_get,
                            mock_member_repo_get, mock_l7rule_repo_get,
                            mock_l7policy_repo_get, mock_listener_repo_get,
                            mock_lb_repo_get, mock_health_mon_repo_get,
                            mock_amp_repo_get):

        _flow_mock.reset_mock()

        cw = controller_worker.ControllerWorker()
        cw.delete_amphora(AMP_ID)

        mock_amp_repo_get.assert_called_once_with('TEST', id=AMP_ID)

        (base_taskflow.BaseTaskFlowEngine._taskflow_load.
         assert_called_once_with('TEST',
                                 store={constants.AMPHORA: _amphora_mock}))

        _flow_mock.run.assert_called_once_with()
Ejemplo n.º 3
0
    def test_create_amphora(self, mock_api_get_session,
                            mock_get_create_amp_flow, mock_dyn_log_listener,
                            mock_taskflow_load, mock_pool_repo_get,
                            mock_member_repo_get, mock_l7rule_repo_get,
                            mock_l7policy_repo_get, mock_listener_repo_get,
                            mock_lb_repo_get, mock_health_mon_repo_get,
                            mock_amp_repo_get):

        _flow_mock.reset_mock()

        cw = controller_worker.ControllerWorker()
        amp = cw.create_amphora()

        (base_taskflow.BaseTaskFlowEngine._taskflow_load.
         assert_called_once_with('TEST'))

        _flow_mock.run.assert_called_once_with()

        _flow_mock.storage.fetch.assert_called_once_with('amphora')

        assert (amp == AMP_ID)
Ejemplo n.º 4
0
    def test_create_health_monitor(
            self, mock_get_create_hm_flow, mock_api_get_session,
            mock_dyn_log_listener, mock_taskflow_load, mock_pool_repo_get,
            mock_member_repo_get, mock_l7rule_repo_get, mock_l7policy_repo_get,
            mock_listener_repo_get, mock_lb_repo_get, mock_health_mon_repo_get,
            mock_amp_repo_get):

        _flow_mock.reset_mock()

        cw = controller_worker.ControllerWorker()
        cw.create_health_monitor(_health_mon_mock)

        (base_taskflow.BaseTaskFlowEngine._taskflow_load.
         assert_called_once_with(_flow_mock,
                                 store={
                                     constants.HEALTH_MON: _health_mon_mock,
                                     constants.LISTENERS: [_listener_mock],
                                     constants.LOADBALANCER:
                                     _load_balancer_mock
                                 }))

        _flow_mock.run.assert_called_once_with()
    def test_create_load_balancer_full_graph_active_standby(
            self, mock_create_active_standby_topology,
            mock_create_single_topology, mock_get_create_load_balancer_flow,
            mock_api_get_session, mock_dyn_log_listener, mock_taskflow_load,
            mock_pool_repo_get, mock_member_repo_get, mock_l7rule_repo_get,
            mock_l7policy_repo_get, mock_listener_repo_get, mock_lb_repo_get,
            mock_health_mon_repo_get, mock_amp_repo_get):

        self.conf.config(
            group="controller_worker",
            loadbalancer_topology=constants.TOPOLOGY_ACTIVE_STANDBY)

        listeners = [
            data_models.Listener(id='listener1'),
            data_models.Listener(id='listener2')
        ]
        lb = data_models.LoadBalancer(id=LB_ID, listeners=listeners)
        mock_lb_repo_get.return_value = lb
        mock_eng = mock.Mock()
        mock_taskflow_load.return_value = mock_eng
        store = {
            constants.LOADBALANCER_ID: LB_ID,
            'update_dict': {
                'topology': constants.TOPOLOGY_ACTIVE_STANDBY
            }
        }

        cw = controller_worker.ControllerWorker()
        cw.create_load_balancer(LB_ID)

        # mock_create_single_topology.assert_not_called()
        # mock_create_active_standby_topology.assert_called_once()
        mock_get_create_load_balancer_flow.assert_called_with(
            topology=constants.TOPOLOGY_ACTIVE_STANDBY, listeners=lb.listeners)
        mock_taskflow_load.assert_called_with(
            mock_get_create_load_balancer_flow.return_value, store=store)
        mock_eng.run.assert_any_call()
Ejemplo n.º 6
0
    def test_delete_listener(self,
                             mock_get_delete_listener_flow,
                             mock_api_get_session,
                             mock_dyn_log_listener,
                             mock_taskflow_load,
                             mock_pool_repo_get,
                             mock_member_repo_get,
                             mock_listener_repo_get,
                             mock_lb_repo_get,
                             mock_health_mon_repo_get,
                             mock_amp_repo_get):

        _flow_mock.reset_mock()

        cw = controller_worker.ControllerWorker()
        cw.delete_listener(LB_ID)

        (base_taskflow.BaseTaskFlowEngine._taskflow_load.
         assert_called_once_with(
             _flow_mock, store={constants.LISTENER: _listener_mock,
                                constants.VIP: _vip_mock,
                                constants.LOADBALANCER: _load_balancer_mock}))

        _flow_mock.run.assert_called_once_with()
Ejemplo n.º 7
0
    def test_create_listener(self,
                             mock_get_create_listener_flow,
                             mock_api_get_session,
                             mock_dyn_log_listener,
                             mock_taskflow_load,
                             mock_pool_repo_get,
                             mock_member_repo_get,
                             mock_listener_repo_get,
                             mock_lb_repo_get,
                             mock_health_mon_repo_get,
                             mock_amp_repo_get):

        _flow_mock.reset_mock()

        cw = controller_worker.ControllerWorker()
        cw.create_listener(LB_ID)

        (base_taskflow.BaseTaskFlowEngine._taskflow_load.
            assert_called_once_with(_flow_mock,
                                    store={'listener': _listener_mock,
                                           'loadbalancer': _load_balancer_mock,
                                           'vip': _vip_mock}))

        _flow_mock.run.assert_called_once_with()
Ejemplo n.º 8
0
    def test_update_l7rule(self, mock_get_update_listener_flow,
                           mock_api_get_session, mock_dyn_log_listener,
                           mock_taskflow_load, mock_pool_repo_get,
                           mock_member_repo_get, mock_l7rule_repo_get,
                           mock_l7policy_repo_get, mock_listener_repo_get,
                           mock_lb_repo_get, mock_health_mon_repo_get,
                           mock_amp_repo_get):

        _flow_mock.reset_mock()

        cw = controller_worker.ControllerWorker()
        cw.update_l7rule(L7RULE_ID, L7RULE_UPDATE_DICT)

        (base_taskflow.BaseTaskFlowEngine._taskflow_load.
         assert_called_once_with(_flow_mock,
                                 store={
                                     constants.L7RULE: _l7rule_mock,
                                     constants.LISTENERS: [_listener_mock],
                                     constants.LOADBALANCER:
                                     _load_balancer_mock,
                                     constants.UPDATE_DICT: L7RULE_UPDATE_DICT
                                 }))

        _flow_mock.run.assert_called_once_with()
Ejemplo n.º 9
0
 def __init__(self):
     self.amp_repo = repo.AmphoraRepository()
     self.cw = cw.ControllerWorker()
Ejemplo n.º 10
0
 def __init__(self):
     self.threads = CONF.house_keeping.cert_rotate_threads
     self.cw = cw.ControllerWorker()
Ejemplo n.º 11
0
    def test_create_load_balancer_full_graph(
            self,
            mock_get_create_load_balancer_graph_flows,
            mock_get_create_load_balancer_flow,
            mock_get_post_lb_amp_association_flow,
            mock_api_get_session,
            mock_dyn_log_listener,
            mock_taskflow_load,
            mock_pool_repo_get,
            mock_member_repo_get,
            mock_l7rule_repo_get,
            mock_l7policy_repo_get,
            mock_listener_repo_get,
            mock_lb_repo_get,
            mock_health_mon_repo_get,
            mock_amp_repo_get):
        CONF.set_override(group='controller_worker',
                          name='loadbalancer_topology',
                          override=constants.TOPOLOGY_SINGLE,
                          enforce_type=True)
        listeners = [data_models.Listener(id='listener1'),
                     data_models.Listener(id='listener2')]
        lb = data_models.LoadBalancer(id=LB_ID, listeners=listeners)
        mock_lb_repo_get.return_value = lb
        mock_eng = mock.Mock()
        mock_eng_post = mock.Mock()
        mock_taskflow_load.side_effect = [mock_eng, mock_eng_post]
        _post_flow = mock.MagicMock()
        mock_get_create_load_balancer_graph_flows.return_value = (
            _flow_mock, _post_flow
        )
        store = {constants.LOADBALANCER_ID: LB_ID,
                 'update_dict': {'topology': 'SINGLE'}}

        cw = controller_worker.ControllerWorker()
        cw.create_load_balancer(LB_ID)

        calls = [mock.call(_flow_mock, store=store),
                 mock.call(_post_flow, store=store)]
        mock_taskflow_load.assert_has_calls(calls, any_order=True)
        mock_eng.run.assert_any_call()
        mock_eng_post.run.assert_any_call()
        mock_get_create_load_balancer_graph_flows.assert_called_once_with(
            'SINGLE', 'post-amphora-association'
        )
        self.assertFalse(mock_get_create_load_balancer_flow.called)
        self.assertFalse(mock_get_post_lb_amp_association_flow.called)

        # Test code path for active standby full lb graph creation
        CONF.set_override(group='controller_worker',
                          name='loadbalancer_topology',
                          override=constants.TOPOLOGY_ACTIVE_STANDBY)
        _flow_mock.reset_mock()
        mock_get_create_load_balancer_graph_flows.reset_mock()
        mock_taskflow_load.reset_mock()
        mock_eng = mock.Mock()
        mock_eng_post = mock.Mock()
        mock_taskflow_load.side_effect = [mock_eng, mock_eng_post]
        _post_flow = mock.MagicMock()
        mock_get_create_load_balancer_graph_flows.return_value = (
            _flow_mock, _post_flow
        )
        store = {constants.LOADBALANCER_ID: LB_ID,
                 'update_dict': {'topology': 'ACTIVE_STANDBY'}}

        cw = controller_worker.ControllerWorker()
        cw.create_load_balancer(LB_ID)

        calls = [mock.call(_flow_mock, store=store),
                 mock.call(_post_flow, store=store)]
        mock_taskflow_load.assert_has_calls(calls, any_order=True)
        mock_eng.run.assert_any_call()
        mock_eng_post.run.assert_any_call()
        mock_get_create_load_balancer_graph_flows.assert_called_once_with(
            'ACTIVE_STANDBY', 'post-amphora-association'
        )
        self.assertFalse(mock_get_create_load_balancer_flow.called)
        self.assertFalse(mock_get_post_lb_amp_association_flow.called)
Ejemplo n.º 12
0
    def test_create_load_balancer(self,
                                  mock_get_create_load_balancer_flow,
                                  mock_get_get_post_lb_amp_association_flow,
                                  mock_api_get_session,
                                  mock_dyn_log_listener,
                                  mock_taskflow_load,
                                  mock_pool_repo_get,
                                  mock_member_repo_get,
                                  mock_l7rule_repo_get,
                                  mock_l7policy_repo_get,
                                  mock_listener_repo_get,
                                  mock_lb_repo_get,
                                  mock_health_mon_repo_get,
                                  mock_amp_repo_get):

        # Test the code path with an SINGLE topology
        CONF.set_override(group='controller_worker',
                          name='loadbalancer_topology',
                          override=constants.TOPOLOGY_SINGLE,
                          enforce_type=True)
        _flow_mock.reset_mock()
        mock_taskflow_load.reset_mock()
        mock_eng = mock.Mock()
        mock_eng_post = mock.Mock()
        mock_taskflow_load.side_effect = [mock_eng, mock_eng_post]
        _post_flow = mock.MagicMock()
        mock_get_get_post_lb_amp_association_flow.return_value = _post_flow
        store = {constants.LOADBALANCER_ID: LB_ID,
                 'update_dict': {'topology': 'SINGLE'}}
        setattr(mock_lb_repo_get.return_value, 'listeners', [])

        cw = controller_worker.ControllerWorker()
        cw.create_load_balancer(LB_ID)

        calls = [mock.call(_flow_mock, store=store),
                 mock.call(_post_flow, store=store)]
        (base_taskflow.BaseTaskFlowEngine._taskflow_load.
            assert_has_calls(calls, any_order=True))
        mock_eng.run.assert_any_call()
        mock_eng_post.run.assert_any_call()

        # Test the code path with an ACTIVE_STANDBY topology
        CONF.set_override(group='controller_worker',
                          name='loadbalancer_topology',
                          override=constants.TOPOLOGY_ACTIVE_STANDBY,
                          enforce_type=True)

        _flow_mock.reset_mock()
        mock_taskflow_load.reset_mock()
        mock_eng = mock.Mock()
        mock_eng_post = mock.Mock()
        mock_taskflow_load.side_effect = [mock_eng, mock_eng_post]
        _post_flow = mock.MagicMock()
        mock_get_get_post_lb_amp_association_flow.return_value = _post_flow
        store = {constants.LOADBALANCER_ID: LB_ID,
                 'update_dict': {'topology': 'ACTIVE_STANDBY'}}

        cw = controller_worker.ControllerWorker()
        cw.create_load_balancer(LB_ID)

        calls = [mock.call(_flow_mock, store=store),
                 mock.call(_post_flow, store=store)]
        (base_taskflow.BaseTaskFlowEngine._taskflow_load.
            assert_has_calls(calls, any_order=True))
        mock_eng.run.assert_any_call()
        mock_eng_post.run.assert_any_call()
Ejemplo n.º 13
0
 def __init__(self):
     self.cw = cw.ControllerWorker()
     self.threads = CONF.health_manager.failover_threads
Ejemplo n.º 14
0
 def __init__(self, **kwargs):
     from octavia.controller.worker import controller_worker
     self.cntrlr_worker = controller_worker.ControllerWorker()
     self.listener_repo = repo.ListenerRepository()
     self.amp_repo = repo.AmphoraRepository()
     super(BaseControllerTask, self).__init__(**kwargs)
Ejemplo n.º 15
0
 def __init__(self, exit_event):
     self.cw = cw.ControllerWorker()
     self.threads = CONF.health_manager.failover_threads
     self.executor = futures.ThreadPoolExecutor(max_workers=self.threads)
     self.amp_health_repo = repo.AmphoraHealthRepository()
     self.dead = exit_event