コード例 #1
0
 def test_application_info(self, mocked_check):
     """ Test the application_info request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all application info
     mocked_rpc = plugin.supvisors().get_all_applications_info
     mocked_rpc.return_value = [
         {'application_name': 'appli_1', 'statename': 'running',
             'major_failure': True, 'minor_failure': False}, 
         {'application_name': 'appli_2', 'statename': 'stopped',
             'major_failure': False, 'minor_failure': True}]
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_application_info, plugin.do_application_info,
         '', [call()])
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_application_info, plugin.do_application_info,
         'all', [call()])
     # test help and request for application info from
     # a selection of application names
     mocked_rpc = plugin.supvisors().get_application_info
     mocked_rpc.side_effect = [
         {'application_name': 'appli_1', 'statename': 'running',
             'major_failure': True, 'minor_failure': False}, 
         {'application_name': 'appli_2', 'statename': 'stopped',
             'major_failure': False, 'minor_failure': True}]
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_application_info, plugin.do_application_info,
         'appli_2 appli_1',
         [call('appli_2'), call('appli_1')])
コード例 #2
0
 def test_sstatus(self, mocked_check):
     """ Test the sstatus request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all process info
     mocked_rpc = plugin.supvisors().get_all_process_info
     mocked_rpc.return_value = [
         {'application_name': 'appli_1', 'process_name': 'proc_1',
             'statename': 'running', 'addresses': ['10.0.1', '10.0.2']}, 
         {'application_name': 'appli_2', 'process_name': 'proc_3',
             'statename': 'stopped', 'addresses': []}]
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_sstatus, plugin.do_sstatus, '',
         [call()])
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_sstatus, plugin.do_sstatus, 'all',
         [call()])
     # test help and request for process info from a selection of namespecs
     mocked_rpc = plugin.supvisors().get_process_info
     mocked_rpc.side_effect = [
         [{'application_name': 'appli_1', 'process_name': 'proc_1',
             'statename': 'running', 'addresses': ['10.0.1', '10.0.2']}],
         [{'application_name': 'appli_2', 'process_name': 'proc_3',
             'statename': 'stopped', 'addresses': []}]]
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_sstatus, plugin.do_sstatus,
         'appli_2:proc_3 appli_1:proc_1',
         [call('appli_2:proc_3'), call('appli_1:proc_1')])
コード例 #3
0
 def test_start_process_args(self, mocked_check):
     """ Test the start_process_args request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test the request using few arguments
     plugin.do_start_process_args('')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     plugin.do_start_process_args('CONFIG')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     plugin.do_start_process_args('CONFIG proc')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test the request using unknown strategy
     plugin.do_start_process_args('strategy program list of arguments')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test request to start the process
     mocked_rpc = plugin.supvisors().start_process
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_start_process_args, plugin.do_start_process_args,
         'LESS_LOADED appli_2:proc_3 a list of arguments',
         [call(1, 'appli_2:proc_3', 'a list of arguments')])
コード例 #4
0
 def test_address_status(self, mocked_check):
     """ Test the address_status request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all address status
     mocked_rpc = plugin.supvisors().get_all_addresses_info
     mocked_rpc.return_value = [
         {'address_name': '10.0.0.1', 'statename': 'running',
             'loading': 10, 'local_time': 1500}, 
         {'address_name': '10.0.0.2', 'statename': 'stopped',
             'loading': 0, 'local_time': 100}]
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_address_status, plugin.do_address_status,
         '', [call()])
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_address_status, plugin.do_address_status,
         'all', [call()])
     # test help and request for address status from
     # a selection of address names
     mocked_rpc = plugin.supvisors().get_address_info
     mocked_rpc.side_effect = [
         {'address_name': '10.0.0.1', 'statename': 'running',
             'loading': 10, 'local_time': 1500}, 
         {'address_name': '10.0.0.2', 'statename': 'stopped',
             'loading': 0, 'local_time': 100}]
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_address_status, plugin.do_address_status,
         '10.0.0.2 10.0.0.1',
         [call('10.0.0.2'), call('10.0.0.1')])
