def test_fetch_first_with_exhausted_cache(self): """Regression test for IMPALA-4580. If a result cache is large enough to include all results, and the fetch is restarted after all rows have been fetched, the final fetch (internally) that returns EOS is not idempotent and can crash.""" RESULT_SET_SIZE = 100 execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.confOverlay = dict() execute_statement_req.confOverlay[self.IMPALA_RESULT_CACHING_OPT] =\ str(RESULT_SET_SIZE) execute_statement_req.statement =\ "SELECT * FROM functional.alltypes ORDER BY id LIMIT %s" % RESULT_SET_SIZE execute_statement_resp = self.hs2_client.ExecuteStatement( execute_statement_req) HS2TestSuite.check_response(execute_statement_resp) # First fetch more than the entire result set, ensuring that coordinator has hit EOS # condition. self.fetch_until(execute_statement_resp.operationHandle, TCLIService.TFetchOrientation.FETCH_NEXT, RESULT_SET_SIZE + 1, RESULT_SET_SIZE) # Now restart the fetch, again trying to fetch more than the full result set size so # that the cache is exhausted and the coordinator is checked for more rows. self.fetch_until(execute_statement_resp.operationHandle, TCLIService.TFetchOrientation.FETCH_FIRST, RESULT_SET_SIZE + 1, RESULT_SET_SIZE) self.close(execute_statement_resp.operationHandle)
def fetch_until(self, handle, orientation, size, expected_num_rows=None): """Tries to fetch exactly 'size' rows from the given query handle, with the given fetch orientation, by repeatedly issuing fetch(size - num rows already fetched) calls. Returns fewer than 'size' rows if either a fetch() returns 0 rows (indicating EOS) or 'expected_num_rows' rows are returned. If 'expected_num_rows' is set to None, it defaults to 'size', so that the effect is to both ask for and expect the same number of rows.""" assert expected_num_rows is None or (size >= expected_num_rows) fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = handle fetch_results_req.orientation = orientation fetch_results_req.maxRows = size fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) HS2TestSuite.check_response(fetch_results_resp) num_rows_fetched = self.get_num_rows(fetch_results_resp.results) if expected_num_rows is None: expected_num_rows = size while num_rows_fetched < expected_num_rows: # Always try to fetch at most 'size' fetch_results_req.maxRows = size - num_rows_fetched fetch_results_req.orientation = TCLIService.TFetchOrientation.FETCH_NEXT fetch_results_resp = self.hs2_client.FetchResults( fetch_results_req) HS2TestSuite.check_response(fetch_results_resp) last_fetch_size = self.get_num_rows(fetch_results_resp.results) assert last_fetch_size > 0 num_rows_fetched += last_fetch_size assert num_rows_fetched == expected_num_rows
def result_metadata(self, handle): """ Gets the schema for the query identified by the handle """ req = TCLIService.TGetResultSetMetadataReq() req.operationHandle = handle resp = self.hs2_client.GetResultSetMetadata(req) HS2TestSuite.check_response(resp) return resp
def test_get_primary_keys(self): req = TCLIService.TGetPrimaryKeysReq() req.sessionHandle = self.session_handle req.schemaName = 'functional' req.tableName = 'parent_table' get_primary_keys_resp = self.hs2_client.GetPrimaryKeys(req) TestHS2.check_response(get_primary_keys_resp) fetch_results_resp = self._fetch_results( get_primary_keys_resp.operationHandle, 100) results = fetch_results_resp.results for i in range(2): table_cat = results.columns[0].stringVal.values[i] table_schema = results.columns[1].stringVal.values[i] table_name = results.columns[2].stringVal.values[i] pk_name = results.columns[5].stringVal.values[i] assert table_cat == '' assert table_schema == 'functional' assert table_name == 'parent_table' assert len(pk_name) > 0 # Assert PK column names. assert results.columns[3].stringVal.values[0] == 'id' assert results.columns[3].stringVal.values[1] == 'year'
def test_no_matching_user_and_group_impersonation(self): open_session_req = TCLIService.TOpenSessionReq() open_session_req.username = '******' open_session_req.configuration = dict() open_session_req.configuration['impala.doas.user'] = '******' resp = self.hs2_client.OpenSession(open_session_req) assert 'User \'hue\' is not authorized to delegate to \'abc\'' in str( resp)
def add_session(self): open_session_req = TCLIService.TOpenSessionReq() open_session_req.username = getuser() open_session_req.configuration = dict() open_session_req.client_protocol = protocol_version resp = self.hs2_client.OpenSession(open_session_req) HS2TestSuite.check_response(resp) self.session_handle = resp.sessionHandle assert protocol_version <= resp.serverProtocolVersion try: fn(self) finally: close_session_req = TCLIService.TCloseSessionReq() close_session_req.sessionHandle = resp.sessionHandle HS2TestSuite.check_response( self.hs2_client.CloseSession(close_session_req)) self.session_handle = None
def get_operation_status(self, operation_handle): """Executes GetOperationStatus with the given operation handle and returns the TGetOperationStatusResp""" get_operation_status_req = TCLIService.TGetOperationStatusReq() get_operation_status_req.operationHandle = operation_handle get_operation_status_resp = \ self.hs2_client.GetOperationStatus(get_operation_status_req) return get_operation_status_resp
def test_change_default_database_case_insensitive(self): execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.statement = "SELECT 1 FROM alltypes LIMIT 1" execute_statement_resp = self.hs2_client.ExecuteStatement( execute_statement_req) # Will fail if there's no table called 'alltypes' in the database TestHS2.check_response(execute_statement_resp)
def test_require_user(self): open_session_req = TCLIService.TOpenSessionReq() open_session_req.username = "" open_session_resp = self.hs2_client.OpenSession(open_session_req) TestAdmissionController.check_response(open_session_resp) try: execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = open_session_resp.sessionHandle execute_statement_req.statement = "select count(1) from functional.alltypes" execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req) TestAdmissionController.check_response(execute_statement_resp, TCLIService.TStatusCode.ERROR_STATUS, "User must be specified") finally: close_req = TCLIService.TCloseSessionReq() close_req.sessionHandle = open_session_resp.sessionHandle TestAdmissionController.check_response(self.hs2_client.CloseSession(close_req))
def setup(self): host, port = (self.cluster.impalads[0].service.hostname, self.cluster.impalads[0].service.hs2_port) self.socket = TSocket(host, port) self.transport = TBufferedTransport(self.socket) self.transport.open() self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport) self.hs2_client = TCLIService.Client(self.protocol)
def test_bad_default_database(self): execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.statement = "SELECT 1 FROM alltypes LIMIT 1" execute_statement_resp = self.hs2_client.ExecuteStatement( execute_statement_req) TestHS2.check_response(execute_statement_resp, TCLIService.TStatusCode.ERROR_STATUS)
def test_close_session(self): """Test that an open session can be closed""" open_session_req = TCLIService.TOpenSessionReq() resp = self.hs2_client.OpenSession(open_session_req) TestHS2.check_response(resp) # Check that CloseSession validates session secret and acts as if the session didn't # exist. invalid_close_session_req = TCLIService.TCloseSessionReq() invalid_close_session_req.sessionHandle = create_session_handle_without_secret( resp.sessionHandle) TestHS2.check_invalid_session( self.hs2_client.CloseSession(invalid_close_session_req)) close_session_req = TCLIService.TCloseSessionReq() close_session_req.sessionHandle = resp.sessionHandle TestHS2.check_response(self.hs2_client.CloseSession(close_session_req))
def check_user_and_effective_user(self, proxy_user): execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.confOverlay = dict() execute_statement_req.statement = "SELECT effective_user(), user()" execute_statement_resp = self.hs2_client.ExecuteStatement( execute_statement_req) HS2TestSuite.check_response(execute_statement_resp) fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = execute_statement_resp.operationHandle fetch_results_req.maxRows = 1 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) HS2TestSuite.check_response(fetch_results_resp) assert self.column_results_to_string( fetch_results_resp.results.columns) == (1, "%s, %s\n" % (proxy_user, USER_NAME))
def test_concurrent_unregister(self): """Test that concurrently unregistering a query from multiple clients is safe and that the profile can be fetched during the process.""" # Attach a UUID to the query text to make it easy to identify in web UI. query_uuid = str(uuid.uuid4()) statement = "/*{0}*/ SELECT COUNT(2) FROM functional.alltypes".format( query_uuid) execute_statement_resp = self.execute_statement(statement) op_handle = execute_statement_resp.operationHandle fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = op_handle fetch_results_req.maxRows = 100 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) TestHS2.check_response(fetch_results_resp) # Create a profile fetch thread and multiple unregister threads. NUM_UNREGISTER_THREADS = 10 threads = [] profile_fetch_exception = [None] unreg_exceptions = [None] * NUM_UNREGISTER_THREADS sockets = [] try: # Start a profile fetch thread first that will fetch the profile # as the query is unregistered. threads.append( threading.Thread(target=self._fetch_profile_loop, args=(profile_fetch_exception, query_uuid, op_handle))) # Start threads that will race to unregister the query. for i in xrange(NUM_UNREGISTER_THREADS): socket, client = self._open_hs2_connection() sockets.append(socket) threads.append( threading.Thread(target=self._unregister_query, args=(i, unreg_exceptions, client, op_handle))) for thread in threads: thread.start() for thread in threads: thread.join() finally: for socket in sockets: socket.close() if profile_fetch_exception[0] is not None: raise profile_fetch_exception[0] # Validate the exceptions and ensure only one thread successfully unregistered # the query. num_successful = 0 for exception in unreg_exceptions: if exception is None: num_successful += 1 elif "Invalid or unknown query handle" not in str(exception): raise exception assert num_successful == 1, "Only one client should have been able to unregister"
def test_invalid_secret(self): """Test that the FetchResults, GetResultSetMetadata and CloseOperation APIs validate the session secret.""" execute_req = TCLIService.TExecuteStatementReq( self.session_handle, "select 'something something'") execute_resp = self.hs2_client.ExecuteStatement(execute_req) HS2TestSuite.check_response(execute_resp) good_handle = execute_resp.operationHandle bad_handle = create_op_handle_without_secret(good_handle) # Fetching and closing operations with an invalid handle should be a no-op, i.e. # the later operations with the good handle should succeed. HS2TestSuite.check_invalid_query(self.hs2_client.FetchResults( TCLIService.TFetchResultsReq(operationHandle=bad_handle, maxRows=1024)), expect_legacy_err=True) HS2TestSuite.check_invalid_query(self.hs2_client.GetResultSetMetadata( TCLIService.TGetResultSetMetadataReq(operationHandle=bad_handle)), expect_legacy_err=True) HS2TestSuite.check_invalid_query(self.hs2_client.CloseOperation( TCLIService.TCloseOperationReq(operationHandle=bad_handle)), expect_legacy_err=True) # Ensure that the good handle remained valid. HS2TestSuite.check_response(self.hs2_client.FetchResults( TCLIService.TFetchResultsReq(operationHandle=good_handle, maxRows=1024))) HS2TestSuite.check_response(self.hs2_client.GetResultSetMetadata( TCLIService.TGetResultSetMetadataReq(operationHandle=good_handle))) HS2TestSuite.check_response(self.hs2_client.CloseOperation( TCLIService.TCloseOperationReq(operationHandle=good_handle)))
def test_get_schemas(self): get_schemas_req = TCLIService.TGetSchemasReq() get_schemas_req.sessionHandle = self.session_handle get_schemas_resp = self.hs2_client.GetSchemas(get_schemas_req) TestHS2.check_response(get_schemas_resp) fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = get_schemas_resp.operationHandle fetch_results_req.maxRows = 100 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) TestHS2.check_response(fetch_results_resp) query_id = operation_id_to_query_id( get_schemas_resp.operationHandle.operationId) profile_page = self.impalad_test_service.read_query_profile_page( query_id) # Test fix for IMPALA-619 assert "Sql Statement: GET_SCHEMAS" in profile_page assert "Query Type: DDL" in profile_page
def _fetch_results(self, operation_handle, max_rows): """Fetch results from 'operation_handle' with up to 'max_rows' rows using self.hs2_client, returning the TFetchResultsResp object.""" fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = operation_handle fetch_results_req.maxRows = max_rows fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) TestHS2.check_response(fetch_results_resp) return fetch_results_resp
def _unregister_query(self, thread_num, exceptions, client, op_handle): # Add some delay/jitter so that unregisters come in at different times. time.sleep(0.01 + 0.005 * random.random()) try: close_operation_req = TCLIService.TCloseOperationReq() close_operation_req.operationHandle = op_handle TestHS2.check_response(client.CloseOperation(close_operation_req)) except BaseException as e: exceptions[thread_num] = e
def create_hs2_client(self): """Creates a new HS2 client connection to the impalad""" host, port = (self.hostname, self.hs2_port) socket = TSocket(host, port) transport = TBufferedTransport(socket) transport.open() protocol = TBinaryProtocol.TBinaryProtocol(transport) hs2_client = TCLIService.Client(protocol) return hs2_client
def test_open_sesssion_query_options(self): """Check that OpenSession sets query options""" open_session_req = TCLIService.TOpenSessionReq() open_session_req.configuration = {'MAX_ERRORS': '45678', 'NUM_NODES': '1234', 'MAX_NUM_RUNTIME_FILTERS': '333'} open_session_resp = self.hs2_client.OpenSession(open_session_req) TestHS2.check_response(open_session_resp) for k, v in open_session_req.configuration.items(): assert open_session_resp.configuration[k] == v
def test_get_operation_status(self): """Tests that GetOperationStatus returns a valid result for a running query""" statement = "SELECT COUNT(*) FROM functional.alltypes" execute_statement_resp = self.execute_statement(statement) get_operation_status_resp = \ self.get_operation_status(execute_statement_resp.operationHandle) TestHS2.check_response(get_operation_status_resp) # If ExecuteStatement() has completed but the results haven't been fetched yet, the # query must have reached either PENDING or RUNNING or FINISHED. assert get_operation_status_resp.operationState in \ [TCLIService.TOperationState.PENDING_STATE, TCLIService.TOperationState.RUNNING_STATE, TCLIService.TOperationState.FINISHED_STATE] fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = execute_statement_resp.operationHandle fetch_results_req.maxRows = 100 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) get_operation_status_resp = \ self.get_operation_status(execute_statement_resp.operationHandle) TestHS2.check_response(get_operation_status_resp) # After fetching the results, the query must be in state FINISHED. assert get_operation_status_resp.operationState == \ TCLIService.TOperationState.FINISHED_STATE # Validate that the operation secret is checked. TestHS2.check_invalid_query(self.get_operation_status( create_op_handle_without_secret( execute_statement_resp.operationHandle)), expect_legacy_err=True) close_operation_req = TCLIService.TCloseOperationReq() close_operation_req.operationHandle = execute_statement_resp.operationHandle TestHS2.check_response( self.hs2_client.CloseOperation(close_operation_req)) get_operation_status_resp = \ self.get_operation_status(execute_statement_resp.operationHandle) # GetOperationState should return 'Invalid or unknown query handle' if the query has # been closed. TestHS2.check_response(get_operation_status_resp, \ TCLIService.TStatusCode.ERROR_STATUS)
def test_get_exec_summary(self): statement = "SELECT COUNT(1) FROM functional.alltypes" execute_statement_resp = self.execute_statement(statement) exec_summary_req = ImpalaHiveServer2Service.TGetExecSummaryReq() exec_summary_req.operationHandle = execute_statement_resp.operationHandle exec_summary_req.sessionHandle = self.session_handle exec_summary_resp = self.hs2_client.GetExecSummary(exec_summary_req) # Test getting the summary while query is running. We can't verify anything # about the summary (depends how much progress query has made) but the call # should work. TestHS2.check_response(exec_summary_resp) # Wait for query to start running so we can get a non-empty ExecSummary. self.wait_for_admission_control(execute_statement_resp.operationHandle) exec_summary_resp = self.hs2_client.GetExecSummary(exec_summary_req) TestHS2.check_response(exec_summary_resp) assert len(exec_summary_resp.summary.nodes) > 0 # Test that session secret is validated. Note that operation secret does not need to # be validated in addition if the session secret is valid and the operation belongs # to the session, because the user has full access to the session. TestHS2.check_invalid_session( self.hs2_client.GetExecSummary( ImpalaHiveServer2Service.TGetExecSummaryReq( execute_statement_resp.operationHandle, create_session_handle_without_secret( self.session_handle)))) # Attempt to access query with different user should fail. evil_user = getuser() + "_evil_twin" with ScopedSession(self.hs2_client, username=evil_user) as session: session_handle2 = session.sessionHandle TestHS2.check_profile_access_denied(self.hs2_client.GetExecSummary( ImpalaHiveServer2Service.TGetExecSummaryReq( execute_statement_resp.operationHandle, session_handle2)), user=evil_user) # Now close the query and verify the exec summary is available. close_operation_req = TCLIService.TCloseOperationReq() close_operation_req.operationHandle = execute_statement_resp.operationHandle TestHS2.check_response( self.hs2_client.CloseOperation(close_operation_req)) # Attempt to access query with different user from log should fail. TestHS2.check_profile_access_denied( self.hs2_client.GetRuntimeProfile( ImpalaHiveServer2Service.TGetRuntimeProfileReq( execute_statement_resp.operationHandle, session_handle2)), user=evil_user) exec_summary_resp = self.hs2_client.GetExecSummary(exec_summary_req) TestHS2.check_response(exec_summary_resp) assert len(exec_summary_resp.summary.nodes) > 0
def get_log(self, query_stmt): execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.statement = query_stmt execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req) TestHS2.check_response(execute_statement_resp) # Fetch results to make sure errors are generated fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = execute_statement_resp.operationHandle fetch_results_req.maxRows = 100 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) TestHS2.check_response(fetch_results_resp) get_log_req = TCLIService.TGetLogReq() get_log_req.operationHandle = execute_statement_resp.operationHandle get_log_resp = self.hs2_client.GetLog(get_log_req) TestHS2.check_response(get_log_resp) return get_log_resp.log
def test_get_operation_status(self): """Tests that GetOperationStatus returns a valid result for a running query""" execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.statement = "SELECT COUNT(*) FROM functional.alltypes" execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req) TestHS2.check_response(execute_statement_resp) get_operation_status_req = TCLIService.TGetOperationStatusReq() get_operation_status_req.operationHandle = execute_statement_resp.operationHandle get_operation_status_resp = \ self.hs2_client.GetOperationStatus(get_operation_status_req) TestHS2.check_response(get_operation_status_resp) assert get_operation_status_resp.operationState in \ [TCLIService.TOperationState.INITIALIZED_STATE, TCLIService.TOperationState.RUNNING_STATE, TCLIService.TOperationState.FINISHED_STATE]
def __run_stmt_and_verify_profile_access(self, stmt, has_access, close_operation): """Runs 'stmt' and retrieves the runtime profile and exec summary. If 'has_access' is true, it verifies that no runtime profile or exec summary are returned. If 'close_operation' is true, make sure the operation is closed before retrieving the profile and exec summary.""" from tests.hs2.test_hs2 import TestHS2 execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.statement = stmt execute_statement_resp = self.hs2_client.ExecuteStatement( execute_statement_req) TestHS2.check_response(execute_statement_resp) if close_operation: close_operation_req = TCLIService.TCloseOperationReq() close_operation_req.operationHandle = execute_statement_resp.operationHandle TestHS2.check_response( self.hs2_client.CloseOperation(close_operation_req)) get_profile_req = ImpalaHiveServer2Service.TGetRuntimeProfileReq() get_profile_req.operationHandle = execute_statement_resp.operationHandle get_profile_req.sessionHandle = self.session_handle get_profile_resp = self.hs2_client.GetRuntimeProfile(get_profile_req) if has_access: TestHS2.check_response(get_profile_resp) assert "Plan: " in get_profile_resp.profile else: assert "User %s is not authorized to access the runtime profile or "\ "execution summary." % (getuser()) in str(get_profile_resp) exec_summary_req = ImpalaHiveServer2Service.TGetExecSummaryReq() exec_summary_req.operationHandle = execute_statement_resp.operationHandle exec_summary_req.sessionHandle = self.session_handle exec_summary_resp = self.hs2_client.GetExecSummary(exec_summary_req) if has_access: TestHS2.check_response(exec_summary_resp) assert exec_summary_resp.summary.nodes is not None else: assert "User %s is not authorized to access the runtime profile or "\ "execution summary." % (getuser()) in str(exec_summary_resp)
def get_log(self, query_stmt): execute_statement_resp = self.execute_statement(query_stmt) # Fetch results to make sure errors are generated. Errors are only guaranteed to be # seen by the coordinator after FetchResults() returns eos. has_more_results = True while has_more_results: fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = execute_statement_resp.operationHandle fetch_results_req.maxRows = 100 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) TestHS2.check_response(fetch_results_resp) has_more_results = fetch_results_resp.hasMoreRows get_log_req = TCLIService.TGetLogReq() get_log_req.operationHandle = execute_statement_resp.operationHandle get_log_resp = self.hs2_client.GetLog(get_log_req) TestHS2.check_response(get_log_resp) return get_log_resp.log
def test_set_invalid_query_option(self): """Tests that GetOperationStatus returns a valid result for a running query""" execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.confOverlay = {"foo": "bar"} execute_statement_req.statement = "select 1" execute_statement_resp = self.hs2_client.ExecuteStatement( execute_statement_req) TestQueryOptionsHS2.check_response( execute_statement_resp, TCLIService.TStatusCode.ERROR_STATUS, "Invalid query option: foo")
def test_malformed_get_operation_status(self): """Tests that a short guid / secret returns an error (regression would be to crash impalad)""" operation_handle = TCLIService.TOperationHandle() operation_handle.operationId = TCLIService.THandleIdentifier() operation_handle.operationId.guid = "short" operation_handle.operationId.secret = "short_secret" assert len(operation_handle.operationId.guid) != 16 assert len(operation_handle.operationId.secret) != 16 operation_handle.operationType = TCLIService.TOperationType.EXECUTE_STATEMENT operation_handle.hasResultSet = False get_operation_status_resp = self.get_operation_status(operation_handle) TestHS2.check_response(get_operation_status_resp, \ TCLIService.TStatusCode.ERROR_STATUS) err_msg = "(guid size: %d, expected 16, secret size: %d, expected 16)" \ % (len(operation_handle.operationId.guid), len(operation_handle.operationId.secret)) assert err_msg in get_operation_status_resp.status.errorMessage
def test_open_session_unsupported_protocol(self): """Test that we get the right protocol version back if we ask for one larger than the server supports. This test will fail as we support newer version of HS2, and should be updated.""" open_session_req = TCLIService.TOpenSessionReq() open_session_req.protocol_version = \ TCLIService.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V7 open_session_resp = self.hs2_client.OpenSession(open_session_req) TestHS2.check_response(open_session_resp) assert open_session_resp.serverProtocolVersion == \ TCLIService.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6
def test_open_session_http_addr(self): """Check that OpenSession returns the coordinator's http address.""" open_session_req = TCLIService.TOpenSessionReq() open_session_resp = self.hs2_client.OpenSession(open_session_req) TestHS2.check_response(open_session_resp) http_addr = open_session_resp.configuration['http_addr'] resp = urlopen("http://%s/queries?json" % http_addr) assert resp.msg == 'OK' queries_json = json.loads(resp.read()) assert 'completed_queries' in queries_json assert 'in_flight_queries' in queries_json