Ejemplo n.º 1
0
 def test_lookup_string_config_not_in_file(self, run_mock):
     run_mock.return_value = _AttributeString('')
     run_mock.return_value.failed = False
     run_mock.return_value.return_code = 1
     config_value = lookup_string_config('config.to.lookup',
                                         NODE_CONFIG_FILE, 'any_host')
     self.assertEqual(config_value, '')
 def test_lookup_string_config_not_in_file(self, run_mock):
     run_mock.return_value = _AttributeString('')
     run_mock.return_value.failed = False
     run_mock.return_value.return_code = 1
     config_value = lookup_string_config('config.to.lookup',
                                         NODE_CONFIG_FILE, 'any_host')
     self.assertEqual(config_value, '')
Ejemplo n.º 3
0
 def test_lookup_string_config(self, sudo_mock):
     sudo_mock.return_value = _AttributeString(
         'config.to.lookup=/path/hello')
     sudo_mock.return_value.failed = False
     sudo_mock.return_value.return_code = 0
     config_value = lookup_string_config('config.to.lookup',
                                         NODE_CONFIG_FILE, 'any_host')
     self.assertEqual(config_value, '/path/hello')
Ejemplo n.º 4
0
def check_server_status():
    """
    Checks if server is running for env.host. Retries connecting to server
    until server is up or till RETRY_TIMEOUT is reached

    Parameters:
        client - client that executes the query

    Returns:
        True or False
    """
    if len(get_coordinator_role()) < 1:
        warn('No coordinator defined.  Cannot verify server status.')
    client = PrestoClient(get_coordinator_role()[0], env.user)
    node_id = lookup_string_config('node.id', os.path.join(constants.REMOTE_CONF_DIR, 'node.properties'), env.host)

    try:
        return query_server_for_status(client, node_id)
    except RetryError:
        return False
Ejemplo n.º 5
0
def check_server_status():
    """
    Checks if server is running for env.host. Retries connecting to server
    until server is up or till RETRY_TIMEOUT is reached

    Parameters:
        client - client that executes the query

    Returns:
        True or False
    """
    if len(get_coordinator_role()) < 1:
        warn('No coordinator defined.  Cannot verify server status.')
    client = PrestoClient(get_coordinator_role()[0], env.user)
    node_id = lookup_string_config(
        'node.id', os.path.join(constants.REMOTE_CONF_DIR, 'node.properties'),
        env.host)

    try:
        return query_server_for_status(client, node_id)
    except RetryError:
        return False