def test_new_teradata_version(self):
     self.assertEqual(
         (0, 148, 't'), strip_tag(('0', '148', 't'))
     )
     self.assertEqual(
         (0, 148, 't', 0, 1), strip_tag(('0', '148', 't', '0', '1'))
     )
Example #2
0
def get_status_from_coordinator():
    with closing(PrestoClient(get_coordinator_role()[0], env.user)) as client:
        try:
            coordinator_status = run_sql(client, SYSTEM_RUNTIME_NODES)
            catalog_status = get_catalog_info_from(client)
        except BaseException as e:
            # Just log errors that come from a missing port or anything else; if
            # we can't connect to the coordinator, we just want to print out a
            # minimal status anyway.
            _LOGGER.warn(e.message)
            coordinator_status = []
            catalog_status = []

        with settings(hide('running')):
            node_information = execute(collect_node_information,
                                       hosts=get_host_list())

        for host in get_host_list():
            if isinstance(node_information[host], Exception):
                external_ip = 'Unknown'
                is_running = False
                error_message = node_information[host].message
            else:
                (external_ip, is_running,
                 error_message) = node_information[host]

            print_status_header(external_ip, is_running, host)
            if error_message:
                print('\t' + error_message)
            elif not coordinator_status:
                print(
                    '\tNo information available: unable to query coordinator')
            elif not is_running:
                print('\tNo information available')
            else:
                version_string = get_presto_version()
                version = strip_tag(split_version(version_string))
                query, processor = NODE_INFO_PER_URI_SQL.for_version(version)
                # just get the node_info row for the host if server is up
                node_info_row = run_sql(client, query % external_ip)
                node_status = processor(node_info_row)
                if node_status:
                    print_node_info(node_status, catalog_status)
                else:
                    print(
                        '\tNo information available: the coordinator has not yet'
                        ' discovered this node')
Example #3
0
def get_status_from_coordinator():
    client = PrestoClient(get_coordinator_role()[0], env.user)
    try:
        coordinator_status = run_sql(client, SYSTEM_RUNTIME_NODES)
        connector_status = get_connector_info_from(client)
    except BaseException as e:
        # Just log errors that come from a missing port or anything else; if
        # we can't connect to the coordinator, we just want to print out a
        # minimal status anyway.
        _LOGGER.warn(e.message)
        coordinator_status = []
        connector_status = []

    with settings(hide('running')):
        node_information = execute(collect_node_information,
                                   hosts=get_host_list())

    for host in get_host_list():
        if isinstance(node_information[host], Exception):
            external_ip = 'Unknown'
            is_running = False
            error_message = node_information[host].message
        else:
            (external_ip, is_running, error_message) = node_information[host]

        print_status_header(external_ip, is_running, host)
        if error_message:
            print('\t' + error_message)
        elif not coordinator_status:
            print('\tNo information available: unable to query coordinator')
        elif not is_running:
            print('\tNo information available')
        else:
            version_string = get_presto_version()
            version = strip_tag(split_version(version_string))
            query, processor = NODE_INFO_PER_URI_SQL.for_version(version)
            # just get the node_info row for the host if server is up
            node_info_row = run_sql(client, query % external_ip)
            node_status = processor(node_info_row)
            if node_status:
                print_node_info(node_status, connector_status)
            else:
                print('\tNo information available: the coordinator has not yet'
                      ' discovered this node')
 def test_all_numeric(self):
     self.assertEqual((1, 2), strip_tag(('1', '2')))
     self.assertEqual((1, 2), strip_tag(['1', '2']))
 def test_teradata_version(self):
     self.assertEqual(
         (0, '115t'), strip_tag(('0', '115t')))
     self.assertEqual(
         (0, '123t'), strip_tag(('0', '123t', 'SNAPSHOT')))
 def test_ancient_tags(self):
     # Teradata and non-Teradata versions
     self.assertEqual(
         (0, '97t'), strip_tag(('0', '97t-SNAPSHOT')))
     self.assertEqual(
         (0, 99), strip_tag(('0', '99-SNAPSHOT')))
 def test_trailing_non_numeric(self):
     self.assertEqual(
         (1, 2), strip_tag(('1', '2', 'THREE', 'FOUR')))
     self.assertEqual(
         (1, 2), strip_tag(['1', '2', 'THR']))
 def test_all_numeric(self):
     self.assertEqual((1, 2), strip_tag(('1', '2')))
     self.assertEqual((1, 2), strip_tag(['1', '2']))
 def test_old_teradata_version(self):
     self.assertEqual((0, '115t'), strip_tag(('0', '115t')))
     self.assertEqual((0, '123t'), strip_tag(('0', '123t', 'SNAPSHOT')))
 def test_no_numeric(self):
     self.assertEqual((), strip_tag(('ONE', 'TWO', 'THREE')))
 def test_non_trailing_non_numeric(self):
     self.assertEqual((1, 3, 't', 4, 't'),
                      strip_tag(('1', 'TWO', '3', 't', '4', 't')))
 def test_ancient_tags(self):
     # Teradata and non-Teradata versions
     self.assertEqual((0, '97t'), strip_tag(('0', '97t', 'SNAPSHOT')))
     self.assertEqual((0, 99), strip_tag(('0', '99', 'SNAPSHOT')))
 def test_trailing_non_numeric(self):
     self.assertEqual((1, 2), strip_tag(('1', '2', 'THREE', 'FOUR')))
     self.assertEqual((1, 2), strip_tag(['1', '2', 'THR']))
 def test_no_numeric(self):
     self.assertEqual(
         (), strip_tag(('ONE', 'TWO', 'THREE'))
     )
 def test_non_trailing_non_numeric(self):
     self.assertEqual(
         (1, 3, 't', 4, 't'), strip_tag(('1', 'TWO', '3', 't', '4', 't')))