コード例 #5
0
 def test_sversion(self, mocked_check):
     """ Test the sversion request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request
     self._check_call(None, plugin.supvisors().get_api_version,
         plugin.help_sversion, plugin.do_sversion, '',
         [call()])
コード例 #6
0
 def test_master(self, mocked_check):
     """ Test the master request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request
     self._check_call(mocked_check, plugin.supvisors().get_master_address,
         plugin.help_master, plugin.do_master, '',
         [call()])
コード例 #7
0
 def test_sshutdown(self, mocked_check):
     """ Test the sshutdown request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request
     mocked_rpc = plugin.supvisors().shutdown
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_sshutdown, plugin.do_sshutdown, '',
         [call()])
コード例 #8
0
 def test_supvisors(self):
     """ Test the access to Supvisors proxy. """
     from supvisors.supvisorsctl import ControllerPlugin
     from supvisors.rpcinterface import RPCInterface
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test the proxy
     self.assertEqual(plugin.supvisors()._spec_class, RPCInterface)
     self.assertEqual([call('supvisors')],
         self.controller.get_server_proxy.call_args_list)
コード例 #9
0
 def test_strategies(self, mocked_check):
     """ Test the master request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request
     mocked_rpc = plugin.supvisors().get_strategies
     mocked_rpc.return_value = {'conciliation': 'hard', 'starting': 'easy', 'auto-fencing': True}
     self._check_call(mocked_check, plugin.supvisors().get_strategies,
         plugin.help_strategies, plugin.do_strategies, '',
         [call()])
コード例 #10
0
 def test_sstate(self, mocked_check):
     """ Test the sstate request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request
     mocked_rpc = plugin.supvisors().get_supvisors_state
     mocked_rpc.return_value = {'statecode':10, 'statename': 'running'}
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_sstate, plugin.do_sstate, '',
         [call()])
コード例 #11
0
 def test_stop_process(self, mocked_check):
     """ Test the stop_process request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # call the common starting test
     mocked_appli = plugin.supvisors().get_all_applications_info
     mocked_rpc = plugin.supvisors().stop_process
     self._check_stop_command(mocked_check, mocked_appli, mocked_rpc,
         plugin.help_stop_process, plugin.do_stop_process,
         ('appli_1:*', 'appli_2:*'),
         'appli_2:proc_3 appli_1:proc_1', ('appli_2:proc_3', 'appli_1:proc_1'))
コード例 #12
0
 def test_restart_application(self, mocked_check):
     """ Test the restart_application request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # call the common starting test
     mocked_appli = plugin.supvisors().get_all_applications_info
     mocked_rpc = plugin.supvisors().restart_application
     self._check_start_command(mocked_check, mocked_appli, mocked_rpc,
         plugin.help_restart_application, plugin.do_restart_application,
         ('appli_1', 'appli_2'),
         'appli_2 appli_1', ('appli_2', 'appli_1'))
コード例 #13
0
 def test_process_rules(self, mocked_check):
     """ Test the process_rules request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all rules
     mocked_appli = plugin.supvisors().get_all_applications_info
     mocked_appli.return_value = [{'application_name': 'appli_1'},
         {'application_name': 'appli_2'}]
     mocked_rpc = plugin.supvisors().get_process_rules
     returned_rules = [
         [{'application_name': 'appli_1', 'process_name': 'proc_1',
             'addresses': ['10.0.0.1', '10.0.0.2'],
             'start_sequence': 2, 'stop_sequence': 3,
             'required': True, 'wait_exit': False,
             'expected_loading': 50,
             'running_failure_strategy': 1}], 
         [{'application_name': 'appli_2', 'process_name': 'proc_3',
             'addresses': ['*'],
             'start_sequence': 1, 'stop_sequence': 0,
             'required': False, 'wait_exit': True,
             'expected_loading': 15,
             'running_failure_strategy': 2}]]
     # first possiblity: no argument
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_process_rules, plugin.do_process_rules, '',
         [call('appli_1:*'), call('appli_2:*')])
     self.assertEqual([call(), call()], mocked_appli.call_args_list)
     mocked_appli.reset_mock()
     # second possiblity: use 'all'
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_process_rules, plugin.do_process_rules, 'all',
         [call('appli_1:*'), call('appli_2:*')])
     self.assertEqual([call(), call()], mocked_appli.call_args_list)
     mocked_appli.reset_mock()
     # test help and request for rules from a selection of namespecs
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_process_rules, plugin.do_process_rules,
         'appli_2:proc_3 appli_1:proc_1',
         [call('appli_2:proc_3'), call('appli_1:proc_1')])
     self.assertEqual(0, mocked_appli.call_count)
     # test help and request with get_all_applications_info error
     mocked_appli.reset_mock()
     mocked_appli.side_effect = xmlrpclib.Fault(0, 'error')
     plugin.do_process_rules('')
     self.assertEqual([call()], mocked_appli.call_args_list)
     self.assertEqual(0, mocked_rpc.call_count)
     self.check_output_error(True)
