Example #1
0
    def test_lb_method_fogroup(self):
        ### fallback ANY ###
        cfg_dict = get_lb_cfg_dict()
        cfg_dict['pools']['test-pool1']['lb_method'] = 'fogroup'
        cfg_dict['pools']['test-pool1']['fallback'] = 'any'
        self.state = state.State(cfg_dict)

        # all members down
        assert self.pool_status('test-pool1') == False
        assert self.rotation_set('test-pool1', '_default') == \
            set(['10.1.1.1', '10.1.2.1','10.1.3.1'])

        # all up
        for member in self.state.pools['test-pool1'].members:
            member.status = True
        assert self.pool_status('test-pool1') == True
        assert self.rotation_set('test-pool1', '_default') == \
            set(['10.1.1.1'])

        # first member down
        self.state.pools['test-pool1'].members[0].status = False
        assert self.pool_status('test-pool1') == True
        assert self.rotation_set('test-pool1', '_default') == \
            set(['10.1.2.1'])

        # first and second members down
        self.state.pools['test-pool1'].members[1].status = False
        assert self.pool_status('test-pool1') == True
        assert self.rotation_set('test-pool1', '_default') == \
            set(['10.1.3.1'])

        ### fallback REFUSE ###
        cfg_dict = get_lb_cfg_dict()
        cfg_dict['pools']['test-pool1']['lb_method'] = 'fogroup'
        cfg_dict['pools']['test-pool1']['fallback'] = 'refuse'
        self.state = state.State(cfg_dict)

        # all members down
        assert self.pool_status('test-pool1') == False
        assert self.rotation_set('test-pool1', '_default') == \
            set([])

        # first member up
        self.state.pools['test-pool1'].members[0].status = True
        assert self.pool_status('test-pool1') == True
        assert self.rotation_set('test-pool1', '_default') == \
            set(['10.1.1.1'])

        # first an second members up
        self.state.pools['test-pool1'].members[1].status = True
        assert self.pool_status('test-pool1') == True
        assert self.rotation_set('test-pool1', '_default') == \
            set(['10.1.1.1'])

        # all up
        self.state.pools['test-pool1'].members[2].status = True
        assert self.pool_status('test-pool1') == True
        assert self.rotation_set('test-pool1', '_default') == \
            set(['10.1.1.1'])
Example #2
0
    def __init__(self, prober_requests, prober_responses):
        """
        args:
            prober_requests: multiprocessing.Queue(), 
                queue to put new probes on
            prober_responses: multiprocessing.Queue(),
                queue to get processed probes from
        """
        super(Tracker, self).__init__()

        self.prober_requests = prober_requests
        self.prober_responses = prober_responses

        # create health state table from the lb config
        global STATE
        STATE = state.State(config_obj=config.LB)
Example #3
0
    def __init__(self, probe_request_queue, probe_response_queue):
        """
        args:
            probe_request_queue: multiprocessing.Queue(), 
                queue to put new probes on
            probe_response_queue: multiprocessing.Queue(),
                queue to get processed probes from

        """
        super(Tracker, self).__init__()

        self.probe_request_queue = probe_request_queue
        self.probe_response_queue = probe_response_queue

        # create health state table from the lb config
        self.state = state.State(config_obj=config.LB)

        # init shared memory client(memcache.Client arg must be a list)
        self._sm = memcache.Client([config.BASE['SHARED_MEM_HOSTNAME']])
Example #4
0
    def __init__(self, prober_requests, prober_responses):
        """
        args:
            prober_requests: multiprocessing.Queue(), 
                queue to put new probes on
            prober_responses: multiprocessing.Queue(),
                queue to get processed probes from
        """
        super(Tracker, self).__init__()

        self.prober_requests = prober_requests
        self.prober_responses = prober_responses

        # create health state table from the lb config
        self.state = state.State(config_obj=config.LB)

        # shared memory client
        self._sm = sharedmem.MemcacheClient(
            [config.BASE['SHARED_MEM_HOSTNAME']],
            socket_timeout=config.BASE['SHARED_MEM_SOCKET_TIMEOUT'],
            server_max_value_length=config.
            BASE['SHARED_MEM_SERVER_MAX_VALUE_LENGTH'])