class TestShowPool(fakes.TestLoadBalancer): _object = fakes.FakePool.create_one() columns = ( 'admin_state_up', 'description', 'healthmonitor_id', 'id', 'lb_algorithm', 'listeners', 'loadbalancers', 'member_ids', 'name', 'protocol', 'provisioning_status', 'session_persistence') data = ( _object.is_admin_state_up, _object.description, # sdk_utils.ListOfIdsColumnBR(_object.health_monitor_ids), _object.health_monitor_id, _object.id, _object.lb_algorithm, sdk_utils.ListOfIdsColumnBR(_object.listener_ids), sdk_utils.ListOfIdsColumnBR(_object.load_balancer_ids), sdk_utils.ListOfIdsColumnBR(_object.member_ids), _object.name, _object.protocol, _object.status, _object.session_persistence, ) def setUp(self): super(TestShowPool, self).setUp() self.cmd = pool.ShowPool(self.app, None) self.client.find_pool = mock.Mock() def test_show_default(self): arglist = [ 'pool_id' ] verifylist = [ ('pool', 'pool_id') ] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.find_pool.side_effect = [ self._object ] # Trigger the action columns, data = self.cmd.take_action(parsed_args) self.client.find_pool.assert_called_once_with( name_or_id='pool_id', ignore_missing=False ) self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data)
class TestShowLoadBalancer(fakes.TestLoadBalancer): _object = fakes.FakeLoadBalancer.create_one() columns = ('admin_state_up', 'description', 'id', 'listener_ids', 'name', 'operating_status', 'pool_ids', 'project_id', 'provider', 'provisioning_status', 'vip_address', 'vip_port_id', 'vip_subnet_id') data = ( _object.is_admin_state_up, _object.description, _object.id, sdk_utils.ListOfIdsColumnBR(_object.listener_ids), _object.name, _object.operating_status, sdk_utils.ListOfIdsColumnBR(_object.pool_ids), _object.project_id, _object.provider, _object.provisioning_status, _object.vip_address, _object.vip_port_id, _object.vip_subnet_id, ) def setUp(self): super(TestShowLoadBalancer, self).setUp() self.cmd = load_balancer.ShowLoadBalancer(self.app, None) self.client.find_load_balancer = mock.Mock() def test_show_default(self): arglist = ['lb'] verifylist = [('load_balancer', 'lb')] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.find_load_balancer.side_effect = [self._object] # Trigger the action columns, data = self.cmd.take_action(parsed_args) self.client.find_load_balancer.assert_called_once_with( name_or_id='lb', ignore_missing=False) self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data)
class TestShowHealthMonitor(fakes.TestLoadBalancer): _object = fakes.FakeHealthMonitor.create_one() columns = ( 'admin_state_up', 'expected_codes', 'http_method', 'id', 'max_retries', 'name', 'pool_ids', 'timeout', 'type', 'url_path') data = ( _object.is_admin_state_up, _object.expected_codes, _object.http_method, _object.id, _object.max_retries, _object.name, sdk_utils.ListOfIdsColumnBR(_object.pool_ids), _object.timeout, _object.type, _object.url_path, ) def setUp(self): super(TestShowHealthMonitor, self).setUp() self.cmd = health_monitor.ShowHealthMonitor(self.app, None) self.client.find_health_monitor = mock.Mock() def test_show_default(self): arglist = [ 'hm' ] verifylist = [ ('health_monitor', 'hm'), ] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.find_health_monitor.side_effect = [ self._object ] # Trigger the action columns, data = self.cmd.take_action(parsed_args) self.client.find_health_monitor.assert_called_once_with( name_or_id='hm', ignore_missing=False ) self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data)
class TestCreateLoadBalancer(fakes.TestLoadBalancer): _object = fakes.FakeLoadBalancer.create_one() columns = ('admin_state_up', 'description', 'id', 'listener_ids', 'name', 'operating_status', 'pool_ids', 'project_id', 'provider', 'provisioning_status', 'vip_address', 'vip_port_id', 'vip_subnet_id') data = ( _object.is_admin_state_up, _object.description, _object.id, sdk_utils.ListOfIdsColumnBR(_object.listener_ids), _object.name, _object.operating_status, sdk_utils.ListOfIdsColumnBR(_object.pool_ids), _object.project_id, _object.provider, _object.provisioning_status, _object.vip_address, _object.vip_port_id, _object.vip_subnet_id, ) def setUp(self): super(TestCreateLoadBalancer, self).setUp() self.cmd = load_balancer.CreateLoadBalancer(self.app, None) self.client.create_load_balancer = mock.Mock() def test_create_default(self): arglist = [ '--disable', '--description', 'descr', '--name', 'nm', '--vip_address', 'vip_addr', '--vip_network_id', 'vip_network_id', '--vip_qos_policy_id', 'vip_qos_policy_id' ] verifylist = [ ('disable', True), ('description', 'descr'), ('name', 'nm'), ('vip_address', 'vip_addr'), ('vip_network_id', 'vip_network_id'), ('vip_qos_policy_id', 'vip_qos_policy_id'), ] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.create_load_balancer.side_effect = [self._object] # Trigger the action columns, data = self.cmd.take_action(parsed_args) self.client.create_load_balancer.assert_called_once_with( is_admin_state_up=False, description='descr', name='nm', vip_address='vip_addr', vip_network_id='vip_network_id', vip_qos_policy_id='vip_qos_policy_id') self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data) def test_create_subnet(self): arglist = [ '--vip_subnet_id', 'vip_subnet_id', ] verifylist = [ ('vip_subnet_id', 'vip_subnet_id'), ] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.create_load_balancer.side_effect = [self._object] # Trigger the action columns, data = self.cmd.take_action(parsed_args) self.client.create_load_balancer.assert_called_once_with( vip_subnet_id='vip_subnet_id', ) self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data) def test_create_port(self): arglist = [ '--vip_port_id', 'vip_port_id', ] verifylist = [ ('vip_port_id', 'vip_port_id'), ] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.create_load_balancer.side_effect = [self._object] # Trigger the action columns, data = self.cmd.take_action(parsed_args) self.client.create_load_balancer.assert_called_once_with( vip_port_id='vip_port_id', ) self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data)
class TestUpdateHealthMonitor(fakes.TestLoadBalancer): _object = fakes.FakeHealthMonitor.create_one() columns = ( 'admin_state_up', 'expected_codes', 'http_method', 'id', 'max_retries', 'name', 'pool_ids', 'timeout', 'type', 'url_path') data = ( _object.is_admin_state_up, _object.expected_codes, _object.http_method, _object.id, _object.max_retries, _object.name, sdk_utils.ListOfIdsColumnBR(_object.pool_ids), _object.timeout, _object.type, _object.url_path, ) def setUp(self): super(TestUpdateHealthMonitor, self).setUp() self.cmd = health_monitor.SetHealthMonitor(self.app, None) self.client.update_health_monitor = mock.Mock() self.client.find_health_monitor = mock.Mock() def test_update_default(self): arglist = [ 'hm', '--disable', '--delay', '1', '--expected_codes', '100', '--http_method', 'CONNECT', '--name', 'name', '--max_retries', '2', '--timeout', '3', '--url_path', 'url' ] verifylist = [ ('health_monitor', 'hm'), ('disable', True), ('delay', 1), ('expected_codes', '100'), ('http_method', 'CONNECT'), ('name', 'name'), ('max_retries', 2), ('timeout', 3), ('url_path', 'url') ] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.update_health_monitor.side_effect = [ self._object ] self.client.find_health_monitor.side_effect = [ self._object ] # Trigger the action columns, data = self.cmd.take_action(parsed_args) self.client.update_health_monitor.assert_called_once_with( health_monitor=self._object.id, is_admin_state_up=False, delay=1, expected_codes='100', http_method='CONNECT', max_retries=2, name='name', timeout=3, url_path='url' ) self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data)
class TestCreateListener(fakes.TestLoadBalancer): _object = fakes.FakeListener.create_one() columns = ( 'admin_state_up', 'connection_limit', 'default_pool_id', 'description', 'id', 'loadbalancers', 'name', 'protocol', 'protocol_port') data = ( _object.is_admin_state_up, _object.connection_limit, _object.default_pool_id, _object.description, _object.id, sdk_utils.ListOfIdsColumnBR(_object.load_balancer_ids), _object.name, _object.protocol, _object.protocol_port, ) def setUp(self): super(TestCreateListener, self).setUp() self.cmd = listener.CreateListener(self.app, None) self.client.create_listener = mock.Mock() def test_create_default(self): arglist = [ 'lb', '--protocol', 'tcp', '--protocol_port', '134', '--disable', '--connection_limit', '-1', '--default_pool', 'pool', '--default_tls_container_ref', 'default_tls_container_ref', '--description', 'description', '--name', 'name' ] verifylist = [ ('protocol', 'TCP'), ('protocol_port', 134), ('load_balancer', 'lb'), ('disable', True), ('connection_limit', -1), ('default_pool', 'pool'), ('default_tls_container_ref', 'default_tls_container_ref'), ('description', 'description'), ('name', 'name') ] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.create_listener.side_effect = [ self._object ] # Trigger the action columns, data = self.cmd.take_action(parsed_args) self.client.create_listener.assert_called_once_with( connection_limit=-1, default_pool_id='pool', default_tls_container_ref='default_tls_container_ref', description='description', is_admin_state_up=False, load_balancer_id='lb', name='name', protocol='TCP', protocol_port=134 ) self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data)
class TestUpdatePool(fakes.TestLoadBalancer): _object = fakes.FakePool.create_one() columns = ('admin_state_up', 'description', 'healthmonitor_id', 'id', 'lb_algorithm', 'listeners', 'loadbalancers', 'member_ids', 'name', 'protocol', 'provisioning_status', 'session_persistence') data = ( _object.is_admin_state_up, _object.description, _object.health_monitor_id, _object.id, _object.lb_algorithm, sdk_utils.ListOfIdsColumnBR(_object.listener_ids), sdk_utils.ListOfIdsColumnBR(_object.load_balancer_ids), sdk_utils.ListOfIdsColumnBR(_object.member_ids), _object.name, _object.protocol, _object.status, _object.session_persistence, ) def setUp(self): super(TestUpdatePool, self).setUp() self.cmd = pool.SetPool(self.app, None) self.client.update_pool = mock.Mock() def test_update_default(self): arglist = [ 'pool', '--lb_algorithm', 'ROUND_ROBIN', '--name', 'name', '--description', 'descr', '--session_persistence', '{"a": "b"}', '--disable' ] verifylist = [ ('pool', 'pool'), ('lb_algorithm', 'ROUND_ROBIN'), ('disable', True), ('name', 'name'), ('description', 'descr'), ('session_persistence', '{"a": "b"}'), ] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.update_pool.side_effect = [self._object] # Trigger the action columns, data = self.cmd.take_action(parsed_args) self.client.update_pool.assert_called_once_with( lb_algorithm='ROUND_ROBIN', pool='pool', name='name', session_persistence={'a': 'b'}, is_admin_state_up=False, description='descr') self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data)