コード例 #14
0
 def test_restart_process(self, mocked_check):
     """ Test the restart_process request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # call the common starting test
     mocked_appli = plugin.supvisors().get_all_applications_info
     mocked_rpc = plugin.supvisors().restart_process
     self._check_start_command(mocked_check, mocked_appli, mocked_rpc,
                               plugin.help_restart_process,
                               plugin.do_restart_process,
                               ('appli_1:*', 'appli_2:*'),
                               'appli_2:proc_3 appli_1:proc_1',
                               ('appli_2:proc_3', 'appli_1:proc_1'))
コード例 #15
0
 def test_conflicts(self, mocked_check):
     """ Test the conflicts request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request
     mocked_rpc = plugin.supvisors().get_conflicts
     mocked_rpc.return_value = [
         {'application_name': 'appli_1', 'process_name': 'proc_1',
             'statename': 'running', 'addresses': ['10.0.0.1', '10.0.0.2']},
         {'application_name': 'appli_2', 'process_name': 'proc_3',
             'statename': 'stopped', 'addresses': ['10.0.0.2', '10.0.0.3']}]
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_conflicts, plugin.do_conflicts, '',
         [call()])
コード例 #16
0
 def test_start_args(self, mocked_check):
     """ Test the start_args request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test the request using few arguments
     plugin.do_start_args('')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test request to start process without extra arguments
     mocked_rpc = plugin.supvisors().start_args
     self._check_call(mocked_check, mocked_rpc, plugin.help_start_args,
                      plugin.do_start_args, 'proc MOST_LOADED all',
                      [call('proc', 'MOST_LOADED all')])
コード例 #17
0
 def test_strategies(self, mocked_check):
     """ Test the master request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request
     mocked_rpc = plugin.supvisors().get_strategies
     mocked_rpc.return_value = {
         'conciliation': 'hard',
         'starting': 'easy',
         'auto-fencing': True
     }
     self._check_call(mocked_check,
                      plugin.supvisors().get_strategies,
                      plugin.help_strategies, plugin.do_strategies, '',
                      [call()])
