Exemplo n.º 1
0
    def test_collect_node_information(self, mock_ext_ip, mock_service,
                                      mock_version, mock_presto_config):
        env.roledefs = {'coordinator': ['Node1'], 'all': ['Node1']}
        mock_ext_ip.side_effect = ['IP1', 'IP3', 'IP4']
        mock_service.side_effect = [True, False, Exception('Not running')]
        mock_version.side_effect = ['', 'Presto not installed', '', '']

        self.assertEqual(('IP1', True, ''), server.collect_node_information())
        self.assertEqual(('Unknown', False, 'Presto not installed'),
                         server.collect_node_information())
        self.assertEqual(('IP3', False, ''), server.collect_node_information())
        self.assertEqual(('IP4', False, ''), server.collect_node_information())
Exemplo n.º 2
0
 def test_warning_presto_version_not_installed(self, mock_warn, mock_run,
                                               mock_run_sql):
     env.host = 'node1'
     env.roledefs['coordinator'] = ['node1']
     env.roledefs['worker'] = ['node1']
     env.roledefs['all'] = ['node1']
     env.hosts = env.roledefs['all']
     output = _AttributeString('package presto is not installed')
     output.succeeded = False
     mock_run.return_value = output
     env.host = 'node1'
     server.collect_node_information()
     installation_warning = 'Presto is not installed.'
     mock_warn.assert_called_with(installation_warning)
Exemplo n.º 3
0
    def test_warning_presto_version_wrong(self, mock_warn, mock_run,
                                          mock_run_sql):
        env.host = 'node1'
        env.roledefs['coordinator'] = ['node1']
        env.roledefs['worker'] = ['node1']
        env.roledefs['all'] = ['node1']
        env.hosts = env.roledefs['all']

        old_version = '0.97'
        output = _AttributeString(old_version)
        output.succeeded = True
        mock_run.return_value = output
        server.collect_node_information()
        version_warning = 'Presto version is %s, version >= 0.%d required.'\
                          % (old_version, PRESTO_RPM_MIN_REQUIRED_VERSION)
        mock_warn.assert_called_with(version_warning)