def test_update_elb_all_defaults(self, mock_config, **kwargs): """ update_elb calls get_or_create_elb with default port and protocol values if all are missing """ aws = DiscoAWS(config=self._get_elb_config(), environment_name=TEST_ENV_NAME, elb=MagicMock()) aws.elb.get_or_create_elb = MagicMock(return_value=MagicMock()) aws.get_meta_network_by_name = _get_meta_network_mock() aws.elb.delete_elb = MagicMock() aws.update_elb("mhcelb", update_autoscaling=False) aws.elb.delete_elb.assert_not_called() aws.elb.get_or_create_elb.assert_called_once_with( 'mhcelb', health_check_url='/foo', hosted_zone_name='example.com', port_config=DiscoELBPortConfig( [ DiscoELBPortMapping(80, 'HTTP', 80, 'HTTP'), ] ), security_groups=['sg-1234abcd'], elb_public=False, sticky_app_cookie=None, subnets=['s-1234abcd', 's-1234abcd', 's-1234abcd'], elb_dns_alias=None, connection_draining_timeout=300, idle_timeout=300, testing=False, tags={ 'environment': 'unittestenv', 'hostclass': 'mhcelb', 'is_testing': '0', 'productline': 'mock_productline' }, cross_zone_load_balancing=True, cert_name=None )
def test_update_elb_all_defaults(self, mock_config, **kwargs): """ update_elb calls get_or_create_elb with default port and protocol values if all are missing """ aws = DiscoAWS(config=self._get_elb_config(), environment_name=TEST_ENV_NAME, elb=MagicMock()) aws.elb.get_or_create_elb = MagicMock(return_value=MagicMock()) aws.get_meta_network_by_name = _get_meta_network_mock() aws.elb.delete_elb = MagicMock() aws.update_elb("mhcelb", update_autoscaling=False) aws.elb.delete_elb.assert_not_called() aws.elb.get_or_create_elb.assert_called_once_with( 'mhcelb', health_check_url='/foo', hosted_zone_name='example.com', port_config=DiscoELBPortConfig( [ DiscoELBPortMapping(80, 'HTTP', 80, 'HTTP'), ] ), security_groups=['sg-1234abcd'], elb_public=False, sticky_app_cookie=None, subnets=['s-1234abcd', 's-1234abcd', 's-1234abcd'], elb_dns_alias=None, connection_draining_timeout=300, idle_timeout=300, testing=False, tags={ 'environment': 'unittestenv', 'hostclass': 'mhcelb', 'is_testing': '0', 'productline': 'mock_productline' }, cross_zone_load_balancing=True, cert_name=None )
def test_update_elb_create(self, mock_config, **kwargs): '''DiscoELB called to update or create ELB when one is configured''' aws = DiscoAWS(config=self._get_elb_config(), environment_name=TEST_ENV_NAME) aws.elb.get_or_create_elb = MagicMock(return_value=MagicMock()) aws.get_meta_network_by_name = _get_meta_network_mock() aws.elb.delete_elb = MagicMock() aws.update_elb("mhcelb", update_autoscaling=False) aws.elb.delete_elb.assert_not_called() aws.elb.get_or_create_elb.assert_called_once_with( 'mhcelb', elb_port=80, health_check_url='/foo', hosted_zone_name='example.com', instance_port=80, elb_protocol='HTTP', instance_protocol='HTTP', security_groups=['sg-1234abcd'], elb_public=False, sticky_app_cookie=None, subnets=['s-1234abcd', 's-1234abcd', 's-1234abcd'], connection_draining_timeout=300, idle_timeout=300)
def test_update_elb_create(self, mock_config, **kwargs): '''DiscoELB called to update or create ELB when one is configured''' aws = DiscoAWS(config=self._get_elb_config(), environment_name=TEST_ENV_NAME) aws.elb.get_or_create_elb = MagicMock(return_value=MagicMock()) aws.get_meta_network_by_name = _get_meta_network_mock() aws.elb.delete_elb = MagicMock() aws.update_elb("mhcelb", update_autoscaling=False) aws.elb.delete_elb.assert_not_called() aws.elb.get_or_create_elb.assert_called_once_with( 'mhcelb', elb_port=80, health_check_url='/foo', hosted_zone_name='example.com', instance_port=80, elb_protocol='HTTP', instance_protocol='HTTP', security_groups=['sg-1234abcd'], elb_public=False, sticky_app_cookie=None, subnets=['s-1234abcd', 's-1234abcd', 's-1234abcd'], connection_draining_timeout=300, idle_timeout=300)
def test_update_elb_mismatch(self, mock_config, **kwargs): """ update_elb sets instance=ELB when given mismatched numbers of instance and ELB ports """ overrides = { 'elb_instance_port': '80, 9001', 'elb_instance_protocol': 'HTTP, HTTP', 'elb_port': '443, 80, 9002', 'elb_protocol': 'HTTPS, HTTP, HTTP' } aws = DiscoAWS( config=self._get_elb_config(overrides), environment_name=TEST_ENV_NAME, elb=MagicMock() ) aws.elb.get_or_create_elb = MagicMock(return_value=MagicMock()) aws.get_meta_network_by_name = _get_meta_network_mock() aws.elb.delete_elb = MagicMock() aws.update_elb("mhcelb", update_autoscaling=False) aws.elb.delete_elb.assert_not_called() aws.elb.get_or_create_elb.assert_called_once_with( 'mhcelb', health_check_url='/foo', hosted_zone_name='example.com', port_config=DiscoELBPortConfig( [ DiscoELBPortMapping(80, 'HTTP', 443, 'HTTPS'), DiscoELBPortMapping(9001, 'HTTP', 80, 'HTTP'), DiscoELBPortMapping(9002, 'HTTP', 9002, 'HTTP') ] ), security_groups=['sg-1234abcd'], elb_public=False, sticky_app_cookie=None, subnets=['s-1234abcd', 's-1234abcd', 's-1234abcd'], elb_dns_alias=None, connection_draining_timeout=300, idle_timeout=300, testing=False, tags={ 'environment': 'unittestenv', 'hostclass': 'mhcelb', 'is_testing': '0', 'productline': 'mock_productline' }, cross_zone_load_balancing=True, cert_name=None )
def test_update_elb_mismatch(self, mock_config, **kwargs): """ update_elb sets instance=ELB when given mismatched numbers of instance and ELB ports """ overrides = { 'elb_instance_port': '80, 9001', 'elb_instance_protocol': 'HTTP, HTTP', 'elb_port': '443, 80, 9002', 'elb_protocol': 'HTTPS, HTTP, HTTP' } aws = DiscoAWS( config=self._get_elb_config(overrides), environment_name=TEST_ENV_NAME, elb=MagicMock() ) aws.elb.get_or_create_elb = MagicMock(return_value=MagicMock()) aws.get_meta_network_by_name = _get_meta_network_mock() aws.elb.delete_elb = MagicMock() aws.update_elb("mhcelb", update_autoscaling=False) aws.elb.delete_elb.assert_not_called() aws.elb.get_or_create_elb.assert_called_once_with( 'mhcelb', health_check_url='/foo', hosted_zone_name='example.com', port_config=DiscoELBPortConfig( [ DiscoELBPortMapping(80, 'HTTP', 443, 'HTTPS'), DiscoELBPortMapping(9001, 'HTTP', 80, 'HTTP'), DiscoELBPortMapping(9002, 'HTTP', 9002, 'HTTP') ] ), security_groups=['sg-1234abcd'], elb_public=False, sticky_app_cookie=None, subnets=['s-1234abcd', 's-1234abcd', 's-1234abcd'], elb_dns_alias=None, connection_draining_timeout=300, idle_timeout=300, testing=False, tags={ 'environment': 'unittestenv', 'hostclass': 'mhcelb', 'is_testing': '0', 'productline': 'mock_productline' }, cross_zone_load_balancing=True, cert_name=None )