コード例 #18
0
 def test_start_args(self, mocked_check):
     """ Test the start_args request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test the request using few arguments
     plugin.do_start_args('')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test request to start process without extra arguments
     mocked_rpc = plugin.supvisors().start_args
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_start_args, plugin.do_start_args,
         'proc MOST_LOADED all',
         [call('proc', 'MOST_LOADED all')])
コード例 #19
0
 def test_application_rules(self, mocked_check):
     """ Test the application_rules request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all rules
     mocked_appli = plugin.supvisors().get_all_applications_info
     mocked_appli.return_value = [{'application_name': 'appli_1'},
         {'application_name': 'appli_2'}]
     mocked_rpc = plugin.supvisors().get_application_rules
     returned_rules = [
         {'application_name': 'appli_1',
             'start_sequence': 2, 'stop_sequence': 3,
             'starting_failure_strategy': 2,
             'running_failure_strategy': 1}, 
         {'application_name': 'appli_2',
             'start_sequence': 1, 'stop_sequence': 0,
             'starting_failure_strategy': 0,
             'running_failure_strategy': 2}]
     # first possiblity: no argument
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_application_rules, plugin.do_application_rules, '',
         [call('appli_1'), call('appli_2')])
     self.assertEqual([call(), call()], mocked_appli.call_args_list)
     mocked_appli.reset_mock()
     # second possiblity: use 'all'
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_application_rules, plugin.do_application_rules, 'all',
         [call('appli_1'), call('appli_2')])
     self.assertEqual([call(), call()], mocked_appli.call_args_list)
     mocked_appli.reset_mock()
     # test help and request for rules from a selection of application names
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_application_rules, plugin.do_application_rules,
         'appli_2 appli_1',
         [call('appli_2'), call('appli_1')])
     self.assertEqual(0, mocked_appli.call_count)
     # test help and request with get_all_applications_info error
     mocked_appli.reset_mock()
     mocked_appli.side_effect = xmlrpclib.Fault(0, 'error')
     plugin.do_application_rules('')
     self.assertEqual([call()], mocked_appli.call_args_list)
     self.assertEqual(0, mocked_rpc.call_count)
     self.check_output_error(True)
コード例 #20
0
 def test_application_info(self, mocked_check):
     """ Test the application_info request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all application info
     mocked_rpc = plugin.supvisors().get_all_applications_info
     mocked_rpc.return_value = [{
         'application_name': 'appli_1',
         'statename': 'running',
         'major_failure': True,
         'minor_failure': False
     }, {
         'application_name': 'appli_2',
         'statename': 'stopped',
         'major_failure': False,
         'minor_failure': True
     }]
     self._check_call(mocked_check, mocked_rpc,
                      plugin.help_application_info,
                      plugin.do_application_info, '', [call()])
     self._check_call(mocked_check, mocked_rpc,
                      plugin.help_application_info,
                      plugin.do_application_info, 'all', [call()])
     # test help and request for application info from
     # a selection of application names
     mocked_rpc = plugin.supvisors().get_application_info
     mocked_rpc.side_effect = [{
         'application_name': 'appli_1',
         'statename': 'running',
         'major_failure': True,
         'minor_failure': False
     }, {
         'application_name': 'appli_2',
         'statename': 'stopped',
         'major_failure': False,
         'minor_failure': True
     }]
     self._check_call(mocked_check, mocked_rpc,
                      plugin.help_application_info,
                      plugin.do_application_info, 'appli_2 appli_1',
                      [call('appli_2'), call('appli_1')])
コード例 #21
0
 def test_conflicts(self, mocked_check):
     """ Test the conflicts request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request
     mocked_rpc = plugin.supvisors().get_conflicts
     mocked_rpc.return_value = [{
         'application_name': 'appli_1',
         'process_name': 'proc_1',
         'statename': 'running',
         'addresses': ['10.0.0.1', '10.0.0.2']
     }, {
         'application_name': 'appli_2',
         'process_name': 'proc_3',
         'statename': 'stopped',
         'addresses': ['10.0.0.2', '10.0.0.3']
     }]
     self._check_call(mocked_check, mocked_rpc, plugin.help_conflicts,
                      plugin.do_conflicts, '', [call()])
