You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2018/02/24 22:35:03 UTC

impala git commit: IMPALA-6582: fix test_multiline_queries_in_history

Repository: impala
Updated Branches:
  refs/heads/master 0f33370b8 -> 9f3c73ddb


IMPALA-6582: fix test_multiline_queries_in_history

The semicolon was in the wrong place in one of the test queries and
the failure was swallowed silently.

This meant that one fewer prompt was displayed than expected. This
didn't cause a test failure because the prompt regex also matched the
"Connected to host:port" message printed in the shell preamble. I'm
unsure why this would cause the test failure but my best theory is that
in the failure case, the "Connected" and prompt messages are both
buffered when we evaluate the first prompt regex, and the regex swallows
up the whole input, rather than just the first instance.

Testing:
Tightened up the prompt regex and checked that the query actually
executed successfully. With these improvements, the broken query
text caused a test failure.

I looped the test for a while to make sure it was robust.

Added a couple of related test cases to make sure we aren't losing
coverage.

Change-Id: If917bbc8e87b83c188b6d5e1acad912892b8c6fe
Reviewed-on: http://gerrit.cloudera.org:8080/9441
Reviewed-by: Alex Behm <al...@cloudera.com>
Tested-by: Impala Public Jenkins


Project: http://git-wip-us.apache.org/repos/asf/impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/9f3c73dd
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/9f3c73dd
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/9f3c73dd

Branch: refs/heads/master
Commit: 9f3c73ddbecd6eed3aa4207d58d848eef5684b2a
Parents: 0f33370
Author: Tim Armstrong <ta...@cloudera.com>
Authored: Fri Feb 23 17:40:22 2018 -0800
Committer: Impala Public Jenkins <im...@gerrit.cloudera.org>
Committed: Sat Feb 24 22:04:15 2018 +0000

----------------------------------------------------------------------
 tests/shell/test_shell_interactive.py | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/impala/blob/9f3c73dd/tests/shell/test_shell_interactive.py
----------------------------------------------------------------------
diff --git a/tests/shell/test_shell_interactive.py b/tests/shell/test_shell_interactive.py
index 7815405..087e40f 100755
--- a/tests/shell/test_shell_interactive.py
+++ b/tests/shell/test_shell_interactive.py
@@ -214,22 +214,29 @@ class TestImpalaShellInteractive(object):
     Additionally, also test that comments are preserved.
     """
     # regex for pexpect, a shell prompt is expected after each command..
-    prompt_regex = '.*%s:2100.*' % socket.getfqdn()
+    prompt_regex = '\[{0}:2100[0-9]\]'.format(socket.getfqdn())
     # readline gets its input from tty, so using stdin does not work.
     child_proc = pexpect.spawn(SHELL_CMD)
-    queries = ["select\n1--comment;",
-        "select /*comment*/\n1;",
-        "select\n/*comm\nent*/\n1;"]
-    for query in queries:
+    # List of (input query, expected text in output).
+    # The expected output is usually the same as the input with a number prefix, except
+    # where the shell strips newlines before a semicolon.
+    queries = [
+        ("select\n1;--comment", "[1]: select\n1;--comment"),
+        ("select 1 --comment\n;", "[2]: select 1 --comment;"),
+        ("select 1 --comment\n\n\n;", "[3]: select 1 --comment;"),
+        ("select /*comment*/\n1;", "[4]: select /*comment*/\n1;"),
+        ("select\n/*comm\nent*/\n1;", "[5]: select\n/*comm\nent*/\n1;")]
+    for query, _ in queries:
       child_proc.expect(prompt_regex)
       child_proc.sendline(query)
+      child_proc.expect("Fetched 1 row\(s\) in .*s")
     child_proc.expect(prompt_regex)
     child_proc.sendline('quit;')
     p = ImpalaShell()
     p.send_cmd('history')
     result = p.get_result()
-    for query in queries:
-      assert query in result.stderr, "'%s' not in '%s'" % (query, result.stderr)
+    for _, history_entry in queries:
+      assert history_entry in result.stderr, "'%s' not in '%s'" % (history_entry, result.stderr)
 
   @pytest.mark.execute_serially
   def test_rerun(self):