def test_queries_closed(self): """Regression test for IMPALA-897.""" args = '-f %s/test_close_queries.sql --quiet -B' % QUERY_FILE_PATH cmd = "%s %s" % (SHELL_CMD, args) # Execute the shell command async p = ImpalaShell(args) impalad_service = ImpaladService(IMPALAD.split(':')[0]) # The last query in the test SQL script will sleep for 10 seconds, so sleep # here for 5 seconds and verify the number of in-flight queries is 1. sleep(5) assert 1 == impalad_service.get_num_in_flight_queries() assert p.get_result().rc == 0 assert 0 == impalad_service.get_num_in_flight_queries()
def wait_for_query_state(self, stmt, state, max_retry=15): """Checks the in flight queries on Impala debug page. Polls the state of the query statement from parameter every second until the query gets to a state given via parameter or a maximum retry count is reached. Restriction: Only works if there is only one in flight query.""" impalad_service = ImpaladService(IMPALAD.split(':')[0]) if not impalad_service.wait_for_num_in_flight_queries(1): raise Exception("No in flight query found") retry_count = 0 while retry_count <= max_retry: query_info = impalad_service.get_in_flight_queries()[0] if query_info['stmt'] != stmt: exc_text = "The found in flight query is not the one under test: " + \ query_info['stmt'] raise Exception(exc_text) if query_info['state'] == state: return retry_count += 1 sleep(1.0) raise Exception("Query didn't reach desired state: " + state)