コード例 #22
0
 def test_sstatus(self, mocked_check):
     """ Test the sstatus request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all process info
     mocked_rpc = plugin.supvisors().get_all_process_info
     mocked_rpc.return_value = [{
         'application_name': 'appli_1',
         'process_name': 'proc_1',
         'statename': 'running',
         'addresses': ['10.0.1', '10.0.2']
     }, {
         'application_name': 'appli_2',
         'process_name': 'proc_3',
         'statename': 'stopped',
         'addresses': []
     }]
     self._check_call(mocked_check, mocked_rpc, plugin.help_sstatus,
                      plugin.do_sstatus, '', [call()])
     self._check_call(mocked_check, mocked_rpc, plugin.help_sstatus,
                      plugin.do_sstatus, 'all', [call()])
     # test help and request for process info from a selection of namespecs
     mocked_rpc = plugin.supvisors().get_process_info
     mocked_rpc.side_effect = [[{
         'application_name': 'appli_1',
         'process_name': 'proc_1',
         'statename': 'running',
         'addresses': ['10.0.1', '10.0.2']
     }],
                               [{
                                   'application_name': 'appli_2',
                                   'process_name': 'proc_3',
                                   'statename': 'stopped',
                                   'addresses': []
                               }]]
     self._check_call(mocked_check, mocked_rpc, plugin.help_sstatus,
                      plugin.do_sstatus, 'appli_2:proc_3 appli_1:proc_1',
                      [call('appli_2:proc_3'),
                       call('appli_1:proc_1')])
コード例 #23
0
 def test_address_status(self, mocked_check):
     """ Test the address_status request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all address status
     mocked_rpc = plugin.supvisors().get_all_addresses_info
     mocked_rpc.return_value = [{
         'address_name': '10.0.0.1',
         'statename': 'running',
         'loading': 10,
         'local_time': 1500
     }, {
         'address_name': '10.0.0.2',
         'statename': 'stopped',
         'loading': 0,
         'local_time': 100
     }]
     self._check_call(mocked_check, mocked_rpc, plugin.help_address_status,
                      plugin.do_address_status, '', [call()])
     self._check_call(mocked_check, mocked_rpc, plugin.help_address_status,
                      plugin.do_address_status, 'all', [call()])
     # test help and request for address status from
     # a selection of address names
     mocked_rpc = plugin.supvisors().get_address_info
     mocked_rpc.side_effect = [{
         'address_name': '10.0.0.1',
         'statename': 'running',
         'loading': 10,
         'local_time': 1500
     }, {
         'address_name': '10.0.0.2',
         'statename': 'stopped',
         'loading': 0,
         'local_time': 100
     }]
     self._check_call(mocked_check, mocked_rpc, plugin.help_address_status,
                      plugin.do_address_status, '10.0.0.2 10.0.0.1',
                      [call('10.0.0.2'), call('10.0.0.1')])
コード例 #24
0
 def test_application_rules(self, mocked_check):
     """ Test the application_rules request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all rules
     mocked_appli = plugin.supvisors().get_all_applications_info
     mocked_appli.return_value = [{
         'application_name': 'appli_1'
     }, {
         'application_name': 'appli_2'
     }]
     mocked_rpc = plugin.supvisors().get_application_rules
     returned_rules = [{
         'application_name': 'appli_1',
         'start_sequence': 2,
         'stop_sequence': 3,
         'starting_failure_strategy': 2,
         'running_failure_strategy': 1
     }, {
         'application_name': 'appli_2',
         'start_sequence': 1,
         'stop_sequence': 0,
         'starting_failure_strategy': 0,
         'running_failure_strategy': 2
     }]
     # first possiblity: no argument
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc,
                      plugin.help_application_rules,
                      plugin.do_application_rules, '',
                      [call('appli_1'), call('appli_2')])
     self.assertEqual([call(), call()], mocked_appli.call_args_list)
     mocked_appli.reset_mock()
     # second possiblity: use 'all'
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc,
                      plugin.help_application_rules,
                      plugin.do_application_rules, 'all',
                      [call('appli_1'), call('appli_2')])
     self.assertEqual([call(), call()], mocked_appli.call_args_list)
     mocked_appli.reset_mock()
     # test help and request for rules from a selection of application names
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc,
                      plugin.help_application_rules,
                      plugin.do_application_rules, 'appli_2 appli_1',
                      [call('appli_2'), call('appli_1')])
     self.assertEqual(0, mocked_appli.call_count)
     # test help and request with get_all_applications_info error
     mocked_appli.reset_mock()
     mocked_appli.side_effect = xmlrpclib.Fault(0, 'error')
     plugin.do_application_rules('')
     self.assertEqual([call()], mocked_appli.call_args_list)
     self.assertEqual(0, mocked_rpc.call_count)
     self.check_output_error(True)
コード例 #25
0
 def test_conciliate(self, mocked_check):
     """ Test the conciliate request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test the request using no strategy
     plugin.do_conciliate('')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test the request using unknown strategy
     plugin.do_conciliate('strategy')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test help and request
     mocked_rpc = plugin.supvisors().conciliate
     self._check_call(mocked_check, mocked_rpc, plugin.help_conciliate,
                      plugin.do_conciliate, 'SENICIDE', [call(0)])
