Ejemplo n.º 1
0
    def test_gather_connectors(self, path_exists, ensure_dir_exists,
                               files_exists, get_mock):
        fabric.api.env.host = 'any_host'
        path_exists.return_value = False
        files_exists.return_value = True
        connector.gather_connectors('local_config_dir')
        get_mock.assert_called_once_with(
            constants.REMOTE_CATALOG_DIR, 'local_config_dir/any_host/catalog')

        # if remote catalog dir does not exist
        get_mock.reset_mock()
        files_exists.return_value = False
        results = connector.gather_connectors('local_config_dir')
        self.assertEqual([], results)
        self.assertFalse(get_mock.called)
Ejemplo n.º 2
0
    def test_gather_connectors(self, path_exists, ensure_dir_exists,
                               files_exists, get_mock):
        fabric.api.env.host = 'any_host'
        path_exists.return_value = False
        files_exists.return_value = True
        connector.gather_connectors('local_config_dir')
        get_mock.assert_called_once_with(
            constants.REMOTE_CATALOG_DIR, 'local_config_dir/any_host/catalog')

        # if remote catalog dir does not exist
        get_mock.reset_mock()
        files_exists.return_value = False
        results = connector.gather_connectors('local_config_dir')
        self.assertEqual([], results)
        self.assertFalse(get_mock.called)
Ejemplo n.º 3
0
def upgrade(new_rpm_path, local_config_dir=None, overwrite=False):
    """
    Copy and upgrade a new presto-server rpm to all of the nodes in the
    cluster. Retains existing node configuration.

    The existing topology information is read from the config.json file.
    Unlike install, there is no provision to supply topology information
    interactively.

    The existing cluster configuration is collected from the nodes on the
    cluster and stored on the host running presto-admin. After the
    presto-server packages have been upgraded, presto-admin pushes the
    collected configuration back out to the hosts on the cluster.

    Note that the configuration files in /etc/opt/prestoadmin are not updated
    during upgrade.

    :param new_rpm_path -       The path to the new Presto RPM to
                                install
    :param local_config_dir -   (optional) Directory to store the cluster
                                configuration in. If not specified, a temp
                                directory is used.
    :param overwrite -          (optional) if set to True then existing
                                configuration will be orerwriten.

    :param --nodeps -           (optional) Flag to indicate if server upgrade
                                should ignore checking Presto rpm package
                                dependencies. Equivalent to adding --nodeps
                                flag to rpm -U.
    """
    stop()

    if not local_config_dir:
        local_config_dir = mkdtemp()
        print('Saving cluster configuration to %s' % local_config_dir)

    configure_cmds.gather_directory(local_config_dir, overwrite)
    filenames = connector.gather_connectors(local_config_dir, overwrite)

    package.deploy_upgrade(new_rpm_path)

    configure_cmds.deploy_all(local_config_dir)
    connector.deploy_files(filenames,
                           os.path.join(local_config_dir, env.host, 'catalog'),
                           constants.REMOTE_CATALOG_DIR,
                           PRESTO_STANDALONE_USER_GROUP)
Ejemplo n.º 4
0
def upgrade(new_rpm_path, local_config_dir=None, overwrite=False):
    """
    Copy and upgrade a new presto-server rpm to all of the nodes in the
    cluster. Retains existing node configuration.

    The existing topology information is read from the config.json file.
    Unlike install, there is no provision to supply topology information
    interactively.

    The existing cluster configuration is collected from the nodes on the
    cluster and stored on the host running presto-admin. After the
    presto-server packages have been upgraded, presto-admin pushes the
    collected configuration back out to the hosts on the cluster.

    Note that the configuration files in /etc/opt/prestoadmin are not updated
    during upgrade.

    :param new_rpm_path -       The path to the new Presto RPM to
                                install
    :param local_config_dir -   (optional) Directory to store the cluster
                                configuration in. If not specified, a temp
                                directory is used.
    :param overwrite -          (optional) if set to True then existing
                                configuration will be orerwriten.

    :param --nodeps -           (optional) Flag to indicate if server upgrade
                                should ignore checking Presto rpm package
                                dependencies. Equivalent to adding --nodeps
                                flag to rpm -U.
    """
    stop()

    if not local_config_dir:
        local_config_dir = mkdtemp()
        print('Saving cluster configuration to %s' % local_config_dir)

    configure_cmds.gather_directory(local_config_dir, overwrite)
    filenames = connector.gather_connectors(local_config_dir, overwrite)

    package.deploy_upgrade(new_rpm_path)

    configure_cmds.deploy_all(local_config_dir)
    connector.deploy_files(
        filenames,
        os.path.join(local_config_dir, env.host, 'catalog'),
        constants.REMOTE_CATALOG_DIR, PRESTO_STANDALONE_USER_GROUP)
Ejemplo n.º 5
0
def upgrade(local_package_path, local_config_dir=None):
    """
    Copy and upgrade a new presto-server rpm to all of the nodes in the
    cluster. Retains existing node configuration.

    The existing topology information is read from the config.json file.
    Unlike install, there is no provision to supply topology information
    interactively.

    The existing cluster configuration is collected from the nodes on the
    cluster and stored on the host running presto-admin. After the
    presto-server packages have been upgraded, presto-admin pushes the
    collected configuration back out to the hosts on the cluster.

    Note that the configuration files in /etc/opt/prestoadmin are not updated
    during upgrade.

    :param local_package_path - Absolute path to the presto rpm to be
                                installed
    :param local_config_dir -   (optional) Directory to store the cluster
                                configuration in. If not specified, a temp
                                directory is used.
    """
    stop()

    if not local_config_dir:
        local_config_dir = mkdtemp()
        print('Saving cluster configuration to %s' % local_config_dir)

    configure_cmds.gather_directory(local_config_dir)
    filenames = connector.gather_connectors(local_config_dir)

    package.deploy_upgrade(local_package_path)

    configure_cmds.deploy_all(local_config_dir)
    connector.deploy_files(
        filenames,
        os.path.join(local_config_dir, env.host, 'catalog'),
        constants.REMOTE_CATALOG_DIR
    )
Ejemplo n.º 6
0
def upgrade(local_package_path, local_config_dir=None):
    """
    Copy and upgrade a new presto-server rpm to all of the nodes in the
    cluster. Retains existing node configuration.

    The existing topology information is read from the config.json file.
    Unlike install, there is no provision to supply topology information
    interactively.

    The existing cluster configuration is collected from the nodes on the
    cluster and stored on the host running presto-admin. After the
    presto-server packages have been upgraded, presto-admin pushes the
    collected configuration back out to the hosts on the cluster.

    Note that the configuration files in /etc/opt/prestoadmin are not updated
    during upgrade.

    :param local_package_path - Absolute path to the presto rpm to be
                                installed
    :param local_config_dir -   (optional) Directory to store the cluster
                                configuration in. If not specified, a temp
                                directory is used.
    """
    stop()

    if not local_config_dir:
        local_config_dir = mkdtemp()
        print('Saving cluster configuration to %s' % local_config_dir)

    configure_cmds.gather_directory(local_config_dir)
    filenames = connector.gather_connectors(local_config_dir)

    package.deploy_upgrade(local_package_path)

    configure_cmds.deploy_all(local_config_dir)
    connector.deploy_files(filenames,
                           os.path.join(local_config_dir, env.host, 'catalog'),
                           constants.REMOTE_CATALOG_DIR)