def test_impala_flags(): test_impala_conf_dir = tempfile.mkdtemp() resets = [] try: if conf.QUERYCACHE_ROWS.get() != 50000: resets.append(conf.QUERYCACHE_ROWS.set_for_testing(50000)) assert_equal(conf.QUERYCACHE_ROWS.get(), 50000) assert_equal(conf.IMPERSONATION_ENABLED.get(), False) flags = """ -webserver_certificate_file=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem -ssl_server_certificate=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem -max_result_cache_size=100000 -authorized_proxy_user_config=hue=* """ file(os.path.join(test_impala_conf_dir, 'impalad_flags'), 'w').write(flags) resets.append(conf.IMPALA_CONF_DIR.set_for_testing(test_impala_conf_dir)) impala_flags.reset() assert_equal(impala_flags.get_webserver_certificate_file(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem') assert_equal(impala_flags.get_ssl_server_certificate(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem') assert_equal(impala_flags.get_max_result_cache_size(), 100000) assert_equal(impala_flags.get_authorized_proxy_user_config(), 'hue=*') # From Config assert_equal(conf.QUERYCACHE_ROWS.get(), 100000) assert_equal(conf.IMPERSONATION_ENABLED.get(), True) finally: impala_flags.reset() for reset in resets: reset()
def test_impala_flags(): test_impala_conf_dir = tempfile.mkdtemp() finish = None try: assert_equal(conf.QUERYCACHE_ROWS.get(), 50000) assert_equal(conf.IMPERSONATION_ENABLED.get(), False) flags = """ -webserver_certificate_file=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem -ssl_server_certificate=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem -max_result_cache_size=100000 -authorized_proxy_user_config=hue=* """ file(os.path.join(test_impala_conf_dir, 'impalad_flags'), 'w').write(flags) finish = conf.IMPALA_CONF_DIR.set_for_testing(test_impala_conf_dir) impala_flags.reset() assert_equal(impala_flags.get_webserver_certificate_file(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem') assert_equal(impala_flags.get_ssl_server_certificate(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem') assert_equal(impala_flags.get_max_result_cache_size(), 100000) assert_equal(impala_flags.get_authorized_proxy_user_config(), 'hue=*') # From Config assert_equal(conf.QUERYCACHE_ROWS.get(), 100000) assert_equal(conf.IMPERSONATION_ENABLED.get(), True) finally: impala_flags.reset() if finish: finish()
def _get_impala_server_url(session): properties = session.get_properties() http_addr = properties.get('coordinator_host', properties.get('http_addr')) # Remove scheme if found http_addr = http_addr.replace('http://', '').replace('https://', '') return ('https://' if get_webserver_certificate_file() else 'http://') + http_addr
def _get_impala_result_size(self, notebook, snippet): total_records_match = None total_records, total_size, msg = None, None, None query_id = self._get_impala_query_id(snippet) session = Session.objects.get_session(self.user, application='impala') protocol = 'https' if get_webserver_certificate_file() else 'http' server_url = '%s://%s' % (protocol, self._get_impala_server_url(session)) if query_id: LOG.info( "Attempting to get Impala query profile at server_url %s for query ID: %s" % (server_url, query_id)) retries = 0 max_retries = 10 total_records_match = None while not total_records_match and retries < max_retries: time.sleep(1.0) fragment = self._get_impala_query_profile(server_url, query_id=query_id) total_records_re = "Coordinator Fragment F\d\d.+?RowsReturned: \d+(?:.\d+[KMB])? \((?P<total_records>\d+)\).*?(Averaged Fragment F\d\d)" total_records_match = re.search(total_records_re, fragment, re.MULTILINE | re.DOTALL) retries += 1 if total_records_match: total_records = int(total_records_match.group('total_records')) return total_records, total_size, msg
def _get_impala_server_url(session): impala_settings = session.get_formatted_properties() http_addr = next((setting['value'] for setting in impala_settings if setting['key'].lower() == 'http_addr'), None) # Remove scheme if found http_addr = http_addr.replace('http://', '').replace('https://', '') return ('https://' if get_webserver_certificate_file() else 'http://') + http_addr
def _get_impala_server_url(session): properties = session.get_properties() http_addr = "" if COORDINATOR_URL.get(): http_addr = COORDINATOR_URL.get() else: http_addr = properties.get('coordinator_host', properties.get('http_addr')) http_addr = http_addr.replace('http://', '').replace('https://', '') return ('https://' if get_webserver_certificate_file() else 'http://') + http_addr
def _get_impala_server_url(session): http_addr = "" if COORDINATOR_URL.get(): http_addr = COORDINATOR_URL.get() else: if not session: raise PopupException(_('No active Thrift session with Impala Coordinator, please run a query first.')) properties = session.get_properties() http_addr = properties.get('coordinator_host', properties.get('http_addr')) http_addr = http_addr.replace('http://', '').replace('https://', '') return ('https://' if get_webserver_certificate_file() else 'http://') + http_addr
def test_impala_flags(): test_impala_conf_dir = tempfile.mkdtemp() resets = [] expected_rows = 50000 try: if conf.QUERYCACHE_ROWS.get() != expected_rows: resets.append(conf.QUERYCACHE_ROWS.set_for_testing(expected_rows)) assert_equal(conf.QUERYCACHE_ROWS.get(), expected_rows) assert_equal(conf.IMPERSONATION_ENABLED.get(), False) flags = """ -webserver_certificate_file=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem -ssl_server_certificate=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem -max_result_cache_size=%d -authorized_proxy_user_config=hue=* """ % expected_rows open_file(os.path.join(test_impala_conf_dir, 'impalad_flags'), 'w').write(flags) resets.append( conf.IMPALA_CONF_DIR.set_for_testing(test_impala_conf_dir)) impala_flags.reset() assert_equal(impala_flags.get_webserver_certificate_file(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem') assert_equal(impala_flags.get_ssl_server_certificate(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem') assert_equal(impala_flags.get_max_result_cache_size(), expected_rows) assert_equal(impala_flags.get_authorized_proxy_user_config(), 'hue=*') # From Config assert_equal(conf.QUERYCACHE_ROWS.get(), expected_rows) assert_equal(conf.IMPERSONATION_ENABLED.get(), True) finally: impala_flags.reset() for reset in resets: reset()
def _get_impala_server_url(self, session): impala_settings = session.get_formatted_properties() http_addr = next((setting['value'] for setting in impala_settings if setting['key'].lower() == 'http_addr'), None) return ('https://' if get_webserver_certificate_file() else 'http://') + http_addr
def _get_impala_server_url(session): properties = session.get_properties() http_addr = properties.get('coordinator_host', properties.get('http_addr')) # Remove scheme if found http_addr = http_addr.replace('http://', '').replace('https://', '') return ('https://' if get_webserver_certificate_file() else 'http://') + http_addr
def _get_impala_server_url(session): impala_settings = session.get_formatted_properties() http_addr = next((setting['value'] for setting in impala_settings if setting['key'].lower() == 'http_addr'), None) # Remove scheme if found http_addr = http_addr.replace('http://', '').replace('https://', '') return ('https://' if get_webserver_certificate_file() else 'http://') + http_addr