2121import pytest
2222from functools import wraps
2323from random import choice
24- from tests .beeswax .impala_beeswax import ImpalaBeeswaxClient
2524from tests .common .impala_service import ImpaladService
25+ from tests .common .impala_connection import ImpalaConnection , create_connection
2626from tests .common .test_dimensions import *
2727from tests .common .test_result_verifier import *
2828from tests .common .test_vector import *
3838from thrift .transport import TTransport , TSocket
3939from thrift .protocol import TBinaryProtocol
4040
41- logging .basicConfig (level = logging .INFO , format = '%(threadName)s: %(message)s' )
41+ logging .basicConfig (level = logging .INFO , format = '-- %(message)s' )
4242LOG = logging .getLogger ('impala_test_suite' )
4343
4444IMPALAD_HOST_PORT_LIST = pytest .config .option .impalad .split (',' )
@@ -80,7 +80,7 @@ def setup_class(cls):
8080 cls .hive_client = ThriftHiveMetastore .Client (protocol )
8181 cls .hive_transport .open ()
8282
83- # The ImpalaBeeswaxClient is used to execute queries in the test suite
83+ # Create a connection to Impala.
8484 cls .client = cls .create_impala_client (IMPALAD )
8585
8686 cls .impalad_test_service = ImpaladService (IMPALAD .split (':' )[0 ])
@@ -98,19 +98,19 @@ def teardown_class(cls):
9898 cls .hive_transport .close ()
9999
100100 if cls .client :
101- cls .client .close_connection ()
101+ cls .client .close ()
102102
103103 @classmethod
104104 def create_impala_client (cls , host_port = IMPALAD ):
105- client = ImpalaBeeswaxClient ( host_port ,
105+ client = create_connection ( host_port = host_port ,
106106 use_kerberos = pytest .config .option .use_kerberos )
107107 client .connect ()
108108 return client
109109
110110 def cleanup_db (self , db_name ):
111111 # To drop a db, we need to first drop all the tables in that db
112112 self .client .execute ("use default" )
113- self .client .set_query_options ({'sync_ddl' : 1 })
113+ self .client .set_configuration ({'sync_ddl' : 1 })
114114 if db_name in self .client .execute ("show databases" , ).data :
115115 for tbl_name in self .client .execute ("show tables in " + db_name ).data :
116116 full_tbl_name = '%s.%s' % (db_name , tbl_name )
@@ -148,6 +148,7 @@ def run_test_case(self, test_file_name, vector, use_db=None, multiple_impalad=Fa
148148 # user specified database for all targeted impalad.
149149 for impalad_client in target_impalad_clients :
150150 ImpalaTestSuite .change_database (impalad_client , table_format_info , use_db )
151+ impalad_client .set_configuration (exec_options )
151152
152153 sections = self .load_query_test_file (self .get_workload (), test_file_name )
153154 for test_section in sections :
@@ -172,7 +173,7 @@ def run_test_case(self, test_file_name, vector, use_db=None, multiple_impalad=Fa
172173 target_impalad_client = choice (target_impalad_clients )
173174 for query in query .split (';' ):
174175 result = \
175- self .execute_query_expect_success (target_impalad_client , query , exec_options )
176+ self .execute_query_expect_success (target_impalad_client , query )
176177 assert result is not None
177178
178179 verify_raw_results (test_section , result ,
@@ -219,7 +220,7 @@ def change_database(cls, impala_client, table_format=None, db_name=None):
219220 query = 'use %s' % db_name
220221 # Clear the exec_options before executing a USE statement.
221222 # The USE statement should not fail for negative exec_option tests.
222- impala_client .clear_query_options ()
223+ impala_client .clear_configuration ()
223224 impala_client .execute (query )
224225
225226 def execute_wrapper (function ):
@@ -247,28 +248,28 @@ def wrapper(*args, **kwargs):
247248 return wrapper
248249
249250 @execute_wrapper
250- def execute_query_expect_success (self , impalad_client , query , query_exec_options = None ):
251+ def execute_query_expect_success (self , impalad_client , query , query_options = None ):
251252 """Executes a query and asserts if the query fails"""
252- result = self .__execute_query (impalad_client , query , query_exec_options )
253+ result = self .__execute_query (impalad_client , query , query_options )
253254 assert result .success
254255 return result
255256
256257 @execute_wrapper
257- def execute_query (self , query , query_exec_options = None ):
258- return self .__execute_query (self .client , query , query_exec_options )
258+ def execute_query (self , query , query_options = None ):
259+ return self .__execute_query (self .client , query , query_options )
259260
260261 def execute_query_using_client (self , client , query , vector ):
261262 self .change_database (client , vector .get_value ('table_format' ))
262263 return client .execute (query )
263264
264265 @execute_wrapper
265- def execute_query_async (self , query , query_exec_options = None ):
266- self .__set_exec_options ( self . client , query_exec_options )
267- return self .client .execute_query_async (query )
266+ def execute_query_async (self , query , query_options = None ):
267+ self .client . set_configuration ( query_options )
268+ return self .client .execute_async (query )
268269
269270 @execute_wrapper
270- def execute_scalar (self , query , query_exec_options = None ):
271- result = self .__execute_query (self .client , query , query_exec_options )
271+ def execute_scalar (self , query , query_options = None ):
272+ result = self .__execute_query (self .client , query , query_options )
272273 assert len (result .data ) <= 1 , 'Multiple values returned from scalar'
273274 return result .data [0 ] if len (result .data ) == 1 else None
274275
@@ -306,25 +307,18 @@ def __drop_partitions(self, db_name, table_name):
306307 for partition in self .hive_client .get_partition_names (db_name , table_name , 0 ):
307308 self .hive_client .drop_partition_by_name (db_name , table_name , partition , True )
308309
309- def __execute_query (self , impalad_client , query , query_exec_options = None ):
310+ def __execute_query (self , impalad_client , query , query_options = None ):
310311 """Executes the given query against the specified Impalad"""
311- LOG .info ('Executing Query(%s): \n %s\n ' % (impalad_client .impalad , query ))
312- self .__set_exec_options (impalad_client , query_exec_options )
312+ if query_options is not None : impalad_client .set_configuration (query_options )
313313 return impalad_client .execute (query )
314314
315- def __execute_query_new_client (self , query , query_exec_options = None ,
315+ def __execute_query_new_client (self , query , query_options = None ,
316316 use_kerberos = False ):
317317 """Executes the given query against the specified Impalad"""
318318 new_client = self .create_impala_client ()
319- self . __set_exec_options ( new_client , query_exec_options )
319+ new_client . set_configuration ( query_options )
320320 return new_client .execute (query )
321321
322- def __set_exec_options (self , impalad_client , query_exec_options ):
323- # Set the specified query exec options, if specified
324- impalad_client .clear_query_options ()
325- if query_exec_options is not None :
326- impalad_client .set_query_options (query_exec_options )
327-
328322 def __reset_table (self , db_name , table_name ):
329323 """Resets a table (drops and recreates the table)"""
330324 table = self .hive_client .get_table (db_name , table_name )
0 commit comments