This is an automated email from the ASF dual-hosted git repository. stigahuang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit ee300a1af09514af5650b0b14b90afc8d23d54b1 Author: jasonmfehr <[email protected]> AuthorDate: Wed May 24 13:38:54 2023 -0700 IMPALA-12163: Fixes two issues when outputting RPC details. The end time of the exact same rpc call was different between stdout and the rpc details file because the end time was calculated each time the details were written out instead of calculating the end time once and reusing that value. The duration of each rpc call was being calculated incorrectly. Change-Id: Ifd9dec189d0f6fb8713fb1c7b2b6c663e492ef05 Reviewed-on: http://gerrit.cloudera.org:8080/19932 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- shell/impala_client.py | 4 ++-- tests/shell/test_shell_commandline.py | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/shell/impala_client.py b/shell/impala_client.py index 87ba6c09c..a8cd36f0c 100755 --- a/shell/impala_client.py +++ b/shell/impala_client.py @@ -1262,9 +1262,9 @@ class ImpalaHS2Client(ImpalaClient): def print_end_to_file(fh): self._print_line_separator(fh) - fh.write("[{0}] RPC CALL FINISHED:\n".format(datetime.now())) + fh.write("[{0}] RPC CALL FINISHED:\n".format(end_time)) fh.write("OPERATION: {0}\nDETAILS:\n".format(rpc_func.__name__)) - fh.write(" * Time: {0}ms\n".format(duration.microseconds / 1000)) + fh.write(" * Time: {0}ms\n".format(duration.total_seconds() * 1000)) fh.write(" * Result: {0}\n".format(result)) if rpc_output is not None: fh.write("\nRPC RESPONSE:\n") diff --git a/tests/shell/test_shell_commandline.py b/tests/shell/test_shell_commandline.py index 9bbbac41c..750a100c2 100644 --- a/tests/shell/test_shell_commandline.py +++ b/tests/shell/test_shell_commandline.py @@ -1422,11 +1422,11 @@ class TestImpalaShell(ImpalaTestSuite): assert "1\n" in lines[len(lines) - 2] assert "Fetched 1 row(s)" in lines[len(lines) - 1] - def skip_if_protocol_is_beeswax(self, vector): + def skip_if_protocol_is_beeswax(self, vector, + skip_msg="Floating-point value formatting is not supported with Beeswax"): """Helper to skip Beeswax protocol on formatting tests""" if vector.get_value("protocol") == "beeswax": - pytest.skip("Floating-point value formatting is not supported " - "with Beeswax") + pytest.skip(skip_msg) def validate_fp_format(self, vector, column_type, format, value, expected_values): args = ['--hs2_fp_format', format, '-q', @@ -1503,15 +1503,40 @@ class TestImpalaShell(ImpalaTestSuite): def test_output_rpc_to_screen_and_file(self, vector, populated_table, tmp_file): """Tests the flags that output hs2 rpc call details to both stdout and a file. Asserts the expected text is written.""" - self.skip_if_protocol_is_beeswax(vector) + self.skip_if_protocol_is_beeswax(vector, + "rpc detail output not supported with beeswax protocol") args = ['--rpc_stdout', '--rpc_file', tmp_file, - '-q', 'select * from {0}'.format(populated_table)] + '-q', 'select * from {0}'.format(populated_table), + '--protocol={0}'.format(vector.get_value("protocol"))] + if vector.get_value("strict_hs2_protocol") is True: + args.append('--strict_hs2_protocol') + result = run_impala_shell_cmd(vector, args) stdout_data = result.stdout.strip() rpc_file_data = open(tmp_file, "r").read().strip() + # compare the rpc details from stdout and file to ensure they match + # stdout contains additional output such as query results, remove all non-rpc details + rpc_sep = "------------------------------------------------" + \ + "------------------------------------------------" + stdout_data_rpc_only = "" + in_rpc_detail = False + for line in stdout_data.split("\n"): + if line == rpc_sep: + in_rpc_detail = not in_rpc_detail + stdout_data_rpc_only += line + "\n" + elif in_rpc_detail: + stdout_data_rpc_only += line + "\n" + + # rpc only stdout data contains an extra ending newline + rpc_file_data += "\n" + + assert stdout_data_rpc_only == rpc_file_data, \ + "difference found between stdout and rpc file:\nSTDOUT:\n{0}\nFILE:\n{1}" \ + .format(stdout_data_rpc_only, rpc_file_data) + def check_multiline(check_desc, regex_lines): """Build and runs a multi-line regular expression against both the shell's stdout and rpc file contents to ensure the expected data about