コード例 #26
0
 def test_conciliate(self, mocked_check):
     """ Test the conciliate request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test the request using no strategy
     plugin.do_conciliate('')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test the request using unknown strategy
     plugin.do_conciliate('strategy')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test help and request
     mocked_rpc = plugin.supvisors().conciliate
     self._check_call(mocked_check, mocked_rpc,
         plugin.help_conciliate, plugin.do_conciliate,
         'SENICIDE', [call(0)])
コード例 #27
0
 def test_TODO(self):
     """ Test the values set at construction. """
     from supvisors.supvisorsctl import ControllerPlugin
     plugin = ControllerPlugin(DummySupervisor())
     self.assertIsNotNone(plugin)
コード例 #28
0
 def test_process_rules(self, mocked_check):
     """ Test the process_rules request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test help and request for all rules
     mocked_appli = plugin.supvisors().get_all_applications_info
     mocked_appli.return_value = [{
         'application_name': 'appli_1'
     }, {
         'application_name': 'appli_2'
     }]
     mocked_rpc = plugin.supvisors().get_process_rules
     returned_rules = [[{
         'application_name': 'appli_1',
         'process_name': 'proc_1',
         'addresses': ['10.0.0.1', '10.0.0.2'],
         'start_sequence': 2,
         'stop_sequence': 3,
         'required': True,
         'wait_exit': False,
         'expected_loading': 50,
         'running_failure_strategy': 1
     }],
                       [{
                           'application_name': 'appli_2',
                           'process_name': 'proc_3',
                           'addresses': ['*'],
                           'start_sequence': 1,
                           'stop_sequence': 0,
                           'required': False,
                           'wait_exit': True,
                           'expected_loading': 15,
                           'running_failure_strategy': 2
                       }]]
     # first possiblity: no argument
     mocked_rpc.side_effect = returned_rules
     self._check_call(
         mocked_check, mocked_rpc, plugin.help_process_rules,
         plugin.do_process_rules, '',
         [call('appli_1:*'), call('appli_2:*')])
     self.assertEqual([call(), call()], mocked_appli.call_args_list)
     mocked_appli.reset_mock()
     # second possiblity: use 'all'
     mocked_rpc.side_effect = returned_rules
     self._check_call(
         mocked_check, mocked_rpc, plugin.help_process_rules,
         plugin.do_process_rules, 'all',
         [call('appli_1:*'), call('appli_2:*')])
     self.assertEqual([call(), call()], mocked_appli.call_args_list)
     mocked_appli.reset_mock()
     # test help and request for rules from a selection of namespecs
     mocked_rpc.side_effect = returned_rules
     self._check_call(mocked_check, mocked_rpc, plugin.help_process_rules,
                      plugin.do_process_rules,
                      'appli_2:proc_3 appli_1:proc_1',
                      [call('appli_2:proc_3'),
                       call('appli_1:proc_1')])
     self.assertEqual(0, mocked_appli.call_count)
     # test help and request with get_all_applications_info error
     mocked_appli.reset_mock()
     mocked_appli.side_effect = xmlrpclib.Fault(0, 'error')
     plugin.do_process_rules('')
     self.assertEqual([call()], mocked_appli.call_args_list)
     self.assertEqual(0, mocked_rpc.call_count)
     self.check_output_error(True)
