Ejemplo n.º 1
0
    def test_no_lbs(self):
        """
        When no loadBalancers are specified, the returned
        DesiredServerGroupState has an empty mapping for desired_lbs. If no
        draining_timeout is provided, returned DesiredServerGroupState has
        draining_timeout as 0.0
        """
        server_config = {'name': 'test', 'flavorRef': 'f'}
        lc = {'args': {'server': server_config}}

        expected_server_config = {
            'server': {
                'name': 'test',
                'flavorRef': 'f',
                'metadata': {
                    'rax:auto_scaling_group_id': 'uuid',
                    'rax:autoscale:group:id': 'uuid'}}}
        state = get_desired_server_group_state('uuid', lc, 2)
        self.assertEqual(
            state,
            DesiredServerGroupState(
                server_config=expected_server_config,
                capacity=2,
                desired_lbs=pset(),
                draining_timeout=0.0))
        self.assert_server_config_hashable(state)
Ejemplo n.º 2
0
    def test_convert(self):
        """
        An Otter launch config a :obj:`DesiredServerGroupState`, ignoring extra
        config information.
        """
        server_config = {'name': 'test', 'flavorRef': 'f'}
        lc = {'args': {'server': server_config,
                       'loadBalancers': [
                           {'loadBalancerId': 23, 'port': 80,
                            'whatsit': 'invalid'},
                           {'loadBalancerId': 23, 'port': 90},
                           {'loadBalancerId': 23, 'type': 'RackConnectV3'},
                           {'loadBalancerId': '12', 'type': 'RackConnectV3'}],
                       'draining_timeout': 35}}

        expected_server_config = {
            'server': {
                'name': 'test',
                'flavorRef': 'f',
                'metadata': {
                    'rax:auto_scaling_group_id': 'uuid',
                    'rax:autoscale:group:id': 'uuid',
                    'rax:autoscale:lb:CloudLoadBalancer:23': json.dumps(
                        [{"port": 80},
                         {"port": 90}]),
                    'rax:autoscale:lb:RackConnectV3:23': '',
                    'rax:autoscale:lb:RackConnectV3:12': ''
                }
            }
        }
        state = get_desired_server_group_state('uuid', lc, 2)
        self.assertEqual(
            state,
            DesiredServerGroupState(
                server_config=expected_server_config,
                capacity=2,
                desired_lbs=pset([
                    CLBDescription(lb_id='23', port=80),
                    CLBDescription(lb_id='23', port=90),
                    RCv3Description(lb_id='23'),
                    RCv3Description(lb_id='12')]),
                draining_timeout=35.0))
        self.assert_server_config_hashable(state)