mirror of
https://github.com/apache/impala.git
synced 2025-12-23 21:08:39 -05:00
IMPALA-13214: Skip wait_until_connected when shell exits
The ImpalaShell class expects to start impala-shell and interact with it by sending instructions over stdin and reading the results. This assumption was incorrect when used for impala-shell batch sessions, where the process exits on its own. If there's a delay in ImpalaShell.__init__ - between starting the process and polling to see that it's running - for a batch process, ImpalaShell will fail the assertion that process_status is None. This can be easily reproduced by adding a small (0.1s) sleep after starting the new process. Most batch runs of impala-shell happen through `run_impala_shell_cmd`. Updated that function to only wait for a successful connection when stdin input is supplied. Otherwise the command is assumed to be a batch function and any failures will be detected during `get_result`. Removed explicit use of `wait_until_connected` as redundant. Fixed cases in test_config_file that previously ignored WARNING before the connection string because they did not specify `wait_until_connected`. Tested by running shell/test_shell_commandline.py with a 0.1s delay before ImpalaShell polls. Change-Id: I24e029b6192a17773760cb44fd7a4f87b71c0aae Reviewed-on: http://gerrit.cloudera.org:8080/21598 Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Reviewed-by: Jason Fehr <jfehr@cloudera.com> Reviewed-by: Kurt Deschler <kdeschle@cloudera.com>
This commit is contained in:
committed by
Kurt Deschler
parent
22b59d27d0
commit
e1098a6a02
@@ -122,15 +122,14 @@ def assert_pattern(pattern, result, text, message):
|
||||
|
||||
|
||||
def run_impala_shell_cmd(vector, shell_args, env=None, expect_success=True,
|
||||
stdin_input=None, wait_until_connected=True,
|
||||
stdout_file=None, stderr_file=None):
|
||||
stdin_input=None, stdout_file=None, stderr_file=None):
|
||||
"""Runs the Impala shell on the commandline.
|
||||
|
||||
'shell_args' is a string which represents the commandline options.
|
||||
Returns a ImpalaShellResult.
|
||||
"""
|
||||
result = run_impala_shell_cmd_no_expect(vector, shell_args, env, stdin_input,
|
||||
expect_success and wait_until_connected,
|
||||
wait_until_connected=expect_success,
|
||||
stdout_file=stdout_file,
|
||||
stderr_file=stderr_file)
|
||||
if expect_success:
|
||||
@@ -151,7 +150,11 @@ def run_impala_shell_cmd_no_expect(vector, shell_args, env=None, stdin_input=Non
|
||||
|
||||
Does not assert based on success or failure of command.
|
||||
"""
|
||||
p = ImpalaShell(vector, shell_args, env=env, wait_until_connected=wait_until_connected,
|
||||
# Only wait_until_connected if we also have input to send. Otherwise expect that
|
||||
# the command will run without input and exit. Avoid waiting as ImpalaShell may
|
||||
# exit before it can detect there is a successful connection and assert False.
|
||||
p = ImpalaShell(vector, shell_args, env=env,
|
||||
wait_until_connected=wait_until_connected and stdin_input,
|
||||
stdout_file=stdout_file, stderr_file=stderr_file)
|
||||
result = p.get_result(stdin_input)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user