コード例 #29
0
 def test_start_process_args(self, mocked_check):
     """ Test the start_process_args request. """
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test the request using few arguments
     plugin.do_start_process_args('')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     plugin.do_start_process_args('CONFIG')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     plugin.do_start_process_args('CONFIG proc')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test the request using unknown strategy
     plugin.do_start_process_args('strategy program list of arguments')
     self.check_output_error(True)
     self.assertEqual([call()], mocked_check.call_args_list)
     mocked_check.reset_mock()
     # test request to start the process
     mocked_rpc = plugin.supvisors().start_process
     self._check_call(mocked_check, mocked_rpc,
                      plugin.help_start_process_args,
                      plugin.do_start_process_args,
                      'LESS_LOADED appli_2:proc_3 a list of arguments',
                      [call(1, 'appli_2:proc_3', 'a list of arguments')])
コード例 #30
0
 def test_upcheck(self):
     """ Test the _upcheck method. """
     from supvisors.rpcinterface import API_VERSION
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test different API versions
     mocked_rpc = plugin.supvisors().get_api_version
     mocked_rpc.return_value = 'dummy_version'
     self.assertFalse(plugin._upcheck())
     self.check_output_error(True)
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test handled RPC error
     mocked_rpc.side_effect = xmlrpclib.Fault(Faults.UNKNOWN_METHOD, '')
     self.assertFalse(plugin._upcheck())
     self.check_output_error(True)
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test not handled RPC error
     mocked_rpc.side_effect = xmlrpclib.Fault(0, 'error')
     with self.assertRaises(xmlrpclib.Fault):
         plugin._upcheck()
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test handled socket errors
     mocked_rpc.side_effect = socket.error(errno.ECONNREFUSED)
     self.assertFalse(plugin._upcheck())
     self.check_output_error(True)
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     mocked_rpc.side_effect = socket.error(errno.ENOENT)
     self.assertFalse(plugin._upcheck())
     self.check_output_error(True)
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test not handled socket error
     mocked_rpc.side_effect = socket.error(errno.EWOULDBLOCK)
     with self.assertRaises(socket.error):
         plugin._upcheck()
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test normal behaviour
     mocked_rpc.side_effect = None
     mocked_rpc.return_value = API_VERSION
     self.assertTrue(plugin._upcheck())
     self.assertEqual([call()], mocked_rpc.call_args_list)
コード例 #31
0
 def test_upcheck(self):
     """ Test the _upcheck method. """
     from supvisors.rpcinterface import API_VERSION
     from supvisors.supvisorsctl import ControllerPlugin
     # create the instance
     plugin = ControllerPlugin(self.controller)
     # test different API versions
     mocked_rpc = plugin.supvisors().get_api_version
     mocked_rpc.return_value = 'dummy_version'
     self.assertFalse(plugin._upcheck())
     self.check_output_error(True)
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test handled RPC error
     mocked_rpc.side_effect = xmlrpclib.Fault(Faults.UNKNOWN_METHOD, '')
     self.assertFalse(plugin._upcheck())
     self.check_output_error(True)
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test not handled RPC error
     mocked_rpc.side_effect = xmlrpclib.Fault(0, 'error')
     with self.assertRaises(xmlrpclib.Fault):
         plugin._upcheck()
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test handled socket errors
     mocked_rpc.side_effect = socket.error(errno.ECONNREFUSED)
     self.assertFalse(plugin._upcheck())
     self.check_output_error(True)
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     mocked_rpc.side_effect = socket.error(errno.ENOENT)
     self.assertFalse(plugin._upcheck())
     self.check_output_error(True)
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test not handled socket error
     mocked_rpc.side_effect = socket.error(errno.EWOULDBLOCK)
     with self.assertRaises(socket.error):
         plugin._upcheck()
     self.assertEqual([call()], mocked_rpc.call_args_list)
     mocked_rpc.reset_mock()
     # test normal behaviour
     mocked_rpc.side_effect = None
     mocked_rpc.return_value = API_VERSION
     self.assertTrue(plugin._upcheck())
     self.assertEqual([call()], mocked_rpc.call_args_list)